unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 74637@debbugs.gnu.org
Subject: bug#74637: [PATCH] Make view-read-only behave like view-file
Date: Tue, 03 Dec 2024 12:06:11 +0200	[thread overview]
Message-ID: <36028.5709075228$1733220462@news.gmane.org> (raw)
In-Reply-To: <86o71t3mob.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 02 Dec 2024 21:33:08 +0200")

[-- Attachment #1: Type: text/plain, Size: 2142 bytes --]

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Björn Bidar <bjorn.bidar@thaodan.de>
>> Cc: 74637@debbugs.gnu.org
>> Date: Mon, 02 Dec 2024 20:08:46 +0200
>> 
>> Eli Zaretskii <eliz@gnu.org> writes:
>> 
>> >> Date: Sun, 01 Dec 2024 22:40:16 +0200
>> >> From:  Björn Bidar via "Bug reports for GNU Emacs,
>> >>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>> >> 
>> >> Make view-mode behave like when called in view-file when entered because
>> >> `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. 
>> >> 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?
>> 
>> 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.
>> 
>> 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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Make-view-read-only-behave-like-view-file.patch --]
[-- Type: text/x-patch, Size: 1957 bytes --]

From 7e9dc995e07ce19022baccd5f54b7e9fecc4cadd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Bidar?= <bjorn.bidar@thaodan.de>
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


  reply	other threads:[~2024-12-03 10:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87ldwzm91r.fsf@>
2024-12-02 12:29 ` bug#74637: [PATCH] Make view-read-only behave like view-file Eli Zaretskii
2024-12-02 18:08   ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
     [not found]   ` <87ttbmj6tt.fsf@>
2024-12-02 19:33     ` Eli Zaretskii
2024-12-03 10:06       ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
     [not found]       ` <87mshdjd2k.fsf@>
2024-12-03 14:01         ` Eli Zaretskii
2024-12-03 14:25           ` Visuwesh
2024-12-03 19:33             ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-03 19:39           ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
     [not found]           ` <874j3kimjv.fsf@>
2024-12-03 19:43             ` Eli Zaretskii
2024-12-01 20:40 Björn Bidar 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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='36028.5709075228$1733220462@news.gmane.org' \
    --to=bug-gnu-emacs@gnu.org \
    --cc=74637@debbugs.gnu.org \
    --cc=bjorn.bidar@thaodan.de \
    --cc=eliz@gnu.org \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).