开发者

Binding a key to elisp find-file function

开发者 https://www.devze.com 2023-03-26 18:41 出处:网络
I tried the below elisp expression to bind the \"F5\" key to load a file in a buffer. (global-set-key (kbd \"<f5>\") \'(find-file \"/etc/fstab\"))

I tried the below elisp expression to bind the "F5" key to load a file in a buffer.

(global-set-key (kbd "<f5>") '(find-file "/etc/fstab"))

which throws error

Wrong type argument: commandp, (find-file "/etc/fstab")

in the mini buffer.

What is the 开发者_如何转开发error in the elisp expression.


What the error says: It's not a command. An command is a function with a interactive form. Try:

(global-set-key (kbd "<f5>") (lambda () (interactive) (find-file "/etc/fstab")))
0

精彩评论

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