all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Kaushal Modi <kaushal.modi@gmail.com>
Cc: 28218@debbugs.gnu.org
Subject: bug#28218: 26.0.50; TOML table name fontification on lines with comments
Date: Fri, 25 Aug 2017 09:57:02 -0600	[thread overview]
Message-ID: <87lgm7iqsx.fsf@tromey.com> (raw)
In-Reply-To: <CAFyQvY3pVUcEOBFQqOpvTJ-FHtEktBF4Bu7TYzG0eJVckO5R7Q@mail.gmail.com> (Kaushal Modi's message of "Thu, 24 Aug 2017 13:34:07 +0000")

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	other threads:[~2017-08-25 15:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-24 13:34 bug#28218: 26.0.50; TOML table name fontification on lines with comments Kaushal Modi
2017-08-25 15:57 ` Tom Tromey [this message]
2017-08-25 16:21   ` Kaushal Modi
2017-08-27  2:39     ` Tom Tromey
2017-08-27 12:19       ` Kaushal Modi
2017-08-27  2:48 ` bug#28218: done Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lgm7iqsx.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=28218@debbugs.gnu.org \
    --cc=kaushal.modi@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.