unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Phillip Lord" <phillip.lord@russet.org.uk>
To: emacs-devel@gnu.org
Subject: Re: Thinking about changed buffers
Date: Tue, 29 Mar 2016 14:14:08 +0100	[thread overview]
Message-ID: <2d55f05e4ba00afeb3f7269953eb0e13.squirrel@cloud103.planethippo.com> (raw)
In-Reply-To: <m3bn5ya4ro.fsf@gnus.org>

On Mon, March 28, 2016 6:31 pm, Lars Magne Ingebrigtsen wrote:
> One idea that popped up is that whenever we mark a buffer as unchanged
> (that is, `(set-buffer-modified-p nil)', we save the byte size of the
> buffer and a cryptographic hash of the buffer.  Then `buffer-modified-p'
> would simply see whether either the size had changed, and if not, whether
> the hash had changed.  If both are identical, then the buffer hasn't
> changed.
>


Rather than doing this in general, why not have a
"with-potentially-unmodified" macro, which calculates this hash and
restores buffer-modified-p if no changes have happened. This would solve
the "fill-paragraph" problem.

Although, I would worry about the implications for the before and
after-change hooks. fill-paragraph is already problematic here because
before and after changes hooks are not necessarily consistent. In the case
where no changes happen, would we expect before and after change hook to
run? Because they would have to, as we do not know whether the buffer will
change before we change.

The only solution I can see for fill-paragraph is to copy the paragraph to
a temp buffer, fill that, check whether it has changed, then if it has,
signal before-change, copy the changed paragraph back, signal after
change. If it has not changed, then fill-paragraph becomes a no-op.

Phil




  parent reply	other threads:[~2016-03-29 13:14 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-28 17:31 Thinking about changed buffers Lars Magne Ingebrigtsen
2016-03-28 17:56 ` Andreas Schwab
2016-03-28 18:00   ` Lars Magne Ingebrigtsen
2016-03-28 18:10     ` Andreas Schwab
2016-03-28 18:19       ` Lars Magne Ingebrigtsen
2016-03-28 18:30         ` Eli Zaretskii
2016-03-28 18:53           ` Lars Magne Ingebrigtsen
2016-03-28 18:57             ` Eli Zaretskii
2016-03-28 19:06               ` Lars Magne Ingebrigtsen
2016-03-28 19:15                 ` Eli Zaretskii
2016-03-28 19:23                   ` Lars Magne Ingebrigtsen
2016-03-28 19:38                     ` Eli Zaretskii
2016-03-28 19:46                       ` Lars Magne Ingebrigtsen
2016-03-28 20:21                         ` Lars Magne Ingebrigtsen
2016-03-29  2:29                           ` Eli Zaretskii
2016-03-28 18:54           ` Andreas Schwab
2016-03-28 18:22     ` Eli Zaretskii
2016-03-28 18:40 ` Lars Magne Ingebrigtsen
2016-03-28 18:49 ` Stephan Mueller
2016-03-28 19:13   ` Stefan Monnier
2016-03-28 19:20     ` Lars Magne Ingebrigtsen
2016-03-28 20:13       ` Clément Pit--Claudel
2016-03-28 20:32       ` Óscar Fuentes
2016-03-28 20:33       ` Stephan Mueller
2016-03-28 20:17     ` Marcin Borkowski
2016-03-28 18:51 ` Lars Magne Ingebrigtsen
2016-03-28 19:22   ` Stefan Monnier
2016-03-28 19:27     ` Lars Magne Ingebrigtsen
2016-03-28 19:32       ` Dmitry Gutov
2016-03-28 20:16         ` Clément Pit--Claudel
2016-03-28 20:22           ` Lars Magne Ingebrigtsen
2016-03-28 21:43       ` Stefan Monnier
2016-03-29  8:53 ` Florian Weimer
2016-03-29 13:14 ` Phillip Lord [this message]
2016-03-29 13:39   ` Stefan Monnier
2016-03-29 15:30     ` Lars Magne Ingebrigtsen
2016-04-03 23:05       ` John Wiegley
2016-04-03 23:29         ` Clément Pit--Claudel
2016-04-03 23:30           ` John Wiegley
2016-04-03 23:44           ` Óscar Fuentes
2016-04-04  0:20             ` Clément Pit--Claudel
2016-04-04  0:29               ` Óscar Fuentes
2016-04-04  5:21             ` Lars Magne Ingebrigtsen
2016-04-04  5:26               ` John Wiegley
2016-03-29 22:26     ` Phillip Lord
2016-04-03 23:05     ` John Wiegley

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=2d55f05e4ba00afeb3f7269953eb0e13.squirrel@cloud103.planethippo.com \
    --to=phillip.lord@russet.org.uk \
    --cc=emacs-devel@gnu.org \
    /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).