首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >emacs AUCTeX宏字体设置

emacs AUCTeX宏字体设置
EN

Stack Overflow用户
提问于 2013-05-02 20:47:44
回答 1查看 901关注 0票数 4

我最近开始使用提供\newcommandx的优秀包xargs。它共享与默认\newcommand类似的语法。我希望font-lock能够反映这一点。我做到了

代码语言:javascript
复制
(custom-set-variables
 '(font-latex-user-keyword-classes
   (quote (("cx" ("newcommandx" "*|{\\[[{")
        (:family "font-lock-type-face") command)))))

但是这只对命令名本身进行了字体处理,而不是对其正文进行字体处理(\newcommand使用'font-lock-function-name-face对正文进行了字体处理,在我的例子中是粗体)。我想让\newcommandx'font-lock-function-name-face来修饰它的身体。

总结这个问题:如何使\newcommandx的字体与\newcommand的字体完全相同(即在我的例子中是粗体)?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-05-13 03:33:53

下面是一个示例,您可以对其进行修改以满足您的需要。有关预定义关键字的完整列表,请参阅auctex-11.86font-latex.el的第280到436行。以下示例用于添加其他关键字,和/或定义您自己的波形/方括号内容的颜色。

代码语言:javascript
复制
;; \EFFECT{[font-lock-function-name-face]}
(setq font-latex-match-function-keywords
    '(
        ("newcommandx" "*|{\\[[{")
    )
 )


;; \EFFECT{[font-lock-constant-face]}
(setq font-latex-match-reference-keywords
    '(
        ("fancypagestyle" "[{")
        ("fancyhead" "[{")
        ("fancyfoot" "[{")
    )
 )


;; \EFFECT{[font-lock-type-face]}
(setq font-latex-match-textual-keywords
    '(
        ("parentext" "{")
        ("hybridblockquote" "[{")
        ("parskip" "")
        ("footskip" "")
    )
)


;; \EFFECT{[font-lock-variable-name-face]}
(setq font-latex-match-variable-keywords
    '(
        ("newgeometry" "[{")
        ("quotingsetup" "[{")
        ("TabPositions" "[{")
        ("rfoot" "")
    )
)


;; \font-latex-warning-face
(setq font-latex-match-warning-keywords
    '(
        ("fixme" "{") 
    )
)


;; only affects inside wavy brackets
(setq font-latex-user-keyword-classes
          '(("my-warning-commands"
                (("fixme" "{"))
                (:foreground "purple" :background "yellow")
                command)))

另请参阅:http://www.gnu.org/software/auctex/manual/auctex/Fontification-of-macros.html

我选择了以下方法来自定义我的所有特殊关键字:

代码语言:javascript
复制
(defvar lawlist-face-01 (make-face 'lawlist-face-01))
(set-face-background 'lawlist-face-01 "black")
(set-face-foreground 'lawlist-face-01 "white")
(set-face-bold-p 'lawlist-face-01 t)
(set-face-italic-p 'lawlist-face-01 t)
(set-face-underline-p 'lawlist-face-01 t)
(set-face-underline 'lawlist-face-01 "yellow")

(defvar lawlist-face-02 (make-face 'lawlist-face-02))
(set-face-attribute 'lawlist-face-02 nil :background "gray" :foreground "red" :font "Courier" :height 180 :bold t :underline "yellow" :italic t)

(font-lock-add-keywords 'latex-mode '(
("\\\\test01\\|insert\\|BUGS\\|FIXME\\|TODO\\|and\\|or\\|not" 0 lawlist-face-01 prepend) ;; 0 = highlight all
("\\\\test02\\|INSERT\\|document-name\\|\\\\begin{document}" 0 lawlist-face-02 prepend) ;; 0 = highlight all
("\\test01{\\([^}]*\\)}" 1 lawlist-face-02 prepend) ;; 1 = colorize contents of wavy brackets
))
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16338466

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档