Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avy.el: Option for avy-goto-line to retain column #347

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions avy.el
Original file line number Diff line number Diff line change
Expand Up @@ -1606,7 +1606,14 @@ Which one depends on variable `subword-mode'."

(defcustom avy-indent-line-overlay nil
"When non-nil, display line overlay next to the first non-whitespace character.
This affects `avy-goto-line'."
This affects `avy-goto-line' and overrides `avy-column-line-overlay'."
:type 'boolean)

(defcustom avy-column-line-overlay nil
"When non-nil, display line overlay in same column as cursor.
Overlay displays at end-of-line on lines that don't reach column.
This affects `avy-goto-line' but has no effect if `avy-indent-line-overlay' is
non-nil."
:type 'boolean)

(defun avy--line-cands (&optional arg beg end bottom-up)
Expand All @@ -1617,7 +1624,8 @@ BEG and END narrow the scope where candidates are searched.
When BOTTOM-UP is non-nil, display avy candidates from top to bottom"
(let (candidates)
(avy-dowindows arg
(let ((ws (or beg (window-start))))
(let ((ws (or beg (window-start)))
(col (current-column)))
(save-excursion
(save-restriction
(narrow-to-region ws (or end (window-end (selected-window) t)))
Expand All @@ -1629,8 +1637,12 @@ When BOTTOM-UP is non-nil, display avy candidates from top to bottom"
(if (eq avy-style 'post)
(line-end-position)
(save-excursion
(when avy-indent-line-overlay
(cond
(avy-indent-line-overlay
(skip-chars-forward " \t"))
(avy-column-line-overlay
(move-to-column col))
(t (ignore)))
(point)))
(selected-window)) candidates))
(if visual-line-mode
Expand Down