define-key:符号的函数定义为void:lisp-interaction-mode-map

时间:2012-03-30 21:28:21

标签: emacs elisp

我有一个我要绑定到密钥的代码段:

(define-key (lisp-interaction-mode-map) (kdb "C-c e")
  (let ((result (eval (read (buffer-substring
                             (point-at-bol) (point-at-eol))))))
    (goto-char (point-at-eol))
    (insert (format " ; %s" result))))

然而,当C-c v *scratch*时,我得到了

define-key: Symbol's function definition is void: lisp-interaction-mode-map

2 个答案:

答案 0 :(得分:3)

你有lisp-interaction-mode-map左右的括号,Lisp解释这意味着你要调用名为lisp-interaction-mode-map的函数。相反,您希望将其用作变量。

我还做了一些其他的编辑,你需要得到你必须工作的东西。我假设你写了read以提示输入用户输入的字符串:

(define-key lisp-interaction-mode-map (kbd "C-c C-e")
  (lambda (result)
    (interactive (list (read-from-minibuffer (buffer-substring (point-at-bol) (point-at-eol)))))
    (goto-char (point-at-eol))
    (insert (format " ; %s" result))))

答案 1 :(得分:0)

正常形式有什么问题?

(define-key lisp-interaction-mode-map [(control e)] 'eval-defun)