这是我第一次尝试为Emacs创建一个函数。
我创建了这个简单的函数:
(defun open-init-file () "Opens the ~/.emacs.d/init.el file" (find-file user-init-file))我把它放进去:
~/.emacs.d/init.el然后我跑了“eval-buffer”。
我没有收到任何错误消息。 然而,我无法调用此功能。 如果我输入Mx并输入“open-init-file”,我被告知没有与该名称匹配的功能。
即使我把这个函数放在自己的缓冲区中,把光标放在最后,然后运行eval-last-sexp,这个函数仍然不会在Emacs中看到。
然而,如果我把它放在缓冲区中:
(find-file user-init-file)如果我把光标放在这个结尾,然后运行eval-last-sexp,那么这就像我期望的那样工作。
我究竟做错了什么?
This is my first attempt at creating a function for Emacs.
I created this simple function:
(defun open-init-file () "Opens the ~/.emacs.d/init.el file" (find-file user-init-file))I put it in:
~/.emacs.d/init.elI then ran "eval-buffer".
I got no error message. And yet I can not call this function. If I type M-x and type "open-init-file" I am told that there is no function matching that name.
Even if I put this function in its own buffer, put the cursor at the end, and run eval-last-sexp, this function still is not see as existing in Emacs.
And yet, if I put this in a buffer:
(find-file user-init-file)and if I put the cursor at the end of this and then run eval-last-sexp, then this works as I expect.
What am I doing wrong?
最满意答案
你应该制作和interactive功能(又名命令)
(defun open-init-file () "Opens the ~/.emacs.d/init.el file" (interactive) (find-file user-init-file))You should make and interactive function (a.k.a. a command)
(defun open-init-file () "Opens the ~/.emacs.d/init.el file" (interactive) (find-file user-init-file))更多推荐
发布评论