mirror of
https://github.com/abo-abo/avy.git
synced 2025-10-13 05:23:05 +00:00
avy.el (avy-goto-whitespace-end): New command
* avy.el (avy--regex-candidates): Allow `group' to be a function. (avy-jump): Pass `group' to `avy--regex-candidates'. Fixes #278
This commit is contained in:
parent
01a311ca6a
commit
27d1af3fa6
27
avy.el
27
avy.el
@ -960,8 +960,11 @@ When GROUP is non-nil, (BEG . END) should delimit that regex group."
|
||||
(when (avy--visible-p (1- (point)))
|
||||
(when (or (null pred)
|
||||
(funcall pred))
|
||||
(push (cons (cons (match-beginning group)
|
||||
(push (cons
|
||||
(if (numberp group)
|
||||
(cons (match-beginning group)
|
||||
(match-end group))
|
||||
(funcall group))
|
||||
wnd) candidates)))))))
|
||||
(nreverse candidates)))
|
||||
|
||||
@ -1233,20 +1236,22 @@ exist."
|
||||
(ignore #'ignore)
|
||||
(t (error "Unexpected style %S" style))))
|
||||
|
||||
(cl-defun avy-jump (regex &key window-flip beg end action pred)
|
||||
(cl-defun avy-jump (regex &key window-flip beg end action pred group)
|
||||
"Jump to REGEX.
|
||||
The window scope is determined by `avy-all-windows'.
|
||||
When WINDOW-FLIP is non-nil, do the opposite of `avy-all-windows'.
|
||||
BEG and END narrow the scope where candidates are searched.
|
||||
ACTION is a function that takes point position as an argument.
|
||||
When PRED is non-nil, it's a filter for matching point positions."
|
||||
When PRED is non-nil, it's a filter for matching point positions.
|
||||
When GROUP is non-nil, it's either a match group in REGEX, or a function
|
||||
that returns a cons of match beginning and end."
|
||||
(setq avy-action (or action avy-action))
|
||||
(let ((avy-all-windows
|
||||
(if window-flip
|
||||
(not avy-all-windows)
|
||||
avy-all-windows)))
|
||||
(avy-process
|
||||
(avy--regex-candidates regex beg end pred))))
|
||||
(avy--regex-candidates regex beg end pred group))))
|
||||
|
||||
(defun avy--generic-jump (regex window-flip &optional beg end)
|
||||
"Jump to REGEX.
|
||||
@ -1361,6 +1366,20 @@ BEG and END narrow the scope where candidates are searched."
|
||||
:beg beg
|
||||
:end end)))
|
||||
|
||||
;;;###autoload
|
||||
(defun avy-goto-whitespace-end (arg &optional beg end)
|
||||
"Jump to the end of a whitespace sequence.
|
||||
The window scope is determined by `avy-all-windows'.
|
||||
When ARG is non-nil, do the opposite of `avy-all-windows'.
|
||||
BEG and END narrow the scope where candidates are searched."
|
||||
(interactive "P")
|
||||
(avy-with avy-goto-whitespace-end
|
||||
(avy-jump "[ \t]+\\|\n[ \t]*"
|
||||
:window-flip arg
|
||||
:beg beg
|
||||
:end end
|
||||
:group (lambda () (cons (point) (1+ (point)))))))
|
||||
|
||||
(defun avy-goto-word-0-above (arg)
|
||||
"Jump to a word start between window start and point.
|
||||
The window scope is determined by `avy-all-windows'.
|
||||
|
Loading…
x
Reference in New Issue
Block a user