unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#61652: 28.2; Read-only mode and View mode
@ 2023-02-20  8:41 Bernd Rellermeyer
  2023-02-20 14:42 ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Bernd Rellermeyer @ 2023-02-20  8:41 UTC (permalink / raw)
  To: 61652


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





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

* bug#61652: 28.2; Read-only mode and View mode
  2023-02-20  8:41 bug#61652: 28.2; Read-only mode and View mode Bernd Rellermeyer
@ 2023-02-20 14:42 ` Eli Zaretskii
  2023-02-21 12:46   ` Bernd Rellermeyer
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2023-02-20 14:42 UTC (permalink / raw)
  To: Bernd Rellermeyer; +Cc: 61652

> From: Bernd Rellermeyer <bernd.rellermeyer@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?





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

* bug#61652: 28.2; Read-only mode and View mode
  2023-02-20 14:42 ` Eli Zaretskii
@ 2023-02-21 12:46   ` Bernd Rellermeyer
  2023-02-21 13:08     ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Bernd Rellermeyer @ 2023-02-21 12:46 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 61652

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@gnu.org>:
> 
>> From: Bernd Rellermeyer <bernd.rellermeyer@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?






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

* bug#61652: 28.2; Read-only mode and View mode
  2023-02-21 12:46   ` Bernd Rellermeyer
@ 2023-02-21 13:08     ` Eli Zaretskii
  2023-09-05 23:48       ` Stefan Kangas
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2023-02-21 13:08 UTC (permalink / raw)
  To: Bernd Rellermeyer; +Cc: 61652

> From: Bernd Rellermeyer <bernd.rellermeyer@t-online.de>
> Date: Tue, 21 Feb 2023 13:46:50 +0100
> Cc: 61652@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?





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

* bug#61652: 28.2; Read-only mode and View mode
  2023-02-21 13:08     ` Eli Zaretskii
@ 2023-09-05 23:48       ` Stefan Kangas
  2023-09-06 11:32         ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Kangas @ 2023-09-05 23:48 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Bernd Rellermeyer, 61652

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Bernd Rellermeyer <bernd.rellermeyer@t-online.de>
>> Date: Tue, 21 Feb 2023 13:46:50 +0100
>> Cc: 61652@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.





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

* bug#61652: 28.2; Read-only mode and View mode
  2023-09-05 23:48       ` Stefan Kangas
@ 2023-09-06 11:32         ` Eli Zaretskii
  2023-09-06 12:08           ` Stefan Kangas
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2023-09-06 11:32 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: bernd.rellermeyer, 61652

> From: Stefan Kangas <stefankangas@gmail.com>
> Date: Tue, 5 Sep 2023 16:48:02 -0700
> Cc: Bernd Rellermeyer <bernd.rellermeyer@t-online.de>, 61652@debbugs.gnu.org
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> >> From: Bernd Rellermeyer <bernd.rellermeyer@t-online.de>
> >> Date: Tue, 21 Feb 2023 13:46:50 +0100
> >> Cc: 61652@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.





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

* bug#61652: 28.2; Read-only mode and View mode
  2023-09-06 11:32         ` Eli Zaretskii
@ 2023-09-06 12:08           ` Stefan Kangas
  0 siblings, 0 replies; 7+ messages in thread
From: Stefan Kangas @ 2023-09-06 12:08 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: bernd.rellermeyer, 61652

tags 61652 wontfix notabug
close 61652
thanks

Eli Zaretskii <eliz@gnu.org> writes:

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

Agreed, closing.





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

end of thread, other threads:[~2023-09-06 12:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-20  8:41 bug#61652: 28.2; Read-only mode and View mode Bernd Rellermeyer
2023-02-20 14:42 ` Eli Zaretskii
2023-02-21 12:46   ` Bernd Rellermeyer
2023-02-21 13:08     ` Eli Zaretskii
2023-09-05 23:48       ` Stefan Kangas
2023-09-06 11:32         ` Eli Zaretskii
2023-09-06 12:08           ` Stefan Kangas

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