diff options
author | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2017-05-13 14:10:06 +0200 |
---|---|---|
committer | Thierry Volpiatto <thierry.volpiatto@gmail.com> | 2017-05-13 14:29:59 +0200 |
commit | c4d2b0a06914fec9b9f2e9ae3403ee348c664731 (patch) | |
tree | 822ccc2e7c6cf5a2d894f5fec8b45062087a51c2 /helm-ring.el | |
parent | 178a2163d5ff85b5f88f82590f191951027656c9 (diff) |
Use markers in mark-ring sources (#1770).
* helm-ring.el (helm-mark-ring-get-candidates): Real is now a marker.
(helm-mark-ring-default-action): New.
(helm-source-mark-ring): Use it.
(helm-source-global-mark-ring): Use it.
(helm-global-mark-ring-get-candidates): Real is now a marker.
Diffstat (limited to 'helm-ring.el')
-rw-r--r-- | helm-ring.el | 42 |
1 files changed, 17 insertions, 25 deletions
diff --git a/helm-ring.el b/helm-ring.el index 6a69e5e2..d31eaa84 100644 --- a/helm-ring.el +++ b/helm-ring.el @@ -223,40 +223,32 @@ This is a command for `helm-kill-ring-map'." (defun helm-mark-ring-get-candidates () (with-helm-current-buffer (cl-loop with marks = (if (mark t) (cons (mark-marker) mark-ring) mark-ring) - for i in marks + for marker in marks with max-line-number = (line-number-at-pos (point-max)) with width = (length (number-to-string max-line-number)) for m = (format (concat "%" (number-to-string width) "d: %s") - (line-number-at-pos i) - (helm-mark-ring-line-string-at-pos i)) - unless (and recip (member m recip)) - collect m into recip + (line-number-at-pos marker) + (helm-mark-ring-line-string-at-pos marker)) + unless (and recip (assoc m recip)) + collect (cons m marker) into recip finally return recip))) +(defun helm-mark-ring-default-action (candidate) + (switch-to-buffer (marker-buffer candidate)) + (helm-goto-char candidate) + (helm-highlight-current-line)) + (defvar helm-source-mark-ring (helm-build-sync-source "mark-ring" :candidates #'helm-mark-ring-get-candidates - :action '(("Goto line" - . (lambda (candidate) - (helm-goto-line (string-to-number candidate))))) - :persistent-action (lambda (candidate) - (switch-to-buffer helm-current-buffer) - (helm-goto-line (string-to-number candidate))) + :action '(("Goto line" . helm-mark-ring-default-action)) :persistent-help "Show this line")) ;;; Global-mark-ring (defvar helm-source-global-mark-ring (helm-build-sync-source "global-mark-ring" :candidates #'helm-global-mark-ring-get-candidates - :action '(("Goto line" - . (lambda (candidate) - (let ((items (split-string candidate ":"))) - (switch-to-buffer (cl-second items)) - (helm-goto-line (string-to-number (car items))))))) - :persistent-action (lambda (candidate) - (let ((items (split-string candidate ":"))) - (switch-to-buffer (cl-second items)) - (helm-goto-line (string-to-number (car items))))) + :action '(("Goto line" . helm-mark-ring-default-action)) :persistent-help "Show this line")) (defun helm-global-mark-ring-format-buffer (marker) @@ -275,13 +267,13 @@ This is a command for `helm-kill-ring-map'." (defun helm-global-mark-ring-get-candidates () (let ((marks global-mark-ring)) (when marks - (cl-loop for i in marks - for mb = (marker-buffer i) + (cl-loop for marker in marks + for mb = (marker-buffer marker) for gm = (unless (or (string-match "^ " (format "%s" mb)) (null mb)) - (helm-global-mark-ring-format-buffer i)) - when (and gm (not (member gm recip))) - collect gm into recip + (helm-global-mark-ring-format-buffer marker)) + when (and gm (not (assoc gm recip))) + collect (cons gm marker) into recip finally return recip)))) (defun helm--push-mark (&optional location nomsg activate) |