summaryrefslogtreecommitdiff
path: root/helm-occur.el
diff options
context:
space:
mode:
authorThierry Volpiatto <thierry.volpiatto@gmail.com>2019-06-05 16:59:33 +0200
committerThierry Volpiatto <thierry.volpiatto@gmail.com>2019-06-05 16:59:33 +0200
commitd684c48586873bfb49a68300d3970953f96527f4 (patch)
tree594ce3fb502e6252afb2796db6ab8adc5e05035b /helm-occur.el
parent59dd0cb412f0bb92b322136c5cf0f619d4a97bbc (diff)
Allow restarting helm-occur with same pattern and buffers
* helm-occur.el (helm-occur-mode-map): Bind it. (helm-occur-mode-resume-session): New. (helm-occur-mode--last-pattern): New local var. (helm-occur-mode): Use it.
Diffstat (limited to 'helm-occur.el')
-rw-r--r--helm-occur.el12
1 files changed, 11 insertions, 1 deletions
diff --git a/helm-occur.el b/helm-occur.el
index e0f44169..2b26667c 100644
--- a/helm-occur.el
+++ b/helm-occur.el
@@ -34,6 +34,8 @@ Don't set it to any value, it will have no effect.")
(defvar helm-occur-history nil)
(defvar helm-occur--search-buffer-regexp "\\`\\([0-9]*\\)\\s-\\{1\\}\\(.*\\)\\'"
"The regexp matching candidates in helm-occur candidate buffer.")
+(defvar helm-occur-mode--last-pattern nil)
+
(defvar helm-occur-map
(let ((map (make-sparse-keymap)))
@@ -344,6 +346,7 @@ persistent action."
(define-key map (kbd "M-p") 'helm-occur-mode-goto-line-ow-backward)
(define-key map (kbd "M-N") 'helm-gm-next-file)
(define-key map (kbd "M-P") 'helm-gm-precedent-file)
+ (define-key map (kbd "C-c b") 'helm-occur-mode-resume-session)
map))
(defun helm-occur-mode-goto-line ()
@@ -450,6 +453,11 @@ persistent action."
(helm-occur-mode-goto-line)))))
(put 'helm-moccur-mode-mouse-goto-line 'helm-only t)
+(defun helm-occur-mode-resume-session ()
+ (interactive)
+ (cl-assert (eq major-mode 'helm-occur-mode) nil "Helm command called in wrong context")
+ (helm-multi-occur-1 helm-occur--buffer-list helm-occur-mode--last-pattern))
+
(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."
@@ -552,7 +560,9 @@ Special commands:
(set (make-local-variable 'helm-occur--buffer-list)
(with-helm-buffer helm-occur--buffer-list))
(set (make-local-variable 'revert-buffer-function)
- #'helm-occur-mode--revert-buffer-function))
+ #'helm-occur-mode--revert-buffer-function)
+ (set (make-local-variable 'helm-occur-mode--last-pattern)
+ helm-input))
(put 'helm-moccur-mode 'helm-only t)