emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 464875a 103/184: counsel.el (counsel-mark-ring): Refactor


From: Oleh Krehel
Subject: [elpa] master 464875a 103/184: counsel.el (counsel-mark-ring): Refactor for reducing nested let
Date: Wed, 16 Oct 2019 13:15:00 -0400 (EDT)

branch: master
commit 464875a58a113db32c1902fb6cab8db015b95542
Author: SAITOU Keita <address@hidden>
Commit: Oleh Krehel <address@hidden>

    counsel.el (counsel-mark-ring): Refactor for reducing nested let
    
    Fixes #2237
---
 counsel.el | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/counsel.el b/counsel.el
index 2d653ab..74114b4 100644
--- a/counsel.el
+++ b/counsel.el
@@ -3758,24 +3758,24 @@ This variable has no effect unless
   "Browse `mark-ring' interactively.
 Obeys `widen-automatically', which see."
   (interactive)
-  (let ((counsel--mark-ring-calling-point (point))
-        (cands
-         (save-excursion
-           (save-restriction
-             ;; Widen, both to save `line-number-at-pos' the trouble
-             ;; and for `buffer-substring' to work.
-             (widen)
-             (let ((fmt (format "%%%dd %%s"
-                                (length (number-to-string
-                                         (line-number-at-pos (point-max)))))))
-               (mapcar (lambda (mark)
-                         (goto-char (marker-position mark))
-                         (let ((linum (line-number-at-pos))
-                               (line  (buffer-substring
-                                       (line-beginning-position)
-                                       (line-end-position))))
-                           (cons (format fmt linum line) (point))))
-                       (sort (delete-dups (copy-sequence mark-ring)) #'<)))))))
+  (let* ((counsel--mark-ring-calling-point (point))
+         (width (length (number-to-string (line-number-at-pos (point-max)))))
+         (fmt (format "%%%dd %%s" width))
+         (make-candidate
+          (lambda (mark)
+            (goto-char (marker-position mark))
+            (let ((linum (line-number-at-pos))
+                  (line (buffer-substring
+                         (line-beginning-position) (line-end-position))))
+              (cons (format fmt linum line) (point)))))
+         (marks (sort (delete-dups (copy-sequence mark-ring)) #'<))
+         (cands
+          ;; Widen, both to save `line-number-at-pos' the trouble
+          ;; and for `buffer-substring' to work.
+          (save-excursion
+            (save-restriction
+              (widen)
+              (mapcar make-candidate marks)))))
     (if cands
         (ivy-read "Mark: " cands
                   :require-match t



reply via email to

[Prev in Thread] Current Thread [Next in Thread]