summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThierry Volpiatto <thierry.volpiatto@gmail.com>2018-08-01 05:53:54 +0200
committerThierry Volpiatto <thierry.volpiatto@gmail.com>2018-08-01 05:59:50 +0200
commitde20f620cc6db96be09dea8bf104146fc9bb6380 (patch)
tree17484d7c31de1fa4820f5dfe0f6d7404a89b54af
parentc98ca62001e34f5116b284a39fb4c3e23c72942b (diff)
Use a dolist loop in *-dabbrev--collect
* helm-dabbrev.el (helm-dabbrev--collect): Do it.
-rw-r--r--helm-dabbrev.el63
1 files changed, 32 insertions, 31 deletions
diff --git a/helm-dabbrev.el b/helm-dabbrev.el
index 21ca7471..c8b399af 100644
--- a/helm-dabbrev.el
+++ b/helm-dabbrev.el
@@ -160,37 +160,38 @@ but the initial search for all candidates in buffer(s)."
pattern pbeg replace-regexp)))
(when (and match-word (not (member match-word result)))
(push match-word result)))))))
- (cl-loop for buf in (if all (helm-dabbrev--buffer-list)
- (list (current-buffer)))
- do (with-current-buffer buf
- (when (or minibuf ; check against all buffers when in minibuffer.
- (if helm-dabbrev-related-buffer-fn
- (funcall helm-dabbrev-related-buffer-fn buffer1)
- t))
- (save-excursion
- ;; Start searching before thing before point.
- (goto-char (- (point) (length str)))
- ;; Search the last 30 lines before point.
- (funcall search-and-store str -2)) ; store pos [1]
- (save-excursion
- ;; Search the next 30 lines after point.
- (funcall search-and-store str 2)) ; store pos [2]
- (save-excursion
- ;; Search all before point.
- ;; If limit is reached in previous call of
- ;; search-and-store pos-before is never set and
- ;; goto-char will fail, so check it.
- (when pos-before
- (goto-char pos-before) ; start from [1]
- (funcall search-and-store str -1)))
- (save-excursion
- ;; Search all after point.
- ;; Same comment as above for pos-after.
- (when pos-after
- (goto-char pos-after) ; start from [2]
- (funcall search-and-store str 1)))))
- when (>= (length result) limit) return (nreverse result)
- finally return (nreverse result))))
+ (catch 'break
+ (dolist (buf (if all (helm-dabbrev--buffer-list)
+ (list (current-buffer))))
+ (with-current-buffer buf
+ (when (or minibuf ; check against all buffers when in minibuffer.
+ (if helm-dabbrev-related-buffer-fn
+ (funcall helm-dabbrev-related-buffer-fn buffer1)
+ t))
+ (save-excursion
+ ;; Start searching before thing before point.
+ (goto-char (- (point) (length str)))
+ ;; Search the last 30 lines before point.
+ (funcall search-and-store str -2)) ; store pos [1]
+ (save-excursion
+ ;; Search the next 30 lines after point.
+ (funcall search-and-store str 2)) ; store pos [2]
+ (save-excursion
+ ;; Search all before point.
+ ;; If limit is reached in previous call of
+ ;; search-and-store pos-before is never set and
+ ;; goto-char will fail, so check it.
+ (when pos-before
+ (goto-char pos-before) ; start from [1]
+ (funcall search-and-store str -1)))
+ (save-excursion
+ ;; Search all after point.
+ ;; Same comment as above for pos-after.
+ (when pos-after
+ (goto-char pos-after) ; start from [2]
+ (funcall search-and-store str 1)))))
+ (when (>= (length result) limit) (throw 'break nil))))
+ (nreverse result)))
(defun helm-dabbrev--search (pattern beg sep-regexp)
"Search word or symbol at point matching PATTERN.