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

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

[elpa] master a817342 14/67: ivy.el: Improve the highlighting in the min


From: Oleh Krehel
Subject: [elpa] master a817342 14/67: ivy.el: Improve the highlighting in the minibuffer
Date: Sun, 22 Mar 2015 17:33:52 +0000

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

    ivy.el: Improve the highlighting in the minibuffer
    
    * ivy.el (ivy--add-face): Use `add-face-text-property' if it's
      available. You need to upgrade to Emacs 24.4 to get this feature.
    (ivy-completions): Use `ivy--add-face'.
---
 ivy.el |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/ivy.el b/ivy.el
index a6b4b66..45a8700 100644
--- a/ivy.el
+++ b/ivy.el
@@ -218,6 +218,16 @@ Should be run via minibuffer `post-command-hook'."
 (defvar ivy--old-cands nil
   "Store the candidates matched by `ivy--old-re'.")
 
+(defun ivy--add-face (str face)
+  "Propertize STR with FACE.
+A better function `add-face-text-property' is used if it's available.
+Otherwise, `propertize'."
+  (if (fboundp 'add-face-text-property)
+      (progn
+        (add-face-text-property 0 (length str) face t str)
+        str)
+    (propertize str 'face face)))
+
 (defun ivy-completions (name candidates)
   "Return as text the current completions.
 NAME is a string of words separated by spaces that is used to
@@ -252,7 +262,7 @@ CANDIDATES is a list of strings."
         (setq ivy--current (copy-sequence
                             (nth index cands)))
         (setf (nth index cands)
-              (propertize ivy--current 'face 'ivy-current-match))
+              (ivy--add-face ivy--current 'ivy-current-match))
         (concat "\n" (mapconcat #'identity cands "\n"))))))
 
 (provide 'ivy)



reply via email to

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