【问题标题】:Having eruby-nxhtml-mumamo-mode be set every time I open a .html.erb file每次打开 .html.erb 文件时都设置 eruby-nxhtml-mumamo-mode
【发布时间】:2012-04-05 03:42:31
【问题描述】:

我下载了 nxhtml 并解压缩。然后我把它放在我的 .emacs 文件中。

(add-to-list 'load-path "~/nxhtml/util")
    (require 'mumamo-fun)
    (setq mumamo-chunk-coloring 'submode-colored)
    (add-to-list 'auto-mode-alist '("\\.rhtml\\'" . eruby-nxhtml-mumamo-mode))
    (add-to-list 'auto-mode-alist '("\\.html\\.erb\\'" . eruby-nxhtml-mumamo-mode))

当我打开一个 .html.erb 文件时,它没有设置正确的模式(因此语法突出显示不正确)。我知道 require 语句运行正确 b/c 我可以手动将 aquamacs 设置为 eruby-nxhtml-mumamo-mode ,如果我注释掉 require 行,我什至无法切换到该模式。我什至尝试将 eruby...-mode 替换为其他模式,例如 c++-mode 和其他我知道可以工作但也不起作用的模式。

那么我的正则表达式有问题吗?我不确定。任何帮助将不胜感激。

【问题讨论】:

  • 我看不出你的代码有什么问题,并且在实验上它对我有用(指定了不同的模式)。当你说你没有进入正确的模式时,你最终会进入哪种模式?也许另一个映射优先。

标签: ruby-on-rails emacs nxhtml


【解决方案1】:

尝试以下方法:

(add-to-list 'auto-mode-alist '("\\.rhtml?$" . eruby-nxhtml-mumamo-mode))
(add-to-list 'auto-mode-alist '("\\.html?\\.erb$" . eruby-nxhtml-mumamo-mode))

您的表达式末尾似乎有一个转义逗号。

我不知道您的标题中缺少“l”是否是故意的,但无论哪种方式,问号都应该说明这一点。美元符号将表达式锚定到字符串的末尾,名义上是可选的,但最好是明确的。

【讨论】:

  • "当匹配字符串而不是缓冲区时,$ 匹配字符串末尾或换行符之前。"而“\' 匹配空字符串,但仅在缓冲区或匹配字符串的末尾。”换句话说,\' 肯定匹配字符串的结尾,而如果有换行符,$ 可能不匹配。就文件名而言,这种差异不太可能成为问题,但我仍然倾向于使用\'
猜你喜欢
  • 2023-02-17
  • 1970-01-01
  • 2014-03-14
  • 2011-10-14
  • 2016-03-01
  • 1970-01-01
  • 1970-01-01
  • 2015-12-29
  • 2023-03-18
相关资源
最近更新 更多