[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 903e172 12/17: Special-case char RET to allow for jumping
From: |
Oleh Krehel |
Subject: |
[elpa] master 903e172 12/17: Special-case char RET to allow for jumping to end-of-lines. |
Date: |
Fri, 08 May 2015 13:42:12 +0000 |
branch: master
commit 903e1725179660f465d20246bc4511bb60a294dd
Author: Tassilo Horn <address@hidden>
Commit: Tassilo Horn <address@hidden>
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.)
---
avy-jump.el | 50 ++++++++++++++++++++++++++++----------------------
1 files changed, 28 insertions(+), 22 deletions(-)
diff --git a/avy-jump.el b/avy-jump.el
index 126b02b..6c7d961 100644
--- a/avy-jump.el
+++ b/avy-jump.el
@@ -92,16 +92,16 @@ POS is either a position or (BEG . END)."
(defun avy--process (candidates overlay-fn)
"Select one of CANDIDATES using `avy-read'."
(unwind-protect
- (cl-case (length candidates)
- (0
- nil)
- (1
- (car candidates))
- (t
- (avy--make-backgrounds (list (selected-window)))
- (avy-read (avy-tree candidates avy-keys)
- overlay-fn
- #'avy--remove-leading-chars)))
+ (cl-case (length candidates)
+ (0
+ nil)
+ (1
+ (car candidates))
+ (t
+ (avy--make-backgrounds (list (selected-window)))
+ (avy-read (avy-tree candidates avy-keys)
+ overlay-fn
+ #'avy--remove-leading-chars)))
(avy--done)))
(defvar avy--overlays-back nil
@@ -157,16 +157,17 @@ When PRED is non-nil, it's a filter for matching point
positions."
(defun avy--overlay (str pt wnd)
"Create an overlay with STR at PT in WND."
- (let* ((pt (+ pt avy--overlay-offset))
- (ol (make-overlay pt (1+ pt) (window-buffer wnd)))
- (old-str (with-selected-window wnd
- (buffer-substring pt (1+ pt)))))
- (when avy-background
- (setq old-str (propertize
- old-str 'face 'avy-background-face)))
- (overlay-put ol 'window wnd)
- (overlay-put ol 'display (concat str old-str))
- (push ol avy--overlays-lead)))
+ (when (<= (1+ pt) (with-selected-window wnd (point-max)))
+ (let* ((pt (+ pt avy--overlay-offset))
+ (ol (make-overlay pt (1+ pt) (window-buffer wnd)))
+ (old-str (with-selected-window wnd
+ (buffer-substring pt (1+ pt)))))
+ (when avy-background
+ (setq old-str (propertize
+ old-str 'face 'avy-background-face)))
+ (overlay-put ol 'window wnd)
+ (overlay-put ol 'display (concat str old-str))
+ (push ol avy--overlays-lead))))
(defun avy--overlay-pre (path leaf)
"Create an overlay with STR at LEAF.
@@ -204,7 +205,9 @@ LEAF is ((BEG . END) . WND)."
(setq old-str (propertize
old-str 'face 'avy-background-face)))
(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))))
(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)."
(interactive "P")
(avy--generic-jump
- (regexp-quote (string (read-char "char: ")))
+ (let ((c (read-char "char: ")))
+ (if (= 13 c)
+ "\n"
+ (regexp-quote (string c))))
arg
avy-goto-char-style))
- [elpa] master updated (74b34f2 -> 876d210), Oleh Krehel, 2015/05/08
- [elpa] master 1684e6a 03/17: Avoid image-mode and doc-view-mode, Oleh Krehel, 2015/05/08
- [elpa] master 1d184b0 05/17: Regexp-quote strings of avy-goto-char* functions., Oleh Krehel, 2015/05/08
- [elpa] master 33546b6 06/17: Fix avy-goto-subword-0, Oleh Krehel, 2015/05/08
- [elpa] master 5677270 04/17: Move obsoletes to one place, Oleh Krehel, 2015/05/08
- [elpa] master 18cf1ef 07/17: README.md: add, Oleh Krehel, 2015/05/08
- [elpa] master 6c1f2f6 02/17: Move from "avi-" to "avy-", leave old stuff obsolete, Oleh Krehel, 2015/05/08
- [elpa] master 974e55b 09/17: avy-jump.el (avy--line): Avoid image-mode and doc-view-mode, Oleh Krehel, 2015/05/08
- [elpa] master 5d2979b 01/17: Initial import, Oleh Krehel, 2015/05/08
- [elpa] master e9d2e60 08/17: Customize the leading char style for chars and words, Oleh Krehel, 2015/05/08
- [elpa] master 903e172 12/17: Special-case char RET to allow for jumping to end-of-lines.,
Oleh Krehel <=
- [elpa] master 487d5ea 11/17: Abstract windows and rely on subword, Oleh Krehel, 2015/05/08
- [elpa] master ca1ca04 14/17: Add avy-goto-subword-1, Oleh Krehel, 2015/05/08
- [elpa] master e4f493e 10/17: README.md: Add command descriptions, Oleh Krehel, 2015/05/08
- [elpa] master 3200351 16/17: avy-jump.el (avy-setup-default): Setup some bindings, Oleh Krehel, 2015/05/08
- [elpa] master b2112e0 13/17: avy-jump.el (avy-goto-word-1): Fix for ".", Oleh Krehel, 2015/05/08
- [elpa] master f2290f2 15/17: avy.el: Update commentary, Oleh Krehel, 2015/05/08
- [elpa] master 876d210 17/17: Add 'packages/avy/' from commit '32003515c8efa2cf38b62c45499dae30bc7cacb8', Oleh Krehel, 2015/05/08