From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Bj=C3=B6rn?= Bidar via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#74637: [PATCH] Make view-read-only behave like view-file Date: Tue, 03 Dec 2024 12:06:11 +0200 Message-ID: <36028.5709075228$1733220462@news.gmane.org> References: <86ldwy46al.fsf@gnu.org> <86o71t3mob.fsf@gnu.org> Reply-To: =?UTF-8?Q?Bj=C3=B6rn?= Bidar 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="9513"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 74637@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 03 11:07:34 2024 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 1tIPob-0002KS-AR for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 03 Dec 2024 11:07:33 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIPo8-00027J-KT; Tue, 03 Dec 2024 05:07:04 -0500 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 1tIPo6-00026r-G7 for bug-gnu-emacs@gnu.org; Tue, 03 Dec 2024 05:07:02 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tIPo6-0007rG-7T for bug-gnu-emacs@gnu.org; Tue, 03 Dec 2024 05:07:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=yMgOe9iHIPdHXzq/cUdDVr/LDoVnix29Sgupx4Mh/As=; b=P1hWgFXn8iOH8uz/xkRlWdwiurAEhi0TIHs+Qbm1Ke/aU3HRVa7sXfzC6F7P9ia8T4hx/eO16+S3lY7r7glMqUtBRIcKG/ayu47utWV5swOM4qAQZ3/CQeX6FS/9dKO51rzqy5MstLwkNxvlzgYYvzjLwMISR9GOZmRqx9duLrcxnbFZ6lHf+a7xlzIUxp/CEw1RGh5jReC9r4xBt+QnJkzS2mHIARN1Z/+IdAtw12oSwF6QT2irJQ6vyP+5VYIiOzPWth/ThGIyuyJdqVNeSN8qUcfDVzMoF9F9lZLZXfW6Vq5C3EoedIQMx8nzwnEn1373ATCZbDWbAzrLnyYclg==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tIPo5-00050U-Qz for bug-gnu-emacs@gnu.org; Tue, 03 Dec 2024 05:07:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Bj=C3=B6rn?= Bidar Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 03 Dec 2024 10:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74637 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 74637-submit@debbugs.gnu.org id=B74637.173322040619217 (code B ref 74637); Tue, 03 Dec 2024 10:07:01 +0000 Original-Received: (at 74637) by debbugs.gnu.org; 3 Dec 2024 10:06:46 +0000 Original-Received: from localhost ([127.0.0.1]:58355 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tIPnp-0004zt-Cu for submit@debbugs.gnu.org; Tue, 03 Dec 2024 05:06:45 -0500 Original-Received: from thaodan.de ([185.216.177.71]:39968) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tIPnn-0004zf-SS for 74637@debbugs.gnu.org; Tue, 03 Dec 2024 05:06:44 -0500 Original-Received: from odin (dsl-trebng12-50dc7b-49.dhcp.inet.fi [80.220.123.49]) by thaodan.de (Postfix) with ESMTPSA id C54E7D0002E; Tue, 3 Dec 2024 12:06:12 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=thaodan.de; s=mail; t=1733220373; bh=jHH9W4vpwyiQuvJNMluPk4ca6cFnkHqTCvoejw9DHPE=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=bhYUTIJXvmXzrtDwssycQ4lRQ5Snbs0psbtGmR+9PO2TCVrrCw3yR5M9uFvY1+Lqi riKr155YA3qIB1uqdtOKwQ7pKSWcBl9wK3l/eR8C2Qigto2oNpDhODDcmXuXbACIVG p+axCRaGgp44Xj68I4uHt3x+7R/6tFZtZfrnF5piesmN3Gx2M+t/R8SBx41K5ZIkFH m2EqDfupV9lPGFmmBAiFjhVLwIUbBeawxOPf25psCEEk4EkO3YR6Us9pAr95qZhJXE 7l92qwdY0I9IaDjDTXgfNumWmvsz7+9R8hdVg1x6xVDkkjJTEf68U/bhiZisQlrz7n GwkyT9aOoRKxpHdi93Y7iYAmG8qBghniTQytqcPdOEdsOn7K20OINHNfQPRL27G0Vy ppQQ9CiLBPwj+3lyzYxjNHHEQsrgux+L4+7QmLC+riTVrOjCeT3+heehqKtzNBFiSq edb54NZKI+2wBagjJSXL3fnqn+FY2/8flKWlVIMHUEsUFBwbhGA2lD64yKOBdUktkC S7XuCg2m2Yn1wQsl8tqPy72JIfuyq+2RqCJIA4Vr/znlmQoCgOkHVb0qxpx+kc/l1l RLHSA2MKbKkNjyQ3ui5ygPECFT3XYIqlBA6By/JNNQ1tiF4asuzRck69bbUH6fYf1m naaM6LEVVra78s47aZaKHR5g= In-Reply-To: <86o71t3mob.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 02 Dec 2024 21:33:08 +0200") Autocrypt: addr=bjorn.bidar@thaodan.de; prefer-encrypt=nopreference; keydata= mDMEZNfpPhYJKwYBBAHaRw8BAQdACBEmr+0xwIIHZfIDlZmm7sa+lHHSb0g9FZrN6qE6ru60JUJq w7ZybiBCaWRhciA8Ympvcm4uYmlkYXJAdGhhb2Rhbi5kZT6IlgQTFgoAPgIbAwULCQgHAgIiAgYV CgkICwIEFgIDAQIeBwIXgBYhBFHxdut1RzAepymoq1wbdKFlHF9oBQJk1/YmAhkBAAoJEFwbdKFl HF9oB9cBAJoIIGQKXm4cpap+Flxc/EGnYl0123lcEyzuduqvlDT0AQC3OlFKm/OiqJ8IMTrzJRZ8 phFssTkSrrFXnM2jm5PYDoiTBBMWCgA7FiEEUfF263VHMB6nKairXBt0oWUcX2gFAmTX6T4CGwMF CwkIBwICIgIGFQoJCAsCBBYCAwECHgcCF4AACgkQXBt0oWUcX2hbCQEAtru7kvM8hi8zo6z9ux2h K+B5xViKuo7Z8K3IXuK5ugwA+wUfKzomzdBPhfxDsqLcEziGRxoyx0Q3ld9aermBUccHtBxCasO2 cm4gQmlkYXIgPG1lQHRoYW9kYW4uZGU+iJMEExYKADsCGwMFCwkIBwICIgIGFQoJCAsCBBYCAwEC HgcCF4AWIQRR8XbrdUcwHqcpqKtcG3ShZRxfaAUCZNf2FQAKCRBcG3ShZRxfaCzSAP4hZ7cSp0YN XYpcjHdsySh2MuBhhoPeLGXs+2kSiqBiOwD/TP8AgPEg/R+SI9GI9on7fBJJ0mp2IT8kZ2rhDOjg gA6IkwQTFgoAOxYhBFHxdut1RzAepymoq1wbdKFlH 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:296361 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Eli Zaretskii writes: >> From: Bj=C3=B6rn Bidar >> Cc: 74637@debbugs.gnu.org >> Date: Mon, 02 Dec 2024 20:08:46 +0200 >>=20 >> Eli Zaretskii writes: >>=20 >> >> Date: Sun, 01 Dec 2024 22:40:16 +0200 >> >> From: Bj=C3=B6rn Bidar via "Bug reports for GNU Emacs, >> >> the Swiss army knife of text editors" >> >>=20 >> >> Make view-mode behave like when called in view-file when entered beca= use >> >> `view-read-only' is true on a file which is not writable. >> >> The change makes the view-read-only behave better on files which are >> >> not writable.=20 >> >> Now it makes Emacs behave more like less on these files. >> > >> > That's an incompatible behavior change. Is that justified? How can >> > we be sure that everyone agrees with your interpretation of this mode? >>=20 >> All other view-file like modes behave like this, you view the file and >> leave the file with q. > > That doesn't change the fact that view-mode didn't behave like that, > until now. View-mode isn't change outside of the specific situation of opening a file which isn't writable. I worded it wrong in the doc string. Please check the updated docstring or different wording. >> But even going with that point: You open a file file which isn't >> writable. Once you hit q the window is quit and the buffer is buried. >> What do you do now next time you visit that file? >> The buffer was buried, view-mode isn't active anymore, you would have >> to activate view-mode again to go where you left off. >>=20 >> If you would want to edit the file the you visited this way you would >> have not pressed q but e to exit view mode and the proceeded to exit >> read-only-mode and edit the file. > > What about entering view-mode by typing "C-x C-q" in a buffer whose > file is writable? Why should we kill the buffer when the user turns > off view-mode in that file's buffer? The change doesn't affect those situations. If you exit view-mode this way after having it activated through "C-x C-q" you would exit view-mode burry the buffer but not kill it. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Make-view-read-only-behave-like-view-file.patch >From 7e9dc995e07ce19022baccd5f54b7e9fecc4cadd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Bidar?= Date: Sun, 1 Dec 2024 22:22:24 +0200 Subject: [PATCH] Make view-read-only behave like view-file Make view-mode also behave like less when entered through the view-read-only option similarly as done in in '1997-06-14 "Make view mode more similar to `less'' (ab7782fc244). * lisp/files.el (after-find-file): When opening a file which is read only and `view-read-only' is true leave view-mode with `kill-buffer-if-not-modified'. * lisp/view.el (view-mode): Document new behavior. --- lisp/files.el | 2 +- lisp/view.el | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/files.el b/lisp/files.el index a65bc4a4ea2..2f062b45daf 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -2874,7 +2874,7 @@ after-find-file (when (and buffer-read-only view-read-only (not (eq (get major-mode 'mode-class) 'special))) - (view-mode-enter)) + (view-mode-enter nil 'kill-buffer-if-not-modified)) (run-hooks 'find-file-hook))) (define-obsolete-function-alias 'report-errors 'with-demoted-errors "25.1") diff --git a/lisp/view.el b/lisp/view.el index 2ac7479739f..e2d77a53695 100644 --- a/lisp/view.el +++ b/lisp/view.el @@ -416,7 +416,7 @@ view-mode The effect of \\[View-leave], \\[View-quit] and \\[View-kill-and-leave] depends on how view-mode was entered. If it was entered by view-file, view-file-other-window, view-file-other-frame, or \\[dired-view-file] \(\\[view-file], \\[view-file-other-window], -\\[view-file-other-frame], or the Dired mode v command), +\\[view-file-other-frame], `view-read-only' on a read-only file, or the Dired mode v command), then \\[View-quit] will try to kill the current buffer. If view-mode was entered from another buffer, by \\[view-buffer], \\[view-buffer-other-window], \\[view-buffer-other frame], \\[view-file], -- 2.45.2 --=-=-=--