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

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

[elpa] master 574b3bd 57/68: Add `aw-leading-char-style' extra-awesome c


From: Oleh Krehel
Subject: [elpa] master 574b3bd 57/68: Add `aw-leading-char-style' extra-awesome custom var
Date: Sat, 21 Mar 2015 19:07:08 +0000

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

    Add `aw-leading-char-style' extra-awesome custom var
    
    * ace-window.el (aw-leading-char-style): When this is `char', the old
      style is used. When this is `path', each window will display the full
      path that can be used to get there. This is a great advantage, since
      you don't need to scan your screen twice, instead reading two (or
      more) chars at once.
    (aw--lead-overlay): Update.
    
    * avy.el (avy-traverse): Pass the whole path to WALKER, not just the
      starting point.
---
 ace-window.el |   38 +++++++++++++++++++++++++-------------
 avy.el        |    8 +++-----
 2 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/ace-window.el b/ace-window.el
index 0697ded..86f910c 100644
--- a/ace-window.el
+++ b/ace-window.el
@@ -85,6 +85,12 @@ Use M-0 `ace-window' to toggle this value."
   "When t, `ace-window' will dim out all buffers temporarily when used.'."
   :type 'boolean)
 
+(defcustom aw-leading-char-style 'char
+  "Style of the leading char overlay."
+  :type '(choice
+          (const :tag "single char" 'char)
+          (const :tag "full path" 'path)))
+
 (defface aw-leading-char-face
     '((((class color)) (:foreground "red"))
       (((background dark)) (:foreground "gray100"))
@@ -150,8 +156,8 @@ Use M-0 `ace-window' to toggle this value."
   (setq aw-overlays-back nil)
   (aw--remove-leading-chars))
 
-(defun aw--lead-overlay (char leaf)
-  "Create an overlay with CHAR at LEAF.
+(defun aw--lead-overlay (path leaf)
+  "Create an overlay using PATH at LEAF.
 LEAF is (PT . WND)."
   (let* ((pt (car leaf))
          (wnd (cdr leaf))
@@ -159,17 +165,23 @@ LEAF is (PT . WND)."
          (old-str (with-selected-window wnd
                     (buffer-substring pt (1+ pt))))
          (new-str
-          (format "%c%s"
-                  char
-                  (cond
-                    ((string-equal old-str "\t")
-                     (make-string (1- tab-width) ?\ ))
-                    ((string-equal old-str "\n")
-                     "\n")
-                    (t
-                     (make-string
-                      (max 0 (1- (string-width old-str)))
-                      ?\ ))))))
+          (concat
+           (cl-case aw-leading-char-style
+             (char
+              (apply #'string (last path)))
+             (path
+              (apply #'string (reverse path)))
+             (t
+              (error "Bad `aw-leading-char-style': %S"
+                     aw-leading-char-style)))
+           (cond ((string-equal old-str "\t")
+                  (make-string (1- tab-width) ?\ ))
+                 ((string-equal old-str "\n")
+                  "\n")
+                 (t
+                  (make-string
+                   (max 0 (1- (string-width old-str)))
+                   ?\ ))))))
     (overlay-put ol 'face 'aw-leading-char-face)
     (overlay-put ol 'window wnd)
     (overlay-put ol 'display new-str)
diff --git a/avy.el b/avy.el
index b572c45..0098b6b 100644
--- a/avy.el
+++ b/avy.el
@@ -80,16 +80,15 @@ KEYS are placed appropriately on internal nodes."
 
 (defun avy-traverse (tree walker &optional recur-key)
   "Traverse TREE generated by `avy-tree'.
-WALKER is a function that takes KEY and LEAF.
+WALKER is a function that takes KEYS and LEAF.
 
 RECUR-KEY is used in recursion.
 
 LEAF is a member of LST argument of `avy-tree'.
 
-KEY is a member of KEYS argument of `avy-tree'.  It corresponds
-to the key of the highest branch of TREE that contains LEAF."
+KEYS is the path from the root of `avy-tree' to LEAF."
   (dolist (br tree)
-    (let ((key (or recur-key (car br))))
+    (let ((key (cons (car br) recur-key)))
       (if (eq (cadr br) 'leaf)
           (funcall walker key (cddr br))
         (avy-traverse (cdr br) walker key)))))
@@ -103,7 +102,6 @@ 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
     (while tree
       (avy-traverse tree display-fn)



reply via email to

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