branch: master commit f5b8bf2d4f05d479741ec5d2c569f9c6eee0c119 Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
Highlight modified file buffers with 'ivy-modified-buffer face * ivy.el (ivy-modified-buffer): New face, blank by default. (ivy--format): When the collection is 'internal-complete-buffer, highlight unsaved file visiting buffers with 'ivy-modified-buffer. Fixes #280 Example custom setting for 'ivy-modified-buffer: (custom-set-faces '(ivy-modified-buffer ((t (:background "#ff7777"))))) --- ivy.el | 25 +++++++++++++++++++------ 1 files changed, 19 insertions(+), 6 deletions(-) diff --git a/ivy.el b/ivy.el index 4cde295..e33d71c 100644 --- a/ivy.el +++ b/ivy.el @@ -63,6 +63,10 @@ '((t (:inherit 'dired-directory))) "Face used by Ivy for highlighting subdirs in the alternatives.") +(defface ivy-modified-buffer + '((t :inherit 'default)) + "Face used by Ivy for highlighting modified file visiting buffers.") + (defface ivy-remote '((t (:foreground "#110099"))) "Face used by Ivy for highlighting remotes in the alternatives.") @@ -1860,12 +1864,21 @@ CANDS is a list of strings." (start (max 0 (min start (- end (1- ivy-height))))) (cands (cl-subseq cands start end)) (index (- ivy--index start))) - (when ivy--directory - (setq cands (mapcar (lambda (x) - (if (string-match-p "/\\'" x) - (propertize x 'face 'ivy-subdir) - x)) - cands))) + (cond (ivy--directory + (setq cands (mapcar (lambda (x) + (if (string-match-p "/\\'" x) + (propertize x 'face 'ivy-subdir) + x)) + cands))) + ((eq (ivy-state-collection ivy-last) 'internal-complete-buffer) + (setq cands (mapcar (lambda (x) + (let ((b (get-buffer x))) + (if (and b + (buffer-file-name b) + (buffer-modified-p b)) + (propertize x 'face 'ivy-modified-buffer) + x))) + cands)))) (setq ivy--current (copy-sequence (nth index cands))) (setq cands (mapcar #'ivy--format-minibuffer-line