all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Indirect text properties
@ 2019-11-17 17:05 Alan Mackenzie
  2019-11-17 22:55 ` Dmitry Gutov
  2019-11-18 18:11 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 4+ messages in thread
From: Alan Mackenzie @ 2019-11-17 17:05 UTC (permalink / raw)
  To: emacs-devel

Hello, Emacs.

This is an idea I had a couple of years ago, and has recently resurfaced
in discussions with Dmitry (Subject: Several major modes).

The idea is that there could be several alternative sets of text
properties with the same symbol simultaneously in a buffer, the Lisp
code selecting which to use by binding a dynamic variable.  This would
be most useful for the syntax-table text property.

How would this work?  In textprop.c, the code would, on any access to a
text property, check its symbol's property 'indirect-text-property, and
if that is a non-nil symbol, access it's value (another symbol) and use
that as the symbol for the text property instead.  It's easier to say in
code, which would look something like:

    #define TEXP_PROP_END_NAME(sym) \
        !NILP (itp = Fget (sym, Qindirect_text_property)) && SYMPOLP (itp) \
        && !NILP (etp = find_symbol_value (itp)) && SYMBOLP (etp) \
        ? etp : sym

.  To switch to a different set of, e.g., syntax-table text properties
it would suffice to bind the lisp variable i-t-p to, say, the gensym
syntax-table-13.  Of course low level caches, e.g. in syntax.c, would
have to be kept synchronised, too.

So, what use would it be?  What I have proposed to Dmitry is having a
distinct set of syntax-table properties for each major mode chunk of an
MMM Mode ("multiple major mode") buffer.  Say syntax-table-13 would be
the set for a CC Mode chunk.  Outside of that chunk, every character
would be given a space syntax-table-13 text property.  This is the
critical thing.

Thus all actions dependent upon syntax (and there are a LOT), could be
performed by CC Mode in the chunk without the other chunks getting in
the way.  It may not even be necessary to narrow to the chunk.

The necessary juggling with the various syntax-table-13s would be done
by MMM Mode.  This might well allow arbitrary major modes to be used in
MMM Mode with minimal, if any, modification.

Thoughts?

-- 
Alan Mackenzie (Nuremberg, Germany).



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-11-18 18:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-17 17:05 Indirect text properties Alan Mackenzie
2019-11-17 22:55 ` Dmitry Gutov
2019-11-18 18:06   ` Alan Mackenzie
2019-11-18 18:11 ` Lars Ingebrigtsen

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.