emacs AUCTeX宏格式化 [英] emacs AUCTeX macros fontification

查看:213
本文介绍了emacs AUCTeX宏格式化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始使用提供 \\\
ewcommandx
的优秀软件包 xargs
。它共享一个类似于默认的 \\\
ewcommand
的语法。
我想要 font-lock 来反映这一点。
我做了

 (custom-set-variables 
'(font-latex-user-keyword- class
((cx(newcommandx* | {\\ [[{)
(:familyfont-lock-type-face)))) ))

但是,这只是命名名称本身,而不是其身体
\\\
ewcommand
使用'font-lock-function-name-face
在我的情况下是大胆的)我想要 \\\
ewcommandx
'font-lock-function-name-face 。 >

总结问题:如何使 \\\
ewcommandx
的格式与完全相同\\\
ewcommand
(即我的情况下的大胆的身体)?

解决方案

这是一个例子,你可以修改以适应您的需要。有关预定义关键字的完整列表,请参见 auctex-11.86 font-latex.el 的第280至436行。以下示例用于添加其他关键字,和/或为波浪/方括号内容定义自己的着色。

  ;; \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[{ $ b(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{)




;;只影响波浪括号
(setq font-latex-user-keyword-classes
'((my-warning-commands
((fixme{))
(:前景紫色:背景黄色)
命令)))

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






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

 (defvar lawlist-face-01(make-face'lawlist-face- 
(set-face-background'lawlist-face-01black)
(set-face-foreground'lawlist-face-01white)
(set- face-bold-p'lawlist-face-01 t)
(set-face-italic-p'lawlist-face-01 t)
(set-face-underline-p' 01 t)
(set-face-underline'lawlist-face-01yellow)

(defvar la w-face-02(make-face'lawlist-face-02))
(set-face-attribute'lawlist-face-02 nil:backgroundgray:foregroundred:fontCourier高度180:粗体t:下划线黄色:斜体t)

(font-lock-add-keywords'latex-mode'(
(\\\\ test01\\ | insert \\ | BUGS\\ | FIXME\\ | | TODO\\ |和\\ |或\\ |不0 lawlist-face-01前置);; 0 =高亮显示所有
(\\\\\test02\\ | INSERT\\ | | document-name\\ | \\\\begin {document} 0 lawlist-face-02 prepend; 0 =高亮全部
(\\test01 {\\([^}] * \\)}1 lawlist-face-02 prepend);; 1 =着色波浪括号的内容
))


I recently started using the excellent package xargs that provides \newcommandx. It shares a syntax similar to the default \newcommand. I would like font-lock to reflect this. I did

(custom-set-variables
 '(font-latex-user-keyword-classes
   (quote (("cx" ("newcommandx" "*|{\\[[{")
        (:family "font-lock-type-face") command)))))

But this fontifies just the command name itself, not its body (\newcommand fontifies the body with 'font-lock-function-name-face, which in my case is bold). I want \newcommandx to fontify its body with 'font-lock-function-name-face.

To summarize the question: how to make fontification for \newcommandx be exactly the same as for \newcommand (i.e. bold body in my case)?

解决方案

Here is an example that you can modify to suit your needs. See lines 280 to 436 of font-latex.el within auctex-11.86 for a complete list of predefined keywords. The following examples are used to add additional keywords, and/or define your own coloration for the contents of wavy / square brackets.

;; \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)))

See also: http://www.gnu.org/software/auctex/manual/auctex/Fontification-of-macros.html


I have chosen the following method to customize all of my special keywords:

(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
))

这篇关于emacs AUCTeX宏格式化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆