[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master b5db5a6443: with-buffer-unmodified-if-unchanged: Tweak the implem
From: |
Stefan Monnier |
Subject: |
master b5db5a6443: with-buffer-unmodified-if-unchanged: Tweak the implementation |
Date: |
Tue, 3 May 2022 15:35:58 -0400 (EDT) |
branch: master
commit b5db5a64435b86de6e5277d1d173c57784783e5e
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
with-buffer-unmodified-if-unchanged: Tweak the implementation
* lisp/emacs-lisp/subr-x.el (with-buffer-unmodified-if-unchanged):
Skip the hash if the buffer was not modified at all.
Use `restore-buffer-modified-p`.
Also mention that it's imperative that the current buffer is preserved.
---
lisp/emacs-lisp/subr-x.el | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el
index afa0423d90..8e763b613e 100644
--- a/lisp/emacs-lisp/subr-x.el
+++ b/lisp/emacs-lisp/subr-x.el
@@ -426,7 +426,9 @@ modification status:
(with-buffer-unmodified-if-unchanged
(insert \"a\")
- (delete-char -1))"
+ (delete-char -1))
+
+BODY must preserve the current buffer."
(declare (debug t) (indent 0))
(let ((hash (gensym)))
`(let ((,hash (and (not (buffer-modified-p))
@@ -437,9 +439,9 @@ modification status:
;; If we didn't change anything in the buffer (and the buffer
;; was previously unmodified), then flip the modification status
;; back to "unchanged".
- (when (and ,hash
+ (when (and ,hash (buffer-modified-p)
(equal ,hash (buffer-hash)))
- (set-buffer-modified-p nil))))))
+ (restore-buffer-modified-p nil))))))
(provide 'subr-x)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master b5db5a6443: with-buffer-unmodified-if-unchanged: Tweak the implementation,
Stefan Monnier <=