Emacs 和 Sweave 的缓冲区局部变量

发布于 2024-08-18 13:36:13 字数 976 浏览 7 评论 0 原文

我使用 Emacs 23.1 和 ESS 5.4 来编辑 Sweave 文件。我想关闭缓冲区中默认的 AUCTeX 缩进行为(以避免逐项列表中包含的代码块带来麻烦),因此在文件顶部我有 % -*- LaTeX-indent-level: 0; LaTeX-项目缩进:0; -*-。当我打开缓冲区并运行 Ch v LaTeX-indent-level 时,我得到了我想要的:

LaTeX-indent-level is a variable defined in `latex.el'.
Its value is 0
Local in buffer test.Rnw; global value is 2

  This variable is a file local variable.

但是,在编辑代码块后,它会返回默认行为。 Ch v LaTeX-indent-level 现在产生:

LaTeX-indent-level is a variable defined in `latex.el'.
Its value is 2

我尝试了 noweb-mode FAQ,建议添加

(add-hook 'noweb-select-mode-hook
              '(lambda () (hack-local-variables-prop-line)))

到我的 .emacs。当我这样做时,上述行为仍然存在。

有什么方法可以让缓冲区局部变量在这种情况下工作吗?我不想在所有 Sweave/noweb 缓冲区中更改我的 .emacs 将 LaTeX-indent-level 设置为 0。

I'm using Emacs 23.1 with ESS 5.4 to edit an Sweave file. I'd like to turn off the default AUCTeX indentation behavior in the buffer (to avoid annoyances with code chunks contained in itemized lists), so at the top of the file I have % -*- LaTeX-indent-level: 0; LaTeX-item-indent: 0; -*-. When I open the buffer and run C-h v LaTeX-indent-level, I get what I wanted:

LaTeX-indent-level is a variable defined in `latex.el'.
Its value is 0
Local in buffer test.Rnw; global value is 2

  This variable is a file local variable.

However, after I edit a code chunk, it returns to the default behavior. C-h v LaTeX-indent-level now yields:

LaTeX-indent-level is a variable defined in `latex.el'.
Its value is 2

I tried the fix suggested in the noweb-mode FAQ, which suggests adding

(add-hook 'noweb-select-mode-hook
              '(lambda () (hack-local-variables-prop-line)))

to my .emacs. The behavior described above persisted when I did this.

Is there any way I can get buffer-local variables to work in this situation? I would prefer not to have to change my .emacs to set LaTeX-indent-level to 0 in all Sweave/noweb buffers.

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

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

发布评论

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

评论(1

穿越时光隧道 2024-08-25 13:36:13

我还没有对此进行测试,但请尝试以下操作:

(add-hook 'noweb-select-mode-hook
              '(lambda () (hack-local-variables)))

也许 hack-local-variables-prop-line 已更改为仅解析值,而不是声明它们。

I haven't tested this, but try the following instead:

(add-hook 'noweb-select-mode-hook
              '(lambda () (hack-local-variables)))

Perhaps hack-local-variables-prop-line has been changed to merely parse the values, not instate them.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文