From: Markus Triska <triska@metalevel.at>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Phillip Lord <phillip.lord@russet.org.uk>, 23906@debbugs.gnu.org
Subject: bug#23906: 25.0.95; Undo boundary after process output is not consistent
Date: Mon, 18 Jul 2016 21:03:14 +0200 [thread overview]
Message-ID: <877fci93bh.fsf@metalevel.at> (raw)
In-Reply-To: <jwv60s34m4x.fsf-monnier+emacsbugs@gnu.org> (Stefan Monnier's message of "Mon, 18 Jul 2016 00:18:36 -0400")
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> How 'bout the patch below (see the viper part to get an idea about how
> to use it in ediprolog)?
It's pretty awesome, thank you!
I have added it to ediprolog.el with the patch below, please let me know
if you have any comments. I like particularly that your functions work
together in a pure way: It's OK if the handle is simply *not* used. At
least I *think* that is the case, i.e., prepare-change-group does not
alter the undo list or any other global state. I am particularly
interested in this case because in ediprolog, the following situation
may arise:
1) a query is started with M-x ediprolog-dwim RET
2) interaction with Prolog takes place
3) critically, user presses C-g to exit the interaction (!)
4) user makes (unrelated) changes elsewhere in the buffer
5) user re-enters the interaction with M-x ediprolog-toplevel RET
7) interaction resumes
8) after a few more answers, interaction finishes
9) C-/ (user presses undo)
To see what I mean, please try M-x ediprolog-dwim RET on the following
query, and press SPACE twice:
?- between(1, 3, X).
%@ X = 1 ;
%@ X = 2
at this state, press C-g to exit the interaction, and (optionally) make
other changes in the buffer. Then do M-x ediprolog-toplevel RET to
resume interaction, and press SPACE once more. In total, you obtain:
?- between(1, 3, X).
%@ X = 1 ;
%@ X = 2 ;
%@ X = 3.
Ideally, if you then press C-/, the *whole* interaction would be undone,
and I may find a good way to do this. However, in its current state
(with the patch below), such interrupted and resumed interactions still
result in undo boundaries, which is also acceptable.
Thus, with the primitives you provide, the case I care most about,
namely a single continuous interaction, now works exactly as expected on
undo (it is undone as a unit on), and interruptions work acceptably
well. Therefore, thank you very much for this!
One thing I noticed in the interaction above is that point is sometimes
at a very unexpected position after undo, in particular if the buffer
contents are modified after the query is interrupted. I will file a
separate issue for this.
And a question: Is there any reason not to write viper-adjust-undo as:
(defun viper-adjust-undo ()
(when viper--undo-change-group-handle
(undo-amalgamate-change-group viper--undo-change-group-handle)
(setq viper--undo-change-group-handle nil)))
The patch to ediprolog.el follows.
Thank you and all the best!
Markus
diff --git a/ediprolog.el b/ediprolog.el
index ee89095..408284b 100644
--- a/ediprolog.el
+++ b/ediprolog.el
@@ -347,11 +347,13 @@ arguments, equivalent to `ediprolog-remove-interactions'."
(error "Missing `.' at the end of this query")))
(query (buffer-substring-no-properties from to)))
(end-of-line)
- (insert "\n" ediprolog-indent-prefix ediprolog-prefix)
- (ediprolog-interact
- (format "%s\n" (mapconcat #'identity
- ;; `%' can precede each query line
- (split-string query "\n[ \t%]*") " "))))
+ (let ((handle (prepare-change-group)))
+ (insert "\n" ediprolog-indent-prefix ediprolog-prefix)
+ (ediprolog-interact
+ (format "%s\n" (mapconcat #'identity
+ ;; `%' can precede each query line
+ (split-string query "\n[ \t%]*") " ")))
+ (undo-amalgamate-change-group handle)))
t))
;;;###autoload
next prev parent reply other threads:[~2016-07-18 19:03 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-06 17:56 bug#23906: 25.0.95; Undo boundary after process output is not consistent Markus Triska
2016-07-06 18:38 ` Eli Zaretskii
2016-07-11 11:45 ` Phillip Lord
2016-07-11 13:54 ` Markus Triska
2016-07-12 16:29 ` Phillip Lord
2016-07-12 17:03 ` Stefan Monnier
2016-07-12 18:56 ` Markus Triska
2016-07-12 20:22 ` Stefan Monnier
2016-07-12 21:02 ` Markus Triska
2016-07-12 21:20 ` Stefan Monnier
2016-07-12 22:35 ` Markus Triska
2016-07-12 22:51 ` Stefan Monnier
2016-07-12 22:45 ` Markus Triska
2016-07-13 22:12 ` Phillip Lord
2016-07-14 8:34 ` Markus Triska
2016-07-14 13:33 ` Phillip Lord
2016-07-14 15:10 ` Markus Triska
2016-07-14 20:25 ` Phillip Lord
2016-07-14 22:12 ` Stefan Monnier
2016-07-18 4:18 ` Stefan Monnier
2016-07-18 19:03 ` Markus Triska [this message]
2016-07-19 0:41 ` Stefan Monnier
2016-07-19 1:05 ` Stefan Monnier
2016-07-24 15:45 ` Phillip Lord
2016-07-24 21:36 ` Stefan Monnier
2020-09-04 13:55 ` Lars Ingebrigtsen
2016-07-13 8:09 ` Phillip Lord
2016-07-13 14:29 ` Markus Triska
2016-07-13 22:23 ` Phillip Lord
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=877fci93bh.fsf@metalevel.at \
--to=triska@metalevel.at \
--cc=23906@debbugs.gnu.org \
--cc=monnier@iro.umontreal.ca \
--cc=phillip.lord@russet.org.uk \
/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).