all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Clément Pit--Claudel" <cpitcla@mit.edu>
To: Emacs developers <emacs-devel@gnu.org>
Subject: How can I undo a change from a modification-hook?
Date: Wed, 26 Apr 2017 03:02:24 -0400	[thread overview]
Message-ID: <2448005f-9fc4-78b2-3203-9fc8204f6f5b@mit.edu> (raw)

[-- Attachment #1: Type: text/plain, Size: 1238 bytes --]

Hey emacs-devel,

I'm using overlays to keep track of buffer regions that have been sent to a subprocess.  Edits in a previously sent ("processed") region are generally forbidden — the only two permissible kinds of changes in processed regions are editing a comment and adding or removing of space at the end of a line.

Adding a modification-hook to my overlays makes it easy to disallow changes (by raising an error), and to allow changes when in a comment.  I can't find a good way to allow whitespace edits at the end of a line, though.  I can detect such changes from the second call to the modification hook (during which it's easy to know whether the change is only adding or removing space at the end of a line), but I can't easily undo the changes and error out if they involve more than whitespace, can I?

What's the right way do disallow certain modifications in text covered by an overlay, in particular when the determination of whether to allow a given modification cannot be made during the first call to the overlay's modification hook?  For example, how can I make an overlay that allows insertion or deletion of space at the end of the lines that it covers, but no other modifications?

Thanks!
Clément.


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 1979 bytes --]

             reply	other threads:[~2017-04-26  7:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-26  7:02 Clément Pit--Claudel [this message]
2017-04-26 12:26 ` How can I undo a change from a modification-hook? Stefan Monnier
2017-04-26 13:45   ` Clément Pit-Claudel
2017-04-26 13:52     ` Stefan Monnier
2017-04-26 14:23       ` Clément Pit-Claudel
2017-04-26 14:51         ` Stefan Monnier
2017-04-26 16:38           ` Clément Pit-Claudel
2017-04-26 18:43             ` Stefan Monnier
2017-04-26 19:02               ` Clément Pit-Claudel
2017-04-27 12:48                 ` Stefan Monnier
2017-04-27 12:58                   ` Clément Pit-Claudel
2017-04-27 17:36                     ` 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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2448005f-9fc4-78b2-3203-9fc8204f6f5b@mit.edu \
    --to=cpitcla@mit.edu \
    --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 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.