Talespin_Kit
Talespin_Kit

Reputation: 21897

Binding a key to elisp find-file function

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.

Upvotes: 0

Views: 112

Answers (1)

Michael Markert
Michael Markert

Reputation: 4026

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")))

Upvotes: 1

Related Questions