From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.bugs Subject: bug#41130: outline-mode: Add new commands like org-cycle and org=global-cycle Date: Wed, 13 May 2020 09:13:14 +0200 Message-ID: <87wo5gxq7p.fsf@gnu.org> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="110270"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 41130@debbugs.gnu.org To: Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed May 13 09:14:10 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 1jYlaj-000SZB-W6 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 13 May 2020 09:14:09 +0200 Original-Received: from localhost ([::1]:40572 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYlai-0001Jl-N4 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 13 May 2020 03:14:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52314) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYlac-0001Hh-9Z for bug-gnu-emacs@gnu.org; Wed, 13 May 2020 03:14:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45689) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jYlac-0000Ax-08 for bug-gnu-emacs@gnu.org; Wed, 13 May 2020 03:14:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jYlab-0001IY-Po for bug-gnu-emacs@gnu.org; Wed, 13 May 2020 03:14:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tassilo Horn Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 13 May 2020 07:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41130 X-GNU-PR-Package: emacs Original-Received: via spool by 41130-submit@debbugs.gnu.org id=B41130.15893540054938 (code B ref 41130); Wed, 13 May 2020 07:14:01 +0000 Original-Received: (at 41130) by debbugs.gnu.org; 13 May 2020 07:13:25 +0000 Original-Received: from localhost ([127.0.0.1]:57235 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jYla0-0001Ha-Qp for submit@debbugs.gnu.org; Wed, 13 May 2020 03:13:25 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:49242) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jYlZz-0001HL-JU for 41130@debbugs.gnu.org; Wed, 13 May 2020 03:13:23 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:59253) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYlZu-0008Hl-D8; Wed, 13 May 2020 03:13:18 -0400 Original-Received: from auth2-smtp.messagingengine.com ([66.111.4.228]:35545) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.82) (envelope-from ) id 1jYlZt-0007z2-5J; Wed, 13 May 2020 03:13:17 -0400 Original-Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailauth.nyi.internal (Postfix) with ESMTP id F330D27C0054; Wed, 13 May 2020 03:13:15 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Wed, 13 May 2020 03:13:15 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrleefgdduudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufhfffgjkfgfgggtsehttdertddtredtnecuhfhrohhmpefvrghsshhi lhhoucfjohhrnhcuoehtshguhhesghhnuhdrohhrgheqnecuggftrfgrthhtvghrnheptd elieffkeeuffduueeffefhiedtjeeutdeuveegfffgtdejleekheegkeetkeevnecukfhp peelfedrvdefiedrudefkedrvddtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrg hmpehmrghilhhfrhhomhepthhhohhrnhdomhgvshhmthhprghuthhhphgvrhhsohhnrghl ihhthidqkeeijeefkeejkeegqdeifeehvdelkedqthhsughhpeepghhnuhdrohhrghesfh grshhtmhgrihhlrdhfmh X-ME-Proxy: Original-Received: from thinkpad-t440p (p5dec8a14.dip0.t-ipconnect.de [93.236.138.20]) by mail.messagingengine.com (Postfix) with ESMTPA id 377AB3066176; Wed, 13 May 2020 03:13:15 -0400 (EDT) In-Reply-To: (Stefan Kangas's message of "Thu, 7 May 2020 16:53:59 -0400") 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:180145 Archived-At: Stefan Kangas writes: > Severity: wishlist > > Please consider adding two new commands to outline-mode similar to > org-cycle and org=global-cycle. I'm also very much in favor of this. I think probably every user has his own incarnation of such a command. > These are the suggested key bindings: > > (define-key outline-minor-mode-map (kbd "C-") 'outline-cycle) > (define-key outline-minor-mode-map (kbd "S-") 'outline-global-cycle) 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. So that's my personal incarnation: --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--- Of course, outline-toggle-children is not exactly like org-cycle or org-global-cycle but it gets the job done. Bye, Tassilo 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.