GNU bug report logs - #34712
Fontification of simple macros

Previous Next

Package: auctex;

Reported by: Arash Esbati <arash <at> gnu.org>

Date: Sat, 2 Mar 2019 21:01:01 UTC

Severity: normal

Done: Arash Esbati <arash <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 34712 in the body.
You can then email your comments to 34712 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-auctex <at> gnu.org:
bug#34712; Package auctex. (Sat, 02 Mar 2019 21:01:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Arash Esbati <arash <at> gnu.org>:
New bug report received and forwarded. Copy sent to bug-auctex <at> gnu.org. (Sat, 02 Mar 2019 21:01:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Arash Esbati <arash <at> gnu.org>
To: auctex-bugs <bug-auctex <at> gnu.org>
Subject: Fontification of simple macros
Date: Sat, 02 Mar 2019 21:53:15 +0100
[Message part 1 (text/plain, inline)]
Hi all,

while looking at this message[1], it seems that there is a bug in
font-latex.el.  This code

    \documentclass{beamer}

    \begin{document}

    \begin{frame}
      \frametitle<presentation>{MySlide}
                 |            |
             font-latex-sedate-face
    \end{frame}

    \foo<bar>-19+*

    \end{document}

looks like this for me:
[x.png (image/png, inline)]
[Message part 3 (text/plain, inline)]
Have a look at <...> and \foo<bar>-19+*.  I think the issue is that the
regexp in `font-latex-match-simple-command' is too greedy.  A possible
fix is attached below: We introduce a new variable
`font-latex-match-simple-include-list' for styles to add their special
characters for fontification to `font-latex-match-simple-command' which
is modified as shown below:

    \documentclass{beamer}

    \begin{document}

    \begin{frame}
      \frametitle<presentation>{MySlide}
                 |            |
             font-latex-sedate-face
    \end{frame}

    \foo<bar>-19+*

    \begin{verbatim}
    (defvar font-latex-match-simple-include-list nil
      "List of characters allowed in a macro for fontification.
    Each character is a string.")
    (make-variable-buffer-local 'font-latex-match-simple-include-list)

    (defun font-latex-match-simple-command (limit)
      "Search for command like \\foo before LIMIT."
      ;; \s_ matches chars with symbol syntax, \sw chars with word syntax,
      ;; \s. chars with punctuation syntax.  We must exclude matches where
      ;; the first character after the \ is a reserved character and
      ;; should not be fontified (e.g. \, in foo\,bar or \- in foo\-bar).
      ;; These characters are stored in
      ;; `font-latex-match-simple-exclude-list'.  In docTeX mode, we
      ;; remove "_" from this list to get correct fontification for macros
      ;; like `\__module_foo:nnn'
      (let* ((search (lambda ()
                       (TeX-re-search-forward-unescaped
                        (concat
                         ;; Chars directly after backslash
                         "\\\\\\(\\s_\\|\\sw\\|\\s.\\)"
                         ;; Start group of the following chars
                         "\\(?:["
                         ;; a-zA-Z are always allowed:
                         "a-zA-Z"
                         ;; Allow `@' used often to redefine internals
                         "@"
                         ;; Check for additional characters added by AUCTeX styles
                         (when font-latex-match-simple-include-list
                           (mapconcat #'identity
                                      font-latex-match-simple-include-list
                                      ""))
                         ;; End group
                         "]\\)*")
                        limit t)))
             (pos (funcall search)))
        (while (and pos
                    (member (match-string 1)
                            (if (eq major-mode 'doctex-mode)
                                (remove "_" font-latex-match-simple-exclude-list)
                              font-latex-match-simple-exclude-list)))
          (setq pos (funcall search)))
        pos))

    (font-latex-update-font-lock)

    \end{verbatim}

    \end{document}

E.g., `expl3.el' must do:

    (setq font-latex-match-simple-include-list '("_" ":"))

Any comments welcome.

Best, Arash

Footnotes:
[1]  http://lists.gnu.org/archive/html/auctex/2019-02/msg00005.html


Reply sent to Arash Esbati <arash <at> gnu.org>:
You have taken responsibility. (Mon, 04 Mar 2019 20:19:02 GMT) Full text and rfc822 format available.

Notification sent to Arash Esbati <arash <at> gnu.org>:
bug acknowledged by developer. (Mon, 04 Mar 2019 20:19:02 GMT) Full text and rfc822 format available.

Message #10 received at 34712-done <at> debbugs.gnu.org (full text, mbox):

From: Arash Esbati <arash <at> gnu.org>
To: 34712-done <at> debbugs.gnu.org
Subject: Re: Fontification of simple macros
Date: Mon, 04 Mar 2019 21:17:51 +0100
Arash Esbati <arash <at> gnu.org> writes:

> A possible fix is attached below: We introduce a new variable
> `font-latex-match-simple-include-list' for styles to add their special
> characters for fontification to `font-latex-match-simple-command'
> which is modified as shown below:

Following up myself, I've pushed a slightly modified solution to AUCTeX
repo.  This should be fixed now.

Best, Arash




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 02 Apr 2019 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 5 years and 20 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.