2
votes

I'm trying to make Emacs position definitions of functions and variables in Emacs Lisp source code on the top line of buffer, instead of on the center line, after looking them up from an Help buffer.

I mean: after looking up a function by means of `describe-function', you get an Help buffer and if such function has been defined in an Emacs Lisp source file, you are offered the choice to press RET on such file's name and be taken to that function's definition. However, such definition will be positioned on the center line of the screen, while I'd like it to be positioned on the top line, to view more of its implementation.

I tried to look up what function I could have adviced. describe-mode' for Help said RET was bound tohelp-follow' and I was ready to advice such function, but looking at its definition it was just a place-holder I think:

(defun help-follow ()
   "Follow cross-reference at point.

   For the cross-reference format, see `help-make-xrefs'."
   (interactive)
   (error "No cross-reference here"))

Any help? I'm using Viper+Vimpulse, I don't know whether that changes anything.

Thank you.

3

3 Answers

1
votes

Seems to me the relevant function is help-button-action (it calls help-do-xref), so you may want to advise that to set the point where you want after the xref is found.

1
votes

You may want to use find-function to go to the function's source code.

It uses a variable find-function-recenter-line which is the line number from which to start displaying a function definition. By default it's value is 1, which should be exactly what you need.

And the function's description is the comment after the declaration, so you don't really need the describe-function.

0
votes

FWIW I use these two to quickly jump to source code of a function/variable (C-h C-f, C-h C-v)

(define-key help-map (kbd "C-f") 'find-function-at-point)
(define-key help-map (kbd "C-v") 'find-variable-at-point)