-
eval-buffer
是用在 elisp 代码buffer,在org-mode中执行当然会报错。提示很清楚:Invalid syntax read: #
,首行的#
是Invalid syntax,因为这是org-mode的注释语法,而非elisp代码。看上去您想实践emacs配置的文学编程。执行org-mode中的lisp代码有两种方式:- 直接把光标移动代码区块,按
C-c C-c
,会执行当前区块代码。适合当下的调试。 - 如果要用org-mode管理配置文件,需要在
init.el
配置org-babel,参见 elisp - Can I use org-mode to structure my .emacs or other .el configuration file? - Emacs Stack Exchange
- 直接把光标移动代码区块,按
-
您可以先执行
org-version
查看org-mode的版本。org 9.2之后,代码区块的tab补全需要手动启用Org Tempo library(require 'org-tempo)
建议善用搜索。不过想要准确地描述问题,需要先了解emacs的一些基本概念,知道如何查看当前emacs及各种package的版本(很多问题是版本不兼容造成的)。emacs学习曲线陡峭,不过私以为值得。欢迎加入。