Skip to content

Emacs function to find definition in git repository using git grep

Notifications You must be signed in to change notification settings

mallt/gg-find-def

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

License GPL 3

gg-find-def for emacs

Find the definition of a symbol in a git repository using git grep. The search terms describing how to find a possible definition are customizable per file extension.

Currently the customization variables only contain defaults for clojure, elisp, javascript and php files.

gg-find-def screencast

Installation

Bind the gg-find-def function to the keybinding of your choice, f.ex. C-c f d.

Customization

The behavior of the gg-find-def function can be customized per file extension with 2 variables:

gg-find-def-extension-search-terms

This is an association list that maps file extensions to a list of search terms. A search term is a string that describes how a possible definition can be found. It has to contain a %s string argument that will be replaced by the return value of the input function defined in the gg-find-def-extension-input-fns variable. All search terms will be used by the git grep command to locate possible definitions.

The default value of this variable contains only a couple of extensions, f.ex. the association for elisp files is ("el" . ("defun %s" "defmacro %s" "defvar %s" "defcustom %s")). This means the gg-find-def function will try to find the definition of a symbol by looking for occurences of defun, defmacro, defvar and defcustom.

gg-find-def-extension-input-fns

This is an assocation list that maps file extensions to an input function. The result of the input function will be used as input for every search term specified by the gg-find-def-extension-search-terms variable.

The default value of this variable contains only a couple of extensions, f.ex. the association for elisp files is ("el" . (lambda () (thing-at-point 'symbol t))). This means the gg-find-def function will replace the %s string argument of the search terms by the thing at point.

Usage

Move the point to a symbol and try to find its definition in the current git repository by pressing the keybinding for the gg-find-def function (f.ex. C-c f d). If more than 1 candidate is found, a list of candidates will be displayed.

Before jumping to the definition the current position will be marked, so jumping back to the position before the find can be done by popping the mark off the local (C-u C-SPC) or global find ring (C-x C-SPC).

About

Emacs function to find definition in git repository using git grep

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published