summaryrefslogtreecommitdiff
path: root/helm-occur.el
diff options
context:
space:
mode:
authorThierry Volpiatto <thierry.volpiatto@gmail.com>2019-04-10 15:12:35 +0200
committerThierry Volpiatto <thierry.volpiatto@gmail.com>2019-04-10 15:12:35 +0200
commitffbae233facb8cc6b319c3dd07bd72833df7307b (patch)
treec0245bd84610e8b3d52768a0bc44822a5a4ee6a9 /helm-occur.el
parentb58a917c483889ba12e57bfba57f35a19dd014a0 (diff)
Remove unneeded args in helm-occur-buffer-substring-with-linums
and add comments and docstrings. * helm-occur.el (helm-occur-buffer-substring-with-linums): Remove BEG and AND. (helm-occur-mode--revert-buffer-function): Use it and add comments.
Diffstat (limited to 'helm-occur.el')
-rw-r--r--helm-occur.el17
1 files changed, 11 insertions, 6 deletions
diff --git a/helm-occur.el b/helm-occur.el
index 21377fd1..96dd7f88 100644
--- a/helm-occur.el
+++ b/helm-occur.el
@@ -424,8 +424,10 @@ Same as `helm-occur-goto-line' but go in new frame."
(helm-occur-mode-goto-line)))))
(put 'helm-moccur-mode-mouse-goto-line 'helm-only t)
-(defun helm-occur-buffer-substring-with-linums (beg end)
- (let ((bufstr (buffer-substring-no-properties beg end))
+(defun helm-occur-buffer-substring-with-linums ()
+ "Returns current-buffer contents as a string with all lines
+numbered. The property 'buffer-name is added to the whole string."
+ (let ((bufstr (buffer-substring-no-properties (point-min) (point-max)))
(bufname (buffer-name)))
(with-temp-buffer
(save-excursion
@@ -439,6 +441,7 @@ Same as `helm-occur-goto-line' but go in new frame."
(buffer-string))))
(defun helm-occur-mode--revert-buffer-function (&optional _ignore-auto _noconfirm)
+ "The `revert-buffer-function' for `helm-occur-mode'."
(goto-char (point-min))
(let (pattern)
(when (re-search-forward "^Occur Results for `\\(.*\\)'" nil t)
@@ -448,8 +451,7 @@ Same as `helm-occur-goto-line' but go in new frame."
(forward-line 1))
(let ((inhibit-read-only t)
(buffer (current-buffer))
- (buflst helm-occur--buffer-list)
- (bsubstring #'helm-occur-buffer-substring-with-linums))
+ (buflst helm-occur--buffer-list))
(delete-region (point) (point-max))
(message "Reverting buffer...")
(save-excursion
@@ -459,22 +461,25 @@ Same as `helm-occur-goto-line' but go in new frame."
(cl-loop for buf in buflst
for bufstr = (or (and (buffer-live-p (get-buffer buf))
(with-current-buffer buf
- (funcall bsubstring
- (point-min) (point-max))))
+ (helm-occur-buffer-substring-with-linums)))
"")
concat bufstr)
"\n")
(goto-char (point-min))
(cl-loop with linum
with mpart
+ ;; Bind helm-pattern used by `helm-grep-split-line'.
with helm-pattern = pattern
while (helm-mm-search pattern)
+ ;; Calculate line number (linum) and extract real
+ ;; part of line (mpart).
do (when (save-excursion
(forward-line 0)
(re-search-forward "^\\([0-9]*\\)\\s-\\{1\\}\\(.*\\)$"
(point-at-eol) t))
(setq linum (string-to-number (match-string 1))
mpart (match-string 2)))
+ ;; Match part after line number.
when (and mpart (string-match pattern mpart))
for line = (format "%s:%d:%s"
(get-text-property (point) 'buffer-name)