From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: Duplicated outline-cycle binding, and problems with the new one Date: Mon, 10 Jan 2022 10:21:39 +0200 Organization: LINKOV.NET Message-ID: <86pmp0ovak.fsf@mail.linkov.net> References: <9DFDAD07-DBC0-4FAE-A565-D1EE6045E7D8@gmail.com> <86ilv25714.fsf@mail.linkov.net> <86pmp6cohf.fsf@mail.linkov.net> <86a6g87lu5.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37954"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) Cc: Stefan Monnier , Emacs developers To: Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Jan 10 09:29:53 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n6q3s-0009iD-S1 for ged-emacs-devel@m.gmane-mx.org; Mon, 10 Jan 2022 09:29:52 +0100 Original-Received: from localhost ([::1]:45192 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6q3r-0005Pp-TD for ged-emacs-devel@m.gmane-mx.org; Mon, 10 Jan 2022 03:29:51 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:46238) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6pzr-0000JK-HB for emacs-devel@gnu.org; Mon, 10 Jan 2022 03:25:44 -0500 Original-Received: from relay2-d.mail.gandi.net ([217.70.183.194]:63121) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6pzo-0003PN-K1 for emacs-devel@gnu.org; Mon, 10 Jan 2022 03:25:43 -0500 Original-Received: (Authenticated sender: juri@linkov.net) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 8347540007; Mon, 10 Jan 2022 08:25:37 +0000 (UTC) In-Reply-To: (Yuan Fu's message of "Sun, 9 Jan 2022 14:55:45 -0800") Received-SPF: pass client-ip=217.70.183.194; envelope-from=juri@linkov.net; helo=relay2-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:284522 Archived-At: >>> 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))))