Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable helm-follow-mode feature for helm-git-grep #43

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
* [Customization](#customization)
* [Variables](#variables)
* [helm\-git\-grep\-sources](#helm-git-grep-sources)
* [helm\-follow\-mode\-persistent](#helm-follow-mode-persistent)
* [helm\-git\-grep\-candidate\-number\-limit](#helm-git-grep-candidate-number-limit)
* [helm\-git\-grep\-max\-length\-history](#helm-git-grep-max-length-history)
* [helm\-git\-grep\-use\-ioccur\-style\-keys](#helm-git-grep-use-ioccur-style-keys)
Expand Down Expand Up @@ -167,6 +168,17 @@ If you don't want to search in submodules, Set only `helm-git-grep-source` like

(setq helm-git-grep-sources '(helm-git-grep-source))

#### `helm-follow-mode-persistent`

Please set `helm-follow-mode-persistent` to non-nil if you want to use `helm-follow-mode` by default.

You must set it before loading `helm-git-grep.el`.

``` lisp
(custom-set-variables
'(helm-follow-mode-persistent t))
```

#### `helm-git-grep-candidate-number-limit`

**(Default: `300`)**
Expand Down
30 changes: 12 additions & 18 deletions helm-git-grep.el
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

;;; Code:

(eval-when-compile (require 'cl))
(eval-when-compile (require 'cl-lib))
(require 'helm)
(require 'helm-files)

Expand Down Expand Up @@ -318,22 +318,11 @@ newline return an empty string."

(defun helm-git-grep-save-results-1 ()
"Save helm git grep result in a `helm-git-grep-mode' buffer."
(let ((prompt "GrepBufferName: ")
(buf "*hggrep*")
new-buf)
(when (get-buffer buf)
(setq new-buf (read-string prompt buf))
(loop for b in (helm-buffer-list)
when (and (string= new-buf b)
(not (y-or-n-p
(format "Buffer `%s' already exists overwrite? "
new-buf))))
do (setq new-buf (read-string prompt "*hggrep ")))
(setq buf new-buf))
(let ((buf "*helm-git-grep*")
(default-dir (helm-git-grep-base-directory)))
(with-current-buffer (get-buffer-create buf)
(setq buffer-read-only t)
(let ((default-dir (helm-git-grep-base-directory))
(inhibit-read-only t))
(let ((inhibit-read-only t))
(erase-buffer)
(insert (format "-*- mode: grep; default-directory: \"%s\" -*-\n\n"
default-dir)
Expand All @@ -346,6 +335,8 @@ newline return an empty string."
(buffer-substring (point) (point-max)))))
(setq default-directory default-dir)
(helm-git-grep-mode)
(if (fboundp 'wgrep-change-to-wgrep-mode)
(wgrep-change-to-wgrep-mode))
(pop-to-buffer buf)))
(message "Helm Git Grep Results saved in `%s' buffer" buf)))

Expand All @@ -358,7 +349,7 @@ if MARK is t, Set mark."
(fname (or (with-current-buffer helm-buffer
(get-text-property (point-at-bol) 'help-echo))
(nth 2 candidate))))
(case where
(cl-case where
(other-window (find-file-other-window fname))
(other-frame (find-file-other-frame fname))
(grep (helm-git-grep-save-results-1))
Expand Down Expand Up @@ -667,11 +658,14 @@ You can save your results in a helm-git-grep-mode buffer, see below.

(defvar helm-git-grep-source
(helm-make-source "Git Grep" 'helm-git-grep-class
:candidates-process 'helm-git-grep-process))
:candidates-process 'helm-git-grep-process
:follow (and helm-follow-mode-persistent 1)))

(defvar helm-git-grep-submodule-source
(helm-make-source "Git Submodule Grep" 'helm-git-grep-class
:candidates-process 'helm-git-grep-submodule-grep-process))
:candidates-process 'helm-git-grep-submodule-grep-process
:follow (and helm-follow-mode-persistent 1)))


(defun helm-git-grep-1 (&optional input)
"Execute helm git grep.
Expand Down