Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call describe-function for current-word in Emacs?

Tags:

emacs

I want to write an Emacs function that calls describe-function for current-word. And if there is no function named current-word then it calls describe-variable.

I tried to write it, but I couldn't even call describe-function for current-word...

(defun describe-function-or-variable ()
(interactive)
(describe-function `(current-word)))

How can I write it?

like image 486
Tetsu Avatar asked Jul 19 '13 21:07

Tetsu


1 Answers

Something like this should work:

(defun describe-function-or-variable ()
  (interactive)
  (let ((sym (intern-soft (current-word))))
    (cond ((null sym)
           "nothing")
          ((functionp sym)
           (describe-function sym))
          (t
           (describe-variable sym)))))
like image 100
jlahd Avatar answered Oct 13 '22 19:10

jlahd