[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/recomplete 5dd7c4d008 4/7: Fix recomplete when a complete
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/recomplete 5dd7c4d008 4/7: Fix recomplete when a complete action doesn't add an undo step |
Date: |
Sat, 7 Jan 2023 19:59:39 -0500 (EST) |
branch: elpa/recomplete
commit 5dd7c4d008752a1b92b088f2f06dd8f5ac6ecc0b
Author: Campbell Barton <ideasman42@gmail.com>
Commit: Campbell Barton <ideasman42@gmail.com>
Fix recomplete when a complete action doesn't add an undo step
---
recomplete.el | 56 ++++++++++++++++++++++++++++++++------------------------
1 file changed, 32 insertions(+), 24 deletions(-)
diff --git a/recomplete.el b/recomplete.el
index 4b946b9386..1a5763808e 100644
--- a/recomplete.el
+++ b/recomplete.el
@@ -402,31 +402,39 @@ step onto the next item)."
(undo-data (cdr buffer-undo-list))
(undo-data-init (cdr buffer-undo-list-init)))
- ;; Since setting undo-data could corrupt the buffer if there is an
unexpected state,
- ;; ensure we have exactly one undo step added, so calling undo
returns to a known state.
- ;;
- ;; While this should never happen, prefer an error message over a
corrupt buffer.
- (unless (eq undo-data-init (recomplete--undo-next undo-data))
- (user-error "(re)complete: unexpected undo-state before undo,
abort!"))
- (let
- ( ;; Roll back the edit, override `this-command' so we have
predictable undo behavior.
- ;; Also so setting it doesn't overwrite the current
`this-command'
- ;; which is checked above as `last-command'.
- (this-command nil)
- ;; We never want to undo in region (unlikely, set just to be
safe).
- (undo-in-region nil)
- ;; The "Undo" message is just noise, don't log it or display it.
- (inhibit-message t)
- (message-log-max nil))
-
- (undo-only)
-
- ;; Ensure a single undo step was rolled back, if not,
- ;; early exit as we must _never_ set undo data for an unexpected
state.
- (setq undo-data (cdr buffer-undo-list))
- (unless (eq undo-data-init (recomplete--undo-next
(recomplete--undo-next undo-data)))
- (user-error "(re)complete: unexpected undo-state after undo,
abort!"))))
+ ;; It's possible the last action did not add an undo step.
+ ;; This can happen when `recomplete' cycles back to the initial
state.
+ ;; While not common it can happen if the complete action compares
the state
+ ;; of the current buffer with the contents that replaces it, where
no change
+ ;; if found and no undo step is added. In this case, the last undo
will be skipped.
+ (unless (eq undo-data-init undo-data)
+ ;; Since setting undo-data could corrupt the buffer if there is an
unexpected state,
+ ;; ensure we have exactly one undo step added,
+ ;; so calling undo returns to a known state.
+ ;;
+ ;; While this should never happen, prefer an error message over a
corrupt buffer.
+ (unless (eq undo-data-init (recomplete--undo-next undo-data))
+ (user-error "(re)complete: unexpected undo-state before undo,
abort!"))
+
+ (let
+ ( ;; Roll back the edit, override `this-command' so we have
predictable undo behavior.
+ ;; Also so setting it doesn't overwrite the current
`this-command'
+ ;; which is checked above as `last-command'.
+ (this-command nil)
+ ;; We never want to undo in region (unlikely, set just to be
safe).
+ (undo-in-region nil)
+ ;; The "Undo" message is just noise, don't log it or display
it.
+ (inhibit-message t)
+ (message-log-max nil))
+
+ (undo-only)
+
+ ;; Ensure a single undo step was rolled back, if not,
+ ;; early exit as we must _never_ set undo data for an unexpected
state.
+ (setq undo-data (cdr buffer-undo-list))
+ (unless (eq undo-data-init (recomplete--undo-next
(recomplete--undo-next undo-data)))
+ (user-error "(re)complete: unexpected undo-state after undo,
abort!")))))
;; Roll back the buffer state, checks above assure us this won't cause
any problems.
(setq buffer-undo-list buffer-undo-list-init)
- [nongnu] elpa/recomplete updated (021ca9b047 -> c4085d13ed), ELPA Syncer, 2023/01/07
- [nongnu] elpa/recomplete 33a4fdfbd5 3/7: Cleanup: sharp-quote function, ELPA Syncer, 2023/01/07
- [nongnu] elpa/recomplete 5dd7c4d008 4/7: Fix recomplete when a complete action doesn't add an undo step,
ELPA Syncer <=
- [nongnu] elpa/recomplete 5aa74e66e6 5/7: Use replace in region function that avoids redundant work, ELPA Syncer, 2023/01/07
- [nongnu] elpa/recomplete c4085d13ed 7/7: Cleanup: function sharp quoting, ELPA Syncer, 2023/01/07
- [nongnu] elpa/recomplete 403c646e97 2/7: Cleanup: tweak doc-string to quiet checkdoc warning, ELPA Syncer, 2023/01/07
- [nongnu] elpa/recomplete 11d7dad04e 6/7: Cleanup: emacs native format, ELPA Syncer, 2023/01/07
- [nongnu] elpa/recomplete 7c47e0e064 1/7: Change URL to codeberg (correct URL), ELPA Syncer, 2023/01/07