From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.bugs Subject: bug#41130: outline-mode: Add new commands like org-cycle and org=global-cycle Date: Mon, 18 May 2020 20:06:00 -0700 Message-ID: References: <87wo5gxq7p.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="122825"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 41130@debbugs.gnu.org To: Tassilo Horn Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue May 19 05:07:09 2020 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 1jasaz-000Vr6-HT for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 19 May 2020 05:07:09 +0200 Original-Received: from localhost ([::1]:40182 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jasay-00066U-Eb for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 18 May 2020 23:07:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49358) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jasas-00065r-Fx for bug-gnu-emacs@gnu.org; Mon, 18 May 2020 23:07:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:37240) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jasas-0006pn-6u for bug-gnu-emacs@gnu.org; Mon, 18 May 2020 23:07:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jasas-0003GN-1M for bug-gnu-emacs@gnu.org; Mon, 18 May 2020 23:07:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Kangas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 19 May 2020 03:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41130 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 41130-submit@debbugs.gnu.org id=B41130.158985757112466 (code B ref 41130); Tue, 19 May 2020 03:07:01 +0000 Original-Received: (at 41130) by debbugs.gnu.org; 19 May 2020 03:06:11 +0000 Original-Received: from localhost ([127.0.0.1]:48786 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jasa3-0003F0-GT for submit@debbugs.gnu.org; Mon, 18 May 2020 23:06:11 -0400 Original-Received: from mail-qk1-f177.google.com ([209.85.222.177]:34207) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jasZz-0003Ek-DH for 41130@debbugs.gnu.org; Mon, 18 May 2020 23:06:10 -0400 Original-Received: by mail-qk1-f177.google.com with SMTP id 190so13082339qki.1 for <41130@debbugs.gnu.org>; Mon, 18 May 2020 20:06:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:in-reply-to:references:mime-version:date:message-id:subject:to :cc; bh=RlTbA55H5ESa9GYl2BSOxxnrpl05V0BM3uqfLXQHRAM=; b=VT32aIwxx66BmbYFpJjjYlfaXrBHU2G1/R6GiapIM89OlenWYP6h+LXDtuC6n8UAKW bJMYcLhQX0avqLQO24QM/RIYXHsZZjZcQMxGn3PwPaW7bu5Ko+ScuKGyGHVTRMKzCycL Rn7QiQWor02GPXIof3EUA2HIBdjVGFM8wiXUC028nm9hah/p0ILZolShW2hihjGQFXsS vWJ0eYVxaGsdq7qDcYISKDvSAPCPFlIMogD/Qxo0hUriztGdRpsvqSrXuj13CxbNXhbN daMERWYde+XLZ5dm/PUUzKYBvQQqqgKY4zXQj3vmeVorTGbVQOXTVJHZmcdORtSRujNk aChw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:in-reply-to:references:mime-version:date :message-id:subject:to:cc; bh=RlTbA55H5ESa9GYl2BSOxxnrpl05V0BM3uqfLXQHRAM=; b=D59qpqx1jYlAsStOHHNEbzvdklAMq4s3Rlb77TNECx2mbK+f5hq9ezQ8QJvwbrClEU VTEoj5UZ3CXEjf62fIr5RgccemwDx90NhMe58WJollPRoM9QBVerf5XtWlPMoBzW/1d7 R0PfWQF0kDZjv1DHPN9whbLvfNBpFeWba/KGMiPw+c/loeafctw39rCZnV4v52Quv5ur HwKo83PIxMAR0pbh3YNGQ5E5W8uKuTHkQ6MBTMsnP2zZO6IOpOFkashDIwoBO0PY2iCq /Ne1yWATN3FBF2Sc+BiBeTEevSixhD20/S1jNEifuf8MtQ8SrlGXKQ9Ykp/oQVeSSA1u 4G0w== X-Gm-Message-State: AOAM531sfzLQHO2ZSiQGIoku6qeQK2V0kKul28Y61lJsEe9wu6zi/gqN pFCpD00+cDQ83bVMqxnlLLotQ69lrHbBlx1+Rd/rcw== X-Google-Smtp-Source: ABdhPJwRXthehUQxJTgAE7iDxcZ01r5Bkjcz2q4b5A0lGvP/kHnsWOf4apWjyO/G0MhE6AuJ6DQ/inNPPk4P0e0Huo0= X-Received: by 2002:a25:4c04:: with SMTP id z4mr30199106yba.466.1589857561857; Mon, 18 May 2020 20:06:01 -0700 (PDT) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Mon, 18 May 2020 20:06:00 -0700 In-Reply-To: <87wo5gxq7p.fsf@gnu.org> 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" Xref: news.gmane.io gmane.emacs.bugs:180576 Archived-At: Tassilo Horn writes: > I'm also very much in favor of this. I think probably every user has > his own incarnation of such a command. I wish I was one of these users. ;-) > Well, I think those shouldn't be commands in outline-minor-mode-map as > they should only be active when point is on an outline heading, no? At > least that's the case with org-mode where TAB acts quite differently > depending on the context. This is a good point, yes. > --8<---------------cut here---------------start------------->8--- > (defmacro th/define-context-key (keymap key dispatch) > "Define KEY in KEYMAP to execute according to DISPATCH. > > DISPATCH is a form that is evaluated and should return the > command to be executed. > > If DISPATCH returns nil, then the command normally bound to KEY > will be executed. > > Example: > > (th/define-context-key hs-minor-mode-map > (kbd \"\") > (cond > ((not (hs-already-hidden-p)) > 'hs-hide-block) > ((hs-already-hidden-p) > 'hs-show-block))) > > This will make show a hidden block. If the block is > shown, then it'll be hidden." > (declare (indent 2)) > `(define-key ,keymap ,key > `(menu-item "context-key" ignore > :filter ,(lambda (&optional ignored) > ,dispatch)))) > > (th/define-context-key outline-minor-mode-map (kbd "") > (when (save-excursion > (move-beginning-of-line 1) > (looking-at-p outline-regexp)) > 'outline-toggle-children)) > --8<---------------cut here---------------end--------------->8--- Interesting. I suppose the only question I have is this: how do we turn this into something we could add to Emacs? There is also the question of C-TAB conflicting with tab-bar-mode. > PS: On a related note, I think there should be some standard facility > for defining keys depending on the context. If Stefan hadn't shown me > the menu-item-with-:filter trick some years ago, I would probably not > found out myself. Agreed. I had not seen that before, until now. Best regards, Stefan Kangas