unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#74637: [PATCH] Make view-read-only behave like view-file
@ 2024-12-01 20:40 Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 12+ messages in thread
From: Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-12-01 20:40 UTC (permalink / raw)
  To: 74637

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

Tags: patch


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.



In GNU Emacs 31.0.50 (build 1, x86_64-suse-linux-gnu, GTK+ Version
3.24.43, cairo version 1.18.2)
Repository revision: eee0ed8442aa78320a3e578ab290df145fb49624
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101014
System Description: openSUSE Tumbleweed

Configured using:
 'configure --disable-build-details --without-pop --with-mailutils
 --without-hesiod --with-gameuser=:games --with-kerberos
 --with-kerberos5 --with-file-notification=inotify --with-modules
 --enable-autodepend --enable-link-time-optimization --prefix=/usr
 --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share
 --localstatedir=/var --sharedstatedir=/var/lib
 --libexecdir=/usr/libexec --with-file-notification=yes
 --libdir=/usr/lib64 --with-native-compilation=aot
 --enable-locallisppath=/usr/share/emacs/31.0.50/site-lisp:/usr/share/emacs/site-lisp
 --with-x --with-xim --with-sound --with-xpm --with-jpeg --with-tiff
 --with-gif --with-png --with-rsvg --with-dbus --with-xft --without-gpm
 --with-tree-sitter --with-x-toolkit=gtk --without-pgtk
 --with-toolkit-scroll-bars --x-includes=/usr/include
 --x-libraries=/usr/lib64 --with-libotf --with-m17n-flt --with-cairo
 --build=x86_64-suse-linux --with-dumping=pdumper
 build_alias=x86_64-suse-linux 'CC=sccache cc' 'CFLAGS=-O2 -Wall
 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong
 -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection
 -Werror=return-type -flto=auto -march=znver3 -mmmx -mpopcnt -msse
 -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -mavx -mavx2 -msse4a -mno-fma4
 -mno-xop -mfma -mbmi -mbmi2 -maes -mpclmul -mno-gfni -mvpclmulqdq
 -mno-3dnow -madx -mabm -mno-cldemote -mclflushopt -mclwb -mclzero
 -mcx16 -mno-enqcmd -mf16c -mfsgsbase -mfxsr -mno-hle -msahf -mno-lwp
 -mlzcnt -mmovbe -mno-movdir64b -mno-movdiri -mmwaitx -mno-pconfig -mpku
 -mprfchw -mno-ptwrite -mrdpid -mrdrnd -mrdseed -mno-rtm -mno-serialize
 -mno-sgx -msha -mshstk -mno-tbm -mno-tsxldtrk -mvaes -mno-waitpkg
 -mwbnoinvd -mxsave -mxsavec -mxsaveopt -mxsaves -mno-amx-tile
 -mno-amx-int8 -mno-amx-bf16 -mno-uintr -mno-hreset -mno-kl -mno-widekl
 -mno-avxvnni -mno-avxifma -mno-avxvnniint8 -mno-avxneconvert
 -mno-cmpccxadd -mno-amx-fp16 -mno-prefetchi -mno-raoint
 -mno-amx-complex --param l1-cache-size=32 --param l1-cache-line-size=64
 --param l2-cache-size=512 -mtune=znver3 -fno-optimize-sibling-calls -O2
 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong
 -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection
 -Werror=return-type -flto=auto -g -D_GNU_SOURCE
 -DGDK_DISABLE_DEPRECATION_WARNINGS -DGLIB_DISABLE_DEPRECATION_WARNINGS
 -pipe -Wno-pointer-sign -Wno-unused-variable -Wno-unused-label
 -DPDMP_BASE='\''"emacs-gtk"'\''' LDFLAGS=-Wl,-O2 'CXX=sccache c++'
 PKG_CONFIG_PATH=:/usr/lib64/pkgconfig:/usr/share/pkgconfig'


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

From d77d0880871061820b1cdf61f1d74f2a7e5224aa 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..422d8a1f537 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', 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


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-12-05  2:15 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [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
     [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-04 13:16           ` Andrea Corallo
2024-12-05  2:15         ` Sean Whitton
2024-12-01 20:40 Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors

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).