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

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

[elpa] master a275a2a 60/67: Use `font-lock-append-text-property' to non


From: Oleh Krehel
Subject: [elpa] master a275a2a 60/67: Use `font-lock-append-text-property' to non-destructively modify a
Date: Sun, 22 Mar 2015 17:34:11 +0000

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

    Use `font-lock-append-text-property' to non-destructively modify a
    string
    
    * ivy.el (ivy--add-face): Improve.
    `font-lock-append-text-property' non-destructively changes properties in
    a string, which means if a string was copied from another and modified,
    the original will not be changed.
    In this way, it's better than `add-face-text-property'; and still better
    than `propertize' that simply erases all properties before applying.
    
    Fixes #22
---
 ivy.el |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/ivy.el b/ivy.el
index 21e6f12..2f798ce 100644
--- a/ivy.el
+++ b/ivy.el
@@ -334,13 +334,10 @@ Should be run via minibuffer `post-command-hook'."
 
 (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)))
+`font-lock-append-text-property' is used, since it's better than
+`propertize' or `add-face-text-property' in this case."
+  (font-lock-append-text-property 0 (length str) 'face face str)
+  str)
 
 (defun ivy-completions (name candidates)
   "Return as text the current completions.



reply via email to

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