bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#28218: 26.0.50; TOML table name fontification on lines with comments


From: Tom Tromey
Subject: bug#28218: 26.0.50; TOML table name fontification on lines with comments
Date: Fri, 25 Aug 2017 09:57:02 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux)

Oops, meant to CC the bug.

>> As soon as I saw it, I tested it out with my Hugo blog config.toml.

Nice, thanks.

>> Everything looks good except for fontification on lines that have
>> comments with square brackets (see the attached screenshot)

The appended patch worked ok on these examples for me.

Maybe it isn't ideal because I think you can do weird things like:

    [section."quoted[]name"]

... and this regexp won't pick that up.

I'm inclined to install this anyway, since it's an improvement, even
though it isn't perfect.

Hmm, maybe it can be fixed using a function to search for the matching
bracket.  I will give that a try.

Tom

diff --git a/lisp/textmodes/conf-mode.el b/lisp/textmodes/conf-mode.el
index 7bcc695..38d617e 100644
--- a/lisp/textmodes/conf-mode.el
+++ b/lisp/textmodes/conf-mode.el
@@ -254,9 +254,9 @@ conf-colon-font-lock-keywords
 
 (defvar conf-toml-font-lock-keywords
   '(;; [section] (do this first because it may look like a parameter)
-    ("^[ \t]*\\[\\(.+\\)\\]" 1 'font-lock-type-face)
+    ("^\\s-*\\[\\([^]]+\\)\\]" 1 'font-lock-type-face)
     ;; var=val or var[index]=val
-    ("^[ \t]*\\(.+?\\)\\(?:\\[\\(.*?\\)\\]\\)?[ \t]*="
+    ("^\\s-*\\(.+?\\)\\(?:\\[\\(.*?\\)\\]\\)?\\s-*="
      (1 'font-lock-variable-name-face)
      (2 'font-lock-constant-face nil t))
     ("\\_<false\\|true\\_>" 0 'font-lock-keyword-face))





reply via email to

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