0

Is there a command which I could bind to F1 in Emacs that would give me (in a temporary or persistent buffer) contextual documentation on the "symbol" under point?

IIUC, that'd give the same results as:

  • C-c C-v RET in ESS buffers (= ess-display-help-on-object)

  • C-h f/C-h v RET in Emacs Lisp buffers (= describe-function/describe-variable)

  • C-h S in Shell buffers (= info-lookup-symbol) + M-x man-follow

  • ??? in AWK, C, Java

  • ??? in AUCTeX buffers (well, that may be a big dream ;-))

  • ...

Somehow, Auto-Complete does that job (at least in ESS and Emacs Lisp buffers), as it displays the right help (on functions, on variables, etc.) in its "quick help" tooltip. Though, it's only displayed during the completion process, not after.

I first thought that info-lookup-symbol would be (part of) the solution, but it does NOT work in ESS, so it's pretty limited...

What should I bind to F1, then?

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
user3341592
  • 1,419
  • 1
  • 17
  • 36
  • Doesn't `info-lookup-symbol` do most of what you are asking? (If you really need something that combines all of what you mention, then write a command that tests the context and calls the appropriate function (`describ-function` or whatever).) For Emacs thingies, maybe see also command `help-on-click/key` in [help+.el](http://www.emacswiki.org/emacs-en/download/help%2b.el). – Drew Aug 28 '14 at 14:29
  • You're describing a missing feature of Emacs. Feel free to `M-x report-emacs-bug` asking for that new feature. – Stefan Aug 28 '14 at 14:46
  • Reported as bug #18346 – user3341592 Aug 28 '14 at 18:49
  • @itsjeyd -- Thanks for editing the style of the key bindings and the function names! – user3341592 Aug 29 '14 at 07:25
  • No problem. Next time you'll know how to do it yourself ;) – itsjeyd Aug 29 '14 at 09:30

1 Answers1

0

I found this snippet somewhere on the internet a while ago, which can do this for Emacs lisp:

(defun describe-symbol-at-point ()
  "Get help for the symbol at point."
  (interactive)
  (let ((sym (intern-soft (current-word))))
    (unless
        (cond ((null sym))
              ((not (eq t (help-function-arglist sym)))
               (describe-function sym))
              ((boundp sym)
               (describe-variable sym)))
      (message "nothing"))))
jpkotta
  • 9,237
  • 3
  • 29
  • 34
  • This is nice to merge help on function + help on variable under one sole function. Though, in my tests, it only works with Emacs Lisp -- not with ESS (R), nor Shell, nor AWK, nor Java. Still thanks for this appetizer... – user3341592 Aug 29 '14 at 07:28