如何在Emacs中为current-word调用describe-function?

Tet*_*tsu 5 emacs

我想写一个Emacs函数来调用describe-functioncurrent-word.如果没有命名的函数current-word则调用describe-variable.

我试着写,但我连打电话describe-functioncurrent-word...

(defun describe-function-or-variable ()
(interactive)
(describe-function `(current-word)))
Run Code Online (Sandbox Code Playgroud)

我怎么写呢?

jla*_*ahd 6

这样的事情应该有效:

(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)))))
Run Code Online (Sandbox Code Playgroud)