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

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

[elpa] externals/consult 8f1bea3e36: Replace consult-preview-cursor with


From: ELPA Syncer
Subject: [elpa] externals/consult 8f1bea3e36: Replace consult-preview-cursor with consult-preview-mark face
Date: Sun, 7 May 2023 05:57:28 -0400 (EDT)

branch: externals/consult
commit 8f1bea3e3634abc92d98084afb5cc98d2a8dc9ee
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Replace consult-preview-cursor with consult-preview-mark face
---
 CHANGELOG.org       |  1 +
 consult-register.el |  2 +-
 consult.el          | 31 +++++++++++++------------------
 3 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/CHANGELOG.org b/CHANGELOG.org
index 228b5a8158..c18046fbee 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -9,6 +9,7 @@
   =completion-table-dynamic= or =completion--file-name-table=. This allows you 
to
   reuse existing completion tables to write completion commands enhanced with
   Consult candidate preview.
+- Replace =consult-preview-cursor= face with =cursor-preview-mark=.
 
 * Version 0.34 (2023-04-21)
 
diff --git a/consult-register.el b/consult-register.el
index a0b2746b83..f7e58cba01 100644
--- a/consult-register.el
+++ b/consult-register.el
@@ -71,7 +71,7 @@ Each element of the list must have the form (char . name).")
         (widen)
         (goto-char val)
         (let* ((line (line-number-at-pos))
-               (str (propertize (consult--line-with-cursor val)
+               (str (propertize (consult--line-with-mark val)
                                 'consult-location (cons val line))))
           (list (consult--format-file-line-match (buffer-name) line str)
                 'multi-category `(consult-location . ,str)
diff --git a/consult.el b/consult.el
index d7e4a812c9..8bb2855c29 100644
--- a/consult.el
+++ b/consult.el
@@ -384,9 +384,10 @@ Used for example in `consult-grep'.")
   '((t :inherit isearch))
   "Face used for match previews, e.g., in `consult-line'.")
 
-(defface consult-preview-cursor
-  '((t :inherit cursor))
-  "Face used for cursor previews and marks, e.g., in `consult-mark'.")
+(defface consult-preview-mark
+  '((t :inherit isearch))
+  "Face used for mark positions in candidates, e.g., in `consult-mark'.
+The face should be different than the `cursor' face to avoid confusion.")
 
 (defface consult-preview-insertion
   '((t :inherit region))
@@ -970,23 +971,17 @@ region has been fontified."
         str)
     (buffer-substring-no-properties beg end)))
 
-(defun consult--region-with-cursor (beg end marker)
-  "Return region string with a marking at the cursor position.
-
-BEG is the begin position.
-END is the end position.
-MARKER is the cursor position."
-  (let ((str (consult--buffer-substring beg end 'fontify)))
+(defun consult--line-with-mark (marker)
+  "Current line string where the MARKER position is highlighted."
+  (let* ((beg (pos-bol))
+         (end (pos-eol))
+         (str (consult--buffer-substring beg end 'fontify)))
     (if (>= marker end)
-        (concat str #(" " 0 1 (face consult-preview-cursor)))
+        (concat str #(" " 0 1 (face consult-preview-mark)))
       (put-text-property (- marker beg) (- (1+ marker) beg)
-                         'face 'consult-preview-cursor str)
+                         'face 'consult-preview-mark str)
       str)))
 
-(defun consult--line-with-cursor (marker)
-  "Return current line where the cursor MARKER is highlighted."
-  (consult--region-with-cursor (pos-bol) (pos-eol) marker))
-
 ;;;; Tofu cooks
 
 (defsubst consult--tofu-p (char)
@@ -3144,7 +3139,7 @@ The symbol at point is added to the future history."
             ;; 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-cursor marker) marker
+                   (consult--line-with-mark marker) marker
                    (line-number-at-pos pos consult-line-numbers-widen)
                    marker)
                   candidates)))))
@@ -3193,7 +3188,7 @@ The symbol at point is added to the future history."
                           (consult--format-file-line-match (buffer-name buf) 
line "")
                           'consult-location (cons marker line)
                           'consult-strip t)
-                         (consult--line-with-cursor marker)
+                         (consult--line-with-mark marker)
                          (consult--tofu-encode marker))
                         candidates))))))))
     (unless candidates



reply via email to

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