summaryrefslogtreecommitdiff
path: root/helm-ring.el
diff options
context:
space:
mode:
authorChunyang Xu <xuchunyang56@gmail.com>2015-10-23 22:48:12 +0800
committerChunyang Xu <xuchunyang56@gmail.com>2015-10-23 22:58:50 +0800
commitc88bc5c1e8a6241169a9c3ea8caf1aa047fab3c4 (patch)
tree99bb5fc25a555418859f9d84343d153baa43a3df /helm-ring.el
parent9181534f63f341617178c3f8e860e38e42731caf (diff)
Improve line number width in helm-mark-ring
The old format of candidate in helm-mark-ring is: (format "%7d: %s" (line-number-at-pos) line) this commit replaces "7" with the width of max line number in `helm-current-buffer'.
Diffstat (limited to 'helm-ring.el')
-rw-r--r--helm-ring.el25
1 files changed, 15 insertions, 10 deletions
diff --git a/helm-ring.el b/helm-ring.el
index 4f70589a..04df6ae5 100644
--- a/helm-ring.el
+++ b/helm-ring.el
@@ -143,23 +143,28 @@ replace with STR as yanked string."
;; the commands `helm-mark-ring', `helm-global-mark-ring' or
;; `helm-all-mark-rings' instead.
-(defun helm-mark-ring-get-marks (pos)
+(defun helm-mark-ring-line-string-at-pos (pos)
+ "Return line string at position POS."
(save-excursion
(goto-char pos)
(forward-line 0)
- (let ((line (car (split-string (thing-at-point 'line) "[\n\r]"))))
- (when (string= "" line)
- (setq line "<EMPTY LINE>"))
- (format "%7d: %s" (line-number-at-pos) line))))
+ (let ((line (car (split-string (thing-at-point 'line) "[\n\r]"))))
+ (if (string= "" line)
+ "<EMPTY LINE>"
+ line))))
(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 m = (helm-mark-ring-get-marks i)
- unless (and recip (member m recip))
- collect m into recip
- finally return recip)))
+ for i 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
+ finally return recip)))
(defvar helm-source-mark-ring
(helm-build-sync-source "mark-ring"