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: Sun, 02 Jan 2022 21:18:20 +0200 Organization: LINKOV.NET Message-ID: <86mtke3q0z.fsf@mail.linkov.net> References: <9DFDAD07-DBC0-4FAE-A565-D1EE6045E7D8@gmail.com> <86ilv25714.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39516"; 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: Yuan Fu , Emacs developers To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Jan 02 20:20:45 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 1n46PM-000A8w-0H for ged-emacs-devel@m.gmane-mx.org; Sun, 02 Jan 2022 20:20:44 +0100 Original-Received: from localhost ([::1]:57338 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n46PJ-0003af-UT for ged-emacs-devel@m.gmane-mx.org; Sun, 02 Jan 2022 14:20:41 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:39924) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n46OF-0002ty-N6 for emacs-devel@gnu.org; Sun, 02 Jan 2022 14:19:35 -0500 Original-Received: from relay7-d.mail.gandi.net ([217.70.183.200]:45555) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n46OD-0001gz-KB for emacs-devel@gnu.org; Sun, 02 Jan 2022 14:19:35 -0500 Original-Received: (Authenticated sender: juri@linkov.net) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 13BE420002; Sun, 2 Jan 2022 19:19:28 +0000 (UTC) Received-SPF: pass client-ip=217.70.183.200; envelope-from=juri@linkov.net; helo=relay7-d.mail.gandi.net X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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:283962 Archived-At: >>> Overall, from my limited knowledge, I think the old approach is more >>> reliable: I wouldn’t have this problem with the old approach. And the >>> new functionality added by the new approach and >>> outline-minor-mode-cycle-filter can be easily implemented in the old >>> approach. We don’t need to fiddle with font-lock-keywords with the >>> old approach, either. How about we go back to the old approach? >> >> Some time ago we discussed this possibility, but it will require writing >> too many wrappers for different modes, for example, for diff-mode: >> >> (defvar-keymap diff-mode-shared-map >> "TAB" (lambda () (interactive) >> (if (and outline-minor-mode (outline-on-heading-p)) >> (outline-cycle) >> (diff-hunk-next))) >> ... > > Why? The old approach used a conditional binding, so it should "just > work" without the major modes knowing about it. Then maybe something like this (not tested): diff --git a/lisp/outline.el b/lisp/outline.el index 0304d2334c..52b9883950 100644 --- a/lisp/outline.el +++ b/lisp/outline.el @@ -195,8 +195,10 @@ outline-minor-mode-cycle--bind :filter ,(or filter (lambda (cmd) - (when (or (not (functionp outline-minor-mode-cycle-filter)) - (funcall outline-minor-mode-cycle-filter)) + (when (and outline-minor-mode-cycle + (outline-on-heading-p) + (or (not (functionp outline-minor-mode-cycle-filter)) + (funcall outline-minor-mode-cycle-filter))) cmd)))))) (defvar outline-minor-mode-cycle-map @@ -225,10 +227,8 @@ outline-font-lock-keywords 0 '(if outline-minor-mode (if outline-minor-mode-cycle (if outline-minor-mode-highlight - (list 'face (outline-font-lock-face) - 'keymap outline-minor-mode-cycle-map) - (list 'face nil - 'keymap outline-minor-mode-cycle-map)) + (list 'face (outline-font-lock-face)) + (list 'face nil)) (if outline-minor-mode-highlight (list 'face (outline-font-lock-face)))) (outline-font-lock-face)) @@ -421,8 +422,10 @@ outline-minor-mode See the command `outline-mode' for more information on this mode." :lighter " Outl" - :keymap (list (cons [menu-bar] outline-minor-mode-menu-bar-map) - (cons outline-minor-mode-prefix outline-mode-prefix-map)) + :keymap (append + (list (cons [menu-bar] outline-minor-mode-menu-bar-map) + (cons outline-minor-mode-prefix outline-mode-prefix-map)) + (cdr outline-minor-mode-cycle-map)) (if outline-minor-mode (progn (when (or outline-minor-mode-cycle outline-minor-mode-highlight) --