【问题标题】:Emacs (Aquamacs) using wrong mode (sometimes)Emacs (Aquamacs) 使用错误的模式(有时)
【发布时间】:2011-03-05 19:35:54
【问题描述】:

我正在使用 2.1 版的 Aquamacs 和来自 https://github.com/myfreeweb/django-mode 的 django-mode。我通过添加安装它(在安装 yasn-ps 之后)

(require 'django-html-mode)
(require 'django-mode)
(yas/load-directory "path-to/django-mode/snippets")
(add-to-list 'auto-mode-alist '("\\.djhtml$" . django-html-mode))

到我的 .emacs 文件。但有时 Aquamacs 使用标准 HTML 模式而不是 django-html-mode。只要文件以 html 标记开头,就会发生这种情况。

我必须进行哪些更改才能使 Aquamacs 优先考虑文件的扩展名而不是其内容(至少对于 .djthml 文件 - 其他一切正常)?

【问题讨论】:

    标签: emacs mode aquamacs


    【解决方案1】:

    检查magic-mode-alist 和magic-fallback-mode-alist(尽管如果文件扩展名在auto-mode-alist 中,则不应应用后者)。您还需要注意案例; Emacs 很可能认为FOO.DJHTML 与"\\.djhtml" 匹配不。我没有安装 Aquamacs,但 Emacs.app 在magic-fallback-mode-alist 中有 HTML 识别正则表达式。

    顺便说一句,如果 区分大小写,请将 auto-mode-alist 行更改为

    (add-to-list 'auto-mode-alist '("\\.[Dd][Jj][Hh][Tt][Mm][Ll]$" . django-html-mode))
    

    【讨论】:

    • 我不知道这是否是这样做的方法,但我将(setq magic-mode-alist nil) 放入我的 .emacs 文件中,现在一切似乎都正常了。非常感谢。
    猜你喜欢
    • 2011-03-21
    • 2015-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-04
    相关资源
    最近更新 更多