5

バッファーで次のコードを押す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)

それは問題ではありませんが、興味のある人のために isend-sendがここで定義されています。

4

1 に答える 1

14

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))として解釈されます。しかし、有効な関数名ではありません。他の LISP では、そのような構造は、 の戻り値自体が関数である場合に有効であり、それが に適用されます。しかし、これは Emacs LISP の場合ではなく、とにかく達成したいことはできません...(select-current-line)isend-send(select-current-line)select-current-line(isend-send)

于 2013-04-08T13:53:16.437 に答える