emacs功能不起作用,但没有错误消息(emacs function won't work, yet there is no error message)

编程入门 行业动态 更新时间:2024-10-10 21:24:47
emacs功能不起作用,但没有错误消息(emacs function won't work, yet there is no error message)

这是我第一次尝试为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.el

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

更多推荐

本文发布于:2023-07-06 07:44:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1047456.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:但没   不起作用   错误   消息   功能

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!