emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 487a0be7f7: Fix tex-mode handling of _ chars in href{} commands


From: Lars Ingebrigtsen
Subject: master 487a0be7f7: Fix tex-mode handling of _ chars in href{} commands
Date: Mon, 24 Jan 2022 06:55:44 -0500 (EST)

branch: master
commit 487a0be7f7eb0ca9402247f13a11e39aa2946d05
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Fix tex-mode handling of _ chars in href{} commands
    
    * lisp/textmodes/tex-mode.el (tex--current-command): New function
    (bug#23102).
    (tex-font-lock-suscript): Don't subscript _ chars in href.
---
 lisp/textmodes/tex-mode.el | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el
index 1925d93d93..929181960b 100644
--- a/lisp/textmodes/tex-mode.el
+++ b/lisp/textmodes/tex-mode.el
@@ -630,6 +630,14 @@ An alternative value is \" . \", if you use a font with a 
narrow period."
              3 '(tex-font-lock-append-prop 'bold) 'append)))))
    "Gaudy expressions to highlight in TeX modes.")
 
+(defun tex--current-command ()
+  "Return the previous \\\\command."
+  (save-excursion
+    (and (re-search-backward "\\\\\\([a-zA-Z@]+\\)\\*?\\({\\)?" nil t)
+         ;; Ignore commands that don't have contents.
+         (and (match-string 2)
+              (match-string 1)))))
+
 (defun tex-font-lock-suscript (pos)
   (unless (or (memq (get-text-property pos 'face)
                    '(font-lock-constant-face font-lock-builtin-face
@@ -639,7 +647,9 @@ An alternative value is \" . \", if you use a font with a 
narrow period."
                    (pos pos))
                (while (eq (char-before pos) ?\\)
                  (setq pos (1- pos) odd (not odd)))
-               odd))
+               odd)
+              ;; Allow bare _ characters in some commands.
+              (member (tex--current-command) '("href" "ProvidesFile")))
     (if (eq (char-after pos) ?_)
        `(face subscript display (raise ,(car tex-font-script-display)))
       `(face superscript display (raise ,(cadr tex-font-script-display))))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]