diff options
| author | Stefan Monnier | 2012-07-17 04:11:31 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2012-07-17 04:11:31 -0400 |
| commit | 45fd731c4dcba0db0ac7e8f4a12d30274396eac7 (patch) | |
| tree | 8c67ff37e6fc1faa53842987c64c9cb50b331c59 | |
| parent | 9ea10cc3431ce03da0a375cd573ceedd5cdbdf67 (diff) | |
| download | emacs-45fd731c4dcba0db0ac7e8f4a12d30274396eac7.tar.gz emacs-45fd731c4dcba0db0ac7e8f4a12d30274396eac7.zip | |
* lisp/textmodes/tex-mode.el (tex-font-lock-keywords-1): Highlight not only
$$..$$ but also $..$ using regexps.
Use tex-verbatim for \url and \path.
(tex-font-lock-keywords): Define as defconst like the others.
(tex-common-initialization): Don't use font-lock-syntax-table any more.
* test/indent/latex-mode.tex: New file.
Fixes: debbugs:11953
| -rw-r--r-- | lisp/ChangeLog | 24 | ||||
| -rw-r--r-- | lisp/textmodes/tex-mode.el | 75 | ||||
| -rw-r--r-- | test/ChangeLog | 4 | ||||
| -rw-r--r-- | test/indent/latex-mode.tex | 11 |
4 files changed, 71 insertions, 43 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 6606940740c..709daf405a7 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2012-07-17 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * textmodes/tex-mode.el (tex-font-lock-keywords-1): Highlight not only | ||
| 4 | $$..$$ but also $..$ using regexps (bug#11953). | ||
| 5 | Use tex-verbatim for \url and \path. | ||
| 6 | (tex-font-lock-keywords): Define as defconst like the others. | ||
| 7 | (tex-common-initialization): Don't use font-lock-syntax-table any more. | ||
| 8 | |||
| 1 | 2012-07-16 René Kyllingstad <Rene@Kyllingstad.com> (tiny change) | 9 | 2012-07-16 René Kyllingstad <Rene@Kyllingstad.com> (tiny change) |
| 2 | 10 | ||
| 3 | * international/mule-cmds.el (ucs-insert): Make it an obsolete | 11 | * international/mule-cmds.el (ucs-insert): Make it an obsolete |
| @@ -14,8 +22,8 @@ | |||
| 14 | Remove vars. | 22 | Remove vars. |
| 15 | (python-nav-list-defun-positions, python-nav-read-defun) | 23 | (python-nav-list-defun-positions, python-nav-read-defun) |
| 16 | (python-imenu-tree-assoc, python-imenu-make-element-tree) | 24 | (python-imenu-tree-assoc, python-imenu-make-element-tree) |
| 17 | (python-imenu-make-tree, python-imenu-create-index): Remove | 25 | (python-imenu-make-tree, python-imenu-create-index): |
| 18 | functions. | 26 | Remove functions. |
| 19 | (python-mode): Update to interact with imenu by setting | 27 | (python-mode): Update to interact with imenu by setting |
| 20 | `imenu-extract-index-name-function' only. | 28 | `imenu-extract-index-name-function' only. |
| 21 | 29 | ||
| @@ -56,8 +64,8 @@ | |||
| 56 | (xterm-mouse-event): New arg specifying mouse protocol. | 64 | (xterm-mouse-event): New arg specifying mouse protocol. |
| 57 | (turn-on-xterm-mouse-tracking-on-terminal) | 65 | (turn-on-xterm-mouse-tracking-on-terminal) |
| 58 | (turn-off-xterm-mouse-tracking-on-terminal): Send DEC 1006 | 66 | (turn-off-xterm-mouse-tracking-on-terminal): Send DEC 1006 |
| 59 | sequence to toggle extended coordinates on newer XTerms. This | 67 | sequence to toggle extended coordinates on newer XTerms. |
| 60 | appears to be harmless on terminals which do not support this. | 68 | This appears to be harmless on terminals which do not support this. |
| 61 | 69 | ||
| 62 | 2012-07-14 Leo Liu <sdl.web@gmail.com> | 70 | 2012-07-14 Leo Liu <sdl.web@gmail.com> |
| 63 | 71 | ||
| @@ -81,8 +89,8 @@ | |||
| 81 | 89 | ||
| 82 | 2012-07-14 Chong Yidong <cyd@gnu.org> | 90 | 2012-07-14 Chong Yidong <cyd@gnu.org> |
| 83 | 91 | ||
| 84 | * bindings.el: Consolidate ctl-x-r-map bindings. Bind | 92 | * bindings.el: Consolidate ctl-x-r-map bindings. |
| 85 | copy-rectangle-as-kill to C-x r w. | 93 | Bind copy-rectangle-as-kill to C-x r w. |
| 86 | 94 | ||
| 87 | * rect.el, register.el: Move bindings to bindings.el. | 95 | * rect.el, register.el: Move bindings to bindings.el. |
| 88 | 96 | ||
| @@ -123,8 +131,8 @@ | |||
| 123 | Remove toggle-read-only. | 131 | Remove toggle-read-only. |
| 124 | 132 | ||
| 125 | * bs.el (bs-toggle-readonly): | 133 | * bs.el (bs-toggle-readonly): |
| 126 | * buff-menu.el (Buffer-menu-toggle-read-only): Remove | 134 | * buff-menu.el (Buffer-menu-toggle-read-only): |
| 127 | with-no-warnings around toggle-read-only. | 135 | Remove with-no-warnings around toggle-read-only. |
| 128 | 136 | ||
| 129 | * ffap.el (ffap--toggle-read-only): Accept a list of buffers. | 137 | * ffap.el (ffap--toggle-read-only): Accept a list of buffers. |
| 130 | Remove with-no-warnings around toggle-read-only. | 138 | Remove with-no-warnings around toggle-read-only. |
diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el index a0e282c6fcc..5571af1ad9b 100644 --- a/lisp/textmodes/tex-mode.el +++ b/lisp/textmodes/tex-mode.el | |||
| @@ -476,46 +476,51 @@ An alternative value is \" . \", if you use a font with a narrow period." | |||
| 476 | '("input" "include" "includeonly" "bibliography" | 476 | '("input" "include" "includeonly" "bibliography" |
| 477 | "epsfig" "psfig" "epsf" "nofiles" "usepackage" | 477 | "epsfig" "psfig" "epsf" "nofiles" "usepackage" |
| 478 | "documentstyle" "documentclass" "verbatiminput" | 478 | "documentstyle" "documentclass" "verbatiminput" |
| 479 | "includegraphics" "includegraphics*" | 479 | "includegraphics" "includegraphics*") |
| 480 | "url" "nolinkurl") | ||
| 481 | t)) | 480 | t)) |
| 481 | (verbish (regexp-opt '("url" "nolinkurl" "path") t)) | ||
| 482 | ;; Miscellany. | 482 | ;; Miscellany. |
| 483 | (slash "\\\\") | 483 | (slash "\\\\") |
| 484 | (opt " *\\(\\[[^]]*\\] *\\)*") | 484 | (opt " *\\(\\[[^]]*\\] *\\)*") |
| 485 | ;; This would allow highlighting \newcommand\CMD but requires | 485 | ;; This would allow highlighting \newcommand\CMD but requires |
| 486 | ;; adapting subgroup numbers below. | 486 | ;; adapting subgroup numbers below. |
| 487 | ;; (arg "\\(?:{\\(\\(?:[^{}\\]+\\|\\\\.\\|{[^}]*}\\)+\\)\\|\\\\[a-z*]+\\)")) | 487 | ;; (arg "\\(?:{\\(\\(?:[^{}\\]+\\|\\\\.\\|{[^}]*}\\)+\\)\\|\\\\[a-z*]+\\)")) |
| 488 | (arg "{\\(\\(?:[^{}\\]+\\|\\\\.\\|{[^}]*}\\)+\\)")) | 488 | (inbraces-re (lambda (re) |
| 489 | (list | 489 | (concat "\\(?:[^{}\\]\\|\\\\.\\|" re "\\)"))) |
| 490 | ;; display $$ math $$ | 490 | (arg (concat "{\\(" (funcall inbraces-re "{[^}]*}") "+\\)"))) |
| 491 | ;; We only mark the match between $$ and $$ because the $$ delimiters | 491 | `( ;; Highlight $$math$$ and $math$. |
| 492 | ;; themselves have already been marked (along with $..$) by syntactic | 492 | ;; This is done at the very beginning so as to interact with the other |
| 493 | ;; fontification. Also this is done at the very beginning so as to | 493 | ;; keywords in the same way as comments and strings. |
| 494 | ;; interact with the other keywords in the same way as $...$ does. | 494 | (,(concat "\\$\\$?\\(?:[^$\\{}]\\|\\\\.\\|{" |
| 495 | (list "\\$\\$\\([^$]+\\)\\$\\$" 1 'tex-math-face) | 495 | (funcall inbraces-re |
| 496 | ;; Heading args. | 496 | (concat "{" (funcall inbraces-re "{[^}]*}") "*}")) |
| 497 | (list (concat slash headings "\\*?" opt arg) | 497 | "*}\\)+\\$?\\$") |
| 498 | ;; If ARG ends up matching too much (if the {} don't match, e.g.) | 498 | (0 tex-math-face)) |
| 499 | ;; jit-lock will do funny things: when updating the buffer | 499 | ;; Heading args. |
| 500 | ;; the re-highlighting is only done locally so it will just | 500 | (,(concat slash headings "\\*?" opt arg) |
| 501 | ;; match the local line, but defer-contextually will | 501 | ;; If ARG ends up matching too much (if the {} don't match, e.g.) |
| 502 | ;; match more lines at a time, so ARG will end up matching | 502 | ;; jit-lock will do funny things: when updating the buffer |
| 503 | ;; a lot more, which might suddenly include a comment | 503 | ;; the re-highlighting is only done locally so it will just |
| 504 | ;; so you get things highlighted bold when you type them | 504 | ;; match the local line, but defer-contextually will |
| 505 | ;; but they get turned back to normal a little while later | 505 | ;; match more lines at a time, so ARG will end up matching |
| 506 | ;; because "there's already a face there". | 506 | ;; a lot more, which might suddenly include a comment |
| 507 | ;; Using `keep' works around this un-intuitive behavior as well | 507 | ;; so you get things highlighted bold when you type them |
| 508 | ;; as improves the behavior in the very rare case where you do | 508 | ;; but they get turned back to normal a little while later |
| 509 | ;; have a comment in ARG. | 509 | ;; because "there's already a face there". |
| 510 | 3 'font-lock-function-name-face 'keep) | 510 | ;; Using `keep' works around this un-intuitive behavior as well |
| 511 | (list (concat slash "\\(?:provide\\|\\(?:re\\)?new\\)command\\** *\\(\\\\[A-Za-z@]+\\)") | 511 | ;; as improves the behavior in the very rare case where you do |
| 512 | 1 'font-lock-function-name-face 'keep) | 512 | ;; have a comment in ARG. |
| 513 | ;; Variable args. | 513 | 3 font-lock-function-name-face keep) |
| 514 | (list (concat slash variables " *" arg) 2 'font-lock-variable-name-face) | 514 | (,(concat slash "\\(?:provide\\|\\(?:re\\)?new\\)command\\** *\\(\\\\[A-Za-z@]+\\)") |
| 515 | ;; Include args. | 515 | 1 font-lock-function-name-face keep) |
| 516 | (list (concat slash includes opt arg) 3 'font-lock-builtin-face) | 516 | ;; Variable args. |
| 517 | ;; Definitions. I think. | 517 | (,(concat slash variables " *" arg) 2 font-lock-variable-name-face) |
| 518 | '("^[ \t]*\\\\def *\\\\\\(\\(\\w\\|@\\)+\\)" | 518 | ;; Include args. |
| 519 | (,(concat slash includes opt arg) 3 font-lock-builtin-face) | ||
| 520 | ;; Verbatim-like args. | ||
| 521 | (,(concat slash verbish opt arg) 3 'tex-verbatim) | ||
| 522 | ;; Definitions. I think. | ||
| 523 | ("^[ \t]*\\\\def *\\\\\\(\\(\\w\\|@\\)+\\)" | ||
| 519 | 1 font-lock-function-name-face)))) | 524 | 1 font-lock-function-name-face)))) |
| 520 | "Subdued expressions to highlight in TeX modes.") | 525 | "Subdued expressions to highlight in TeX modes.") |
| 521 | 526 | ||
| @@ -629,7 +634,7 @@ An alternative value is \" . \", if you use a font with a narrow period." | |||
| 629 | (1 (tex-font-lock-suscript (match-beginning 0)) append)))) | 634 | (1 (tex-font-lock-suscript (match-beginning 0)) append)))) |
| 630 | "Experimental expressions to highlight in TeX modes.") | 635 | "Experimental expressions to highlight in TeX modes.") |
| 631 | 636 | ||
| 632 | (defvar tex-font-lock-keywords tex-font-lock-keywords-1 | 637 | (defconst tex-font-lock-keywords tex-font-lock-keywords-1 |
| 633 | "Default expressions to highlight in TeX modes.") | 638 | "Default expressions to highlight in TeX modes.") |
| 634 | 639 | ||
| 635 | (defvar tex-verbatim-environments | 640 | (defvar tex-verbatim-environments |
| @@ -1219,7 +1224,7 @@ Entering SliTeX mode runs the hook `text-mode-hook', then the hook | |||
| 1219 | (set (make-local-variable 'font-lock-defaults) | 1224 | (set (make-local-variable 'font-lock-defaults) |
| 1220 | '((tex-font-lock-keywords tex-font-lock-keywords-1 | 1225 | '((tex-font-lock-keywords tex-font-lock-keywords-1 |
| 1221 | tex-font-lock-keywords-2 tex-font-lock-keywords-3) | 1226 | tex-font-lock-keywords-2 tex-font-lock-keywords-3) |
| 1222 | nil nil ((?$ . "\"")) nil | 1227 | nil nil nil nil |
| 1223 | ;; Who ever uses that anyway ??? | 1228 | ;; Who ever uses that anyway ??? |
| 1224 | (font-lock-mark-block-function . mark-paragraph) | 1229 | (font-lock-mark-block-function . mark-paragraph) |
| 1225 | (font-lock-syntactic-face-function | 1230 | (font-lock-syntactic-face-function |
diff --git a/test/ChangeLog b/test/ChangeLog index 489298dbebe..ce7e2f02284 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2012-07-17 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * indent/latex-mode.tex: New file. | ||
| 4 | |||
| 1 | 2012-07-11 Stefan Monnier <monnier@iro.umontreal.ca> | 5 | 2012-07-11 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 6 | ||
| 3 | * eshell.el: Use cl-lib. | 7 | * eshell.el: Use cl-lib. |
diff --git a/test/indent/latex-mode.tex b/test/indent/latex-mode.tex new file mode 100644 index 00000000000..55c8e7033bd --- /dev/null +++ b/test/indent/latex-mode.tex | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | \documentclass{article} % -*- eval: (bug-reference-mode 1) -*- | ||
| 2 | |||
| 3 | \usepackage[utf8]{inputenc} | ||
| 4 | |||
| 5 | \begin{document} | ||
| 6 | |||
| 7 | To fix this, remove the \url{sn9c102.ko} from where it appears in | ||
| 8 | \url{/lib/modules/$(uname -r)}, %bug#11953. | ||
| 9 | and install the appropriate \url{gspca-modules} package. | ||
| 10 | |||
| 11 | \end{document} | ||