unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#68827: 29.1; Latex mode: tex-verbatim face has priority on font-lock-comment-face
@ 2024-01-30 18:16 Gabriele Nicolardi
  2024-01-31 19:56 ` bug#68827: Possible solution Gabriele Nicolardi
       [not found] ` <handler.68827.D68827.170802793225463.notifdone@debbugs.gnu.org>
  0 siblings, 2 replies; 6+ messages in thread
From: Gabriele Nicolardi @ 2024-01-30 18:16 UTC (permalink / raw)
  To: 68827


[-- Attachment #1.1: Type: text/plain, Size: 5725 bytes --]

Hi,
I switched to Emacs 29.1 recently.

I noticed that the tex-verbatim face used in latex-mode to highlight the
\href argument has priority on font-lock-comment-face.


The tex-verbatim face is defined in tex-mode.el:

(defface tex-verbatim
'((t :inherit fixed-pitch-serif))
"Face used to highlight TeX verbatim environments."
:group 'tex)

I think that this is a bug or, at least, very annoying.

This is a fragment of LaTeX code that contains the issue:

\bibitem{Zhang:1992fs}
%
%X.-m. Zhang,
%^[mph{Operators analysis for Higgs potential and cosmological bound on 
Higgs mass},
%\href{https://doi.org/10.1103/PhysRevD.47.3065}{^[mph{Phys. Rev. D} 
{\bfseries 47} (1993) 3065--3067},
%[\href{https://arxiv.org/abs/hep-ph/9301277}{{ tfamily hep-ph/9301277}}].
%
X.-M.~Zhang,
^[mph{Operators analysis for Higgs potential and cosmological bound on 
Higgs mass},
\href{https://doi.org/10.1103/PhysRevD.47.3065}{^[mph{Phys. Rev. D} 
{\bfseries 47} (1993) 3065}
[\uniarXiv{hep-ph/9301277}]
[\uninspire{literature/340299}].

\bibitem{Ham:2004zs}
%
%S.~W. Ham and S.~K. Oh,
%^[mph{Electroweak phase transition in the standard model with a 
dimension-six Higgs operator at one-loop level},
%\href{https://doi.org/10.1103/PhysRevD.70.093007}{^[mph{Phys. Rev. D} 
{\bfseries 70} (2004) 093007},
%[\href{https://arxiv.org/abs/hep-ph/0408324}{{ tfamily hep-ph/0408324}}].
%
S.W.~Ham and S.K.~Oh,
^[mph{Electroweak phase transition in the standard model with a 
dimension-six Higgs operator at one-loop level},
\href{https://doi.org/10.1103/PhysRevD.70.093007}{^[mph{Phys. Rev. D} 
{\bfseries 70} (2004) 093007}
[\uniarXiv{hep-ph/0408324}]
[\uninspire{literature/657708}].

I have attached a figure to better illustrate the issue.

I also opened an issue on StackExchange: 
https://emacs.stackexchange.com/q/80201/15606

Best,

Gabriel Nicolardi




In GNU Emacs 29.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.20,
cairo version 1.16.0) of 2023-12-10 built on lcy02-amd64-098
Repository revision: 28fb02492c2444c5976eb53fd6f9badfe54f4ea1
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12013000
System Description: Ubuntu 20.04.6 LTS

Configured using:
'configure --prefix=/snap/emacs/current/usr --with-x-toolkit=gtk3
--without-xaw3d --with-modules --with-cairo
--with-native-compilation=aot --with-xinput2 --with-tree-sitter
--with-json
'CFLAGS=-isystem/build/emacs/parts/emacs/install/usr/include
-isystem/build/emacs/parts/emacs/install/usr/include/x86_64-linux-gnu
-isystem/build/emacs/stage/usr/include -O2'
'CPPFLAGS=-isystem/build/emacs/parts/emacs/install/usr/include
-isystem/build/emacs/parts/emacs/install/usr/include/x86_64-linux-gnu
-isystem/build/emacs/stage/usr/include'
'LDFLAGS=-L/build/emacs/parts/emacs/install/lib
-L/build/emacs/parts/emacs/install/usr/lib
-L/build/emacs/parts/emacs/install/lib/x86_64-linux-gnu
-L/build/emacs/parts/emacs/install/usr/lib/x86_64-linux-gnu
-L/build/emacs/stage/usr/lib''

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES
NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3
THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER X11 XDBE XIM XINPUT2 XPM
GTK3 ZLIB

Important settings:
value of $LANG: it_IT.UTF-8
locale-coding-system: utf-8-unix

Major mode: LaTeX

Minor modes in effect:
shell-dirtrack-mode: t
tooltip-mode: t
global-eldoc-mode: t
show-paren-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
line-number-mode: t
transient-mark-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny dired
dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068
epg-config gnus-util time-date mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mail-utils vc-git diff-mode easy-mmode
vc-dispatcher cl-loaddefs comp comp-cstr warnings icons rx cl-seq
cl-macs gv cl-extra help-mode bytecomp byte-compile cl-lib tex-mode
compile text-property-search shell subr-x pcomplete comint ansi-osc
ansi-color ring latexenc rmc iso-transl tooltip cconv eldoc paren
electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads dbusbind inotify lcms2
dynamic-setting system-font-setting font-render-setting cairo
move-toolbar gtk x-toolkit xinput2 x multi-tty make-network-process
native-compile emacs)

Memory information:
((conses 16 102004 9296)
(symbols 48 8726 0)
(strings 32 25838 1504)
(string-bytes 1 806567)
(vectors 16 18509)
(vector-slots 8 370440 15774)
(floats 8 41 82)
(intervals 56 903 0)
(buffers 984 12))

[-- Attachment #1.2: Type: text/html, Size: 10896 bytes --]

[-- Attachment #2: Selezione_112.png --]
[-- Type: image/png, Size: 121194 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#68827: Possible solution
  2024-01-30 18:16 bug#68827: 29.1; Latex mode: tex-verbatim face has priority on font-lock-comment-face Gabriele Nicolardi
@ 2024-01-31 19:56 ` Gabriele Nicolardi
  2024-02-10  8:25   ` Eli Zaretskii
  2024-02-15 20:11   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
       [not found] ` <handler.68827.D68827.170802793225463.notifdone@debbugs.gnu.org>
  1 sibling, 2 replies; 6+ messages in thread
From: Gabriele Nicolardi @ 2024-01-31 19:56 UTC (permalink / raw)
  To: 68827

[-- Attachment #1: Type: text/plain, Size: 1040 bytes --]

Hi,

I checked the value of the font-lock-keywords variable and found:

```lang-el

("\\\(ProvidesFile\|href\|nolinkurl\|path\|url\) \(\[[^]]\] 
\){\(\(?:[^{}\]\|\\.\|{[^}]}\)+\)" 3 'tex-verbatim t)

```

If I use this command to add fontification:

```lang-el

(font-lock-add-keywords nil 
'(("\\\(ProvidesFile\|href\|nolinkurl\|path\|url\) \(\[[^]]\] 
\){\(\(?:[^{}\]\|\\.\|{[^}]}\)+\)" 3 'tex-verbatim keep)))

```

the problem disappears.

 From the manual, I read:

The last two values in subexp-highlighter, override and laxmatch, are 
optional flags. If override is |t|, this element can override existing 
fontification made by previous elements of |font-lock-keywords|. If it 
is |keep|, then each character is fontified if it has not been fontified 
already by some other element. If it is |prepend|, the face specified by 
facespec is added to the beginning of the |font-lock-face| property. If 
it is |append|, the face is added to the end of the |font-lock-face| 
property.

So I think that "keep" should be the right choice.


[-- Attachment #2: Type: text/html, Size: 1774 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#68827: Possible solution
  2024-01-31 19:56 ` bug#68827: Possible solution Gabriele Nicolardi
@ 2024-02-10  8:25   ` Eli Zaretskii
  2024-02-15 20:11   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2024-02-10  8:25 UTC (permalink / raw)
  To: Gabriele Nicolardi, Stefan Monnier; +Cc: 68827

> Date: Wed, 31 Jan 2024 20:56:12 +0100
> From: Gabriele Nicolardi <gabriele@medialab.sissa.it>
> 
> I checked the value of the font-lock-keywords variable and found: 
> 
> ```lang-el
> 
> ("\\\(ProvidesFile\|href\|nolinkurl\|path\|url\) \(\[[^]]\] \){\(\(?:[^{}\]\|\\.\|{[^}]}\)+\)" 3 'tex-verbatim t)
> 
> ```
> 
> If I use this command to add fontification:
> 
> ```lang-el
> 
> (font-lock-add-keywords nil '(("\\\(ProvidesFile\|href\|nolinkurl\|path\|url\) \(\[[^]]\] \){\(\(?:[^{}\]\|\\.\|{[^}]}\)+\)" 3
> 'tex-verbatim keep)))
> 
> ```
> 
> the problem disappears.
> 
> From the manual, I read:
> 
> The last two values in subexp-highlighter, override and laxmatch, are optional flags. If override is t, this
> element can override existing fontification made by previous elements of font-lock-keywords. If it is
> keep, then each character is fontified if it has not been fontified already by some other element. If it is
> prepend, the face specified by facespec is added to the beginning of the font-lock-face property. If it
> is append, the face is added to the end of the font-lock-face property. 
> 
> So I think that "keep" should be the right choice.

Stefan, any comments to this proposed solution?





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#68827: Possible solution
  2024-01-31 19:56 ` bug#68827: Possible solution Gabriele Nicolardi
  2024-02-10  8:25   ` Eli Zaretskii
@ 2024-02-15 20:11   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 0 replies; 6+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-02-15 20:11 UTC (permalink / raw)
  To: Gabriele Nicolardi; +Cc: 68827-done

> I noticed that the tex-verbatim face used in latex-mode to highlight the
> \href argument has priority on font-lock-comment-face.

I'm not sure if it should qualify as a bug or as a feature, to be honest.

> (font-lock-add-keywords nil
>  '(("\\\(ProvidesFile\|href\|nolinkurl\|path\|url\) \(\[[^]]\]
>  \){\(\(?:[^{}\]\|\\.\|{[^}]}\)+\)" 3 'tex-verbatim keep)))

Thanks.  `keep` seems right for the case where the match is inside
a comment, as in your case, but there are other cases where we want
to override the previously applied face (e.g. $math$).

I pushed a patch which re-arranges the rules to avoid that
other problem.


        Stefan






^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#68827: closed (Re: bug#68827: Possible solution)
       [not found] ` <handler.68827.D68827.170802793225463.notifdone@debbugs.gnu.org>
@ 2024-02-20 13:45   ` Gabriele Nicolardi
  2024-02-20 14:42     ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Gabriele Nicolardi @ 2024-02-20 13:45 UTC (permalink / raw)
  To: 68827

[-- Attachment #1: Type: text/plain, Size: 422 bytes --]

I updated to Emacs 29.2 but I still see the problem.


Il 15/02/24 21:13, GNU bug Tracking System ha scritto:
> Your bug report
>
> #68827: 29.1; Latex mode: tex-verbatim face has priority on font-lock-comment-face
>
> which was filed against the emacs package, has been closed.
>
> The explanation is attached below, along with your original report.
> If you require more details, please reply to 68827@debbugs.gnu.org.
>

[-- Attachment #2: Selezione_118.png --]
[-- Type: image/png, Size: 37437 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#68827: closed (Re: bug#68827: Possible solution)
  2024-02-20 13:45   ` bug#68827: closed (Re: bug#68827: Possible solution) Gabriele Nicolardi
@ 2024-02-20 14:42     ` Eli Zaretskii
  0 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2024-02-20 14:42 UTC (permalink / raw)
  To: Gabriele Nicolardi; +Cc: 68827

> Date: Tue, 20 Feb 2024 14:45:22 +0100
> From: Gabriele Nicolardi <gabriele@medialab.sissa.it>
> 
> I updated to Emacs 29.2 but I still see the problem.

This was solved by Stefan on the master branch, so the solution will
be in Emacs 30.





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-02-20 14:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-30 18:16 bug#68827: 29.1; Latex mode: tex-verbatim face has priority on font-lock-comment-face Gabriele Nicolardi
2024-01-31 19:56 ` bug#68827: Possible solution Gabriele Nicolardi
2024-02-10  8:25   ` Eli Zaretskii
2024-02-15 20:11   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
     [not found] ` <handler.68827.D68827.170802793225463.notifdone@debbugs.gnu.org>
2024-02-20 13:45   ` bug#68827: closed (Re: bug#68827: Possible solution) Gabriele Nicolardi
2024-02-20 14:42     ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).