emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Duplicated outline-cycle binding, and problems with the new one


From: Juri Linkov
Subject: Re: Duplicated outline-cycle binding, and problems with the new one
Date: Mon, 10 Jan 2022 10:21:39 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu)

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]