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.
old-master
Oleh Krehel 11 years ago
parent d7cafcb964
commit 574b3bddfc
  1. 38
      ace-window.el
  2. 8
      avy.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)

@ -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)

Loading…
Cancel
Save