unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Jackson Ray Hamilton <jackson@jacksonrayhamilton.com>
Cc: emacs-devel@gnu.org
Subject: Re: Comprehensive JSX support in Emacs
Date: Fri, 15 Feb 2019 08:25:44 -0500	[thread overview]
Message-ID: <jwvd0ntmc3f.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <4281f8fd-9849-07ef-30f3-8516004930c9@jacksonrayhamilton.com> (Jackson Ray Hamilton's message of "Fri, 15 Feb 2019 00:21:09 -0800")

> I think one obvious reason to have JSX-specific settings is that
> sgml-basic-offset defaults to 2, and js-indent-level defaults to 4; so no
> matter what, OOTB users probably think Emacs indents JSX “wrong.”  It would
> surprise me if people were actually content with using 4 spaces for JS and
> 2 spaces for JSX blocks within.

Makes sense.

> A philosophical and practical reason to switch will be decoupling JSX from
> SGML.  Using sgml-indent-line to indent JSX probably should have been kept
> an implementation detail, but requiring the use of sgml- 
> variables uncovered that detail.  If I end up changing the implementation,
> as I’m considering, we could pay a price for that.  However, I expect that
> most users will have already configured their JSX indentation to be
> consistent with JS, and thus will be unaffected; else, I think most will
> welcome a change to consistent defaults as a “fix.”

I think such breakage is usually not a big deal, as long as there's
a clear explanation somewhere of why it's changed and how to get back
the old behavior.

>> Would there be any harm in activating JSX indentation&highlighting in
>> a Javascript buffer that doesn't use JSX?
> Indeed, that could eliminate some false negatives and simplify the code, and
> we may be able to get away with it indefinitely.

BTW, I do think it's important to keep this feature conditional on some
setting, but if it's mostly harmless, then we can be a lot more lazy (in
the sense of a lazy programmer, not a lazy program) in terms of when we
enable/disable it.

>> - Any reason why you add a call to js--disambiguate-js-from-jsx at the
>>    end of js-syntax-propertize instead of adding it directly within the
>>    syntax-propertize-rules?
> Reason: Me not knowing what I’m doing. :-)  I figured that could be
> written better.

OK, good.

> Actually, I was hoping we’d be able to talk about that part.  I wanted to
> know if you thought I should repeat the pattern that I see near that code,
> where js-syntax-propertize-regexp is called in syntax-propertize-function
> first at the beginning of the function and again later in
> syntax-propertize-rules — I haven’t yet figured out why that pattern of
> calling the same propertize function in multiple places exists in this mode
> and others (like ruby-mode’s
> ruby-syntax-propertize/ruby-syntax-propertize-heredoc).

This pattern is used to deal with "modes".  `syntax-propertize-rules`
doesn't try to find matched to all the regexps everywhere: once a regexp
has matched its code is run and that code can move point and after that
we start matching again at that position.  This is typically used for
things that are "string-like" or "comment-like" so we don't mistakenly
treat the inside of one of those elements (which typically contains
arbitrary text rather than code) as code, and so we correctly recognize
and mark the "end".

The pattern you mention happens for those kinds of situations, in order
to handle the case where syntax-propertize-function is called with point
in the middle of one of those "string/comment-like" elements.

> I’ve also been wondering in the back of my mind if I’ll need to use
> syntax-propertize-extend-region-functions in this implementation.

If your code which propertizes the < and > also wants to skip text and
prevent the rest of the syntax-propertize-rules to apply to that skipped
text, then you'll probably want to follow that same pattern.  But if
not, then it's not needed.


        Stefan


> (BTW, I’m currently figuring out the process for replying to a mailing list
> — replying to you, CCing emacs-devel, trying to set In-Reply-To in my mail
> client.  Hopefully that works this time.)

I just "reply-all".



  reply	other threads:[~2019-02-15 13:25 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-14  5:06 Comprehensive JSX support in Emacs Jackson Ray Hamilton
2019-02-14  8:03 ` Marcin Borkowski
2019-02-14 14:10 ` Stefan Monnier
2019-02-14 15:04   ` Clément Pit-Claudel
2019-02-15  8:21   ` Jackson Ray Hamilton
2019-02-15 13:25     ` Stefan Monnier [this message]
2019-02-15 13:54     ` Dmitry Gutov
2019-02-15 14:39 ` Dmitry Gutov
2019-02-16 20:50 ` Jostein Kjønigsen
2019-02-18  7:17   ` Jackson Ray Hamilton
2019-03-27  8:03 ` Jackson Ray Hamilton
2019-03-27  9:36   ` Marcin Borkowski
2019-03-30  2:18     ` Jackson Ray Hamilton
2019-04-02  1:12       ` Dmitry Gutov
2019-04-06 16:09         ` Jackson Ray Hamilton
2019-03-30  2:08   ` Jackson Ray Hamilton
2019-04-02  1:07   ` Dmitry Gutov
2019-04-02 11:23     ` Stefan Monnier
2019-04-06 16:02       ` Jackson Ray Hamilton
2019-04-07 23:19         ` Jackson Ray Hamilton
2019-04-09  6:06       ` Jackson Ray Hamilton
2019-04-09  8:12         ` Eli Zaretskii
2019-04-10  1:56           ` Jackson Ray Hamilton
2019-04-10 15:43             ` Eli Zaretskii
2019-04-06 15:55     ` Jackson Ray Hamilton
2019-04-07  0:31       ` Dmitry Gutov
2019-04-09  6:16         ` Jackson Ray Hamilton
2019-04-09  7:10           ` Marcin Borkowski
2019-04-09  8:00             ` Jackson Ray Hamilton
2019-04-11 19:51               ` Marcin Borkowski
2019-10-20 16:57                 ` Steinar Bang
  -- strict thread matches above, loose matches on Subject: below --
2019-02-15  6:38 Jackson Ray Hamilton
2019-02-17  6:10 ` Marcin Borkowski

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=jwvd0ntmc3f.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=jackson@jacksonrayhamilton.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).