mirror of
https://github.com/abo-abo/avy.git
synced 2025-10-14 13:53:04 +00:00
Special-case char RET to allow for jumping to end-of-lines.
With this change you can use `avy-goto-char' also to jump to the end of some currently visible line. E.g., C-c j <return> (assuming C-c j is bound to `avy-goto-char') makes all line endings jump targets. `avy--overlay-at' had to be adapted so that the overlay at \n doesn't make the line-break disappear. `avy--overlay' had to be adapted in order not to put an overlay on the char after (point-max) in case `avy--overlay-post' is used. (Honestly, this feature is a bit awkward with 'post overlays where the jump location is visualized as first char in the next line.)
This commit is contained in:
parent
487d5ea201
commit
903e172517
12
avy-jump.el
12
avy-jump.el
@ -157,6 +157,7 @@ When PRED is non-nil, it's a filter for matching point positions."
|
|||||||
|
|
||||||
(defun avy--overlay (str pt wnd)
|
(defun avy--overlay (str pt wnd)
|
||||||
"Create an overlay with STR at PT in WND."
|
"Create an overlay with STR at PT in WND."
|
||||||
|
(when (<= (1+ pt) (with-selected-window wnd (point-max)))
|
||||||
(let* ((pt (+ pt avy--overlay-offset))
|
(let* ((pt (+ pt avy--overlay-offset))
|
||||||
(ol (make-overlay pt (1+ pt) (window-buffer wnd)))
|
(ol (make-overlay pt (1+ pt) (window-buffer wnd)))
|
||||||
(old-str (with-selected-window wnd
|
(old-str (with-selected-window wnd
|
||||||
@ -166,7 +167,7 @@ When PRED is non-nil, it's a filter for matching point positions."
|
|||||||
old-str 'face 'avy-background-face)))
|
old-str 'face 'avy-background-face)))
|
||||||
(overlay-put ol 'window wnd)
|
(overlay-put ol 'window wnd)
|
||||||
(overlay-put ol 'display (concat str old-str))
|
(overlay-put ol 'display (concat str old-str))
|
||||||
(push ol avy--overlays-lead)))
|
(push ol avy--overlays-lead))))
|
||||||
|
|
||||||
(defun avy--overlay-pre (path leaf)
|
(defun avy--overlay-pre (path leaf)
|
||||||
"Create an overlay with STR at LEAF.
|
"Create an overlay with STR at LEAF.
|
||||||
@ -204,7 +205,9 @@ LEAF is ((BEG . END) . WND)."
|
|||||||
(setq old-str (propertize
|
(setq old-str (propertize
|
||||||
old-str 'face 'avy-background-face)))
|
old-str 'face 'avy-background-face)))
|
||||||
(overlay-put ol 'window wnd)
|
(overlay-put ol 'window wnd)
|
||||||
(overlay-put ol 'display str)
|
(overlay-put ol 'display (if (string= old-str "\n")
|
||||||
|
(concat str "\n")
|
||||||
|
str))
|
||||||
(push ol avy--overlays-lead))))
|
(push ol avy--overlays-lead))))
|
||||||
|
|
||||||
(defun avy--overlay-post (path leaf)
|
(defun avy--overlay-post (path leaf)
|
||||||
@ -267,7 +270,10 @@ STYLE determines the leading char overlay style."
|
|||||||
The window scope is determined by `avy-all-windows' (ARG negates it)."
|
The window scope is determined by `avy-all-windows' (ARG negates it)."
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(avy--generic-jump
|
(avy--generic-jump
|
||||||
(regexp-quote (string (read-char "char: ")))
|
(let ((c (read-char "char: ")))
|
||||||
|
(if (= 13 c)
|
||||||
|
"\n"
|
||||||
|
(regexp-quote (string c))))
|
||||||
arg
|
arg
|
||||||
avy-goto-char-style))
|
avy-goto-char-style))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user