From: Spencer Baugh <sbaugh@janestreet.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: monnier@iro.umontreal.ca, 64071@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 [thread overview]
Message-ID: <ierv8f7ycpl.fsf@janestreet.com> (raw)
In-Reply-To: <83pm5fvmoi.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 28 Jun 2023 14:41:33 +0300")
[-- Attachment #1: Type: text/plain, Size: 850 bytes --]
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Spencer Baugh <sbaugh@janestreet.com>
>> Cc: Stefan Monnier <monnier@iro.umontreal.ca>, 64071@debbugs.gnu.org
>> Date: Tue, 27 Jun 2023 16:17:45 -0400
>>
>> Eli Zaretskii <eliz@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?
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Make-newly-created-smerge-diff-buffers-read-only.patch --]
[-- Type: text/x-patch, Size: 1374 bytes --]
From 4de911b6ed34ee1a728e1c57a65e9314f3785dc4 Mon Sep 17 00:00:00 2001
From: Spencer Baugh <sbaugh@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
next prev parent reply other threads:[~2023-06-28 12:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-14 21:41 bug#64071: 28.2; smerge-diff creates *vc-diff* without setting it up Spencer Baugh
2023-06-15 7:20 ` Eli Zaretskii
2023-06-27 20:17 ` Spencer Baugh
2023-06-28 11:41 ` Eli Zaretskii
2023-06-28 12:48 ` Spencer Baugh [this message]
2023-06-28 12:58 ` Eli Zaretskii
2023-08-19 12:32 ` sbaugh
2023-08-19 12:48 ` Eli Zaretskii
2023-10-04 14:05 ` Spencer Baugh
2023-10-05 8:06 ` Eli Zaretskii
2023-06-15 15:09 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ierv8f7ycpl.fsf@janestreet.com \
--to=sbaugh@janestreet.com \
--cc=64071@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=monnier@iro.umontreal.ca \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.