3

Is it possible to merge find-function and find-variable to a single find-function-or-variable to be able to search both functions and variables at the same time and going to their definition in the same way as for find-function and find-variable? (possibly with the ability to use TAB completion like the original find-function and find-variable and choosing between two options when a function and a variable bear the same name as remarked by @lawlist).

Name
  • 7,689
  • 4
  • 38
  • 84
  • This is problematic because some functions and variables bear the same name and the interface would need to be adjusted to then ask the user which one -- or display both. It is of course doable, but is *perhaps* a larger project than would fit squarely into a standard answer. However, there are some really bright forum participants who may have a quick modification that would pleasantly surprise me. I have *grep* on speed-dial, along with `find-function`, `find-variable` and `find-face`. – lawlist Aug 26 '15 at 21:46
  • @lawlist Is bearing the same name for the functions and variables loaded by `emacs -Q` too frequent? – Name Aug 26 '15 at 21:57
  • I can only think of a few off the top of my head -- `org-agenda-files` -- `buffer-file-name` -- but the answer would be easier to write up if the user is forced to choose which one when presented with two hits/options, rather than displaying both answers in the help-buffer. The latter is doable, but may be a larger project. – lawlist Aug 26 '15 at 21:59
  • 1
    You can evaluate `(let ((f-and-vs nil)) (mapatoms (lambda (s) (when (and (boundp s) (fboundp s)) (push s f-and-vs)))) f-and-vs)` to get all loaded cases of a symbol being both a function and variable. – npostavs Aug 26 '15 at 22:38

1 Answers1

4

You can use C-h o (describe-symbol) on Emacs 25, here is the related NEWS info:

  • Changes in Emacs 25.1

** New doc command `describe-symbol'. Works for functions, vars, faces, etc...

(It was originally called describe-function-or-variable according to this commit.)

Variable and function with the same name can be showed at the same time, for example, emacs-version

e.g., query "emacs-version"

xuchunyang
  • 14,302
  • 1
  • 18
  • 39
  • Thanks xuchunyang, I use 24.5, but it is interesting to know. My main motivation is to go to the definition in the source file as is for `find-function` or `find-variable`. – Name Aug 26 '15 at 22:35
  • I think you can just try to use [Tags](http://www.gnu.org/software/emacs/manual/html_node/emacs/Tags.html), Emacs's etags works well for me, you need to create Tags and set `tags-table-list` first, then type `M-.` to use it. – xuchunyang Aug 26 '15 at 22:41
  • If anyone wants to use this for 24.x, I've assembled the necessary code from the Emacs 25 sources and placed it in a [gist](https://gist.github.com/troyp/93b020c18c6869f4e61f545b72e1421b). – pyrocrasty Jun 24 '16 at 03:14