From 86cebc1fe6083630bf8d99ceaa285647779bd0b4 Mon Sep 17 00:00:00 2001 From: rubikitch Date: Thu, 22 Jul 2010 06:53:00 +0900 Subject: [PATCH] anything.el (anything-candidates-in-buffer-1): refactor: extract function: anything-initial-candidates-from-candidate-buffer --- anything.el | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/anything.el b/anything.el index f86630a..90de129 100644 --- a/anything.el +++ b/anything.el @@ -2824,17 +2824,9 @@ get-line and search-from-end attributes. See also `anything-sources' docstring. (endp (if search-from-end #'bobp #'eobp))) (goto-char (1- start-point)) (if (string= pattern "") - (delq nil (loop with next-line-fn = - (if search-from-end - (lambda (x) (goto-char (max (1- (point-at-bol)) 1))) - #'forward-line) - until (funcall endp) - for i from 1 to limit - collecting (funcall get-line-fn (point-at-bol) (point-at-eol)) - do (funcall next-line-fn 1))) - - (let ((i 1) - buffer-read-only + (anything-initial-candidates-from-candidate-buffer + endp get-line-fn limit search-from-end) + (let (buffer-read-only matches exit newmatches) (anything-search-candidate-buffer-internal (lambda () @@ -2842,7 +2834,8 @@ get-line and search-from-end attributes. See also `anything-sources' docstring. (dolist (searcher search-fns) (goto-char start-point) (setq newmatches nil) - (loop with next-line-fn = + (loop with i = 1 + with next-line-fn = (if search-from-end (lambda (x) (goto-char (max (point-at-bol) 1))) #'forward-line) @@ -2860,6 +2853,16 @@ get-line and search-from-end attributes. See also `anything-sources' docstring. (if exit (return))))) (delq nil matches))))))) +(defun anything-initial-candidates-from-candidate-buffer (endp get-line-fn limit search-from-end) + (delq nil (loop with next-line-fn = + (if search-from-end + (lambda (x) (goto-char (max (1- (point-at-bol)) 1))) + #'forward-line) + until (funcall endp) + for i from 1 to limit + collecting (funcall get-line-fn (point-at-bol) (point-at-eol)) + do (funcall next-line-fn 1)))) + (defun anything-search-candidate-buffer-internal (search-fn) (goto-char (point-min)) (insert "\n") -- 2.11.4.GIT