【问题标题】:emacs lisp: how to append to the list "LaTeX-clean-intermediate-suffixes"?emacs lisp:如何附加到列表“LaTeX-clean-intermediate-suffixes”?
【发布时间】:2012-02-12 15:30:29
【问题描述】:

我想将一些正则表达式附加到乳胶命令LaTeX-clean-intermediate-suffixes。我试过了

(setq LaTeX-clean-intermediate-suffixes
        (append LaTeX-clean-intermediate-suffixes (list "\\.foo" "\\.bar"))) 

但我收到以下警告:

Warning (initialization): An error occurred while loading `/Users/myusername/.emacs':

Symbol's value as variable is void: LaTeX-clean-intermediate-suffixes

To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with
the `--debug-init' option to view a complete error backtrace.

如何在此列表中添加一些字符串/后缀?

【问题讨论】:

  • 感谢您的帮助,我在上面添加了警告。

标签: emacs latex elisp


【解决方案1】:

看起来您正试图在加载定义它的包之前修改变量的值。 C-h v 表明该变量是在“latex.el”文件中定义的,因此请尝试执行以下操作:

(eval-after-load 'latex
  '(setq LaTeX-clean-intermediate-suffixes
     (append LaTeX-clean-intermediate-suffixes (list "\\.foo" "\\.bar"))))

请注意,eval-after-load 是一个函数,并且需要引用您要评估的代码 - 有点令人困惑,因为它不同于名称相似的 eval-when-compile 和朋友,它们是宏。

顺便说一句,您还可以使用add-to-list 将项目添加到列表中,使用t 的第三个参数使其附加而不是将它们放在前面。 add-to-list也是一个函数,所以这里需要引用变量名。有时这比setqappend 的组合更具可读性,但您一次只能添加一项​​:

(add-to-list 'LaTeX-clean-intermediate-suffixes "\\.foo" t)

这样做的另一个优点是它会在添加之前检查"\\.foo" 是否已经存在于列表中——这对于加载路径之类的东西很有用。

【讨论】:

    猜你喜欢
    • 2014-08-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多