GNU bug report logs - #70383
Conf-mode[toml] badly set face property

Previous Next

Package: emacs;

Reported by: Alastair Irving <alastair.j.irving <at> gmail.com>

Date: Sun, 14 Apr 2024 15:21:04 UTC

Severity: normal

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Alastair Irving <alastair.j.irving <at> gmail.com>, 70383 <at> debbugs.gnu.org, casouri <at> gmail.com, jostein <at> kjonigsen.net
Subject: bug#70383: Conf-mode[toml] badly set face property
Date: Wed, 17 Apr 2024 14:17:43 -0400
> diff --git a/lisp/textmodes/conf-mode.el b/lisp/textmodes/conf-mode.el
> index 5e16360..8a201bd 100644
> --- a/lisp/textmodes/conf-mode.el
> +++ b/lisp/textmodes/conf-mode.el
> @@ -180,7 +180,7 @@ conf-font-lock-keywords
>       (1 'font-lock-variable-name-face)
>       (2 'font-lock-constant-face nil t))
>      ;; section { ... } (do this last because some assign ...{...)
> -    ("^[ \t]*\\([^#=:\n]+?\\)[ \t\n]*{[^{}]*?$" 1 'font-lock-type-face prepend))
> +    ("^[ \t]*\\([^[#=:\n]+?\\)[ \t\n]*{[^{}]*?$" 1 'font-lock-type-face prepend))
>    "Keywords to highlight in Conf mode.")

AFAICT this rule is not even activated in for TOML files.
The patch below seems to DTRT for me.
[ I'd even argue that it should (goto-char end).  ]

[ I found the culprit after noticing that the number of
  `font-lock-type-face` elements in the list in the `face` property was
  the same as the number of characters between the two "sections".  ]


        Stefan


diff --git a/lisp/textmodes/conf-mode.el b/lisp/textmodes/conf-mode.el
index 5e1636033f6..e74409128df 100644
--- a/lisp/textmodes/conf-mode.el
+++ b/lisp/textmodes/conf-mode.el
@@ -613,7 +613,6 @@
   "Font-lock helper function for `conf-toml-mode'.
 Handles recognizing TOML section names, like [section],
 \[[section]], or [something.\"else\".section]."
-  (save-excursion
     ;; Skip any number of "[" to handle things like [[section]].
     (when (re-search-forward "^\\s-*\\[+" limit t)
       (let ((start (point)))
@@ -633,7 +632,7 @@
             (goto-char start)
             (unless (search-forward "," end t)
               (set-match-data (list start end))
-              t)))))))
+            t))))))
 
 ;;;###autoload
 (define-derived-mode conf-toml-mode conf-mode "Conf[TOML]"





This bug report was last modified 1 year and 89 days ago.

Previous Next


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