branch: master commit a275a2a37db9b062a20876c16aec2d9f058a0c5c Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
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.