2013-04-08 91 views
2

当我在缓冲区按下C-c c以下代码时,Emacs以Invalid function: (select-current-line)抱怨。为什么?Emacs抱怨无效功能?

(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在这里定义。

+0

只是出于好奇,你为什么要这样做?调用没有活动区域的isend-send已经发送了当前行,所以我不明白你想要实现哪种行为。无论如何,请随时在[github]上打开功能请求(https://github.com/ffevotte/isend-mode.el)... – Francesco 2013-04-08 14:03:44

回答

10

你缺少一个progn形式语句组合到一起:

(defun my-isend() 
    (interactive) 

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

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

没有progn形式,((select-current-line) (isend-send))被解释为适用于呼叫isend-send不带参数的结果(select-current-line)功能。但(select-current-line)不是有效的函数名称。在其他LISP中,如果select-current-line的返回值本身是一个函数,那么这样的结构可能是有效的,然后将其应用于(isend-send)。但是这不是Emacs LISP的情况,这不会做你想达到的目的......