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

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

[elpa] master 0091c8a 058/348: ivy.el (ivy-set-prompt-text-properties-fu


From: Oleh Krehel
Subject: [elpa] master 0091c8a 058/348: ivy.el (ivy-set-prompt-text-properties-function): New devar
Date: Sat, 8 Apr 2017 11:03:24 -0400 (EDT)

branch: master
commit 0091c8a5475f16a549996e3eef7b6f3b504e1e28
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    ivy.el (ivy-set-prompt-text-properties-function): New devar
    
    * ivy.el (ivy-set-prompt-text-properties-default): New defun.
    
    Fixes #545.
    
    Notes:
    
    - User-facing variables should preferably be without `--', hence the
      rename from `ivy--prompt-text-prop-override-function' to
      `ivy-set-prompt-text-properties-function'.
    
    - Using the (defvar foo-function 'foo-function-default) pattern is a
      simple and easy-to-debug and customize approach.
---
 ivy.el | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/ivy.el b/ivy.el
index 093ae1b..b661a6d 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1920,17 +1920,19 @@ depending on the number of candidates."
     (goto-char (minibuffer-prompt-end))
     (delete-region (line-end-position) (point-max))))
 
-(defvar ivy--prompt-text-prop-override-function
-  (lambda (prompt std-props)
-    (ivy--set-match-props prompt "confirm"
-                          `(face ivy-confirm-face ,@std-props))
-    (ivy--set-match-props prompt "match required"
-                          `(face ivy-match-required-face ,@std-props))
-    prompt)
-  "Function to override the text properties of the default ivy prompt.
+(defvar ivy-set-prompt-text-properties-function
+  'ivy-set-prompt-text-properties-default
+  "Function to set the text properties of the default ivy prompt.
 Called with two arguments, PROMPT and STD-PROPS.
 The returned value should be the updated PROMPT.")
 
+(defun ivy-set-prompt-text-properties-default (prompt std-props)
+  (ivy--set-match-props prompt "confirm"
+                        `(face ivy-confirm-face ,@std-props))
+  (ivy--set-match-props prompt "match required"
+                        `(face ivy-match-required-face ,@std-props))
+  prompt)
+
 (defun ivy--insert-prompt ()
   "Update the prompt according to `ivy--prompt'."
   (when ivy--prompt
@@ -1984,7 +1986,7 @@ The returned value should be the updated PROMPT.")
           (set-text-properties 0 (length n-str)
                                `(face minibuffer-prompt ,@std-props)
                                n-str)
-          (setq n-str (funcall ivy--prompt-text-prop-override-function
+          (setq n-str (funcall ivy-set-prompt-text-properties-function
                                n-str std-props))
           (insert n-str))
         ;; get out of the prompt area



reply via email to

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