branch: externals/consult
commit 8c507e6be6d328a352743fb8275f5651c5effc42
Author: Daniel Mendler <[email protected]>
Commit: Daniel Mendler <[email protected]>

    consult-mark: Add line numbers directly to the candidate
    
    Similar approach as in consult-global-mark.
---
 consult.el | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/consult.el b/consult.el
index 9582072c2c..dac54d78c3 100644
--- a/consult.el
+++ b/consult.el
@@ -3463,8 +3463,12 @@ argument.  The symbol at point is added to the future 
history."
 (defun consult--mark-candidates (markers)
   "Return list of candidates strings for MARKERS."
   (consult--forbid-minibuffer)
-  (let ((candidates)
-        (current-buf (current-buffer)))
+  (let* ((candidates)
+         (current-buf (current-buffer))
+         (width (length (number-to-string (line-number-at-pos
+                                           (point-max)
+                                           consult-line-numbers-widen))))
+         (fmt (format #("%%%dd %%s%%s" 0 6 (face consult-line-number-prefix)) 
width)))
     (save-excursion
       (dolist (marker markers)
         (when-let ((pos (marker-position marker))
@@ -3476,11 +3480,11 @@ argument.  The symbol at point is added to the future 
history."
             ;; replaced everywhere.  However in this case the slow
             ;; line-number-at-pos does not hurt much, since the mark ring is
             ;; usually small since it is limited by `mark-ring-max'.
-            (push (consult--location-candidate
-                   (consult--line-with-mark marker) marker
-                   (line-number-at-pos pos consult-line-numbers-widen)
-                   marker)
-                  candidates)))))
+            (let* ((line (line-number-at-pos pos consult-line-numbers-widen))
+                   (cand (format fmt line (consult--line-with-mark marker) 
(consult--tofu-encode marker))))
+              (put-text-property 0 width 'consult-strip t cand)
+              (put-text-property 0 (length cand) 'consult-location (cons 
marker line) cand)
+              (push cand candidates))))))
     (unless candidates
       (user-error "No marks"))
     (nreverse (delete-dups candidates))))
@@ -3496,7 +3500,6 @@ The symbol at point is added to the future history."
    (consult--mark-candidates
     (or markers (cons (mark-marker) mark-ring)))
    :prompt "Go to mark: "
-   :annotate (consult--line-prefix)
    :category 'consult-location
    :sort nil
    :require-match t

Reply via email to