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

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

[elpa] externals/embark 4bb47b04df 1/3: Consult now uses "cheap markers"


From: ELPA Syncer
Subject: [elpa] externals/embark 4bb47b04df 1/3: Consult now uses "cheap markers" for consult-location
Date: Sat, 19 Feb 2022 12:57:32 -0500 (EST)

branch: externals/embark
commit 4bb47b04df8e073fb1a5a762cc09da8c99e133a2
Author: Omar Antolín <omar.antolin@gmail.com>
Commit: Omar Antolín <omar.antolin@gmail.com>

    Consult now uses "cheap markers" for consult-location
    
    We need to upgrade them to regular markers upon export and collect.
    For export this is handled by the call to consult--get-location in
    embark-consult-export-occur. For Embark collect the situation is
    slightly more complicated:
    
    - For snapshots, it is handled by a function we add to
      embark-collect-mode-hook, namely embark-consult--upgrade-markers.
    - For live completion we wouldn't need to upgrade the markers except
      if no window switching took place before quitting the minibuffer.
      Instead of being precise, we just upgrade the markers anyway.
    - For completions collections it is unnecessary to upgrade the
      markers since here Consult takes care of it upon a switching
      windows.
---
 embark-consult.el | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/embark-consult.el b/embark-consult.el
index fd6ead9102..8e9d2536a3 100644
--- a/embark-consult.el
+++ b/embark-consult.el
@@ -114,7 +114,7 @@
 
 (defun embark-consult-goto-location (target)
   "Jump to consult location TARGET."
-  (consult--jump (car (get-text-property 0 'consult-location target)))
+  (consult--jump (car (consult--get-location target)))
   (pulse-momentary-highlight-one-line (point)))
 
 (setf (alist-get 'consult-location embark-default-action-overrides)
@@ -129,7 +129,7 @@ The elements of LINES are assumed to be values of category 
`consult-line'."
     (with-current-buffer buf
       (dolist (line lines)
         (pcase-let*
-            ((`(,loc . ,num) (get-text-property 0 'consult-location line))
+            ((`(,loc . ,num) (consult--get-location line))
              ;; the text properties added to the following strings are
              ;; taken from occur-engine
              (lineno (propertize (format "%7d:" num)
@@ -158,10 +158,18 @@ The elements of LINES are assumed to be values of 
category `consult-line'."
       (occur-mode))
     (pop-to-buffer buf)))
 
+(defun embark-consult--upgrade-markers ()
+  "Upgrade consult-location cheap markers to real markers.
+This function is meant to be added to `embark-collect-mode-hook'."
+  (when (and (eq embark--type 'consult-location)
+             (not (eq embark-collect--kind :completions)))
+    (mapc #'consult--get-location embark-collect-candidates)))
+
 (setf (alist-get 'consult-location embark-collect-initial-view-alist)
       'list)
 (setf (alist-get 'consult-location embark-exporters-alist)
       #'embark-consult-export-occur)
+(cl-pushnew #'embark-consult--upgrade-markers embark-collect-mode-hook)
 
 ;;; Support for consult-grep
 



reply via email to

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