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.bugs Subject: bug#60426: 29.0.60; Binding to outline-minor-mode-cycle-map correctly is unintuitive and hard Date: Tue, 10 Jan 2023 20:59:55 +0200 Organization: LINKOV.NET Message-ID: <86tu0ymc2s.fsf@mail.linkov.net> References: <871qohm8ht.fsf@zohomail.eu> <861qo95fzi.fsf@mail.linkov.net> <877cy0ztuj.fsf@zoho.eu> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12735"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) Cc: 60426@debbugs.gnu.org To: Rah Guzar Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jan 10 20:29:16 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1pFKJ9-0002zX-K4 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 10 Jan 2023 20:29:15 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFKEQ-00073Q-PH; Tue, 10 Jan 2023 14:24:24 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pFKE6-0006kZ-Tu for bug-gnu-emacs@gnu.org; Tue, 10 Jan 2023 14:24:05 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pFKE6-0008NU-99 for bug-gnu-emacs@gnu.org; Tue, 10 Jan 2023 14:24:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pFKE5-0000oh-Oa for bug-gnu-emacs@gnu.org; Tue, 10 Jan 2023 14:24:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 10 Jan 2023 19:24:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60426 X-GNU-PR-Package: emacs Original-Received: via spool by 60426-submit@debbugs.gnu.org id=B60426.16733785973081 (code B ref 60426); Tue, 10 Jan 2023 19:24:01 +0000 Original-Received: (at 60426) by debbugs.gnu.org; 10 Jan 2023 19:23:17 +0000 Original-Received: from localhost ([127.0.0.1]:41166 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pFKDM-0000na-QA for submit@debbugs.gnu.org; Tue, 10 Jan 2023 14:23:17 -0500 Original-Received: from relay4-d.mail.gandi.net ([217.70.183.196]:37553) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pFKDL-0000nM-8U for 60426@debbugs.gnu.org; Tue, 10 Jan 2023 14:23:16 -0500 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id B2895E0004; Tue, 10 Jan 2023 19:23:05 +0000 (UTC) In-Reply-To: <877cy0ztuj.fsf@zoho.eu> (Rah Guzar's message of "Thu, 05 Jan 2023 19:28:38 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:253105 Archived-At: --=-=-= Content-Type: text/plain >> (outline-minor-mode-cycle--bind map (kbd "TAB") #'outline-cycle) >> >> Maybe this requirement should be documented in the docstring >> and mentioned in NEWS? > > I think this is a good idea since people who have already keys bound > on outline-minor-mode-cycle-map are likely to be as surprised as I was. > > But I also think that it is more important to mention this in the > docstring for outline-minor-mode-cycle-map. Since its current > docstring "Keymap used by outline-minor-mode-cycle." is misleading in > my opinion, especially since any key there is going to be active > if outline-minor-mode is on, regardless of the value of > `outline-minor-mode-cycle`. Thanks for suggestions. The following patch addresses all the points that have been raised, except obsoleting `outline-minor-mode-cycle-map`. It's more convenient to bind keys in this map since `outline-minor-mode-map` is not explicitly defined unlike `outline-mode-map`. > Also I was confused by the two hyphens in the name > outline-minor-mode-cycle--bind and thought that it was a private > function even though in retrospect they are in the wrong place > for it to be private. Two hyphens in the name rather indicated that the implementation is subject to change without notice - an assumption that is true for internal functions. So now I'm not sure if adding an alias without two hyphens is worth to do. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=outline-minor-mode-cycle--bind.patch diff --git a/etc/NEWS b/etc/NEWS index a28f5c9a65a..6ae79e6cebc 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -350,6 +350,15 @@ next button, even if the mode has bound it to something else. This also means that 'TAB' on a button in an 'outline-minor-mode' heading will move point instead of collapsing the outline. +--- +** 'outline-minor-mode-cycle-map' is now parent of 'outline-minor-mode'. +Instead of adding font-lock text property 'keymap' with +'outline-minor-mode-cycle' on outline headings in 'outline-minor-mode', +the keymap 'outline-minor-mode-cycle' is now active in the whole buffer. +But keybindings in 'outline-minor-mode-cycle' are still take effect +only on outline headings because they are bound with the help of +'outline-minor-mode-cycle--bind' that checks if point is on a heading. + --- ** 'Info-default-directory-list' is no longer populated at Emacs startup. If you have code in your init file that removes directories from diff --git a/lisp/outline.el b/lisp/outline.el index 91f6040687b..26e41735a01 100644 --- a/lisp/outline.el +++ b/lisp/outline.el @@ -210,7 +210,12 @@ outline-minor-mode-cycle-filter (defvar outline-minor-mode-cycle) (defun outline-minor-mode-cycle--bind (map key binding &optional filter) - (define-key map key + "Define KEY as BINDING in MAP using FILTER. +The key takes effect only on the following conditions: +`outline-minor-mode-cycle' is non-nil, point is located on the heading line, +FILTER or `outline-minor-mode-cycle-filter' is nil or returns non-nil. +The argument MAP is optional and defaults to `outline-minor-mode-cycle-map'." + (define-key (or map outline-minor-mode-cycle-map) key `(menu-item "" ,binding ;; Filter out specific positions on the heading. @@ -227,8 +232,16 @@ outline-minor-mode-cycle-map (let ((map (make-sparse-keymap))) (outline-minor-mode-cycle--bind map (kbd "TAB") #'outline-cycle) (outline-minor-mode-cycle--bind map (kbd "") #'outline-cycle-buffer) + (keymap-set map " " 'outline-cycle) + (keymap-set map " " 'outline-cycle) + (keymap-set map " S-" 'outline-cycle-buffer) + (keymap-set map " S-" 'outline-cycle-buffer) map) - "Keymap used by `outline-minor-mode-cycle'.") + "Keymap used as a parent of the `outline-minor-mode' keymap. +It contains key bindings that can be used to cycle visibility. +The recommended way to bind keys is with `outline-minor-mode-cycle--bind' +when the key should be enabled only when `outline-minor-mode-cycle' is +non-nil and point is located on the heading line.") (defvar outline-mode-map (let ((map (make-sparse-keymap))) @@ -518,10 +532,6 @@ outline-minor-mode :keymap (define-keymap :parent outline-minor-mode-cycle-map "" outline-minor-mode-menu-bar-map - " " 'outline-cycle - " " 'outline-cycle - " S-" 'outline-cycle-buffer - " S-" 'outline-cycle-buffer (key-description outline-minor-mode-prefix) outline-mode-prefix-map) (if outline-minor-mode (progn --=-=-=--