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

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

[elpa] master 8efed40 20/36: Add `avy-lead-face-1' for dimmed matched ch


From: Oleh Krehel
Subject: [elpa] master 8efed40 20/36: Add `avy-lead-face-1' for dimmed matched chars
Date: Tue, 19 May 2015 12:38:14 +0000

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

    Add `avy-lead-face-1' for dimmed matched chars
    
    * avy.el (avy-lead-face-0): Update doc.
    (avy-lead-face-1): New face.
    (avy-current-path): New defvar.
    (avy-read): Store the current matched chars in `avy-current-path'.
    (avy--overlay-pre):
    (avy--overlay-post): Extend the string with the matched part. This
    prevents shifting during selection, and looks nice too.
    
    Fixes #38
---
 avy.el |   22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/avy.el b/avy.el
index 84a2c34..f676b77 100644
--- a/avy.el
+++ b/avy.el
@@ -127,7 +127,11 @@ When nil, punctuation chars will not be matched.
 
 (defface avy-lead-face-0
   '((t (:foreground "white" :background "#4f57f9")))
-  "Face used for the leading chars.")
+  "Face used for first non-terminating leading chars.")
+
+(defface avy-lead-face-1
+    '((t (:foreground "white" :background "gray")))
+  "Face used for matched leading chars.")
 
 (defface avy-lead-face
   '((t (:foreground "white" :background "#e52b50")))
@@ -208,6 +212,9 @@ KEYS is the path from the root of `avy-tree' to LEAF."
 (defvar avy-handler-function 'avy-handler-default
   "A function to call for a bad `read-char' in `avy-read'.")
 
+(defvar avy-current-path ""
+  "Store the current incomplete path during `avy-read'.")
+
 (defun avy-read (tree display-fn cleanup-fn)
   "Select a leaf from TREE using consecutive `read-char'.
 
@@ -218,6 +225,7 @@ commonly done by adding a CHAR overlay at LEAF position.
 CLEANUP-FN should take no arguments and remove the effects of
 multiple DISPLAY-FN invokations."
   (catch 'done
+    (setq avy-current-path "")
     (while tree
       (let ((avy--leafs nil))
         (avy-traverse tree
@@ -230,7 +238,9 @@ multiple DISPLAY-FN invokations."
         (funcall cleanup-fn)
         (if (setq branch (assoc char tree))
             (if (eq (car (setq tree (cdr branch))) 'leaf)
-                (throw 'done (cdr tree)))
+                (throw 'done (cdr tree))
+              (setq avy-current-path
+                    (concat avy-current-path (string char))))
           (funcall avy-handler-function char))))))
 
 ;;** Rest
@@ -372,6 +382,10 @@ LEAF is normally ((BEG . END) . WND)."
                          'face 'avy-lead-face)))
     (when (> (length str) 1)
       (set-text-properties 0 1 '(face avy-lead-face-0) str))
+    (setq str (concat
+               (propertize avy-current-path
+                           'face 'avy-lead-face-1)
+               str))
     (avy--overlay
      str
      (cond ((numberp leaf)
@@ -456,6 +470,10 @@ LEAF is normally ((BEG . END) . WND)."
                          'face 'avy-lead-face)))
     (when (> (length str) 1)
       (set-text-properties 0 1 '(face avy-lead-face-0) str))
+    (setq str (concat
+               (propertize avy-current-path
+                           'face 'avy-lead-face-1)
+               str))
     (avy--overlay
      str
      (cond ((numberp leaf)



reply via email to

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