Closed some-mthfka closed 5 years ago
Nevermind, the answer was just right around the corner
where the modes of the submode region run (if ever)
In a temporary, empty buffer, one per submode.
and when they are turned on
When the major mode function runs? After that mmm-mode can be turned on, and it performs all initialization.
Are necessary modes just allowed to run at the right time for the whole buffer?
I guess so (not sure about the exact meaning of your wording).
But then, how are they limited in their effect to just the necessary region? Narrowing?
Mostly narrowing, yes. And also variables like font-lock-dont-widen
. And defining mmm-aware syntax-propertize-function, font-lock-fontify-region-function, etc.
Or is it that only some very specific parts of a submode are applied (the list of things quoted above)?
You could say that. The exact lists of variables that are saved per-subregion (or per-submode) are pre-defined. See mmm-save-local-variables
in mmm-vars.el
.
Do I understand correctly that something like syntax checking for a subregion can't currently be done using mmm-mode?
I would say it can be implemented, and it's not exactly rocket science. New flymake's flymake-diagnostic-functions
API can be used similarly to how mmm-fontify-region
works: collect all chunks, put them in a temporary buffer in the right submode, and run the diagnostic function for the relevant major mode in that buffer (if it needs a file on disk, guess it'll have to be saved first).
Alright, my picture is now as follows:
When the cursor jumps to a submode region:
On any user interaction:
When the region has to have it's own buffer (such as for syntax checking if it requires a saved file):
Is that right? If so, what are the other uses for a temporary empty buffer?
Keymap/modeline/... is changed
...because mmm-update-submode-region
is called. Because it's on post-command-hook
.
On any user interaction: The region is temporarily narrowed to (w/ those other changes applied as you listed, like font-lock-dont-widen)
No. The user doesn't see any narrowing. Narrowing is only done temporarily during the runtime of every major facility (font-lock, indentation, ...).
Is that right?
It should work, yes. We don't have any code doing exactly that, yet.
If so, what are the other uses for a temporary empty buffer?
After the major mode and minor mode functions run, we collect and remember the local variable values they had set in that buffer.
Got it, thanks!
I have skimmed the info file, but something there seems missing as to the basic working principles.
According to the info file:
What I don't understand is (1) where the modes of the submode region run (if ever) (2) and when they are turned on. Are necessary modes just allowed to run at the right time for the whole buffer? But then, how are they limited in their effect to just the necessary region? Narrowing? Or is it that only some very specific parts of a submode are applied (the list of things quoted above)? Do I understand correctly that something like syntax checking for a subregion can't currently be done using mmm-mode?
A clarification could help and this is currently discussed here (if you feel like it, please, feel free to respond there as well).
Thanks!