[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Sun, 2 Nov 2014 15:15:24 +0100
Emacs by default uses etags.el to find definitions. This is great for C
and similar more static languages, but many more dynamic languages have
other ways of finding definitions. This has lead to major/minor modes
redefining M-. to a specialized "go to definition" function (e.g.
SLIME for CL, slime-nav for Emacs Lisp, Geiser, Cider, Elpy etc.). I
think it would be good if Emacs provided a generalized functionality
for M-. and related commands instead of having all these modes
If I get positive feedback on the following ideas, I'm happy to do the
necessary coding (once the git transition is done).
M-. is bound to a new command `find-definition', which primarily calls
the value of a new variable `find-definition-function' (by default a
wrapper around `find-tag' to keep the current functionality intact).
`find-definition' also keeps track of the tag ring, so this would move
`find-tag-marker-ring' and related functionality out of etags.el, too.
M-* is the standard opposite command for this, so that would be
extracted as well. SLIME and a few other modes re-define M-, to be the
opposite for M-. instead for easier navigation. How do you feel about
swapping the definition of M-, and M-* in etags.el?
C-M-. is currently bound to find-tag-regexp. There is currently no
standard functionality in Emacs to find the callers of a symbol at
point, which might be nice to put on C-M-. if it is defined at some
point for symmetry reasons. If so, find-tag-regexp needs a new key
binding. I'm unsure how useful find-tag-regexp is to begin with as I do
not use tags tables, so I kept it out of the proposal below, even
though it is certainly related.
Other commands affected by this would be C-x 4 . and C-x 5 .
So the new module find-definition.el would define:
A function to be called to find definitions for the symbol at point. It
is called with no arguments, and should return a marker for the
location of the definition.
Call `find-definition-function' and go to the marker returned, if any.
Store the old location in `find-definition-marker-ring'.
M-, or M-* find-definition-pop-mark
Go to the last location in `find-definition-marker-ring'
C-x 4 . and C-x 5 .
Same as `find-definition', except the marker returned by
`find-definition-function' is displayed in another window or frame
Changes to etags.el:
Remove the aforementioned key bindings.
Provide a new function, `etags-find-definition', which calls
`find-tag-noselect'. This will also check for the current prefix
argument to mimic the old behavior for NEXT-P.
Changes to elisp-mode.el:
Provide a value for `find-definition-function' which finds the
definition of the symbol at point.