Permalink
Browse files

* helm-regexp.el (helm-m-occur-use-ioccur-style-keys): New user var.

  • Loading branch information...
1 parent 3211573 commit f167a01e710314fd4ea85032575831f5cdb5c767 @thierryvolpiatto thierryvolpiatto committed Sep 9, 2012
Showing with 22 additions and 3 deletions.
  1. +22 −3 helm-regexp.el
View
@@ -61,6 +61,11 @@ This setting apply also to `helm-c-source-occur'."
:group 'helm-regexp
:type 'float)
+(defcustom helm-m-occur-use-ioccur-style-keys t
+ "Similar to `helm-c-grep-use-ioccur-style-keys' but for multi occur."
+ :group 'helm-regexp
+ :type 'boolean)
+
(defface helm-moccur-buffer
'((t (:foreground "DarkTurquoise" :underline t)))
@@ -75,6 +80,9 @@ This setting apply also to `helm-c-source-occur'."
(define-key map (kbd "M-<up>") 'helm-c-goto-precedent-file)
(define-key map (kbd "C-w") 'helm-yank-text-at-point)
(define-key map (kbd "C-c ?") 'helm-moccur-help)
+ (when helm-m-occur-use-ioccur-style-keys
+ (define-key map (kbd "<right>") 'helm-m-occur-run-persistent-action)
+ (define-key map (kbd "<left>") 'helm-m-occur-run-default-action))
(delq nil map))
"Keymap used in Moccur source.")
@@ -211,10 +219,23 @@ arg METHOD can be one of buffer, buffer-other-window, buffer-other-frame."
(buffer-other-frame (switch-to-buffer-other-frame buf)))
(helm-goto-line lineno)))
+(defun helm-m-occur-persistent-action (candidate)
+ (helm-m-occur-goto-line candidate)
+ (helm-match-line-color-current-line))
@lewang

lewang Sep 12, 2012

Member
(helm-match-line-color-current-line)

Is not necessary helm-goto-line already animates.

@thierryvolpiatto

thierryvolpiatto via email Sep 12, 2012

Owner
@lewang

lewang via email Sep 12, 2012

Member
+
+(defun helm-m-occur-run-persistent-action ()
+ (interactive)
+ (when helm-alive-p
+ (helm-execute-persistent-action)))
+
(defun helm-m-occur-goto-line (candidate)
"From multi occur, switch to buffer and go to nth 1 CANDIDATE line."
(helm-m-occur-action candidate))
+(defun helm-m-occur-run-default-action ()
+ (interactive)
+ (helm-c-quit-and-execute-action 'helm-m-occur-goto-line))
+
(defvar helm-c-source-moccur
`((name . "Moccur")
(init . (lambda ()
@@ -227,9 +248,7 @@ arg METHOD can be one of buffer, buffer-other-window, buffer-other-frame."
(get-line . helm-m-occur-get-line)
(migemo)
(action . (("Go to Line" . helm-m-occur-goto-line)))
- (persistent-action . (lambda (candidate)
- (helm-m-occur-goto-line candidate)
- (helm-match-line-color-current-line)))
+ (persistent-action . helm-m-occur-persistent-action)
(persistent-help . "Go to line")
(recenter)
(candidate-number-limit . 9999)

0 comments on commit f167a01

Please sign in to comment.