mirror of
https://github.com/abo-abo/avy.git
synced 2025-10-13 13:33:03 +00:00
avy.el (avy--overlay-at-full): Use avy--overlay
* avy.el (avy-styles-alist): Reset to nil. (avy--overlay): Also set 'category to 'avy. (avy--overlay-at-full): Use `avy--overlay'. Fixes #110
This commit is contained in:
parent
d4b693f274
commit
0756c0b48a
45
avy.el
45
avy.el
@ -93,7 +93,7 @@ Use `avy-styles-alist' to customize this per-command."
|
|||||||
(const :tag "Post" post)
|
(const :tag "Post" post)
|
||||||
(const :tag "De Bruijn" de-bruijn)))
|
(const :tag "De Bruijn" de-bruijn)))
|
||||||
|
|
||||||
(defcustom avy-styles-alist '((avy-goto-line . pre))
|
(defcustom avy-styles-alist nil
|
||||||
"Alist of avy-jump commands to the style for each command.
|
"Alist of avy-jump commands to the style for each command.
|
||||||
If the commands isn't on the list, `avy-style' is used."
|
If the commands isn't on the list, `avy-style' is used."
|
||||||
:type '(alist
|
:type '(alist
|
||||||
@ -635,6 +635,7 @@ COMPOSE-FN is a lambda that concatenates the old string at BEG with STR."
|
|||||||
(when os-wrap-prefix
|
(when os-wrap-prefix
|
||||||
(add-text-properties 0 1 `(wrap-prefix ,os-wrap-prefix) str))
|
(add-text-properties 0 1 `(wrap-prefix ,os-wrap-prefix) str))
|
||||||
(overlay-put ol 'window wnd)
|
(overlay-put ol 'window wnd)
|
||||||
|
(overlay-put ol 'category 'avy)
|
||||||
(overlay-put ol 'display (funcall
|
(overlay-put ol 'display (funcall
|
||||||
(or compose-fn #'concat)
|
(or compose-fn #'concat)
|
||||||
str old-str))
|
str old-str))
|
||||||
@ -725,7 +726,8 @@ LEAF is normally ((BEG . END) . WND)."
|
|||||||
'face 'avy-lead-face))
|
'face 'avy-lead-face))
|
||||||
(len (length path))
|
(len (length path))
|
||||||
(beg (avy-candidate-beg leaf))
|
(beg (avy-candidate-beg leaf))
|
||||||
(wnd (cdr leaf)))
|
(wnd (cdr leaf))
|
||||||
|
end)
|
||||||
(dotimes (i len)
|
(dotimes (i len)
|
||||||
(set-text-properties (- len i 1) (- len i)
|
(set-text-properties (- len i 1) (- len i)
|
||||||
`(face ,(nth i avy-lead-faces))
|
`(face ,(nth i avy-lead-faces))
|
||||||
@ -739,33 +741,28 @@ LEAF is normally ((BEG . END) . WND)."
|
|||||||
(with-selected-window wnd
|
(with-selected-window wnd
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(goto-char beg)
|
(goto-char beg)
|
||||||
(let* ((len-and-str (avy--update-offset-and-str len str))
|
(let ((len-and-str (avy--update-offset-and-str len str)))
|
||||||
(len (car len-and-str))
|
(setq len (car len-and-str))
|
||||||
(str (cdr len-and-str))
|
(setq str (cdr len-and-str))
|
||||||
(end (if (= beg (line-end-position))
|
(setq end (if (= beg (line-end-position))
|
||||||
(1+ beg)
|
(1+ beg)
|
||||||
(min (+ beg
|
(min (+ beg
|
||||||
(if (eq (char-after) ?\t)
|
(if (eq (char-after) ?\t)
|
||||||
1
|
1
|
||||||
len))
|
len))
|
||||||
(line-end-position))))
|
(line-end-position)))))))
|
||||||
(ol (make-overlay
|
(avy--overlay
|
||||||
beg end
|
str beg end wnd
|
||||||
(current-buffer)))
|
(lambda (str old-str)
|
||||||
(old-str (avy--old-str beg wnd)))
|
(cond ((string= old-str "\n")
|
||||||
(overlay-put ol 'window wnd)
|
(concat str "\n"))
|
||||||
(overlay-put ol 'category 'avy)
|
((string= old-str "\t")
|
||||||
(overlay-put ol 'display
|
(concat str (make-string (max (- tab-width len) 0) ?\ )))
|
||||||
(cond ((string= old-str "\n")
|
(t
|
||||||
(concat str "\n"))
|
;; add padding for wide-width character
|
||||||
((string= old-str "\t")
|
(if (eq (string-width old-str) 2)
|
||||||
(concat str (make-string (max (- tab-width len) 0) ?\ )))
|
(concat str " ")
|
||||||
(t
|
str)))))))
|
||||||
;; add padding for wide-width character
|
|
||||||
(if (eq (string-width old-str) 2)
|
|
||||||
(concat str " ")
|
|
||||||
str))))
|
|
||||||
(push ol avy--overlays-lead))))))
|
|
||||||
|
|
||||||
(defun avy--overlay-post (path leaf)
|
(defun avy--overlay-post (path leaf)
|
||||||
"Create an overlay with PATH at LEAF.
|
"Create an overlay with PATH at LEAF.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user