summaryrefslogtreecommitdiff
path: root/helm-dabbrev.el
diff options
context:
space:
mode:
authorThierry Volpiatto <thierry.volpiatto@gmail.com>2017-08-19 05:11:13 +0200
committerThierry Volpiatto <thierry.volpiatto@gmail.com>2017-08-19 05:11:13 +0200
commit90dc01d208383ce49d443c7a9b3d904068509893 (patch)
tree0dd90ac77a48b814ddd2a4827c26f36a59bbad1a /helm-dabbrev.el
parentbd7abcd8bc8203b959c766193b20f335e3484fd4 (diff)
Fix long lines and reindent, no code change
* helm-dabbrev.el (helm-dabbrev--collect): Do it.
Diffstat (limited to 'helm-dabbrev.el')
-rw-r--r--helm-dabbrev.el111
1 files changed, 58 insertions, 53 deletions
diff --git a/helm-dabbrev.el b/helm-dabbrev.el
index 8057e0e8..476a97f5 100644
--- a/helm-dabbrev.el
+++ b/helm-dabbrev.el
@@ -131,66 +131,71 @@ but the initial search for all candidates in buffer(s)."
(defun helm-dabbrev--collect (str limit ignore-case all)
(let* ((case-fold-search ignore-case)
- (buffer1 (current-buffer)) ; start buffer.
+ (buffer1 (current-buffer)) ; start buffer.
(minibuf (minibufferp buffer1))
result pos-before pos-after
(search-and-store
(lambda (pattern direction)
- (while (cl-case direction
- (1 (search-forward pattern nil t))
- (-1 (search-backward pattern nil t))
- (2 (let ((pos
- (save-excursion
- (forward-line
- helm-dabbrev-lineno-around)
- (point))))
- (setq pos-after pos)
- (search-forward pattern pos t)))
- (-2 (let ((pos
- (save-excursion
- (forward-line
- (- helm-dabbrev-lineno-around))
- (point))))
- (setq pos-before pos)
- (search-backward pattern pos t))))
- (let* ((pbeg (match-beginning 0))
- (replace-regexp (concat "\\(" helm-dabbrev--regexp "\\)\\'"))
- (match-word (save-excursion
- (goto-char (1- pbeg))
- (when (re-search-forward
- (concat "\\(" helm-dabbrev--regexp "\\)"
- "\\(?99:\\(" pattern "\\(\\sw\\|\\s_\\)+\\)\\)")
- (point-at-eol) t)
- (replace-regexp-in-string
- replace-regexp "" (match-string-no-properties 99))))))
- (unless (member match-word result)
- (push match-word result)))))))
+ (while (cl-case direction
+ (1 (search-forward pattern nil t))
+ (-1 (search-backward pattern nil t))
+ (2 (let ((pos
+ (save-excursion
+ (forward-line
+ helm-dabbrev-lineno-around)
+ (point))))
+ (setq pos-after pos)
+ (search-forward pattern pos t)))
+ (-2 (let ((pos
+ (save-excursion
+ (forward-line
+ (- helm-dabbrev-lineno-around))
+ (point))))
+ (setq pos-before pos)
+ (search-backward pattern pos t))))
+ (let* ((pbeg (match-beginning 0))
+ (replace-regexp (concat "\\(" helm-dabbrev--regexp
+ "\\)\\'"))
+ (match-word (save-excursion
+ (goto-char (1- pbeg))
+ (when (re-search-forward
+ (concat "\\("
+ helm-dabbrev--regexp
+ "\\)"
+ "\\(?99:\\(" pattern
+ "\\(\\sw\\|\\s_\\)+\\)\\)")
+ (point-at-eol) t)
+ (replace-regexp-in-string
+ replace-regexp ""
+ (match-string-no-properties 99))))))
+ (unless (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.
- (goto-char pos-before) ; start from [1]
- (funcall search-and-store str -1))
- (save-excursion
- ;; Search all after point.
- (goto-char pos-after) ; start from [2]
- (funcall search-and-store str 1))))
- when (> (length result) limit) return (nreverse result)
- finally return (nreverse result))))
+ 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.
+ (goto-char pos-before) ; start from [1]
+ (funcall search-and-store str -1))
+ (save-excursion
+ ;; Search all after point.
+ (goto-char pos-after) ; start from [2]
+ (funcall search-and-store str 1))))
+ when (> (length result) limit) return (nreverse result)
+ finally return (nreverse result))))
(defun helm-dabbrev--get-candidates (abbrev)
(cl-assert abbrev nil "[No Match]")