GNU bug report logs - #61652
28.2; Read-only mode and View mode

Previous Next

Package: emacs;

Reported by: Bernd Rellermeyer <bernd.rellermeyer <at> t-online.de>

Date: Mon, 20 Feb 2023 14:09:02 UTC

Severity: normal

Tags: notabug, wontfix

Found in version 28.2

Done: Stefan Kangas <stefankangas <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 61652 in the body.
You can then email your comments to 61652 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#61652; Package emacs. (Mon, 20 Feb 2023 14:09:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Bernd Rellermeyer <bernd.rellermeyer <at> t-online.de>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 20 Feb 2023 14:09:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Bernd Rellermeyer <bernd.rellermeyer <at> t-online.de>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.2; Read-only mode and View mode
Date: Mon, 20 Feb 2023 09:41:33 +0100
I have the following scenario:

1. View a buffer in View mode.
2. Turn off Read-Only mode, e.g. by pressing `C-x C-q`.
3. Turn on Read-Only mode and View mode again, eg. by pressing `C-x
C-q`-
4. Exit View mode by `View-exit`, e.g. by pressing `e`.

Now the buffer is in Read-Only mode. In my opinion it should be
writable. The reason is the variable `view-old-buffer-read-only`, which
is set on entering View mode (`view--enable`) to the (old) value of
`buffer-read-only`. But in my scenario, the value of `buffer-read-only`
is already the new one, as set in `read-only-mode`.

I think the solution is to reset `read-only-mode` to nil in the specific
branch of `read-only-mode` and depend on the fact that it is set to t in
`view--enable`:

```
  (cond
   ((and (not buffer-read-only) view-mode)
    (View-exit-and-edit)
    (setq-local view-read-only t))		; Must leave view mode.
   ((and buffer-read-only view-read-only
         ;; If view-mode is already active, `view-mode-enter' is a nop.
         (not view-mode)
         (not (eq (get major-mode 'mode-class) 'special)))
    (setq buffer-read-only nil)
    (view-mode-enter))))
```


In GNU Emacs 28.2 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G95))
 of 2022-09-12 built on builder10-14.lan
Windowing system distributor 'Apple', version 10.3.2299
System Description:  macOS 13.2.1

Configured using:
 'configure --with-ns '--enable-locallisppath=/Library/Application
 Support/Emacs/${version}/site-lisp:/Library/Application
 Support/Emacs/site-lisp' --with-modules'

Configured features:
ACL GMP GNUTLS JSON LIBXML2 MODULES NOTIFY KQUEUE NS PDUMPER THREADS
TOOLKIT_SCROLL_BARS ZLIB

Important settings:
  value of $LANG: de_DE.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Help

Minor modes in effect:
  which-function-mode: t
  delete-selection-mode: t
  cua-mode: t
  global-auto-revert-mode: t
  global-display-glyphs-mode: t
  override-global-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
/Users/bernd/.config/emacs/elpa/magit-3.3.0/magit-section-pkg hides /Users/bernd/.config/emacs/elpa/magit-section-3.3.0/magit-section-pkg
/Users/bernd/.config/emacs/elpa/transient-0.3.7/transient hides /Applications/Emacs.app/Contents/Resources/lisp/transient
/Users/bernd/.config/emacs/elpa/xref-1.6.1/xref hides /Applications/Emacs.app/Contents/Resources/lisp/progmodes/xref
/Users/bernd/.config/emacs/elpa/project-0.9.8/project hides /Applications/Emacs.app/Contents/Resources/lisp/progmodes/project

Features:
(shadow sort mail-extr emacsbug calc-alg calc-ext calc-menu calc
calc-loaddefs rect calc-macs pandoc-mode pandoc-mode-utils hydra lv
markdown-mode edit-indirect transient magit-utils dash org-colview
org-clock disp-table zetteltags-global zetteltags pcre2el rxt pcase
re-builder crm adaptive-wrap text-face face-remap org-element avl-tree
generator ol-eww eww xdg url-queue mm-url ol-rmail ol-mhe ol-irc ol-info
ol-gnus nnselect gnus-search gnus-art mm-uu mml2015 mm-view mml-smime
smime dig gnus-sum shr kinsoku svg dom gnus-group gnus-undo gnus-start
gnus-dbus dbus xml gnus-cloud nnimap nnmail mail-source utf7 netrc nnoo
parse-time gnus-spec gnus-int gnus-range message rmc puny rfc822 mml
mml-sec epa derived epg rfc6068 epg-config mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader gnus-win ol-docview
doc-view image-mode exif ol-bibtex ol-bbdb ol-w3m ol-doi org-link-doi
org-agenda org-refile reftxt reftex-cite reftex reftex-loaddefs
reftex-vars org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro
org-footnote org-src ob-comint org-pcomplete pcomplete comint ansi-color
org-list org-faces org-entities noutline outline org-version
ob-emacs-lisp ob-core ob-eval org-table oc-basic bibtex iso8601 org-keys
oc org-loaddefs ol rx org-compat advice org-macs format-spec cal-menu
calendar cal-loaddefs eieio-opt speedbar ezimage dframe shortdoc undo-fu
debug dabbrev misearch multi-isearch pulse thai-util thai-word help-fns
radix-tree cl-print edebug backtrace find-func dired-aux dired-x dired
dired-loaddefs add-log which-func imenu delsel cua-base quail autorevert
filenotify view-x hi-lock scroll-lock view god-mode cl-extra help-mode
ns-plist jka-compr display-glyphs unfill color modus-vivendi-theme
modus-operandi-theme modus-themes launch my-skeletons skeleton xref
project bind-key easy-mmode zetteldeft ace-window thingatpt avy ring
deft gnus nnheader gnus-util rmail rmail-loaddefs text-property-search
time-date sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr
mail-utils cus-edit pp cus-load wid-edit edmacro kmacro tex-site info
package browse-url url url-proxy url-privacy url-expand url-methods
url-history url-cookie url-domsuf url-util mailcap url-handlers
url-parse auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs
password-cache json subr-x map url-vars seq byte-opt gv bytecomp
byte-compile cconv cl-loaddefs cl-lib iso-transl tooltip eldoc paren
electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
term/ns-win ns-win ucs-normalize mule-util term/common-win tool-bar dnd
fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow
isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax
font-core term/tty-colors frame minibuffer cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice button loaddefs faces cus-face macroexp files
window text-properties overlay sha1 md5 base64 format env code-pages
mule custom widget hashtable-print-readable backquote threads kqueue
cocoa ns multi-tty make-network-process emacs)

Memory information:
((conses 16 605640 36594)
 (symbols 48 36818 4)
 (strings 32 124518 7449)
 (string-bytes 1 4182471)
 (vectors 16 67356)
 (vector-slots 8 1431598 28878)
 (floats 8 501 324)
 (intervals 56 10795 698)
 (buffers 992 32))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#61652; Package emacs. (Mon, 20 Feb 2023 14:43:02 GMT) Full text and rfc822 format available.

Message #8 received at 61652 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Bernd Rellermeyer <bernd.rellermeyer <at> t-online.de>
Cc: 61652 <at> debbugs.gnu.org
Subject: Re: bug#61652: 28.2; Read-only mode and View mode
Date: Mon, 20 Feb 2023 16:42:25 +0200
> From: Bernd Rellermeyer <bernd.rellermeyer <at> t-online.de>
> Date: Mon, 20 Feb 2023 09:41:33 +0100
> 
> 
> I have the following scenario:
> 
> 1. View a buffer in View mode.
> 2. Turn off Read-Only mode, e.g. by pressing `C-x C-q`.
> 3. Turn on Read-Only mode and View mode again, eg. by pressing `C-x
> C-q`-
> 4. Exit View mode by `View-exit`, e.g. by pressing `e`.
> 
> Now the buffer is in Read-Only mode. In my opinion it should be
> writable. The reason is the variable `view-old-buffer-read-only`, which
> is set on entering View mode (`view--enable`) to the (old) value of
> `buffer-read-only`. But in my scenario, the value of `buffer-read-only`
> is already the new one, as set in `read-only-mode`.

If the buffer is already read-only when you enter View mode, why
should we reset read-only when exiting View mode?  We are trying to
leave the buffer as we found it, which in this case is read-only.

Or what am I missing?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#61652; Package emacs. (Tue, 21 Feb 2023 13:09:02 GMT) Full text and rfc822 format available.

Message #11 received at 61652 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Bernd Rellermeyer <bernd.rellermeyer <at> t-online.de>
Cc: 61652 <at> debbugs.gnu.org
Subject: Re: bug#61652: 28.2; Read-only mode and View mode
Date: Tue, 21 Feb 2023 15:08:49 +0200
> From: Bernd Rellermeyer <bernd.rellermeyer <at> t-online.de>
> Date: Tue, 21 Feb 2023 13:46:50 +0100
> Cc: 61652 <at> debbugs.gnu.org
> 
> In step 3, View mode is entered implicitly, because `view-read-only` is non-nil. From the user perspective it is only one command. I.e. the user just turns off and on Read-only mode. That means the user enters View mode vie Read-Only mode from a writable buffer. I think this should not alter the behavior of `View-exit` and after calling `View-exit` he should be in a writable buffer. Or am I wrong?

I'm not sure I agree with your interpretation.

Does anyone else have an opinion?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#61652; Package emacs. (Tue, 21 Feb 2023 13:38:02 GMT) Full text and rfc822 format available.

Message #14 received at 61652 <at> debbugs.gnu.org (full text, mbox):

From: Bernd Rellermeyer <bernd.rellermeyer <at> t-online.de>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 61652 <at> debbugs.gnu.org
Subject: Re: bug#61652: 28.2; Read-only mode and View mode
Date: Tue, 21 Feb 2023 13:46:50 +0100
In step 3, View mode is entered implicitly, because `view-read-only` is non-nil. From the user perspective it is only one command. I.e. the user just turns off and on Read-only mode. That means the user enters View mode vie Read-Only mode from a writable buffer. I think this should not alter the behavior of `View-exit` and after calling `View-exit` he should be in a writable buffer. Or am I wrong?

> Am 20.02.2023 um 15:42 schrieb Eli Zaretskii <eliz <at> gnu.org>:
> 
>> From: Bernd Rellermeyer <bernd.rellermeyer <at> t-online.de>
>> Date: Mon, 20 Feb 2023 09:41:33 +0100
>> 
>> 
>> I have the following scenario:
>> 
>> 1. View a buffer in View mode.
>> 2. Turn off Read-Only mode, e.g. by pressing `C-x C-q`.
>> 3. Turn on Read-Only mode and View mode again, eg. by pressing `C-x
>> C-q`-
>> 4. Exit View mode by `View-exit`, e.g. by pressing `e`.
>> 
>> Now the buffer is in Read-Only mode. In my opinion it should be
>> writable. The reason is the variable `view-old-buffer-read-only`, which
>> is set on entering View mode (`view--enable`) to the (old) value of
>> `buffer-read-only`. But in my scenario, the value of `buffer-read-only`
>> is already the new one, as set in `read-only-mode`.
> 
> If the buffer is already read-only when you enter View mode, why
> should we reset read-only when exiting View mode?  We are trying to
> leave the buffer as we found it, which in this case is read-only.
> 
> Or what am I missing?





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#61652; Package emacs. (Tue, 05 Sep 2023 23:49:02 GMT) Full text and rfc822 format available.

Message #17 received at 61652 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Bernd Rellermeyer <bernd.rellermeyer <at> t-online.de>, 61652 <at> debbugs.gnu.org
Subject: Re: bug#61652: 28.2; Read-only mode and View mode
Date: Tue, 5 Sep 2023 16:48:02 -0700
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Bernd Rellermeyer <bernd.rellermeyer <at> t-online.de>
>> Date: Tue, 21 Feb 2023 13:46:50 +0100
>> Cc: 61652 <at> debbugs.gnu.org
>>
>> In step 3, View mode is entered implicitly, because `view-read-only` is
>> non-nil. From the user perspective it is only one command. I.e. the user just
>> turns off and on Read-only mode. That means the user enters View mode vie
>> Read-Only mode from a writable buffer. I think this should not alter the
>> behavior of `View-exit` and after calling `View-exit` he should be in a
>> writable buffer. Or am I wrong?
>
> I'm not sure I agree with your interpretation.
>
> Does anyone else have an opinion?

I don't think I agree either.  Once the user starts changing
read-only-mode, I think disabling it when leaving view-mode would be
surprising.

In any case, leaving it as read-only is only a minor annoyance.
Changing it to read-write means the user can suddenly start doing
destructive things in a situation where that might be unexpected.

So I'm not sure we should do anything at all here.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#61652; Package emacs. (Wed, 06 Sep 2023 11:33:01 GMT) Full text and rfc822 format available.

Message #20 received at 61652 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: bernd.rellermeyer <at> t-online.de, 61652 <at> debbugs.gnu.org
Subject: Re: bug#61652: 28.2; Read-only mode and View mode
Date: Wed, 06 Sep 2023 14:32:18 +0300
> From: Stefan Kangas <stefankangas <at> gmail.com>
> Date: Tue, 5 Sep 2023 16:48:02 -0700
> Cc: Bernd Rellermeyer <bernd.rellermeyer <at> t-online.de>, 61652 <at> debbugs.gnu.org
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> >> From: Bernd Rellermeyer <bernd.rellermeyer <at> t-online.de>
> >> Date: Tue, 21 Feb 2023 13:46:50 +0100
> >> Cc: 61652 <at> debbugs.gnu.org
> >>
> >> In step 3, View mode is entered implicitly, because `view-read-only` is
> >> non-nil. From the user perspective it is only one command. I.e. the user just
> >> turns off and on Read-only mode. That means the user enters View mode vie
> >> Read-Only mode from a writable buffer. I think this should not alter the
> >> behavior of `View-exit` and after calling `View-exit` he should be in a
> >> writable buffer. Or am I wrong?
> >
> > I'm not sure I agree with your interpretation.
> >
> > Does anyone else have an opinion?
> 
> I don't think I agree either.  Once the user starts changing
> read-only-mode, I think disabling it when leaving view-mode would be
> surprising.
> 
> In any case, leaving it as read-only is only a minor annoyance.
> Changing it to read-write means the user can suddenly start doing
> destructive things in a situation where that might be unexpected.
> 
> So I'm not sure we should do anything at all here.

Since no one has chimed in during all this time, I think we should
leave this alone.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#61652; Package emacs. (Wed, 06 Sep 2023 12:09:01 GMT) Full text and rfc822 format available.

Message #23 received at 61652 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: bernd.rellermeyer <at> t-online.de, 61652 <at> debbugs.gnu.org
Subject: Re: bug#61652: 28.2; Read-only mode and View mode
Date: Wed, 6 Sep 2023 05:08:22 -0700
tags 61652 wontfix notabug
close 61652
thanks

Eli Zaretskii <eliz <at> gnu.org> writes:

> Since no one has chimed in during all this time, I think we should
> leave this alone.

Agreed, closing.




Added tag(s) wontfix and notabug. Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Wed, 06 Sep 2023 12:09:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 61652 <at> debbugs.gnu.org and Bernd Rellermeyer <bernd.rellermeyer <at> t-online.de> Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Wed, 06 Sep 2023 12:09:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 05 Oct 2023 11:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 196 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.