保存时自动进行字节编译

发布于 2024-11-09 19:50:24 字数 156 浏览 7 评论 0原文

每次我以 emacs lisp 模式保存文件时,我都希望它能自动进行字节编译。如果当前的主要模式是 emacs lisp 模式,有人可以想出一个对当前文件进行字节编译文件的函数吗?我想将该函数add-hook添加到after-save-hook

Everytime I save a file in emacs lisp mode, I want it to be automatically byte-compiled. Can someone come up with a function that does byte-compile-file on the current file if the current major mode is emacs lisp mode? I want to add-hook that function to after-save-hook.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ζ澈沫 2024-11-16 19:50:24

我在此处找到了答案。下面就完成了这一切。这是链接网站的副本。

(add-hook 'after-save-hook 
          (lambda ()
            (if (eq major-mode 'emacs-lisp-mode)
                (save-excursion (byte-compile-file buffer-file-name)))))

I found an answer here. The following does it all. It is a copy from the linked site.

(add-hook 'after-save-hook 
          (lambda ()
            (if (eq major-mode 'emacs-lisp-mode)
                (save-excursion (byte-compile-file buffer-file-name)))))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文