From: Alan Mackenzie <acm@muc.de>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: emacs-devel@gnu.org
Subject: Re: Several Major Modes.
Date: Fri, 15 Nov 2019 20:10:16 +0000 [thread overview]
Message-ID: <20191115201016.GA5257@ACM> (raw)
In-Reply-To: <4eb06378-b6ce-e6b6-5939-b1cb34267a9c@yandex.ru>
Hello, Dmitry.
On Fri, Nov 15, 2019 at 00:11:17 +0200, Dmitry Gutov wrote:
> On 14.11.2019 23:24, Alan Mackenzie wrote:
> > Hello, Dmitry.
> > On Thu, Nov 14, 2019 at 00:33:33 +0200, Dmitry Gutov wrote:
> > [ .... ]
> >>>> In mmm-mode context, however, we apply definite boundaries to the
> >>>> region chunks. Here's an example of some Noweb code:
> >>>> https://en.wikipedia.org/wiki/Noweb#Example_of_a_simple_noweb_program
> >>>> The inside of hello.c block would be narrowed to.
> >>> I think I've said this before, but I don't think narrowing is the right
> >>> tool for that task. I don't think there is a suitable tool in Emacs at
> >>> the moment.
> >> *shrug* We do the best with what we have.
> > Why can we not formulate something better, an enhancement to the Emacs
> > core which would support several major modes properly? I have made
> > proposals in this area before, but I think they were to grandiose to be
> > implementable.
> > What seems to be needed is a way of partioning a buffer into several
> > sub-buffers (which I have called "islands" in the past), and having a new
> > type of local variable, one valid in exactly one sub-buffer. More or
> > less.
> There are options. We'd have to decide on a suitable model, calling them
> islands or whatever, but I think the first approximation is to either
> make sure narrowing is available for this purpose ....
You also need to make sure narrowing is available for any purpose
required by a major mode.
> .... or, if we absolutely can't make it work, add a new element to
> prog-indentation-context which will be a function that would return the
> bounds of the current chunk.
Or something like that.
> Regarding "new type of local variable", mmm-mode already tracks
> something like that.
I was envisaging something at the C level, where different regions of a
buffer would have different values of variables, without needing the
continual swapping at the Lisp level. Maybe such a thing isn't needed.
> >>>> Now, I have remembered that CC Mode calls widen from many places
> >>>> already, so it already is problematic for using in a context like
> >>>> that.
> >>> It does, yes. Users also use widening and narrowing.
> > I believe these problems won't go away, and there will always be
> > conflicts between CC Mode (as it is) and mmm-mode (as it is).
> I think we should also try to understand whether making CC Mode play
> nice to doable/feasible, and for what uses. Like, I think it can work
> (more or less) already when it's the primary major mode (meaning the
> buffer starts and ends with it), so the embedded chunks are all other
> modes.
It can't work if any external Lisp corrupts its syntax-table text
properties. This is what syntax-ppss-flush-cache (on
before-change-functions for many modes) would do if there were a non-nil
syntax-propertize-function at the time. This may be the biggest problem
to getting CC Mode integrated into MMM Mode.
> 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. So I don't see why not, once the problem with the
syntax-table text properties is solved.
> By answering these questions we can temper our expectations and come up
> with a practical plan.
> Doing nothing is also a valid choice, BTW, since for many uses replacing
> c-mode with js-mode works pretty okay. I've been recommending it to
> MMM-mode users.
That's a rather rough workaround. It would be better if we could solve
the problems.
--
Alan Mackenzie (Nuremberg, Germany).
next prev parent reply other threads:[~2019-11-15 20:10 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 ` Alan Mackenzie [this message]
2019-11-15 21:45 ` Several Major Modes Dmitry Gutov
2019-11-16 13:10 ` Alan Mackenzie
2019-11-17 12:48 ` Dmitry Gutov
2019-11-17 16:03 ` Alan Mackenzie
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
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=20191115201016.GA5257@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 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).