unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* How can I undo a change from a modification-hook?
@ 2017-04-26  7:02 Clément Pit--Claudel
  2017-04-26 12:26 ` Stefan Monnier
  0 siblings, 1 reply; 12+ messages in thread
From: Clément Pit--Claudel @ 2017-04-26  7:02 UTC (permalink / raw)
  To: Emacs developers

[-- 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 --]

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

end of thread, other threads:[~2017-04-27 17:36 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-26  7:02 How can I undo a change from a modification-hook? Clément Pit--Claudel
2017-04-26 12:26 ` 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

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