aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTassilo Horn2015-08-21 09:38:01 +0200
committerTassilo Horn2015-08-21 09:38:01 +0200
commitff2f35fc478d0047fef4ae3e0b09f43c37961bec (patch)
tree3d815d3779741a02dda28d7d35bfd98eb4650a66
parentc88063faefdcda6016548fa64c002f4b79281ee3 (diff)
downloademacs-ff2f35fc478d0047fef4ae3e0b09f43c37961bec.tar.gz
emacs-ff2f35fc478d0047fef4ae3e0b09f43c37961bec.zip
Add TeX defaults for prettify-symbol-mode
* lisp/textmodes/tex-mode.el (tex--prettify-symbols-alist): Rename from tex-prettify-symbols-alist. (tex--prettify-symbols-compose-p): New function. (tex-common-initialization): Use them as prettify-symbols-alist and prettify-symbols-compose-predicate.
-rw-r--r--lisp/textmodes/tex-mode.el20
1 files changed, 18 insertions, 2 deletions
diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el
index 54783869403..8f68c71fd17 100644
--- a/lisp/textmodes/tex-mode.el
+++ b/lisp/textmodes/tex-mode.el
@@ -1205,6 +1205,7 @@ Entering SliTeX mode runs the hook `text-mode-hook', then the hook
1205 1205
1206(defvar tildify-space-string) 1206(defvar tildify-space-string)
1207(defvar tildify-foreach-region-function) 1207(defvar tildify-foreach-region-function)
1208(defvar tex--prettify-symbols-alist)
1208 1209
1209(defun tex-common-initialization () 1210(defun tex-common-initialization ()
1210 ;; Regexp isearch should accept newline and formfeed as whitespace. 1211 ;; Regexp isearch should accept newline and formfeed as whitespace.
@@ -1246,7 +1247,7 @@ Entering SliTeX mode runs the hook `text-mode-hook', then the hook
1246 (setq-local facemenu-remove-face-function t) 1247 (setq-local facemenu-remove-face-function t)
1247 (setq-local font-lock-defaults 1248 (setq-local font-lock-defaults
1248 '((tex-font-lock-keywords tex-font-lock-keywords-1 1249 '((tex-font-lock-keywords tex-font-lock-keywords-1
1249 tex-font-lock-keywords-2 tex-font-lock-keywords-3) 1250 tex-font-lock-keywords-2 tex-font-lock-keywords-3)
1250 nil nil nil nil 1251 nil nil nil nil
1251 ;; Who ever uses that anyway ??? 1252 ;; Who ever uses that anyway ???
1252 (font-lock-mark-block-function . mark-paragraph) 1253 (font-lock-mark-block-function . mark-paragraph)
@@ -1254,6 +1255,8 @@ Entering SliTeX mode runs the hook `text-mode-hook', then the hook
1254 . tex-font-lock-syntactic-face-function) 1255 . tex-font-lock-syntactic-face-function)
1255 (font-lock-unfontify-region-function 1256 (font-lock-unfontify-region-function
1256 . tex-font-lock-unfontify-region))) 1257 . tex-font-lock-unfontify-region)))
1258 (setq-local prettify-symbols-alist tex--prettify-symbols-alist)
1259 (setq-local prettify-symbols-compose-predicate #'tex--prettify-symbols-compose-p)
1257 (setq-local syntax-propertize-function 1260 (setq-local syntax-propertize-function
1258 (syntax-propertize-rules latex-syntax-propertize-rules)) 1261 (syntax-propertize-rules latex-syntax-propertize-rules))
1259 ;; TABs in verbatim environments don't do what you think. 1262 ;; TABs in verbatim environments don't do what you think.
@@ -2945,7 +2948,7 @@ There might be text before point."
2945 2948
2946;;; Prettify Symbols Support 2949;;; Prettify Symbols Support
2947 2950
2948(defvar tex-prettify-symbols-alist 2951(defvar tex--prettify-symbols-alist
2949 '( ;; Lowercase Greek letters. 2952 '( ;; Lowercase Greek letters.
2950 ("\\alpha" . ?α) 2953 ("\\alpha" . ?α)
2951 ("\\beta" . ?β) 2954 ("\\beta" . ?β)
@@ -3056,6 +3059,8 @@ There might be text before point."
3056 ("\\centerdot" . ?·) 3059 ("\\centerdot" . ?·)
3057 ("\\checkmark" . ?✓) 3060 ("\\checkmark" . ?✓)
3058 ("\\chi" . ?χ) 3061 ("\\chi" . ?χ)
3062 ("\\cdot" . ?⋅)
3063 ("\\cdots" . ?⋯)
3059 ("\\circ" . ?∘) 3064 ("\\circ" . ?∘)
3060 ("\\circeq" . ?≗) 3065 ("\\circeq" . ?≗)
3061 ("\\circlearrowleft" . ?↺) 3066 ("\\circlearrowleft" . ?↺)
@@ -3398,6 +3403,17 @@ There might be text before point."
3398 ("\\textreferencemark" . ?※)) 3403 ("\\textreferencemark" . ?※))
3399 "A `prettify-symbols-alist' usable for (La)TeX modes.") 3404 "A `prettify-symbols-alist' usable for (La)TeX modes.")
3400 3405
3406(defun tex--prettify-symbols-compose-p (start end _match)
3407 (let* ((after-char (char-after end))
3408 (after-syntax (char-syntax after-char)))
3409 (not (or
3410 ;; Don't compose \alpha@foo.
3411 (eq after-syntax ?_)
3412 ;; The \alpha in \alpha2 may be composed but of course \alphax may not.
3413 (and (eq after-syntax ?w)
3414 (or (< after-char ?0)
3415 (> after-char ?9)))))))
3416
3401(run-hooks 'tex-mode-load-hook) 3417(run-hooks 'tex-mode-load-hook)
3402 3418
3403(provide 'tex-mode) 3419(provide 'tex-mode)