From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh Newsgroups: gmane.emacs.bugs Subject: bug#64071: 28.2; smerge-diff creates *vc-diff* without setting it up Date: Wed, 28 Jun 2023 08:48:38 -0400 Message-ID: References: <83ttv9tcnh.fsf@gnu.org> <83pm5fvmoi.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18678"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: monnier@iro.umontreal.ca, 64071@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jun 28 15:09:04 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qEUuu-0004h2-89 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 28 Jun 2023 15:09:04 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qEUbY-0005Am-P2; Wed, 28 Jun 2023 08:49:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qEUbX-00058l-3V for bug-gnu-emacs@gnu.org; Wed, 28 Jun 2023 08:49:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qEUbW-00065T-Q4 for bug-gnu-emacs@gnu.org; Wed, 28 Jun 2023 08:49:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qEUbW-00064r-7z for bug-gnu-emacs@gnu.org; Wed, 28 Jun 2023 08:49:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 28 Jun 2023 12:49:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64071 X-GNU-PR-Package: emacs Original-Received: via spool by 64071-submit@debbugs.gnu.org id=B64071.168795652623338 (code B ref 64071); Wed, 28 Jun 2023 12:49:02 +0000 Original-Received: (at 64071) by debbugs.gnu.org; 28 Jun 2023 12:48:46 +0000 Original-Received: from localhost ([127.0.0.1]:50254 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qEUbF-00064M-Ht for submit@debbugs.gnu.org; Wed, 28 Jun 2023 08:48:45 -0400 Original-Received: from mxout5.mail.janestreet.com ([64.215.233.18]:53653) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qEUbD-000645-NS for 64071@debbugs.gnu.org; Wed, 28 Jun 2023 08:48:44 -0400 In-Reply-To: <83pm5fvmoi.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 28 Jun 2023 14:41:33 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:264213 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> From: Spencer Baugh >> Cc: Stefan Monnier , 64071@debbugs.gnu.org >> Date: Tue, 27 Jun 2023 16:17:45 -0400 >> >> Eli Zaretskii 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? --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Make-newly-created-smerge-diff-buffers-read-only.patch >From 4de911b6ed34ee1a728e1c57a65e9314f3785dc4 Mon Sep 17 00:00:00 2001 From: Spencer Baugh 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 --=-=-=--