1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-19 18:13:55 +00:00

Prettify TeX macros not ending in a word char

* lisp/textmodes/tex-mode.el (tex--prettify-symbols-compose-p): Prettify
macros which don't end in a word character.
This commit is contained in:
Tassilo Horn 2015-10-28 08:47:26 +01:00
parent 9db11fa2d6
commit 6e2a4021d3

View File

@ -3410,18 +3410,24 @@ There might be text before point."
"A `prettify-symbols-alist' usable for (La)TeX modes.")
(defun tex--prettify-symbols-compose-p (_start end _match)
(let* ((after-char (char-after end))
(after-syntax (char-syntax after-char)))
(not (or
;; Don't compose \alpha@foo.
(eq after-char ?@)
;; The \alpha in \alpha2 or \alpha-\beta may be composed but
;; of course \alphax may not.
(and (eq after-syntax ?w)
(not (memq after-char
'(?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9 ?+ ?- ?' ?\"))))
;; Don't compose inside verbatim blocks.
(eq 2 (nth 7 (syntax-ppss)))))))
(or
;; If the matched symbol doesn't end in a word character, then we
;; simply allow composition. The symbol is probably something like
;; \|, \(, etc.
(not (eq ?w (char-syntax (char-before end))))
;; Else we look at what follows the match in order to decide.
(let* ((after-char (char-after end))
(after-syntax (char-syntax after-char)))
(not (or
;; Don't compose \alpha@foo.
(eq after-char ?@)
;; The \alpha in \alpha2 or \alpha-\beta may be composed but
;; of course \alphax may not.
(and (eq after-syntax ?w)
(not (memq after-char
'(?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9 ?+ ?- ?' ?\"))))
;; Don't compose inside verbatim blocks.
(eq 2 (nth 7 (syntax-ppss))))))))
(run-hooks 'tex-mode-load-hook)