branch: master
commit 1273871f444afe6db7f5e4881abd3d3b82653149
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>
avy-jump.el (avi--regex-candidates): Allow for a predicate
---
avy-jump.el | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/avy-jump.el b/avy-jump.el
index b83f7a8..7419319 100644
--- a/avy-jump.el
+++ b/avy-jump.el
@@ -75,9 +75,10 @@ POS is either a position or (BEG . END)."
#'aw--remove-leading-chars))))
(aw--done)))
-(defun avi--regex-candidates (regex &optional wnd beg end)
+(defun avi--regex-candidates (regex &optional wnd beg end pred)
"Return all elements that match REGEX in WND.
-Each element of the list is ((BEG . END) . WND)."
+Each element of the list is ((BEG . END) . WND)
+When PRED is non-nil, it's a filter for matching point positions."
(setq wnd (or wnd (selected-window)))
(let ((we (or end (window-end (selected-window) t)))
candidates)
@@ -86,9 +87,11 @@ Each element of the list is ((BEG . END) . WND)."
(save-excursion
(goto-char (or beg (window-start)))
(while (re-search-forward regex we t)
- (push (cons (cons (match-beginning 0)
- (match-end 0))
- wnd) candidates)))
+ (when (or (null pred)
+ (funcall pred))
+ (push (cons (cons (match-beginning 0)
+ (match-end 0))
+ wnd) candidates))))
(nreverse candidates))))
(defun avi--overlay (str pt wnd)