all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: emacs-devel@gnu.org
Subject: Re: Several Major Modes.
Date: Sun, 17 Nov 2019 16:03:26 +0000	[thread overview]
Message-ID: <20191117160326.GA11551@ACM> (raw)
In-Reply-To: <12fbf5de-e4a8-cfc5-b92e-be368eb2c1f4@yandex.ru>

Hello, Dmitry.

On Sun, Nov 17, 2019 at 14:48:35 +0200, Dmitry Gutov wrote:
> Hi Alan,

> On 16.11.2019 15:10, Alan Mackenzie wrote:

> >>> You also need to make sure narrowing is available for any purpose
> >>> required by a major mode.

> >> Eh, I think it's "available" already, but I'd have to see specific
> >> examples.

> > Oh good!  I have to admit I haven't actually seen MMM Mode running,
> > or at least I don't remember it.

> I think we won't really know until there's a good change of CC Mode
> working with MMM Mode, so then people could try and exercise various
> features. And we'll see what works and what does not.

Other than CC Mode's handling of syntax-table text properties, what
precisely is hindering it working in MMM Mode?  (That question's partly
addressed at myself.)

[ .... ]

> >>>> Is it feasible to support embedded chunks? To support chunks with
> >>>> incomplete pieces of code (which are e.g. included conditionally
> >>>> by the surrounding template)?

> >>> Well CC Mode already supports preprocessor macros and (for C++) raw
> >>> strings, which are syntactically somewhat and very different from the
> >>> enclosing code.

> >> I'm not sure it's the same. Like, would CC Mode cope with a region
> >> starting with closing brackets, etc. This might not be a frequent
> >> situation, but at least it shouldn't blow up.

> > Maybe having several sets of syntax-table text properties in a buffer,
> > one set for each sub-buffer, would help.  I devised and half-implemented
> > such a facility back in 2017, calling it "indirect text properties".  To
> > switch to a different set of properties, you would merely have to set
> > (or bind) a dynamic variable.

> > With this, I could set whitespace syntax-table props all over the non-CC
> > Mode regions while CC Mode is "in scope", thus making syntactic stuff
> > and fontification easy.

> It's an interesting suggestion, but a difficult problem. Like, if you 
> just swap the meanings of syntax-table text properties, it would make 
> syntax-ppss caches invalid without telling it. A better solution would 
> be to somehow integrate with it.

Being more precise, with this idea there would be several sets of s-t
properties present at the same time.  Each would have a different symbol,
e.g. gensyms like syntax-table-13, syntax-table-14, .....  The code in
textprop.c would check the symbol 'syntax-table for a particular symbol
property, which if set would cause it to substitute, say,
syntax-table-13, and read/write that property instead.   Fast, and only a
bit inelegant.

Naturally, all the low-level caches in syntax.c would need to be
synchronised at the same time we bind the thing to syntax-table-13.  The
caches belonging to each individual MMM chunk (such as syntax-ppss
caches) would be OK without change, since they would only be used while
the chunk was current, and hence syntax-table-13 currently in use.

Given how much in Emacs depends on syntax, this scheme might save a lot
of work and a lot of workarounds in MMM Mode.  If MMM Mode could be
responsible for putting space syntax-table-13 properties on all chunks
but the current one, it is possible major modes could be used in MMM Mode
with only minimal adaptations to those major modes.

Implementing this scheme would not be difficult.  (As I said, it's half
done already.)  How would you feel about using it in MMM Mode, and do you
see any difficult problems with it?

> Anyway, you mentioned a real problem (for which I only have workarounds 
> thus far), but for now I was just asking whether an isolated 
> "incomplete" chunk would work okay.

:-)  Sorry, yes.  I think working with an incomplete chunk would be
difficult at the moment.  With all the other chunks "spaced out", as
suggested above, it would be easy, I think.

-- 
Alan Mackenzie (Nuremberg, Germany).



  reply	other threads:[~2019-11-17 16:03 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20191109144026.20810.76129@vcs0.savannah.gnu.org>
     [not found] ` <20191109144027.DDC3720927@vcs0.savannah.gnu.org>
2019-11-11 16:52   ` master 7362554: Widen around c-font-lock-fontify-region. This fixes bug #38049 Dmitry Gutov
2019-11-11 20:34     ` Alan Mackenzie
2019-11-12 13:36       ` Dmitry Gutov
2019-11-13 21:19         ` Alan Mackenzie
2019-11-13 22:33           ` Dmitry Gutov
2019-11-14 13:42             ` Stefan Monnier
2019-11-14 14:05               ` Dmitry Gutov
2019-11-14 14:29                 ` Eli Zaretskii
2019-11-14 14:35                   ` Dmitry Gutov
2019-11-14 14:48                     ` Eli Zaretskii
2019-11-14 14:50                       ` Dmitry Gutov
2019-11-14 16:08                         ` Eli Zaretskii
2019-11-14 21:07                           ` Dmitry Gutov
2019-11-15  9:31                             ` Eli Zaretskii
2019-11-15 10:24                               ` Dmitry Gutov
2019-11-15 13:00                                 ` Eli Zaretskii
2019-11-14 13:49             ` Eli Zaretskii
2019-11-14 14:08               ` Dmitry Gutov
2019-11-14 14:37             ` Dmitry Gutov
2019-11-14 14:55               ` Stefan Monnier
2019-11-14 15:02                 ` Dmitry Gutov
2019-11-14 15:33                   ` Stefan Monnier
2019-11-14 16:12                 ` Eli Zaretskii
2019-11-14 18:51                   ` Stefan Monnier
2019-11-14 19:19                     ` Eli Zaretskii
2019-11-14 19:48                       ` Dmitry Gutov
2019-11-14 19:56                         ` Eli Zaretskii
2019-11-14 19:59                           ` Dmitry Gutov
2019-11-15  7:34                             ` Eli Zaretskii
2019-11-15  7:52                               ` Dmitry Gutov
2019-11-14 21:29                       ` Stefan Monnier
2019-11-14 21:46                         ` Dmitry Gutov
2019-11-15  9:36                         ` Eli Zaretskii
2019-11-15 10:26                           ` Dmitry Gutov
2019-11-15 23:27                           ` Stefan Monnier
2019-11-16  8:02                             ` Eli Zaretskii
2019-11-17  0:50                               ` Stefan Monnier
2019-11-17  3:33                                 ` Eli Zaretskii
2019-11-17  7:36                             ` Dmitry Gutov
2019-11-17 15:44                               ` Eli Zaretskii
2019-11-17 17:59                                 ` Dmitry Gutov
2019-11-17 18:26                                   ` Eli Zaretskii
2019-11-17 18:35                                     ` Dmitry Gutov
2019-11-14 19:58                 ` Dmitry Gutov
2019-11-14 21:24             ` Several Major Modes. [Was: master 7362554: Widen around c-font-lock-fontify-region. This fixes bug #38049.] Alan Mackenzie
2019-11-14 22:11               ` Dmitry Gutov
2019-11-15 20:10                 ` Several Major Modes Alan Mackenzie
2019-11-15 21:45                   ` Dmitry Gutov
2019-11-16 13:10                     ` Alan Mackenzie
2019-11-17 12:48                       ` Dmitry Gutov
2019-11-17 16:03                         ` Alan Mackenzie [this message]
2019-11-17 21:56                           ` Dmitry Gutov
2019-11-14 13:35           ` master 7362554: Widen around c-font-lock-fontify-region. This fixes bug #38049 Eli Zaretskii
2019-11-15 22:43           ` Dmitry Gutov
2019-11-14 12:02         ` Eli Zaretskii

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=20191117160326.GA11551@ACM \
    --to=acm@muc.de \
    --cc=dgutov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    /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.