【问题标题】:customize emacs mode and font-lock-defaults自定义 emacs 模式和 font-lock-defaults
【发布时间】:2012-05-17 10:27:58
【问题描述】:

我正在为 HTML/PHP 模板编写次要模式。

我有一个带有 PHP 关键字的 var

(defvar web-mode-php-keywords
 '("array" "as" "break" "catch" "continue")
  "PHP keywords.")

这个 var 用于像这样的字体锁定:

(defvar web-mode-php-font-lock-keywords
 (list
  (cons (concat "\\<\\(" (regexp-opt web-mode-php-keywords) "\\)\\>") 'web-mode-keyword-face)
...

我没有设法让用户在.emacsweb-mode-php-keywords 列表中添加关键字

web-mode-php-font-lock-keywords 依赖于 web-mode-php-keywords 并尝试在挂钩中更改 web-mode-php-keywords 不起作用,因为 web-mode-php-font-lock-keywords 已经构建

我想我错过了什么... (这和eval-after-load有关吗?)

【问题讨论】:

    标签: emacs font-lock


    【解决方案1】:

    我猜你可以在加载网络模式文件之前执行(setq web-mode-php-keywords '("array" "as" "break" "catch" "continue" "mykeyword1" "mykeyword2"...))

    【讨论】:

    • 我不想让用户添加关键字而不是设置所有关键字列表。我已经这样做了:(defconst web-mode-php-constants (eval-when-compile (regexp-opt (append (if (boundp 'web-mode-php-constants) web-mode-php-constants '()) '("TRUE" "FALSE" "NULL" "true" "false" "null")))) "PHP constants.") .... 但也许存在更好的解决方案
    猜你喜欢
    • 2015-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-06
    • 2011-07-26
    相关资源
    最近更新 更多