GNU bug report logs - #41130
outline-mode: Add new commands like org-cycle and org-global-cycle

Previous Next

Package: emacs;

Reported by: Stefan Kangas <stefankangas <at> gmail.com>

Date: Thu, 7 May 2020 20:55:02 UTC

Severity: wishlist

Tags: patch

Merged with 41198

Found in version 27.0.60

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Tassilo Horn <tsdh <at> gnu.org>
Cc: 41130 <at> debbugs.gnu.org
Subject: bug#41130: outline-mode: Add new commands like org-cycle and org=global-cycle
Date: Mon, 18 May 2020 20:06:00 -0700
Tassilo Horn <tsdh <at> gnu.org> 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 \"<C-tab>\")
>      (cond
>       ((not (hs-already-hidden-p))
>        'hs-hide-block)
>       ((hs-already-hidden-p)
>        'hs-show-block)))
>
> This will make <C-tab> 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 "<tab>")
>     (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




This bug report was last modified 4 years and 156 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.