Emacs抱怨无效功能? [英] Emacs complaining with invalid function?

查看:125
本文介绍了Emacs抱怨无效功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在缓冲区上按下面的代码 Cc c 时,Emacs抱怨无效的函数:(select-current-line) code>。为什么?

When I press C-c c with the following code on a buffer, Emacs complains with Invalid function: (select-current-line). Why?

(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)

不重要,但对于那些感兴趣的人 isend-send 被定义在这里。

Not that it matters, but for those interested isend-send is defined here.

推荐答案

你缺少一个 progn 表单组合语句:

You are missing a progn form to group statements together:

(defun my-isend ()
  (interactive)

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

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






没有 progn form,((select-current-line)(isend-send))被解释为(select-current-line)函数应用于没有参数调用 isend-send 的结果。但是(select-current-line)不是一个有效的函数名。在其他LISP中,如果 select-current-line 的返回值本身是一个函数,那么这样的结构可能是有效的,然后将其应用于 (isend-SEND)。但是Emacs LISP并不是这样,这样做不会达到你想要实现的目的。


Without the progn form, ((select-current-line) (isend-send)) is interpreted as the (select-current-line) function applied to the result of calling isend-send without arguments. But (select-current-line) is not a valid function name. In other LISPs, such a construct could be valid if the return value of select-current-line was itself a function, which would then be applied to (isend-send). But this is not the case of Emacs LISP and this would not do what you wanted to achieve anyway...

这篇关于Emacs抱怨无效功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆