bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#21201: 25.0.50; (buffer-modified-p) errors inside cl-letf


From: Noam Postavsky
Subject: bug#21201: 25.0.50; (buffer-modified-p) errors inside cl-letf
Date: Tue, 17 Jul 2018 08:16:09 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

tags 21201 + patch
quit

Nicolas Richard <youngfrog@members.fsf.org> writes:

> Artur Malabarba <bruce.connor.am@gmail.com> writes:
>> 2015-08-06 21:07 GMT+01:00 Nicolas Richard <youngfrog@members.fsf.org>:
>>>  (gv-define-setter buffer-modified-p (flag &optional buf)
>>> -  `(with-current-buffer ,buf
>>> -     (set-buffer-modified-p ,flag)))
>>> +  (if buf
>>> +      `(with-current-buffer ,buf
>>> +         (set-buffer-modified-p ,flag))
>>> +    `(set-buffer-modified-p ,flag)))
>>
>> Don't know if it's possible, but shouldn't it try to ensure that it's
>> in the same buffer as before?
>
> I agree with you, but I don't know how to do that.

This seems to work.

>From 1481f8893ff04a83b578f403cd22c7bdd2ec65f0 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Mon, 16 Jul 2018 22:14:32 -0400
Subject: [PATCH] Allow setf of buffer-modified-p without argument (Bug#21201)

* lisp/emacs-lisp/cl-lib.el (setf buffer-modified-p): Take current
buffer if optional argument BUF is not passed.
---
 lisp/emacs-lisp/cl-lib.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/emacs-lisp/cl-lib.el b/lisp/emacs-lisp/cl-lib.el
index 381784d1fd..ba5f9d64a1 100644
--- a/lisp/emacs-lisp/cl-lib.el
+++ b/lisp/emacs-lisp/cl-lib.el
@@ -521,8 +521,9 @@ cl-pairlis
 ;; Some more Emacs-related place types.
 (gv-define-simple-setter buffer-file-name set-visited-file-name t)
 (gv-define-setter buffer-modified-p (flag &optional buf)
-  `(with-current-buffer ,buf
-     (set-buffer-modified-p ,flag)))
+  (macroexp-let2 nil buffer `(or ,buf (current-buffer))
+    `(with-current-buffer ,buffer
+       (set-buffer-modified-p ,flag))))
 (gv-define-simple-setter buffer-name rename-buffer t)
 (gv-define-setter buffer-string (store)
   `(insert (prog1 ,store (erase-buffer))))
-- 
2.11.0


reply via email to

[Prev in Thread] Current Thread [Next in Thread]