【问题标题】:My Emacs mode does not highlight keywords我的 Emacs 模式不突出显示关键字
【发布时间】:2015-12-10 02:42:15
【问题描述】:

我正在尝试编写 Emacs 主模式,但它不起作用;具体来说,我的关键字没有显示在关键字字体中。我试图按照教程进行操作,但我一定做错了什么。我会一点 Lisp,但我不会 Emacs 脚本。

我的 Emacs 模式脚本:

;; emacs mode for OldRope
;; does no work for some reason
(setq oldrope-directive-keywords-regexp (regexp-opt  '("page" "link" "goto" "act" "end" "div" "span" "include")))
(defvar oldrope-font-lock-defaults  '((
                       (oldrope-directive-keywords-regexp . font-lock-keyword-face))))
(define-derived-mode oldrope-mode fundamental-mode
  "oldrope mode"
  "Major mode for editing OldRope games"
  (setq comment-start "/*")
  (setq comment-end "*/")
  (setq font-lock-defaults oldrope-font-lock-defaults))
(provide 'oldrope-mode)

测试文件:

$[page start]$ Hello $[link]$ Click me $[act]$ That is right. $[end]$

(对于上下文,这是https://github.com/martinellison/oldrope 的一部分,但这与问题并不真正相关)。

【问题讨论】:

    标签: emacs


    【解决方案1】:

    你需要这个 - 其余的都可以:

     (defvar oldrope-font-lock-defaults
             `(((,oldrope-directive-keywords-regexp . font-lock-keyword-face))))
    

    通过简单地引用您未评估的列表oldrope-directive-keywords-regexp - 您引用的列表只是将该符号作为其汽车。

    使用反引号 (`) 加逗号 (,) 或 (list (list (cons oldrope-directive-keywords-regexp 'font-lock-keyword-face))) 计算该变量并在结果列表中使用其值。

    【讨论】:

      猜你喜欢
      • 2013-03-17
      • 2010-09-24
      • 2013-12-12
      • 1970-01-01
      • 1970-01-01
      • 2017-10-18
      • 2012-02-10
      • 2017-10-04
      • 1970-01-01
      相关资源
      最近更新 更多