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

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

[elpa] externals/consult 04286c40f8 3/3: Add consult-register-prefix


From: ELPA Syncer
Subject: [elpa] externals/consult 04286c40f8 3/3: Add consult-register-prefix
Date: Thu, 17 Feb 2022 11:57:22 -0500 (EST)

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

    Add consult-register-prefix
---
 CHANGELOG.org       |  1 +
 README.org          |  1 +
 consult-register.el | 17 +++++++++++------
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/CHANGELOG.org b/CHANGELOG.org
index 50997881a2..f4fd5ef658 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -8,6 +8,7 @@
   on project.el.
 - Add =consult-project-buffer=, a variant of =consult-buffer= restricted to the
   current project.
+- Add =consult-register-prefix= option.
 
 * Version 0.15 (2022-01-31)
 
diff --git a/README.org b/README.org
index d5180f1d20..2a16ebf41c 100644
--- a/README.org
+++ b/README.org
@@ -953,6 +953,7 @@ configuration examples.
  | consult-project-root-function    | Function which returns current project 
root           |
  | consult-recent-file-filter       | Filter for =consult-recent-file=         
               |
  | consult-register-narrow          | Narrowing configuration for 
=consult-register=          |
+ | consult-register-prefix          | Prefix string for register keys during 
completion     |
  | consult-ripgrep-args             | Command line arguments for ripgrep       
             |
  | consult-themes                   | List of themes to be presented for 
selection          |
  | consult-widen-key                | Widening key during completion           
             |
diff --git a/consult-register.el b/consult-register.el
index eb2e5d2e75..fe764d0845 100644
--- a/consult-register.el
+++ b/consult-register.el
@@ -25,6 +25,11 @@
 
 (require 'consult)
 
+(defcustom consult-register-prefix #("@" 0 1 (face consult-key))
+  "Prepend prefix in front of register keys during completion."
+  :type '(choice (const nil) string)
+  :group 'consult)
+
 (defcustom consult-register-narrow
   `((?n "Number" ,#'numberp)
     (?s "String" ,#'stringp)
@@ -50,7 +55,7 @@ SHOW-EMPTY must be t if the window should be shown for an 
empty register list."
   (let ((regs (consult-register--alist 'noerror))
         (separator
          (and (display-graphic-p)
-              (propertize (concat (propertize " " 'display '(space :align-to 
right)) "\n")
+              (propertize #(" \n" 0 1 (display (space :align-to right)))
                           'face '(:inherit consult-separator :height 1 
:underline t)))))
     (when (or show-empty regs)
       (with-current-buffer-window buffer
@@ -69,15 +74,15 @@ SHOW-EMPTY must be t if the window should be shown for an 
empty register list."
                  regs nil))))))
 
 ;;;###autoload
-(defun consult-register-format (reg &optional no-newline)
+(defun consult-register-format (reg &optional completion)
   "Enhanced preview of register REG.
-
 This function can be used as `register-preview-function'.
-Append newline if NO-NEWLINE is nil."
+If COMPLETION is non-nil format the register for completion."
   (pcase-let ((`(,key . ,val) reg))
     (let* ((key-str (propertize (single-key-description key) 'face 
'consult-key))
            (len (max 3 (length key-str))))
       (concat
+       (and completion consult-register-prefix)
        key-str (make-string (- len (length key-str)) ?\s) " "
        ;; Special printing for certain register types
        (cond
@@ -107,7 +112,7 @@ Append newline if NO-NEWLINE is nil."
                                          (consult--line-with-cursor val))))))
         ;; Default printing for the other types
         (t (register-describe-oneline key)))
-       (and (not no-newline) "\n")))))
+       (and (not completion) "\n")))))
 
 (defun consult-register--alist (&optional noerror)
   "Return sorted register list.
@@ -120,7 +125,7 @@ Raise an error if the list is empty and NOERROR is nil."
 (defun consult-register--candidates ()
   "Return list of formatted register candidates."
   (mapcar (lambda (reg)
-            (let ((str (consult-register-format reg 'no-newline)))
+            (let ((str (consult-register-format reg 'completion)))
               (add-text-properties
                0 (length str)
                (list 'consult--candidate (car reg)



reply via email to

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