GNU bug report logs - #64071
28.2; smerge-diff creates *vc-diff* without setting it up

Previous Next

Package: emacs;

Reported by: Spencer Baugh <sbaugh <at> janestreet.com>

Date: Wed, 14 Jun 2023 21:42:01 UTC

Severity: normal

Found in version 28.2

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Spencer Baugh <sbaugh <at> janestreet.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: monnier <at> iro.umontreal.ca, 64071 <at> debbugs.gnu.org
Subject: bug#64071: 28.2; smerge-diff creates *vc-diff* without setting it up
Date: Wed, 28 Jun 2023 08:48:38 -0400
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Spencer Baugh <sbaugh <at> janestreet.com>
>> Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>,  64071 <at> debbugs.gnu.org
>> Date: Tue, 27 Jun 2023 16:17:45 -0400
>> 
>> Eli Zaretskii <eliz <at> gnu.org> writes:
>> 
>> > That command enters diff-mode, and diff-mode doesn't force read-only
>> > status on the current buffer.  Why should Smerge force that?
>> 
>> Buffer named "*vc-diff*" are universally read-only, except if they are
>> created through this path.
>
> But users can legitimately make a *vc-diff* buffer modifiable, no?
> And your patch silently makes it read-only again, behind the user's
> back.  That's hardly nice, is it?
>
>> Stefan likes my simple patch, so what's wrong with it?
>
> See above: we shouldn't change the read-only attribute that was set by
> the user.

Good point.  How about this?

[0001-Make-newly-created-smerge-diff-buffers-read-only.patch (text/x-patch, inline)]
From 4de911b6ed34ee1a728e1c57a65e9314f3785dc4 Mon Sep 17 00:00:00 2001
From: Spencer Baugh <sbaugh <at> janestreet.com>
Date: Wed, 28 Jun 2023 08:48:01 -0400
Subject: [PATCH] Make newly-created smerge-diff-buffers read-only

Buffers name *vc-diff* are usually created by vc, which makes them
read-only.  If we create such a buffer, let's make it read-only too.
If the buffer already exists, though, don't change that since the user
might have deliberately made it writable.

* lisp/vc/smerge-mode.el (smerge-diff): Make newly-created
smerge-diff-buffers read-only. (bug#64071)
---
 lisp/vc/smerge-mode.el | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lisp/vc/smerge-mode.el b/lisp/vc/smerge-mode.el
index c39a9cc2f22..524a042fb55 100644
--- a/lisp/vc/smerge-mode.el
+++ b/lisp/vc/smerge-mode.el
@@ -1243,7 +1243,11 @@ smerge-diff
     (write-region beg1 end1 file1 nil 'nomessage)
     (write-region beg2 end2 file2 nil 'nomessage)
     (unwind-protect
-	(with-current-buffer (get-buffer-create smerge-diff-buffer-name)
+	(save-current-buffer
+          (if-let (buffer (get-buffer smerge-diff-buffer-name))
+              (set-buffer buffer)
+            (set-buffer (get-buffer-create smerge-diff-buffer-name))
+            (setq buffer-read-only t))
 	  (setq default-directory dir)
 	  (let ((inhibit-read-only t))
 	    (erase-buffer)
-- 
2.39.3


This bug report was last modified 1 year and 285 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.