Why some functions in simple.el are invokable with M-x and some others aren't?
For example I can do M-x what-line but I can't do M-x line-number-at-pos.
- emacs.stackexchange.com/tags/elisp/infoDrew– Drew2022-05-14 21:19:08 +00:00Commented May 14, 2022 at 21:19
- There are also other duplicates, e.g. emacs.stackexchange.com/q/54602/105.Drew– Drew2022-05-14 21:25:19 +00:00Commented May 14, 2022 at 21:25
- See Defining Commands in the Emacs Lisp Manual.NickD– NickD2022-05-15 02:00:25 +00:00Commented May 15, 2022 at 2:00
Add a comment |
1 Answer
Only functions which are declared to be interactive are callable with M-x. The declaration is done by putting an (interactive) form as the first thing in the body of the function. Like this:
(defun an-example () "this is an example function" (interactive) (insert "42")) There is a lot of other information you should know about interactive functions, so you should type C-h f and enter interactive to see more help for it.