Permalink
Browse files

run real grep from helm-grep-mode

resolves #156
  • Loading branch information...
1 parent d79b543 commit 7f6a128c7da95c19171cfe6c23559437877b71e3 Le Wang committed Nov 18, 2012
Showing with 14 additions and 3 deletions.
  1. +14 −3 helm-grep.el
View
@@ -198,6 +198,8 @@ Where '%f' format spec is filename and '%p' is page number"
It is intended to use as a let-bound variable, DON'T set this globaly.")
(defvar helm-pdfgrep-targets nil)
(defvar helm-grep-last-cmd-line nil)
+(defvar helm-grep-cmd-line nil)
+(make-variable-buffer-local 'helm-grep-cmd-line)
(defun helm-c-grep-prepare-candidates (candidates)
"Prepare filenames and directories CANDIDATES for grep command line."
@@ -454,20 +456,25 @@ WHERE can be one of other-window, elscreen, other-frame."
(setq buffer-read-only t)
(let ((inhibit-read-only t))
(erase-buffer)
- (insert "-*- mode: helm-grep -*-\n\n"
- (format "Grep Results for `%s':\n\n" helm-pattern))
+ (insert "-*- mode: helm-grep -*- Press \"g\" to run Emacs grep.\n\n"
+ (format "Grep Results for `%s':\n\n" helm-pattern)
+ )
(save-excursion
(insert (with-current-buffer helm-buffer
(goto-char (point-min)) (forward-line 1)
(buffer-substring (point) (point-max))))))
- (helm-grep-mode) (pop-to-buffer buf))
+ (helm-grep-mode)
+ (pop-to-buffer buf)
+ (setq default-directory helm-grep-last-default-directory)
+ (setq helm-grep-cmd-line helm-grep-last-cmd-line))
(message "Helm Grep Results saved in `%s' buffer" buf)))
(defvar helm-grep-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "RET") 'helm-grep-mode-jump)
(define-key map (kbd "C-o") 'helm-grep-mode-jump-other-window)
(define-key map (kbd "q") 'helm-grep-mode-quit)
+ (define-key map (kbd "g") 'helm-grep-run-real-grep)
(define-key map (kbd "<C-down>") 'helm-grep-mode-jump-other-window-forward)
(define-key map (kbd "<C-up>") 'helm-grep-mode-jump-other-window-backward)
(define-key map (kbd "<M-down>") 'helm-gm-next-file)
@@ -533,6 +540,10 @@ Special commands:
(helm-c-grep-action candidate 'other-window)
(error nil))))
+(defun helm-grep-run-real-grep ()
+ (interactive)
+ (grep helm-grep-cmd-line))
+
(defun helm-c-grep-persistent-action (candidate)
"Persistent action for `helm-do-grep'.
With a prefix arg record CANDIDATE in `mark-ring'."

0 comments on commit 7f6a128

Please sign in to comment.