2

我已经定义了一个自定义评论环境(通过\usepackage{verbatim}):

\newenvironment{customComment}[1]
    {
    \noindent{\textsc{Commented bloc}: #1}}
    \comment}
        Commented block
    {\endcomment}

我想要做的是突出 \begin...\end{customComment} 的内容:

  1. 作为一个已经存在的环境(font-lock-comment-face也许但还没有找到任何工作示例);或者
  2. 通过完整的字体/背景等定制。

已经defvar...这里尝试了解决方案,并且(这次是类似的命令这个例子

如果您找到一个只需要编辑.emacs or adding a.el` 的解决方案,那就太好了(我有很多这些 customComments)。

4

2 回答 2

1

在 Emacs 内置的 tex 模式中,您可以通过将环境添加到tex-verbatim-environments.

于 2013-09-06T01:49:45.747 回答
1

如果原始海报(或其他任何人)可能对突出显示在打开/关闭 LaTeX 代码之间的文本感兴趣,下面是一些示例。活性成分是一个正则表达式(\\(.\\|\n\\)+?\\),它可能是其他类似的东西,但需要有效地做同样的事情。以下示例设置为突出显示出现在引号之间的文本,LaTeX 艺术家皱眉,一个粗体命令,一个下划线和一个双下划线,使用名为ulem, bold 和 underline 的 tex 包,我投入了一个开始/结束文档示例所以原始海报(或其他任何人)可以结合示例制作他/她自己的。

注意:随着定义变得更加复杂并且倾向于与其他定义重叠,它们出现的顺序可能很关键——即,一个定义可能胜过另一个。

(font-lock-add-keywords 'latex-mode (list

  (list (concat "\\(\"\\)\\(\\(.\\|\n\\)+?\\)\\(\"\\)")
    '(1 lawlist-super-orange t)
    '(2 lawlist-super-cyan t)
    '(4 lawlist-super-orange t))

  (list (concat "\\(\{\\)\\(\\\\bf\\)\\(\\(.\\|\n\\)+?\\)\\(\}\\)")
    '(1 lawlist-regular t)
    '(2 lawlist-purple t)
    '(3 lawlist-bold t)
    '(5 lawlist-regular t))

  (list (concat "\\(\\\\uline\\|\\\\uuline\\)\\(\{\\)\\(\\(.\\|\n\\)+?\\)\\(\}\\)")
    '(1 lawlist-green t)
    '(2 lawlist-regular t)
    '(3 lawlist-underline t)
    '(5 lawlist-regular t))

  (list (concat "\\(\{\\)\\(\\\\bf\\)\\(\\\\uline\\)\\(\{\\)\\(\\(.\\|\n\\)+?\\)\\(\}\\)\\(\}\\)")
    '(1 lawlist-regular t)
    '(2 lawlist-red t)
    '(3 lawlist-blue t)
    '(4 lawlist-regular t)
    '(5 lawlist-bold-underline t)
    '(7 lawlist-regular t)
    '(8 lawlist-regular t))

  (list (concat "\\(\\\\begin\\|\\\\end\\)\\(\{\\)\\(document\\)\\(\}\\)")
    '(1 lawlist-super-orange t)
    '(2 lawlist-super-SeaGreen t)
    '(3 lawlist-super-HotPink1 t)
    '(4 lawlist-super-SeaGreen t))

   ))


(defvar lawlist-regular (make-face 'lawlist-regular))
(set-face-attribute 'lawlist-regular nil
  :background "white" :foreground "black")

(defvar lawlist-bold (make-face 'lawlist-bold))
(set-face-attribute 'lawlist-bold nil
  :background "white" :foreground "black" :bold t)

(defvar lawlist-bold-underline (make-face 'lawlist-bold-underline))
(set-face-attribute 'lawlist-bold-underline nil
  :background "white" :foreground "black" :bold t :underline "black")

(defvar lawlist-underline (make-face 'lawlist-underline))
(set-face-attribute 'lawlist-underline nil
  :background "white" :foreground "black" :underline "black")

(defvar lawlist-bumble-bee (make-face 'lawlist-bumble-bee))
(set-face-attribute 'lawlist-bumble-bee nil
  :background "black" :foreground "yellow" :bold t :underline "red")

(defvar lawlist-red (make-face 'lawlist-red))
(set-face-attribute 'lawlist-red nil
  :background "white" :foreground "red" :bold t)

(defvar lawlist-blue (make-face 'lawlist-blue))
(set-face-attribute 'lawlist-blue nil
  :background "white" :foreground "blue" :bold t)

(defvar lawlist-green (make-face 'lawlist-green))
(set-face-attribute 'lawlist-green nil
  :background "white" :foreground "green3" :bold t)

(defvar lawlist-orange (make-face 'lawlist-orange))
(set-face-attribute 'lawlist-orange nil
  :background "white" :foreground "orange" :bold t)

(defvar lawlist-purple (make-face 'lawlist-purple))
(set-face-attribute 'lawlist-purple nil
  :background "white" :foreground "purple" :bold t)

(defvar lawlist-pink (make-face 'lawlist-pink))
(set-face-attribute 'lawlist-pink nil
  :background "white" :foreground "pink" :bold t)

(defvar lawlist-super-orange (make-face 'lawlist-super-orange))
(set-face-attribute 'lawlist-super-orange nil
  :background "white" :foreground "orange" :bold t :underline nil)

(defvar lawlist-super-cyan (make-face 'lawlist-super-cyan))
(set-face-attribute 'lawlist-super-cyan nil
  :background "white" :foreground "cyan" :bold t :underline nil)

(defvar lawlist-super-blue (make-face 'lawlist-super-blue))
(set-face-attribute 'lawlist-super-blue nil
  :background "white" :foreground "blue" :bold t :underline nil)

(defvar lawlist-super-red (make-face 'lawlist-super-red))
(set-face-attribute 'lawlist-super-red nil
  :background "white" :foreground "red" :bold t :underline nil)

(defvar lawlist-super-purple (make-face 'lawlist-super-purple))
(set-face-attribute 'lawlist-super-purple nil
  :background "white" :foreground "purple" :bold t :underline nil)

(defvar lawlist-super-HotPink1 (make-face 'lawlist-super-HotPink1))
(set-face-attribute 'lawlist-super-HotPink1 nil
  :background "white" :foreground "HotPink1" :bold t :underline nil)

(defvar lawlist-super-SeaGreen (make-face 'lawlist-super-SeaGreen))
(set-face-attribute 'lawlist-super-SeaGreen nil
  :background "white" :foreground "SeaGreen" :bold t :underline nil)
于 2013-09-05T14:12:38.090 回答