开发者

Newbie: Keybindings error in Elisp

I am trying to make a simple 开发者_StackOverflow中文版keybinding to the "na" function. When I execute (na) it inserts "å" in the current buffer, which it is supposed to, but the when I try the keybinding as described in the first line I get the error: "Wrong argument: commandp, na". I am not sure if it matters, but I have also put the (local-set-key) command at the end of the code, but it produces the same error.

Now, I'm sure there is an easy solution to this. I just cannot see it =/

(local-set-key (kbd "C-c C-t") 'na)

(defun na ()
       "Liten å"
       (setq varlol "å")
       (insert varlol))


What you're missing is a call to interactive:

(defun na ()
  "Liten å"
  (interactive)
  (setq varlol "å")
  (insert varlol))

From the documentation for it:

This special form declares that a function is a command, and that it may therefore be called interactively (via M-x or by entering a key sequence bound to it). The argument arg-descriptor declares how to compute the arguments to the command when the command is called interactively.


"interactive" is missing

(defun na ()
  (interactive)
       "Liten å"
       (setq varlol "å")
       (insert varlol))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜