Skip to content

Commit

Permalink
Enable helm-follow-mode feature for helm-git-grep
Browse files Browse the repository at this point in the history
  • Loading branch information
zw963 committed Mar 5, 2020
1 parent 744cea0 commit 41b3797
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 18 deletions.
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
39 changes: 21 additions & 18 deletions helm-git-grep.el
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,10 @@ newline return an empty string."
(defun helm-git-grep-submodule-grep-command ()
"Create command of `helm-git-submodule-grep-process' in `helm-git-grep'."
(list "git" "--no-pager" "submodule" "--quiet" "foreach"
(format "git grep -n --no-color %s %s %s %s | sed s!^!$path/!"
(if helm-git-grep-ignore-case "-i" "")
(if helm-git-grep-wordgrep "-w" "")
(helm-git-grep-showing-leading-and-trailing-lines-option t)
(format "git grep -n --no-color %s %s %s %s | sed s!^!$path/!"
(if helm-git-grep-ignore-case "-i" "")
(if helm-git-grep-wordgrep "-w" "")
(helm-git-grep-showing-leading-and-trailing-lines-option t)
(mapconcat (lambda (x)
(format "-e %s " (shell-quote-argument x)))
(split-string helm-pattern " +" t)
Expand Down Expand Up @@ -359,10 +359,10 @@ if MARK is t, Set mark."
(get-text-property (point-at-bol) 'help-echo))
(nth 2 candidate))))
(case where
(other-window (find-file-other-window fname))
(other-frame (find-file-other-frame fname))
(grep (helm-git-grep-save-results-1))
(t (find-file fname)))
(other-window (find-file-other-window fname))
(other-frame (find-file-other-frame fname))
(grep (helm-git-grep-save-results-1))
(t (find-file fname)))
(unless (or (eq where 'grep))
(helm-goto-line lineno))
(when mark
Expand Down Expand Up @@ -412,9 +412,9 @@ Argument SOURCE is not used."
(filename lineno content)
"Propertize FILENAME LINENO CONTENT and concatenate them."
(format "%s:%s:%s"
(propertize filename 'face 'helm-git-grep-file)
(propertize lineno 'face 'helm-git-grep-line)
(helm-git-grep-highlight-match content)))
(propertize filename 'face 'helm-git-grep-file)
(propertize lineno 'face 'helm-git-grep-line)
(helm-git-grep-highlight-match content)))

(defun helm-git-grep-highlight-match (content)
"Highlight matched text with `helm-git-grep-match' face in CONTENT."
Expand All @@ -426,7 +426,7 @@ Argument SOURCE is not used."

(defun helm-git-grep-filtered-candidate-transformer-file-line-1 (candidate)
"Transform CANDIDATE to `helm-git-grep-mode' format."
; truncate any very long lines
; truncate any very long lines
(when (> (length candidate) (window-width))
(setq candidate (substring candidate 0 (window-width))))

Expand Down Expand Up @@ -454,7 +454,7 @@ Argument SOURCE is not used."
With a prefix arg record CANDIDATE in `mark-ring'."
(if current-prefix-arg
(helm-git-grep-action candidate nil 'mark)
(helm-git-grep-action candidate))
(helm-git-grep-action candidate))
(helm-highlight-current-line))

(defun helm-git-grep-get-region-substring ()
Expand Down Expand Up @@ -493,7 +493,7 @@ With a prefix arg record CANDIDATE in `mark-ring'."

(defun helm-git-grep-concat-string-list (list)
"Concatenate string LIST separated by a space."
(mapconcat 'identity(delq nil list) " "))
(mapconcat 'identity(delq nil list) " "))

(defun helm-git-grep-header-name (name)
"Create header NAME for `helm-git-grep'."
Expand Down Expand Up @@ -590,8 +590,8 @@ which is defined by `helm-git-grep-pathspecs'."
(insert (format "git ls-files %s\n\n"
(helm-git-grep-concat-string-list args))))
(when (apply 'call-process "git" nil buf nil
(append '("ls-files") args)))
(display-buffer buf))
(append '("ls-files") args)))
(display-buffer buf))
(message helm-git-grep-pathspec-disabled-message)))

(defvar helm-git-grep-help-message
Expand Down Expand Up @@ -667,11 +667,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

0 comments on commit 41b3797

Please sign in to comment.