emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 1273871 2/6: avy-jump.el (avi--regex-candidates): Allow fo


From: Oleh Krehel
Subject: [elpa] master 1273871 2/6: avy-jump.el (avi--regex-candidates): Allow for a predicate
Date: Thu, 16 Apr 2015 12:13:05 +0000

branch: master
commit 1273871f444afe6db7f5e4881abd3d3b82653149
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]