unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: mvar <mvar.40k@gmail.com>
Cc: 39277@debbugs.gnu.org, Hadrien Lacour <hadrien.lacour@posteo.net>
Subject: bug#39277: 26.3; Tcl font lock does not understand quoting
Date: Tue, 27 Oct 2020 09:27:45 -0400	[thread overview]
Message-ID: <jwvzh47lsnj.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87lffs1zvw.fsf@cnu407c2zx.nsn-intra.net> (mvar's message of "Mon, 26 Oct 2020 22:44:03 +0200")

>> Hello, tcl-mode's font lock (highlighting) chokes on this simple case:
>>     puts {"hello}
>> where it considers the double quote inside the curly braces as a
>> "quoting" character.
>> I have confirmed it works with `emacs -Q`.
> there's some generic(?) syntactic font lock getting triggered once the
> doublequote character is found, that expects a closing doublequote - until then
> everything is locked as a string. Is this what this bug is about (it was not
> 100% clear to me from your initial report) ? i'm attaching a patch that works
> around this behavior but i don't know if it is the proper way to deal with the
> problem (it certainly doesn't look pretty).

It's been too long since I last had to deal with Tcl so I can't remember
the rules.  The patch you submitted is most likely not "correct" in the
sense that it still leaves many cases that are mishandled.

Could someone remind me how " and {..} interact in Tcl?

E.g.

    proc foo1 () {
       puts "hello"
    }

prints "hello" (without the quotes)?
And

    proc foo2 () {
       puts {"hello}
    }

prints "hello (with the quote)?
And what about

    proc foo3 () {
       puts "hello}"
    }

    proc foo4 () {
       puts "hello\}"
    }

    proc foo5 () {
       puts "hello
    }

> The idea is to insert an additional
> rule in tcl-syntax-propertize-function that will match the tcl-builtin-list

I'm thinking that maybe a better option is to catch all " in
tcl-syntax-propertize-function and for every one of them see if they're
"closing" a string and if not, check whether they're closed by a } before
a matching " and if so mark them as "not opening a string".

> +         '("{\\([^}]+\\)}" 1 font-lock-string-face)

Won't this catch cases not usually considered as strings, like

    proc foo5 () {
        return 6
    }

?

        Stefan






  parent reply	other threads:[~2020-10-27 13:27 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-25 10:00 bug#39277: 26.3; Tcl font lock does not understand quoting Hadrien Lacour
2020-01-25 10:12 ` bug#39277: tcl-mode " Hadrien Lacour
2020-01-25 10:53 ` Hadrien Lacour
2020-10-26 20:44 ` bug#39277: 26.3; Tcl font lock " mvar
2020-10-27  8:31   ` bug#39277: (no subject) Lars Ingebrigtsen
2020-10-27  8:51   ` bug#39277: 26.3; Tcl font lock does not understand quoting Andreas Schwab
2020-10-27  8:56     ` Lars Ingebrigtsen
2020-10-27 13:27   ` Stefan Monnier [this message]
2020-10-27 17:45     ` Lars Ingebrigtsen
2020-10-27 20:42       ` mvar
2020-10-27 20:47         ` Lars Ingebrigtsen
2020-10-27 22:48         ` Stefan Monnier
2020-10-29 17:39           ` Stefan Monnier
2020-10-30 12:02             ` Lars Ingebrigtsen
2020-10-31 11:01             ` mvar
2020-10-31 13:20               ` Stefan Monnier
2020-11-03 19:47                 ` mvar
2020-11-03 21:45                   ` Stefan Monnier
2020-11-05 12:38                     ` mvar
2020-10-27 15:24 ` bug#39277: Hadrien Lacour

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=jwvzh47lsnj.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=39277@debbugs.gnu.org \
    --cc=hadrien.lacour@posteo.net \
    --cc=mvar.40k@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 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).