[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#35419: [O] [Proposal] Buffer Lenses and the Case of Org-Mode (also,

From: Dmitry Gutov
Subject: bug#35419: [O] [Proposal] Buffer Lenses and the Case of Org-Mode (also, Jupyter)
Date: Sun, 5 Apr 2020 04:46:08 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1


Some late clarifications about mmm-mode.

On 26.04.2019 00:00, Dmitrii Korobeinikov wrote:
 > A lot of the functionality of MMM Mode---that which makes the major mode
 > appear to change---is implemented by saving and restoring the values of
 > local variables, or pseudo-variables.

What I don't understand is where the modes of the submode region run and when they are turned on.

They are run in an empty temporary buffer, see mmm-update-mode-info. That is true for all the "submodes" in a buffer. The primary major mode is run in the context of that buffer (IIRC). After any of them runs, the code responsible for it collects the values of a certain number of known variables and associates that map with the major mode (this is a bit of a simplification).

Are necessary modes just allowed to run at the right time for the whole buffer?

When you move between the "chunks", no major mode functions are called. Instead, the values of variables are swapped in. Including the value of the 'major-mode' variable.

But then, how are they limited in their effect to just the necessary region? Narrowing?

Usually, yes. Especially when we're talking about font-lock and syntax-propertize-function. See mmm-fontify-region-list for an example.

Could, for example, syntax checking be done efficiently that way?

That depends on the combination of modes and how they are used (either they can be nested, like in web templates, or it's a flat list where chunks are largely independent like in Jupyter). But in most cases, I think, you could pick a good strategy. There are no universal ones, though.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]