Skip to content

yasuyk/helm-git-grep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

helm-git-grep.el

License GPL 3 travis badge coveralls badge melpa badge melpa stable badge

helm for git-grep(1), an incremental git-grep(1).

helm-git-grep

Table of Contents

Created by gh-md-toc

Features

  • Grep submodules too, if submodules exists.
  • Open in other window, other frame, or [elscreen].
  • Toggle ignore case option when incremental greping.
  • Save grep result in grep buffer which is writable with [wgrep].

Minimum requirements

Optional requirements

  • wgrep

    wgrep enable a grep buffer editable and apply those changes to the file buffer.

  • elscreen

    You can open a file in elscleen.

  • git >= 1.9.0

    You must have the git version 1.9.0 or above to use pathspec feature.

Installation

If you're an Emacs 24 user or you have a recent version of package.el you can install helm-git-grep.el from the MELPA repository.

Configuration

Add the following to your emacs init file.

(require 'helm-git-grep) ;; Not necessary if installed by package.el
(global-set-key (kbd "C-c g") 'helm-git-grep)
;; Invoke `helm-git-grep' from isearch.
(define-key isearch-mode-map (kbd "C-c g") 'helm-git-grep-from-isearch)
;; Invoke `helm-git-grep' from other helm.
(eval-after-load 'helm
  '(define-key helm-map (kbd "C-c g") 'helm-git-grep-from-helm))

Basic usage

M-x helm-git-grep

Helm git grep. if submodules exists, grep submodules too.

M-x helm-git-grep-at-point

Helm git grep with symbol at point. if submodules exists, grep submodules too.

Actions

These Actions are available.

Action Description
Find file Jump to result.
Find file other frame Jump to result in other frame.
Find file in Elscreen Jump to result in elscreen.
Save results in grep buffer Save helm git grep result in a grep-mode buffer.
Find file other window Jump to result in other window.

Advanced usage

Keymap helm-git-grep-map

These commands are available when executing incremental [git grep] by helm-git-grep.

For more information about keymap, execute C-c ? helm-git-grep-help.

Key Command Description
C-z helm-git-grep-persistent-action Persistent action. With a prefix arg record candidate in mark-ring.
C-c C-o helm-git-grep-run-other-frame-action Jump to result in other frame.
C-c e helm-git-grep-run-elscreen-action Jump to result in elscreen.
C-x C-s helm-git-grep-run-save-buffer Save helm git grep result in a grep-mode buffer.
C-c o helm-git-grep-run-other-window-action Jump to result in other window.
C-c i helm-git-grep-toggle-ignore-case Toggle ignore case option.
C-w helm-yank-text-at-point Yank text at point in invocation buffer into minibuffer.
C-c ? helm-git-grep-help Help command for helm-git-grep.
M-<down> helm-goto-next-file Go to precedent file in helm git grep buffers.
M-<up> helm-goto-precedent-file Go to next file in helm git grep buffers.

C-c i helm-git-grep-toggle-ignore-case

Toggle ignore case option when incremental greping.

The ignore case option is correspond to -i option of git grep.

A buffer name is *helm git grep [i]* with ignore case option.

A buffer name is *helm git grep* without ignore case option.

Customization

Variables

helm-git-grep-sources

(Default: '(helm-git-grep-source helm-git-grep-submodule-source))

Default helm sources for helm-git-grep.

If you don't want to search in submodules, Set only helm-git-grep-source like this:

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

helm-git-grep-candidate-number-limit

(Default: 300)

Limit candidate number helm-git-grep.

helm-git-grep-max-length-history

(Default: 100)

Max number of elements to save in helm-git-grep-history.

helm-git-grep-use-ioccur-style-keys

(Default: t)

Use Arrow keys to jump to occurrences.

helm-git-grep-ignore-case

(Default: t)

Ignore case when matching.

helm-git-grep-at-point-deactivate-mark

(Default: nil)

Deactivate the mark when helm-git-grep-at-point is invoked.

helm-git-grep-base-directory

(Default: 'root)

Base directory for search by git-grep(1).

Possible value are:

  • root: git root directory
  • current: current directory (default directory of current buffer)

helm-git-grep-pathspecs

(Default: nil)

Pattern used to limit paths in git-grep(1) commands.

Each pathspec have not to be quoted by singe quotation like executing git command in inferior shell. Because helm-git-grep run git command by start-process, and start-process is not executed in inferior shell. So, if pathspec is quoted by singe quotation, pathspec can't work in git-grep(1) by helm-git-grep.

For more information about pathspec, See pathspec in Git gitglossary Documentation.

If there is something wrong about pathspec configuration, you can check limit paths by pathspec using helm-git-grep-ls-files-limited-by-pathspec.

Faces

helm-git-grep-match

Face used to highlight git-grep(1) matches.

helm-git-grep-file

Face used to highlight git-grep(1) results filenames.

helm-git-grep-line

Face used to highlight git-grep(1) number lines.