unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Vitalie Spinu <spinuvit@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: trunk r116426: * lisp/jit-lock.el (jit-lock-mode): Keep it disabled in indirect buffers.
Date: Fri, 23 May 2014 23:10:43 -0400	[thread overview]
Message-ID: <jwvsinz51qt.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <8738g0ccig.fsf@gmail.com> (Vitalie Spinu's message of "Fri, 23 May 2014 16:15:51 -0700")

> Note that if I am in the indirect buffer, I don't want to run
> base-buffer after/before-change-functions at all!

The problem is that you're not the only user of
after/before-change-functions.  In the general case, all the related
buffers might care to know that some part of their text has
been modified.

> Each time the after/before-change-functions are initialized in
> indirect-buffer I will have to somehow prohibit execution of the
> base-buffer change-functions and execute those from
> indirect-buffer.

Why prohibit the hooks from the base buffer?  If they're there it's
presumably because they're needed.

> Kinda mind-stretch. That there is no way to figure out indirect
> buffers from the base buffer complicates the stuff even further.

It's easy to find all the indirect buffers.  In your case you'll just
want to find the indirect buffer that corresponds to a particular buffer
position, and that's something I'd expect you need at other places anyway.

> More generally, the fact that hooks are not executed in current-buffer
> will probably cause havoc in other usages of indirect buffers. I imagine
> that all designers of after/before-change-functions assume that the
> action happens in the current buffer. Your proposal will invalidate this
> assumption.

Running the after/before-change-functions of the base buffer in the base
buffer means that "the action happens in the current buffer", and indeed
it does: a buffer-modification happens in all the related buffers, not
just in the one that happens to be current.

> In conclusion, unless I miss something essential, I don't see it as "the
> simplest option". The simplest option is to execute the hooks only in
> the buffer that initiated the hook (always current buffer?).

That means the other related buffers aren't told about the modification
in their text, which is also unexpected.

> What can go wrong with "run hooks in the current buffer only"
> implementation?

OK, let's say you chunks

    chunk 1 in mode A
    chunk 2 in mode B
    chunk 3 in mode A

And let's say that mode A does some clever caching, so it sets up an
after-change-functions hook to flush its cache.  Now you go and delete
a block of text in chunk 3, mode A is not warned about it and fails to
flush its cache which now holds completely broken data about chunk 3.

Of course, running the after-change-functions only in the base buffer
won't directly help with that.  I find such discussions depressing,
because they always go back to "indirect buffers are an attractive
nuisance", introducing more problems than they solve.

> The idea of indirect buffers is great.

On its own, it's almost great.  But once you throw in text-properties,
overlays, and buffer-local variables, plus the fact that the choice
between text-properties and overlays is never based on whether "it
should be shared between indirect buffers or not", plus ...  it's just
a big mess that just shuffles problems around without helping
solve them.


        Stefan



  reply	other threads:[~2014-05-24  3:10 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-07 18:34 trunk r116426: * lisp/jit-lock.el (jit-lock-mode): Keep it disabled in indirect buffers João Távora
2014-04-07 20:37 ` Glenn Morris
2014-04-07 20:48   ` João Távora
2014-04-07 20:40 ` Stefan Monnier
2014-05-22  4:51   ` Vitalie Spinu
2014-05-23 13:27     ` Stefan Monnier
2014-05-23 17:58       ` Vitalie Spinu
2014-05-23 20:49         ` Stefan Monnier
2014-05-23 23:15           ` Vitalie Spinu
2014-05-24  3:10             ` Stefan Monnier [this message]
2014-05-24  9:46               ` Vitalie Spinu
2014-05-24 14:35                 ` Stefan Monnier
2014-05-30 19:26                   ` Vitalie Spinu
2014-05-30 19:54                     ` Stefan Monnier

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=jwvsinz51qt.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --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 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).