681 |
|
|
682 |
;;; Syntactic keywords |
;;; Syntactic keywords |
683 |
|
|
|
(defcustom font-latex-verbatim-environments |
|
|
'("verbatim" "verbatim*") |
|
|
"Environments which should be fontified as verbatim." |
|
|
:type '(repeat (string)) |
|
|
:group 'font-latex) |
|
|
|
|
|
(defvar font-latex-verbatim-environments-local nil |
|
|
"Buffer-local keywords to add to `font-latex-verbatim-environments'. |
|
|
This must be a list of strings. The variable is not for end |
|
|
users; they should customize `font-latex-verbatim-environments' |
|
|
instead. It is for authors of Lisp files that get loaded when |
|
|
LaTeX style files are used in the current buffer. They should |
|
|
add keywords to this list and rebuild the variable |
|
|
`font-latex-syntactic-keywords' by calling the function |
|
|
`font-latex-set-syntactic-keywords'.") |
|
|
(make-variable-buffer-local 'font-latex-verbatim-environments-local) |
|
|
|
|
|
(defcustom font-latex-verb-like-commands |
|
|
'("verb" "verb*") |
|
|
"Commands with the form \\foo|...| to be fontified as verbatim." |
|
|
:type '(repeat (string)) |
|
|
:group 'font-latex) |
|
|
|
|
|
(defvar font-latex-verb-like-commands-local nil |
|
|
"Buffer-local keywords to add to `font-latex-verb-like-commands'. |
|
|
This must be a list of strings. The variable is not for end |
|
|
users; they should customize `font-latex-verb-like-commands' |
|
|
instead. It is for authors of Lisp files that get loaded when |
|
|
LaTeX style files are used in the current buffer. They should |
|
|
add keywords to this list and rebuild the variable |
|
|
`font-latex-syntactic-keywords' by calling the function |
|
|
`font-latex-set-syntactic-keywords'.") |
|
|
(make-variable-buffer-local 'font-latex-verb-like-commands-local) |
|
|
|
|
|
(defcustom font-latex-verbatim-macros nil |
|
|
"Macros with the form \\foo{...} to be fontified as verbatim." |
|
|
:type '(repeat (string)) |
|
|
:group 'font-latex) |
|
|
|
|
|
(defvar font-latex-verbatim-macros-local nil |
|
|
"Buffer-local keywords to add to `font-latex-verbatim-macros'. |
|
|
This must be a list of strings. The variable is not for end |
|
|
users; they should customize `font-latex-verbatim-macros' |
|
|
instead. It is for authors of Lisp files that get loaded when |
|
|
LaTeX style files are used in the current buffer. They should |
|
|
add keywords to this list and rebuild the variable |
|
|
`font-latex-syntactic-keywords' by calling the function |
|
|
`font-latex-set-syntactic-keywords'.") |
|
|
(make-variable-buffer-local 'font-latex-verbatim-macros-local) |
|
|
|
|
684 |
(defun font-latex-set-syntactic-keywords () |
(defun font-latex-set-syntactic-keywords () |
685 |
"Set the variable `font-latex-syntactic-keywords'. |
"Set the variable `font-latex-syntactic-keywords'. |
686 |
This function can be used to refresh the variable in case other |
This function can be used to refresh the variable in case other |
688 |
have changed." |
have changed." |
689 |
;; Checks for non-emptiness of lists added in order to cater for |
;; Checks for non-emptiness of lists added in order to cater for |
690 |
;; installations where `(regexp-opt-group nil)' would enter a loop. |
;; installations where `(regexp-opt-group nil)' would enter a loop. |
691 |
(let ((verb-envs (append font-latex-verbatim-environments |
(let ((verb-envs (append LaTeX-verbatim-environments |
692 |
font-latex-verbatim-environments-local)) |
LaTeX-verbatim-environments-local)) |
693 |
(verb-like-commands (append font-latex-verb-like-commands |
(verb-macros-with-delims (append |
694 |
font-latex-verb-like-commands-local)) |
LaTeX-verbatim-macros-with-delims |
695 |
(verb-macros (append font-latex-verbatim-macros |
LaTeX-verbatim-macros-with-delims-local)) |
696 |
font-latex-verbatim-macros-local))) |
(verb-macros-with-braces (append |
697 |
|
LaTeX-verbatim-macros-with-braces |
698 |
|
LaTeX-verbatim-macros-with-braces-local))) |
699 |
(setq verb-envs (and verb-envs (regexp-opt verb-envs)) |
(setq verb-envs (and verb-envs (regexp-opt verb-envs)) |
700 |
verb-like-commands (and verb-like-commands |
verb-macros-with-delims (and verb-macros-with-delims |
701 |
(regexp-opt verb-like-commands)) |
(regexp-opt verb-macros-with-delims)) |
702 |
verb-macros (and verb-macros (regexp-opt verb-macros)) |
verb-macros-with-braces (and verb-macros-with-braces |
703 |
|
(regexp-opt verb-macros-with-braces)) |
704 |
font-latex-syntactic-keywords nil) |
font-latex-syntactic-keywords nil) |
705 |
(unless (= (length verb-envs) 0) |
(unless (= (length verb-envs) 0) |
706 |
(add-to-list 'font-latex-syntactic-keywords |
(add-to-list 'font-latex-syntactic-keywords |
710 |
(add-to-list 'font-latex-syntactic-keywords |
(add-to-list 'font-latex-syntactic-keywords |
711 |
`(,(concat "\\(\n\\)[ \t]*\\\\end *{\\(?:" verb-envs "\\)}") |
`(,(concat "\\(\n\\)[ \t]*\\\\end *{\\(?:" verb-envs "\\)}") |
712 |
(1 "|" t)))) |
(1 "|" t)))) |
713 |
(unless (= (length verb-like-commands) 0) |
(unless (= (length verb-macros-with-delims) 0) |
714 |
(add-to-list 'font-latex-syntactic-keywords |
(add-to-list 'font-latex-syntactic-keywords |
715 |
`(,(concat "\\\\\\(?:" verb-like-commands "\\)" |
`(,(concat "\\\\\\(?:" verb-macros-with-delims "\\)" |
716 |
;; An opening curly brace as delimiter |
;; An opening curly brace as delimiter |
717 |
;; is valid, but allowing it might screw |
;; is valid, but allowing it might screw |
718 |
;; up fontification of stuff like |
;; up fontification of stuff like |
724 |
;; like "\verb|foo\|". |
;; like "\verb|foo\|". |
725 |
"\\(" (regexp-quote TeX-esc) "*\\)\\(\\1\\)") |
"\\(" (regexp-quote TeX-esc) "*\\)\\(\\1\\)") |
726 |
(1 "\"") (2 ".") (3 "\"")))) |
(1 "\"") (2 ".") (3 "\"")))) |
727 |
(unless (= (length verb-macros) 0) |
(unless (= (length verb-macros-with-braces) 0) |
728 |
(add-to-list 'font-latex-syntactic-keywords |
(add-to-list 'font-latex-syntactic-keywords |
729 |
`(,(concat "\\\\\\(?:" verb-macros "\\)" |
`(,(concat "\\\\\\(?:" verb-macros-with-braces "\\)" |
730 |
"\\({\\).*?[^\\]\\(?:\\\\\\\\\\)*\\(}\\)") |
"\\({\\).*?[^\\]\\(?:\\\\\\\\\\)*\\(}\\)") |
731 |
(1 "|") (2 "|"))))) |
(1 "|") (2 "|"))))) |
732 |
;; Cater for docTeX mode. |
;; Cater for docTeX mode. |