From: Juri Linkov <juri@linkov.net>
To: Yuan Fu <casouri@gmail.com>
Cc: Stefan Monnier <monnier@iro.umontreal.ca>,
Emacs developers <emacs-devel@gnu.org>
Subject: Re: Duplicated outline-cycle binding, and problems with the new one
Date: Mon, 10 Jan 2022 10:21:39 +0200 [thread overview]
Message-ID: <86pmp0ovak.fsf@mail.linkov.net> (raw)
In-Reply-To: <BAAF0597-D670-4E82-913F-50669E8D3E2C@gmail.com> (Yuan Fu's message of "Sun, 9 Jan 2022 14:55:45 -0800")
>>> Maybe we should use a hook on `read-only-mode` to set/unset
>>> a `diff-mode-read-only` variable so we can add the keymap
>>> (conditionalized on this new `diff-mode-read-only`) to
>>> `minor-mode-map-alist` instead of `minor-mode-overriding-map-alist`.
>>
>> So this is because `minor-mode-map-alist` is not buffer-local.
>> Then this requires changing `(setq buffer-read-only t)` to
>> `(read-only-mode 1)` in diff-related places. Since `read-only-mode`
>> always activates `view-mode` when `view-read-only` is t,
>> it needs let-binding: (let ((view-read-only nil)) (read-only-mode 1)).
>> This will keep the current behavior. Then special-handling of
>> `view-mode` in `diff-mode` is not needed because `view-mode`
>> is higher than `diff-mode-read-only` in `minor-mode-map-alist`,
>> where `diff-mode-read-only` is at the end to not take precedence
>> over `outline-minor-mode`.
>
> Once again, LGTM :-)
Testing shows that it requires more changes in other modes,
e.g. a change is needed in diff.el to make read-only
only after calling diff-mode that adds read-only-mode-hook:
diff --git a/lisp/vc/diff.el b/lisp/vc/diff.el
index 4abcf6c15a..a8423237cf 100644
--- a/lisp/vc/diff.el
+++ b/lisp/vc/diff.el
@@ -182,12 +182,12 @@ diff-no-select
" "))
(thisdir default-directory))
(with-current-buffer buf
- (setq buffer-read-only t)
(buffer-disable-undo (current-buffer))
(let ((inhibit-read-only t))
(erase-buffer))
(buffer-enable-undo (current-buffer))
(diff-mode)
+ (let ((view-read-only nil)) (read-only-mode 1))
(setq-local revert-buffer-function
(lambda (_ignore-auto _noconfirm)
(diff-no-select old new switches no-async (current-buffer))))
next prev parent reply other threads:[~2022-01-10 8:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-31 23:32 Duplicated outline-cycle binding, and problems with the new one Yuan Fu
2022-01-02 18:25 ` Juri Linkov
2022-01-02 19:07 ` Stefan Monnier
2022-01-02 19:18 ` Juri Linkov
2022-01-04 1:40 ` Yuan Fu
2022-01-05 18:35 ` Juri Linkov
2022-01-05 19:21 ` Stefan Monnier
2022-01-06 18:56 ` Juri Linkov
2022-01-09 22:55 ` Yuan Fu
2022-01-10 8:21 ` Juri Linkov [this message]
2022-01-10 18:30 ` Juri Linkov
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=86pmp0ovak.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=casouri@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/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).