From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Rah Guzar via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#60426: 29.0.60; Binding to outline-minor-mode-cycle-map correctly is unintuitive and hard Date: Wed, 11 Jan 2023 17:29:22 +0100 Message-ID: <87fschrpqw.fsf@zohomail.eu> References: <871qohm8ht.fsf@zohomail.eu> <861qo95fzi.fsf@mail.linkov.net> <877cy0ztuj.fsf@zoho.eu> <86tu0ymc2s.fsf@mail.linkov.net> Reply-To: Rah Guzar Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40449"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.8.13; emacs 29.0.60 Cc: 60426@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jan 11 17:39:45 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 1pFe8e-000A2X-Oi for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 11 Jan 2023 17:39:44 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFe80-000576-Pu; Wed, 11 Jan 2023 11:39:04 -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 1pFe7y-00054j-Sv for bug-gnu-emacs@gnu.org; Wed, 11 Jan 2023 11:39:02 -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 1pFe7y-0007mH-7o for bug-gnu-emacs@gnu.org; Wed, 11 Jan 2023 11:39:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pFe7y-0002LM-3N for bug-gnu-emacs@gnu.org; Wed, 11 Jan 2023 11:39:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Rah Guzar Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 11 Jan 2023 16:39:02 +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.16734550918946 (code B ref 60426); Wed, 11 Jan 2023 16:39:02 +0000 Original-Received: (at 60426) by debbugs.gnu.org; 11 Jan 2023 16:38:11 +0000 Original-Received: from localhost ([127.0.0.1]:43648 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pFe78-0002KE-FS for submit@debbugs.gnu.org; Wed, 11 Jan 2023 11:38:10 -0500 Original-Received: from sender11-pp-o91.zoho.eu ([31.186.226.249]:25283) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pFe75-0002K4-7B for 60426@debbugs.gnu.org; Wed, 11 Jan 2023 11:38:08 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1673455084; cv=none; d=zohomail.eu; s=zohoarc; b=NC8UBU3qHKLZmCI+WtzIG6ilg8k+vdFT0S9D8iaJOR6Sha48JeUPRoBlGr6MQ85fn8efqYR3TmCA1FKP8mxEgiPkokBaEcB7wLZcGbYt/XATOcodeGyd/UkSYDTWcQiS+clAVVF7fPLjk38iudl9CfKOstaaPzoZM7qou3dNC10= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1673455084; h=Content-Type:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=lFUXjs0y3eUeUUP7OvlqlO6mgZ4rim4Ykk3MqsPQiOM=; b=iNEuwUwHUkc9pr+zRSpQOk0RUrTBRB0BfP3vY53HaEYt8V44pCLh9ZFM/C3s+badqyYIde4eyAgZMzzo6bx8V9iV3XIQXmYWak7mKlEqLL7kz0HqVjQWbylMdvkaiHHrTL/T6AsAExuyB81NldEnaVSWT+pRWIQUyMKkhhE3s1k= ARC-Authentication-Results: i=1; mx.zohomail.eu; dkim=pass header.i=zohomail.eu; spf=pass smtp.mailfrom=rahguzar@zohomail.eu; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1673455084; s=zoho; d=zohomail.eu; i=rahguzar@zohomail.eu; h=References:From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:In-reply-to:Message-ID:MIME-Version:Content-Type:Message-Id:Reply-To; bh=lFUXjs0y3eUeUUP7OvlqlO6mgZ4rim4Ykk3MqsPQiOM=; b=sdnXlUb54IUfvlu0gNmCXSfEw4lQ0e+9UFkf5banstI6a+JVHZ3g2Atn3uwR9ud7 hf2fnsNH4VyLARRxmEYo7QBLNt22KT/mALRLfGBtYUGqStjlGKlPNM1Md2b0HmVD4IZ WTll8nxOYfvEZBprMZ5p79NkdF3XnW8kXyO6j/c8= Original-Received: from localhost (81-231-79-170-no600.tbcn.telia.com [81.231.79.170]) by mx.zoho.eu with SMTPS id 1673455081811687.3295555621853; Wed, 11 Jan 2023 17:38:01 +0100 (CET) In-reply-to: <86tu0ymc2s.fsf@mail.linkov.net> X-ZohoMailClient: External 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:253153 Archived-At: Thanks a lot! The patch look good to me. Minor quibbles: 1. I think in the NEWS entry, "font-lock text property 'keymap'" should probably just be "text property 'keymap'" i.e. why mention font-lock? 2. Since the implementation of `outline-minor-mode-cycle--bind` can change, it is better to change the order of arguments and make `map` an actual third argument. It is awkward to pass `nil` as the first argument and I think that way the actual map key is bound to can be treated as an implementation detail with `outline-minor-mode-cycle--bind` the official way of binding keys on headings. Thanks again! Juri Linkov writes: >>> (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. > > [2. text/x-diff; 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