emacs - 是否可以让特定的组织模式文件使用自定义主题或外观?

标签 emacs themes org-mode

我希望能够指定特定于将在 org-mode 中打开的文件的主题或自定义外观集。我有什么办法可以做到这一点吗?我已经有https://github.com/vic/color-theme-buffer-local但这并没有提供在打开特定文件时自动应用它的方法。

理想的解决方案不会涉及在 init.el 中进行硬编码,而是涉及在加载的文件(或引用的安装文件)中设置变量或调用 elisp。

举个例子来说明为什么这很有用,一些文件非常扁平,使用一组样式更具可读性,而其他文件则深度嵌套,并从另一组样式中受益。

最佳答案

原始发布者引用了一个名为 color-theme-buffer-local ( https://github.com/vic/color-theme-buffer-local ) 的特定库,原始发布者希望将其应用于在主要模式下打开的文件org-mode——仅当某个变量是t时。

以下示例通过调用以下代码行来使用 color-theme-buffer-local 说明中引用的代码:(load-theme-buffer-local 'misterioso (current -buffer)) 变量 my-favorite-variable 将控制打开 org-mode 缓冲区时何时调用上一行代码 - 即,当non-nil时它适用,当nil时它不适用。


编辑(2014 年 11 月 16 日):以下是根据原始发布者使用文件本地变量的愿望修改的答案:

https://www.gnu.org/software/emacs/manual/html_node/emacs/Specifying-File-Variables.html#Specifying-File-Variables

http://www.gnu.org/software/emacs/manual/html_node/elisp/File-Local-Variables.html#File-Local-Variables

原始发布者在该答案下面的评论中描述的行为是由于常规org-mode-hook在文件本地之前运行的事实变量被考虑在内。因此,当 org-mode-hook 运行时(使用初始答案),变量 my-favorite-variable 仍然是 nil。以下修订后的答案使用 hack-local-variables-hook,它在考虑文件本地变量之后运行。

(defvar my-favorite-variable nil)

(defun my-favorite-function ()
(interactive)
  (when
      (with-current-buffer (current-buffer)
        my-favorite-variable)
    (load-theme-buffer-local 'misterioso (current-buffer))))

(add-hook 'hack-local-variables-hook 'my-favorite-function)

关于emacs - 是否可以让特定的组织模式文件使用自定义主题或外观?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26943803/

相关文章:

emacs - 为什么 slime 的 "package"和劣等的 lisp 不一样?

plugins - Wordpress:从主题访问插件的功能

r - 使用 theme_void r 查看 bar/texte d'axe/etiquettes 标签

emacs - 在 org-babel 的结果 block 中启用字体粗细和颜色

python - Emacs org-mode Python 源代码块不使用 python-mode.el 导出

emacs - 如何评估 Emacs init.el 文件中的某些内容?

emacs - 如何告诉 emacs 在 M-x 编译或 elisp 编译错误时不拆分窗口?

emacs - 自动保存和编译

php - 下划线 Wordpress 主题 - 添加第二个侧边栏

emacs - 组织模式:保护重点