Emacs抱怨功能无效?

Ame*_*ina 4 emacs elisp

当我C-c c在缓冲区上按下以下代码时,Emacs会抱怨Invalid function: (select-current-line).为什么?

(defun select-current-line ()
  "Select the current line"
  (interactive)
  (end-of-line) ; move to end of line
  (set-mark (line-beginning-position)))

(defun my-isend ()
  (interactive)

  (if (and transient-mark-mode mark-active)
      (isend-send)

    ((select-current-line)
     (isend-send)))
)

(global-set-key (kbd "C-c c") 'my-isend)
Run Code Online (Sandbox Code Playgroud)

并不重要,但对于那些感兴趣的人来说,isend-send在这里定义.

ffe*_*tte 13

您缺少一个progn表单来将语句组合在一起:

(defun my-isend ()
  (interactive)

  (if (and transient-mark-mode mark-active)
      (isend-send)

    (progn
      (select-current-line)
      (isend-send))))
Run Code Online (Sandbox Code Playgroud)

没有progn表单,((select-current-line) (isend-send))被解释为(select-current-line)应用于isend-send不带参数调用的结果的函数.但(select-current-line)不是有效的函数名称.在其他LISP中,如果返回值select-current-line本身是一个函数,则这样的构造可以是有效的,然后将其应用于该函数(isend-send).但这不是Emacs LISP的情况,而且无论如何都不会做你想要实现的......