all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Alan Mackenzie <acm@muc.de>, emacs-devel@gnu.org
Cc: Vitalie Spinu <spinuvit@gmail.com>
Subject: Re: Indirect text properties
Date: Mon, 18 Nov 2019 00:55:50 +0200	[thread overview]
Message-ID: <a660ada8-a3bb-4d83-7e9f-0d6523b8c16d@yandex.ru> (raw)
In-Reply-To: <20191117170527.GB11551@ACM>

Hi Alan,

On 17.11.2019 19:05, Alan Mackenzie wrote:

> 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.

Could char-property-alias-alist help?

> 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.

It's a lot of work with likely some performance overhead even for the 
default case as well. It sounds like it could be a piece of the puzzle, 
but let's see if we get the full picture first.

Also, I think most (all?) of this proposal could be implemented in Lisp 
by just setting the 'syntax-table' on the overlays that cover different 
submode regions. With more overhead when setting but less overhead than 
accessing the values.

> 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.

It doesn't seem like it covers all problematic cases. Maybe not even the 
majority:

- Would this win over "local" syntax-table properties as assigned by 
syntax-table? By the usual logic of how we implement property 
priorities, probably not. But it should, for this to work.
- Some code can just be looking for certain characters instead of syntax 
classes with re-search-backward, etc. It wouldn't be fooled either. So 
this would likely require some "are we still in the same major mode" 
predicate. At which point we might get by without the space-syntax-table 
swapping entirely.

So what are the exact scenarios that your aim is to fix with this?

/Cc Vitalie, he could have some ideas, maybe even tell us how Polymode 
maybe solves this problem already.



  reply	other threads:[~2019-11-17 22:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-17 17:05 Indirect text properties Alan Mackenzie
2019-11-17 22:55 ` Dmitry Gutov [this message]
2019-11-18 18:06   ` Alan Mackenzie
2019-11-18 18:11 ` Lars Ingebrigtsen

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=a660ada8-a3bb-4d83-7e9f-0d6523b8c16d@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    --cc=spinuvit@gmail.com \
    /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.