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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 41130 in the body.
You can then email your comments to 41130 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Thu, 07 May 2020 20:55:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan Kangas <stefankangas <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 07 May 2020 20:55:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: outline-mode: Add new commands like org-cycle and org=global-cycle
Date: Thu, 7 May 2020 16:53:59 -0400
Severity: wishlist

Please consider adding two new commands to outline-mode similar to
org-cycle and org=global-cycle.

These are the suggested key bindings:

(define-key outline-minor-mode-map (kbd "C-<tab>") 'outline-cycle)
(define-key outline-minor-mode-map (kbd "S-<tab>") 'outline-global-cycle)

They are already there in Org-mode and many users swear by them.
(In Org-mode, org-cycle is bound to TAB instead of C-TAB, but I don't
think that would work very well with outline-minor-mode.)

Background:
https://lists.gnu.org/archive/html/emacs-devel/2020-04/msg01887.html

These keybindings were first suggested by Howard Melman in the above
thread.

Best regards,
Stefan Kangas




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Thu, 07 May 2020 21:04:02 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: outline-mode: Add new commands like org-cycle and org=global-cycle
Date: Thu, 7 May 2020 17:03:54 -0400
Stefan Kangas <stefankangas <at> gmail.com> writes:

> org-cycle and org=global-cycle.
                ^^^^^^^^^^^^^^^^
                should be `org-global-cycle', of course.




Changed bug title to 'outline-mode: Add new commands like org-cycle and org-global-cycle' from 'outline-mode: Add new commands like org-cycle and org=global-cycle' Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Thu, 07 May 2020 21:09:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Tue, 12 May 2020 23:00:03 GMT) Full text and rfc822 format available.

Message #13 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: 41130 <at> debbugs.gnu.org
Subject: Re: bug#41130: outline-mode: Add new commands like org-cycle and
 org=global-cycle
Date: Wed, 13 May 2020 01:52:55 +0300
> (define-key outline-minor-mode-map (kbd "C-<tab>") 'outline-cycle)
> (define-key outline-minor-mode-map (kbd "S-<tab>") 'outline-global-cycle)
>
> They are already there in Org-mode and many users swear by them.
> (In Org-mode, org-cycle is bound to TAB instead of C-TAB, but I don't
> think that would work very well with outline-minor-mode.)

C-TAB switches tabs in tab-bar-mode.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Wed, 13 May 2020 07:14:01 GMT) Full text and rfc822 format available.

Message #16 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Tassilo Horn <tsdh <at> gnu.org>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: 41130 <at> debbugs.gnu.org
Subject: Re: bug#41130: outline-mode: Add new commands like org-cycle and
 org=global-cycle
Date: Wed, 13 May 2020 09:13:14 +0200
Stefan Kangas <stefankangas <at> gmail.com> 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-<tab>") 'outline-cycle)
> (define-key outline-minor-mode-map (kbd "S-<tab>") '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 \"<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---

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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Wed, 13 May 2020 16:55:02 GMT) Full text and rfc822 format available.

Message #19 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: Tassilo Horn <tsdh <at> gnu.org>
Cc: 41130 <at> debbugs.gnu.org, Stefan Kangas <stefankangas <at> gmail.com>
Subject: Re: bug#41130: outline-mode: Add new commands like org-cycle and
 org=global-cycle
Date: Wed, 13 May 2020 18:54:44 +0200
>>>>> On Wed, 13 May 2020 09:13:14 +0200, Tassilo Horn <tsdh <at> gnu.org> said:

    Tassilo> PS: On a related note, I think there should be some standard facility
    Tassilo> for defining keys depending on the context.  If Stefan hadn't shown me
    Tassilo> the menu-item-with-:filter trick some years ago, I would probably not
    Tassilo> found out myself.

You can set a 'keymap property on buffer text. Of course then you have
to make sure that the property is kept up to date....

Robert




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Wed, 13 May 2020 18:52:01 GMT) Full text and rfc822 format available.

Message #22 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Tassilo Horn <tsdh <at> gnu.org>
To: Robert Pluim <rpluim <at> gmail.com>
Cc: 41130 <at> debbugs.gnu.org, Stefan Kangas <stefankangas <at> gmail.com>
Subject: Re: bug#41130: outline-mode: Add new commands like org-cycle and
 org=global-cycle
Date: Wed, 13 May 2020 20:51:30 +0200
Robert Pluim <rpluim <at> gmail.com> writes:

>>>>>> On Wed, 13 May 2020 09:13:14 +0200, Tassilo Horn <tsdh <at> gnu.org> said:
>
>     Tassilo> PS: On a related note, I think there should be some
>     Tassilo> standard facility for defining keys depending on the
>     Tassilo> context.  If Stefan hadn't shown me the
>     Tassilo> menu-item-with-:filter trick some years ago, I would
>     Tassilo> probably not found out myself.
>
> You can set a 'keymap property on buffer text. Of course then you have
> to make sure that the property is kept up to date....

Yes, that's not something which could be done easily for users.  And it
restricts dispatch to where point is on.  FWIW, in my uses of
th/define-context-key I also dispatch on the syntax at point or even
last-command-event in order to do something else when hitting the key
twice.

Anyway, I don't want to hijack this bug report.

Bye,
Tassilo




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Tue, 19 May 2020 02:46:02 GMT) Full text and rfc822 format available.

Message #25 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Yuan Fu <casouri <at> gmail.com>
Cc: 41130 <at> debbugs.gnu.org, 41198 <at> debbugs.gnu.org
Subject: Re: bug#41198: 27.0.60; [PATCH] heading cycling command for outline
Date: Mon, 18 May 2020 19:45:10 -0700
forcemerge 41130 41198
thanks

Yuan Fu <casouri <at> gmail.com> writes:

> Add two commands that cycles a heading (like that in Org mode) in outline-mode:
>
> - outline-cycle: cycles between “hide all”, “sub headings” and “show all” state. They are called “FOLDED”, “CHILDREN”, “SUBTREE” in Org mode.
> - outline-cycle-buffer: cycles between “only top level headings”, “all headings”, “show all” states

Thanks for working on this.  I've tested your patch, and it seems to
work as advertised.

> Could this be useful?

I think it could.  I have previously sent the wishlist Bug#41130, which
I have now merged with this bug.  I have seen no objections to that
proposal, so I hope that it is uncontroversial.

In Bug#41130, I also suggest to add the same keybinding as in org-mode:
TAB and S-TAB.  Could you add such keybindings to outline-mode-map in
your patch?

I think we also need ChangeLog in the commit message, an entry in NEWS,
and updates to the manual.

> +(defun outline-cycle ()
> +  "Cycle between “hide all”, “headings only” and “show all”.
> +
> +“Hide all” means hide all subheadings and their bodies.
> +“Headings only” means show sub headings but not their bodies.
> +“Show all” means show all subheadings and their bodies."

I can't remember seeing double quotes used like that before in doc
strings.  Correct me if I'm wrong, but wouldn't we normally use
`single-quotes' for something like this?

Best regards,
Stefan Kangas




Forcibly Merged 41130 41198. Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Tue, 19 May 2020 02:46:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Tue, 19 May 2020 03:01:01 GMT) Full text and rfc822 format available.

Message #30 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Juri Linkov <juri <at> linkov.net>
Cc: 41130 <at> debbugs.gnu.org
Subject: Re: bug#41130: outline-mode: Add new commands like org-cycle and
 org-global-cycle
Date: Mon, 18 May 2020 20:00:36 -0700
Juri Linkov <juri <at> linkov.net> writes:

>> (define-key outline-minor-mode-map (kbd "C-<tab>") 'outline-cycle)
>> (define-key outline-minor-mode-map (kbd "S-<tab>") 'outline-global-cycle)
>>
>> They are already there in Org-mode and many users swear by them.
>> (In Org-mode, org-cycle is bound to TAB instead of C-TAB, but I don't
>> think that would work very well with outline-minor-mode.)
>
> C-TAB switches tabs in tab-bar-mode.

Sorry, it seems I wrote this bug report in a very confusing way.
Please let me try again.

One part would be to add:

    (define-key outline-mode-map (kbd "<tab>") 'outline-cycle)
    (define-key outline-mode-map (kbd "S-<tab>") 'outline-global-cycle)

I also think we should also consider:

    (define-key outline-minor-mode-map (kbd "C-<tab>") 'outline-cycle)
    (define-key outline-minor-mode-map (kbd "S-<tab>") 'outline-global-cycle)

If there is a conflict with tab-bar-mode on C-TAB, maybe we could use
M-TAB instead?

Best regards,
Stefan Kangas




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Tue, 19 May 2020 03:07:02 GMT) Full text and rfc822 format available.

Message #33 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Tassilo Horn <tsdh <at> gnu.org>
Cc: 41130 <at> debbugs.gnu.org
Subject: Re: 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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Tue, 19 May 2020 18:33:01 GMT) Full text and rfc822 format available.

Message #36 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: 41130 <at> debbugs.gnu.org, 41198 <at> debbugs.gnu.org
Subject: Re: bug#41198: 27.0.60; [PATCH] heading cycling command for outline
Date: Tue, 19 May 2020 14:31:52 -0400
[Message part 1 (text/plain, inline)]

> On May 18, 2020, at 10:45 PM, Stefan Kangas <stefan <at> marxist.se> wrote:
> 
> forcemerge 41130 41198
> thanks
> 
> Yuan Fu <casouri <at> gmail.com> writes:
> 
>> Add two commands that cycles a heading (like that in Org mode) in outline-mode:
>> 
>> - outline-cycle: cycles between “hide all”, “sub headings” and “show all” state. They are called “FOLDED”, “CHILDREN”, “SUBTREE” in Org mode.
>> - outline-cycle-buffer: cycles between “only top level headings”, “all headings”, “show all” states
> 
> Thanks for working on this.  I've tested your patch, and it seems to
> work as advertised.

Thanks.

> 
>> Could this be useful?
> 
> I think it could.  I have previously sent the wishlist Bug#41130, which
> I have now merged with this bug.  I have seen no objections to that
> proposal, so I hope that it is uncontroversial.
> 
> In Bug#41130, I also suggest to add the same keybinding as in org-mode:
> TAB and S-TAB.  Could you add such keybindings to outline-mode-map in
> your patch?

It seems that the outline-mode bindings all live under C-c. Maybe C-c TAB and C-c S-TAB? Should I ask on emacs-devel for for suggestions?

> 
> I think we also need ChangeLog in the commit message, an entry in NEWS,
> and updates to the manual.

I updated NEWS and the manual. For ChangeLog, I thought that’s automatically generated from commit messages?

> 
>> +(defun outline-cycle ()
>> +  "Cycle between “hide all”, “headings only” and “show all”.
>> +
>> +“Hide all” means hide all subheadings and their bodies.
>> +“Headings only” means show sub headings but not their bodies.
>> +“Show all” means show all subheadings and their bodies."
> 
> I can't remember seeing double quotes used like that before in doc
> strings.  Correct me if I'm wrong, but wouldn't we normally use
> `single-quotes' for something like this?
> 

Done.

Yuan

[outline.patch (application/octet-stream, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Tue, 19 May 2020 22:26:02 GMT) Full text and rfc822 format available.

Message #39 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: 41130 <at> debbugs.gnu.org
Subject: Re: bug#41130: outline-mode: Add new commands like org-cycle and
 org-global-cycle
Date: Wed, 20 May 2020 01:04:01 +0300
>>> (define-key outline-minor-mode-map (kbd "C-<tab>") 'outline-cycle)
>>> (define-key outline-minor-mode-map (kbd "S-<tab>") 'outline-global-cycle)
>>>
>>> They are already there in Org-mode and many users swear by them.
>>> (In Org-mode, org-cycle is bound to TAB instead of C-TAB, but I don't
>>> think that would work very well with outline-minor-mode.)
>>
>> C-TAB switches tabs in tab-bar-mode.
>
> Sorry, it seems I wrote this bug report in a very confusing way.
> Please let me try again.
>
> One part would be to add:
>
>     (define-key outline-mode-map (kbd "<tab>") 'outline-cycle)
>     (define-key outline-mode-map (kbd "S-<tab>") 'outline-global-cycle)
>
> I also think we should also consider:
>
>     (define-key outline-minor-mode-map (kbd "C-<tab>") 'outline-cycle)
>     (define-key outline-minor-mode-map (kbd "S-<tab>") 'outline-global-cycle)
>
> If there is a conflict with tab-bar-mode on C-TAB, maybe we could use
> M-TAB instead?

M-TAB switches desktop windows in many window managers.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Tue, 19 May 2020 22:37:02 GMT) Full text and rfc822 format available.

Message #42 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Yuan Fu <casouri <at> gmail.com>
Cc: 41130 <at> debbugs.gnu.org, 41198 <at> debbugs.gnu.org
Subject: Re: bug#41198: 27.0.60; [PATCH] heading cycling command for outline
Date: Tue, 19 May 2020 15:36:01 -0700
Yuan Fu <casouri <at> gmail.com> writes:

>> In Bug#41130, I also suggest to add the same keybinding as in org-mode:
>> TAB and S-TAB.  Could you add such keybindings to outline-mode-map in
>> your patch?
>
> It seems that the outline-mode bindings all live under C-c. Maybe C-c
> TAB and C-c S-TAB? Should I ask on emacs-devel for for suggestions?

I think it is better to use the same keys as org-mode, since one
important motivation for this feature is precisely to align the
outline-mode keybindings with org-mode.  This aspect would be
significantly diminished by using other keys, IMHO.

My impression was that also there was consensus around (or at least no
objections to) that idea the last time we discussed it.  I would
therefore propose to just add TAB and S-TAB to the patch, but allow a
week or two before pushing to give others a chance to comment here.

But, if you really want to, of course you could also ask on emacs-devel.
Worst case, we get to have another round of bikeshedding. ;-)

>> I think we also need ChangeLog in the commit message, an entry in NEWS,
>> and updates to the manual.
>
> I updated NEWS and the manual. For ChangeLog, I thought that’s
> automatically generated from commit messages?

That is my understanding too.

But I only saw a diff attached, not a patch with a commit message.  That
is what I tried to say, but I could've been more clear.

(CONTRIBUTE suggests using `git format-patch -1' to email a patch, which
includes the commit message.)

> +@findex outline-cycle
> +@findex outline-cycle-buffer
> +  Outline also provides two convenience commands to cycle the
> +visibility of each heading and the whole buffer.  @code{outline-cycle}
> +cycles the current heading between "hide all", "subheadings", and
> +"show all" state.  @code{outline-cycle-buffer} cycles the whole buffer
> +between "only top-level headings", "all headings and subheadings", and
> +"show all" states.
[...]
> +*** New commands to cycle heading visibility.
> +'outline-cycle' cycles the current heading between "hide all",
> +"subheadings", and "show all" state. 'outline-cycle-buffer' cycles the
> +whole buffer between "only top-level headings", "all headings and
> +subheadings", and "show all" states.

Looks good to me (but should refer to the above keybindings if they're
added).

Best regards,
Stefan Kangas




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Wed, 20 May 2020 01:38:01 GMT) Full text and rfc822 format available.

Message #45 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Stefan Kangas <stefan <at> marxist.se>
Cc: 41130 <at> debbugs.gnu.org, 41198 <at> debbugs.gnu.org
Subject: Re: bug#41198: 27.0.60; [PATCH] heading cycling command for outline
Date: Tue, 19 May 2020 21:37:26 -0400
[Message part 1 (text/plain, inline)]

> On May 19, 2020, at 6:36 PM, Stefan Kangas <stefan <at> marxist.se> wrote:
> 
> Yuan Fu <casouri <at> gmail.com> writes:
> 
>>> In Bug#41130, I also suggest to add the same keybinding as in org-mode:
>>> TAB and S-TAB.  Could you add such keybindings to outline-mode-map in
>>> your patch?
>> 
>> It seems that the outline-mode bindings all live under C-c. Maybe C-c
>> TAB and C-c S-TAB? Should I ask on emacs-devel for for suggestions?
> 
> I think it is better to use the same keys as org-mode, since one
> important motivation for this feature is precisely to align the
> outline-mode keybindings with org-mode.  This aspect would be
> significantly diminished by using other keys, IMHO.
> 
> My impression was that also there was consensus around (or at least no
> objections to) that idea the last time we discussed it.  I would
> therefore propose to just add TAB and S-TAB to the patch, but allow a
> week or two before pushing to give others a chance to comment here.
> 
> But, if you really want to, of course you could also ask on emacs-devel.
> Worst case, we get to have another round of bikeshedding. ;-)

I added TAB and S-TAB bindings. Though S-TAB appears to be <backtab> on my machine (Mac) for both terminal and GUI so I bound that instead. Is that so for other machines? To reduce the possible allergy, I made the TAB binding conditional—only invokes outline-cycle when point is on a heading.

A minor thing: if the motivation is to align with Org mode, should I change the text message to align with Org mode? It prints “show all”, “hide all”, etc (because they make sense), but Org mode prints stuff like “CHILDREN”, “SUBTREE”, etc.

> 
>>> I think we also need ChangeLog in the commit message, an entry in NEWS,
>>> and updates to the manual.
>> 
>> I updated NEWS and the manual. For ChangeLog, I thought that’s
>> automatically generated from commit messages?
> 
> That is my understanding too.
> 
> But I only saw a diff attached, not a patch with a commit message.  That
> is what I tried to say, but I could've been more clear.
> 
> (CONTRIBUTE suggests using `git format-patch -1' to email a patch, which
> includes the commit message.)

Ah sorry, I switched to a new way to generate patches and didn’t notice that the commit message is gone. It is included this time.

> 
>> +@findex outline-cycle
>> +@findex outline-cycle-buffer
>> +  Outline also provides two convenience commands to cycle the
>> +visibility of each heading and the whole buffer.  @code{outline-cycle}
>> +cycles the current heading between "hide all", "subheadings", and
>> +"show all" state.  @code{outline-cycle-buffer} cycles the whole buffer
>> +between "only top-level headings", "all headings and subheadings", and
>> +"show all" states.
> [...]
>> +*** New commands to cycle heading visibility.
>> +'outline-cycle' cycles the current heading between "hide all",
>> +"subheadings", and "show all" state. 'outline-cycle-buffer' cycles the
>> +whole buffer between "only top-level headings", "all headings and
>> +subheadings", and "show all" states.
> 
> Looks good to me (but should refer to the above keybindings if they're
> added).

Yuan

[outline.patch (application/octet-stream, attachment)]
[Message part 3 (text/plain, inline)]



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Wed, 20 May 2020 14:13:02 GMT) Full text and rfc822 format available.

Message #48 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Howard Melman <hmelman <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#41130: bug#41198: 27.0.60;
 [PATCH] heading cycling command for outline
Date: Wed, 20 May 2020 10:12:23 -0400
Yuan Fu <casouri <at> gmail.com> writes:

>> On May 19, 2020, at 6:36 PM, Stefan Kangas <stefan <at> marxist.se> wrote:
>> 
>> Yuan Fu <casouri <at> gmail.com> writes:
>> 
>>>> In Bug#41130, I also suggest to add the same keybinding as in org-mode:
>>>> TAB and S-TAB.  Could you add such keybindings to outline-mode-map in
>>>> your patch?
>>> 
>>> It seems that the outline-mode bindings all live under C-c. Maybe C-c
>>> TAB and C-c S-TAB? Should I ask on emacs-devel for for suggestions?
>> 
>> I think it is better to use the same keys as org-mode, since one
>> important motivation for this feature is precisely to align the
>> outline-mode keybindings with org-mode.  This aspect would be
>> significantly diminished by using other keys, IMHO.
>> 
>> My impression was that also there was consensus around (or at least no
>> objections to) that idea the last time we discussed it.  I would
>> therefore propose to just add TAB and S-TAB to the patch, but allow a
>> week or two before pushing to give others a chance to comment here.

My original motivation was just to use org's cycling concept
to avoid having to remember all of outlines various commands
and bindings. So regardless of where these commands end up,
I think just having them is a big win. Of course if they
exist, aligning them with org bindings would be very nice.

The idea was to use this for code folding in programming
modes. S-TAB doesn't typically have a binding so it's safe
to use and aligns with org-mode.  

TAB is more problematic as it's typically bound to indenting
commands. I don't think context awareness would solve the
issue as you could want to indent or cycle when point is on
a "heading".  But if the other bindings (I think from
bug#41198) for M-right and M-left were included they could
substitute for indenting.

So in a programming mode with outline-minor-mode enabled:
- S-TAB can be used anywhere for global cycling
- TAB on a heading is used for cycling
- TAB not on a heading is used to indent
- M-right and M-left anywhere can be used to indent/unindent

I think this aligns with org-mode ('m not an org mode
user). If someone is bothered by having to use M-arrows for
indentation in this case, the answer is to not use
outline-minor-mode in a programming mode or rebind outline-cycle.

> A minor thing: if the motivation is to align with Org mode, should I
> change the text message to align with Org mode? It prints “show all”,
> “hide all”, etc (because they make sense), but Org mode prints stuff
> like “CHILDREN”, “SUBTREE”, etc.

IMHO consistency with outline terms is more important
here. It would be helpful if outline and org agreed on
terms. If they don't, then perhaps this could use both with
org terms in parenthesis.

-- 

Howard





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Wed, 20 May 2020 21:35:01 GMT) Full text and rfc822 format available.

Message #51 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Howard Melman <hmelman <at> gmail.com>, 41130 <at> debbugs.gnu.org
Subject: Re: bug#41130: bug#41198: 27.0.60; [PATCH] heading cycling command
 for outline
Date: Wed, 20 May 2020 14:34:06 -0700
Howard Melman <hmelman <at> gmail.com> writes:

> So in a programming mode with outline-minor-mode enabled:
> - S-TAB can be used anywhere for global cycling
> - TAB on a heading is used for cycling
> - TAB not on a heading is used to indent
> - M-right and M-left anywhere can be used to indent/unindent

Thanks.

I think what you say makes sense for outline-minor-mode.  We should take
care to distinguish that case from outline-mode, however.

>> A minor thing: if the motivation is to align with Org mode, should I
>> change the text message to align with Org mode? It prints “show all”,
>> “hide all”, etc (because they make sense), but Org mode prints stuff
>> like “CHILDREN”, “SUBTREE”, etc.
>
> IMHO consistency with outline terms is more important
> here. It would be helpful if outline and org agreed on
> terms. If they don't, then perhaps this could use both with
> org terms in parenthesis.

I think outline-mode should also be internally consistent with itself.
So I would suggest to stick to whatever terminology outline-mode uses
elsewhere also for these commands.

Maybe this suggests that the terminology in org-mode and outline-mode
could be aligned also on this point?  But that seems to be a different
issue than the one at hand.

Best regards,
Stefan Kangas




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Sun, 24 May 2020 07:28:01 GMT) Full text and rfc822 format available.

Message #54 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Bastien <bzg <at> gnu.org>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: 41130 <at> debbugs.gnu.org
Subject: Re: bug#41130: outline-mode: Add new commands like org-cycle and
 org=global-cycle
Date: Sun, 24 May 2020 09:26:45 +0200
Stefan Kangas <stefankangas <at> gmail.com> writes:

> (define-key outline-minor-mode-map (kbd "C-<tab>") 'outline-cycle)
                                           ^^^^^^^

Why not just <tab>, when point is on an outline entry?

-- 
 Bastien




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Sun, 24 May 2020 07:30:02 GMT) Full text and rfc822 format available.

Message #57 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Bastien <bzg <at> gnu.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 41130 <at> debbugs.gnu.org, Stefan Kangas <stefan <at> marxist.se>
Subject: Re: bug#41130: outline-mode: Add new commands like org-cycle and
 org-global-cycle
Date: Sun, 24 May 2020 09:29:41 +0200
Juri Linkov <juri <at> linkov.net> writes:

>> If there is a conflict with tab-bar-mode on C-TAB, maybe we could use
>> M-TAB instead?
>
> M-TAB switches desktop windows in many window managers.

Indeed.  I suggest using C-M-tab.

`org-force-cycle-archived' is not so used IMHO.

-- 
 Bastien




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Sun, 24 May 2020 14:36:01 GMT) Full text and rfc822 format available.

Message #60 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Bastien <bzg <at> gnu.org>
Cc: 41130 <at> debbugs.gnu.org, stefan <at> marxist.se, juri <at> linkov.net
Subject: Re: bug#41130: outline-mode: Add new commands like org-cycle and
 org-global-cycle
Date: Sun, 24 May 2020 17:35:50 +0300
> From: Bastien <bzg <at> gnu.org>
> Date: Sun, 24 May 2020 09:29:41 +0200
> Cc: Stefan Kangas <stefan <at> marxist.se>, 41130 <at> debbugs.gnu.org
> 
> Juri Linkov <juri <at> linkov.net> writes:
> 
> >> If there is a conflict with tab-bar-mode on C-TAB, maybe we could use
> >> M-TAB instead?
> >
> > M-TAB switches desktop windows in many window managers.
> 
> Indeed.  I suggest using C-M-tab.

C-M-TAB is not available with some window managers.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Sun, 24 May 2020 14:50:01 GMT) Full text and rfc822 format available.

Message #63 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: "Philip K." <philip <at> warpmail.net>
To: Bastien <bzg <at> gnu.org>
Cc: 41130 <at> debbugs.gnu.org, Stefan Kangas <stefankangas <at> gmail.com>
Subject: Re: bug#41130: outline-mode: Add new commands like org-cycle and
 org=global-cycle
Date: Sun, 24 May 2020 16:49:34 +0200
Bastien <bzg <at> gnu.org> writes:

> Stefan Kangas <stefankangas <at> gmail.com> writes:
>
>> (define-key outline-minor-mode-map (kbd "C-<tab>") 'outline-cycle)
>                                            ^^^^^^^
> Why not just <tab>, when point is on an outline entry?

I've tried something like this once, but it becomes quite annoying in
lisp modes, because "(" becomes a outline entry, making it tricky to
indent some code with TAB from anywhere on the line.

-- 
	Philip K.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Sun, 24 May 2020 16:28:01 GMT) Full text and rfc822 format available.

Message #66 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Bastien <bzg <at> gnu.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 41130 <at> debbugs.gnu.org, stefan <at> marxist.se, juri <at> linkov.net
Subject: Re: bug#41130: outline-mode: Add new commands like org-cycle and
 org-global-cycle
Date: Sun, 24 May 2020 18:26:50 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

> C-M-TAB is not available with some window managers.

Yes, right.  Would C-S-TAB be a better candidate then?

-- 
 Bastien




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Sun, 24 May 2020 16:31:02 GMT) Full text and rfc822 format available.

Message #69 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Bastien <bzg <at> gnu.org>
To: "Philip K." <philip <at> warpmail.net>
Cc: 41130 <at> debbugs.gnu.org, Stefan Kangas <stefankangas <at> gmail.com>
Subject: Re: bug#41130: outline-mode: Add new commands like org-cycle and
 org=global-cycle
Date: Sun, 24 May 2020 18:30:18 +0200
Hi Philip,

"Philip K." <philip <at> warpmail.net> writes:

> Bastien <bzg <at> gnu.org> writes:
>
>> Stefan Kangas <stefankangas <at> gmail.com> writes:
>>
>>> (define-key outline-minor-mode-map (kbd "C-<tab>") 'outline-cycle)
>>                                            ^^^^^^^
>> Why not just <tab>, when point is on an outline entry?
>
> I've tried something like this once, but it becomes quite annoying in
> lisp modes, because "(" becomes a outline entry, making it tricky to
> indent some code with TAB from anywhere on the line.

Er, yes, you're right.  Then I'd suggest this:

    S-TAB for outline-cycle
  C-S-TAB for outline-global-cycle

IMO it is more common to want to cycle an entry than the whole buffer.

-- 
 Bastien




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Sun, 24 May 2020 16:40:02 GMT) Full text and rfc822 format available.

Message #72 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Bastien <bzg <at> gnu.org>
Cc: 41130 <at> debbugs.gnu.org, stefan <at> marxist.se, juri <at> linkov.net
Subject: Re: bug#41130: outline-mode: Add new commands like org-cycle and
 org-global-cycle
Date: Sun, 24 May 2020 19:39:34 +0300
> From: Bastien <bzg <at> gnu.org>
> Cc: stefan <at> marxist.se,  41130 <at> debbugs.gnu.org,  juri <at> linkov.net
> Date: Sun, 24 May 2020 18:26:50 +0200
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> > C-M-TAB is not available with some window managers.
> 
> Yes, right.  Would C-S-TAB be a better candidate then?

Maybe.  It's free here.  I'll let people who know about its use to
chime in.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Sun, 24 May 2020 17:10:02 GMT) Full text and rfc822 format available.

Message #75 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Eli Zaretskii <eliz <at> gnu.org>, Bastien <bzg <at> gnu.org>
Cc: 41130 <at> debbugs.gnu.org, stefan <at> marxist.se, juri <at> linkov.net
Subject: Re: bug#41130: outline-mode: Add new commands like org-cycle and
 org-global-cycle
Date: Sun, 24 May 2020 20:09:16 +0300
On 24.05.2020 19:39, Eli Zaretskii wrote:
>> Yes, right.  Would C-S-TAB be a better candidate then?
> Maybe.  It's free here.  I'll let people who know about its use to
> chime in.

C-S-TAB invoked tab-previous in tab-bar-mode. Like in many other programs.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Mon, 25 May 2020 08:51:01 GMT) Full text and rfc822 format available.

Message #78 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Bastien <bzg <at> gnu.org>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 41130 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>, stefan <at> marxist.se,
 juri <at> linkov.net
Subject: Re: bug#41130: outline-mode: Add new commands like org-cycle and
 org-global-cycle
Date: Mon, 25 May 2020 10:50:44 +0200
Dmitry Gutov <dgutov <at> yandex.ru> writes:

> On 24.05.2020 19:39, Eli Zaretskii wrote:
>>> Yes, right.  Would C-S-TAB be a better candidate then?
>> Maybe.  It's free here.  I'll let people who know about its use to
>> chime in.
>
> C-S-TAB invoked tab-previous in tab-bar-mode. Like in many other
> programs.

Yes, of course, you are right.  

I'm leaning toward binding C-c C-TAB for `org-force-cycle-archived'
which, again, I don't expect to be that much used by Org users.

-- 
 Bastien




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Tue, 23 Jun 2020 22:28:01 GMT) Full text and rfc822 format available.

Message #81 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: Bastien <bzg <at> gnu.org>
Cc: 41130 <at> debbugs.gnu.org, juri <at> linkov.net, stefan <at> marxist.se,
 Dmitry Gutov <dgutov <at> yandex.ru>
Subject: Re: bug#41130: outline-mode: Add new commands like org-cycle and
 org-global-cycle
Date: Tue, 23 Jun 2020 23:27:01 +0100
Bastien <bzg <at> gnu.org> writes:

> Dmitry Gutov <dgutov <at> yandex.ru> writes:
>
>> On 24.05.2020 19:39, Eli Zaretskii wrote:
>>>> Yes, right.  Would C-S-TAB be a better candidate then?
>>> Maybe.  It's free here.  I'll let people who know about its use to
>>> chime in.
>>
>> C-S-TAB invoked tab-previous in tab-bar-mode. Like in many other
>> programs.
>
> Yes, of course, you are right.  
>
> I'm leaning toward binding C-c C-TAB for `org-force-cycle-archived'
> which, again, I don't expect to be that much used by Org users.

Isn't TAB often the same thing as C-i, at least in text terminals?  It
would be nice to have something that works in such environments as well,
unlike some exotic Org bindings.

-- 
Basil




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Mon, 17 Aug 2020 22:31:01 GMT) Full text and rfc822 format available.

Message #84 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Howard Melman <hmelman <at> gmail.com>
To: 41130 <at> debbugs.gnu.org
Subject: Re: bug#41130: outline-mode: Add new commands like org-cycle and 
 org-global-cycle 
Date: Mon, 17 Aug 2020 18:30:04 -0400
Has the previously mentioned patch been applied yet? I'm looking in master here and don't see it:
http://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/outline.el

I just upgraded to Emacs 27.1 and found that the new org-mode included no longer supports my hack of calling org-global-cycle from non-org-mode buffers which use outline-minor-mode.  As such I'm interested in getting this working and would love if it could be included in Emacs 27.2.

Howard





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Tue, 18 Aug 2020 04:31:01 GMT) Full text and rfc822 format available.

Message #87 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Howard Melman <hmelman <at> gmail.com>
Cc: 41130 <at> debbugs.gnu.org
Subject: Re: bug#41130: outline-mode: Add new commands like org-cycle and
 org-global-cycle
Date: Tue, 18 Aug 2020 07:30:16 +0300
> From: Howard Melman <hmelman <at> gmail.com>
> Date: Mon, 17 Aug 2020 18:30:04 -0400
> 
> Has the previously mentioned patch been applied yet? I'm looking in master here and don't see it:
> http://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/outline.el
> 
> I just upgraded to Emacs 27.1 and found that the new org-mode included no longer supports my hack of calling org-global-cycle from non-org-mode buffers which use outline-minor-mode.  As such I'm interested in getting this working and would love if it could be included in Emacs 27.2.

This is a new feature, so it's inappropriate for 27.2, which will be a
bug-fix release.  Sorry.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Sun, 06 Sep 2020 08:23:01 GMT) Full text and rfc822 format available.

Message #90 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Bastien <bzg <at> gnu.org>
To: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Cc: 41130 <at> debbugs.gnu.org, juri <at> linkov.net, stefan <at> marxist.se,
 Dmitry Gutov <dgutov <at> yandex.ru>
Subject: Re: bug#41130: outline-mode: Add new commands like org-cycle and
 org-global-cycle
Date: Sun, 06 Sep 2020 10:22:49 +0200
Hi Basil,

"Basil L. Contovounesios" <contovob <at> tcd.ie> writes:

> Isn't TAB often the same thing as C-i, at least in text terminals?  It
> would be nice to have something that works in such environments as well,
> unlike some exotic Org bindings.

Yes, I agree.  Patch welcome!

-- 
 Bastien




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Tue, 13 Oct 2020 03:17:02 GMT) Full text and rfc822 format available.

Message #93 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Yuan Fu <casouri <at> gmail.com>
Cc: 41130 <at> debbugs.gnu.org, Stefan Kangas <stefan <at> marxist.se>,
 41198 <at> debbugs.gnu.org
Subject: Re: bug#41130: bug#41198: 27.0.60; [PATCH] heading cycling command
 for outline
Date: Tue, 13 Oct 2020 05:16:12 +0200
Yuan Fu <casouri <at> gmail.com> writes:

> Ah sorry, I switched to a new way to generate patches and didn’t
> notice that the commit message is gone. It is included this time.

Skimming this thread, it seemed that everybody was in agreement that
this was a good change, but the patch was never applied, so I did that
now.

Some discussion then followed about what key(s) would be the best ones
here, and I didn't see any consensus, so I left the patch as is.  Feel
free to change the keys as you want, but I'm closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 28.1, send any further explanations to 41130 <at> debbugs.gnu.org and Stefan Kangas <stefankangas <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 13 Oct 2020 03:17:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Tue, 13 Oct 2020 13:17:02 GMT) Full text and rfc822 format available.

Message #98 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 41130 <at> debbugs.gnu.org, Stefan Kangas <stefan <at> marxist.se>,
 41198 <at> debbugs.gnu.org
Subject: Re: bug#41130: bug#41198: 27.0.60; [PATCH] heading cycling command
 for outline
Date: Tue, 13 Oct 2020 09:16:00 -0400

> On Oct 12, 2020, at 11:16 PM, Lars Ingebrigtsen <larsi <at> gnus.org> wrote:
> 
> Yuan Fu <casouri <at> gmail.com> writes:
> 
>> Ah sorry, I switched to a new way to generate patches and didn’t
>> notice that the commit message is gone. It is included this time.
> 
> Skimming this thread, it seemed that everybody was in agreement that
> this was a good change, but the patch was never applied, so I did that
> now.
> 
> Some discussion then followed about what key(s) would be the best ones
> here, and I didn't see any consensus, so I left the patch as is.  Feel
> free to change the keys as you want, but I'm closing this bug report.
> 
> -- 
> (domestic pets only, the antidote for overdose, milk.)
>   bloggy blog: http://lars.ingebrigtsen.no

Thanks Lars :-)



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Wed, 14 Oct 2020 19:51:02 GMT) Full text and rfc822 format available.

Message #101 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Stefan Kangas <stefan <at> marxist.se>, Yuan Fu <casouri <at> gmail.com>,
 41130 <at> debbugs.gnu.org, 41198 <at> debbugs.gnu.org
Subject: Re: bug#41130: bug#41198: 27.0.60; [PATCH] heading cycling command
 for outline
Date: Wed, 14 Oct 2020 22:24:10 +0300
> Skimming this thread, it seemed that everybody was in agreement that
> this was a good change, but the patch was never applied, so I did that
> now.

Now finally org keys are available in etc/NEWS, nice!
But typing S-TAB at the beginning of etc/NEWS signals the error:

  Debugger entered--Lisp error: (error "Before first heading")
    signal(error ("Before first heading"))

This is not how org-mode works - S-TAB doesn't fail before first heading
in org-mode.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Thu, 15 Oct 2020 07:03:01 GMT) Full text and rfc822 format available.

Message #104 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: Stefan Kangas <stefan <at> marxist.se>, Yuan Fu <casouri <at> gmail.com>,
 41130 <at> debbugs.gnu.org, 41198 <at> debbugs.gnu.org
Subject: Re: bug#41130: bug#41198: 27.0.60; [PATCH] heading cycling command
 for outline
Date: Thu, 15 Oct 2020 09:02:25 +0200
Juri Linkov <juri <at> linkov.net> writes:

>> Skimming this thread, it seemed that everybody was in agreement that
>> this was a good change, but the patch was never applied, so I did that
>> now.
>
> Now finally org keys are available in etc/NEWS, nice!
> But typing S-TAB at the beginning of etc/NEWS signals the error:
>
>   Debugger entered--Lisp error: (error "Before first heading")
>     signal(error ("Before first heading"))
>
> This is not how org-mode works - S-TAB doesn't fail before first heading
> in org-mode.

How does it work in org-mode?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Thu, 15 Oct 2020 07:53:01 GMT) Full text and rfc822 format available.

Message #107 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Stefan Kangas <stefan <at> marxist.se>, Yuan Fu <casouri <at> gmail.com>,
 41130 <at> debbugs.gnu.org, 41198 <at> debbugs.gnu.org, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#41130: bug#41198: 27.0.60; [PATCH] heading cycling command
 for outline
Date: Thu, 15 Oct 2020 09:52:08 +0200
>>>>> On Thu, 15 Oct 2020 09:02:25 +0200, Lars Ingebrigtsen <larsi <at> gnus.org> said:

    Lars> Juri Linkov <juri <at> linkov.net> writes:
    >>> Skimming this thread, it seemed that everybody was in agreement that
    >>> this was a good change, but the patch was never applied, so I did that
    >>> now.
    >> 
    >> Now finally org keys are available in etc/NEWS, nice!
    >> But typing S-TAB at the beginning of etc/NEWS signals the error:
    >> 
    >> Debugger entered--Lisp error: (error "Before first heading")
    >> signal(error ("Before first heading"))
    >> 
    >> This is not how org-mode works - S-TAB doesn't fail before first heading
    >> in org-mode.

    Lars> How does it work in org-mode?

The same as anywhere else: it cycles the visibility of the headings downbuffer.

Robert
-- 




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Thu, 15 Oct 2020 23:34:01 GMT) Full text and rfc822 format available.

Message #110 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: Stefan Kangas <stefan <at> marxist.se>, Lars Ingebrigtsen <larsi <at> gnus.org>,
 41130 <at> debbugs.gnu.org, 41198 <at> debbugs.gnu.org
Subject: Re: bug#41130: bug#41198: 27.0.60; [PATCH] heading cycling command
 for outline
Date: Thu, 15 Oct 2020 19:33:39 -0400

> On Oct 14, 2020, at 3:24 PM, Juri Linkov <juri <at> linkov.net> wrote:
> 
>> Skimming this thread, it seemed that everybody was in agreement that
>> this was a good change, but the patch was never applied, so I did that
>> now.
> 
> Now finally org keys are available in etc/NEWS, nice!
> But typing S-TAB at the beginning of etc/NEWS signals the error:
> 
>  Debugger entered--Lisp error: (error "Before first heading")
>    signal(error ("Before first heading"))
> 
> This is not how org-mode works - S-TAB doesn't fail before first heading
> in org-mode.

Do you suggest to change it to a user-error? Or just be silent?

Yuan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Fri, 16 Oct 2020 03:13:02 GMT) Full text and rfc822 format available.

Message #113 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: Stefan Kangas <stefan <at> marxist.se>, Lars Ingebrigtsen <larsi <at> gnus.org>,
 41130 <at> debbugs.gnu.org, 41198 <at> debbugs.gnu.org
Subject: Re: bug#41130: bug#41198: 27.0.60; [PATCH] heading cycling command
 for outline
Date: Thu, 15 Oct 2020 23:12:01 -0400
[Message part 1 (text/plain, inline)]

> On Oct 15, 2020, at 7:33 PM, Yuan Fu <casouri <at> gmail.com> wrote:
> 
> 
> 
>> On Oct 14, 2020, at 3:24 PM, Juri Linkov <juri <at> linkov.net> wrote:
>> 
>>> Skimming this thread, it seemed that everybody was in agreement that
>>> this was a good change, but the patch was never applied, so I did that
>>> now.
>> 
>> Now finally org keys are available in etc/NEWS, nice!
>> But typing S-TAB at the beginning of etc/NEWS signals the error:
>> 
>> Debugger entered--Lisp error: (error "Before first heading")
>>   signal(error ("Before first heading"))
>> 
>> This is not how org-mode works - S-TAB doesn't fail before first heading
>> in org-mode.
> 
> Do you suggest to change it to a user-error? Or just be silent?
> 

This patch should suppresses errors in both commands. Let me use it for a while and see if it works ok.

Yuan


[outline-fix.patch (application/octet-stream, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Fri, 16 Oct 2020 05:00:02 GMT) Full text and rfc822 format available.

Message #116 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Yuan Fu <casouri <at> gmail.com>
Cc: Stefan Kangas <stefan <at> marxist.se>, 41130 <at> debbugs.gnu.org,
 41198 <at> debbugs.gnu.org, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#41130: bug#41198: 27.0.60; [PATCH] heading cycling command
 for outline
Date: Fri, 16 Oct 2020 06:59:37 +0200
Yuan Fu <casouri <at> gmail.com> writes:

> Do you suggest to change it to a user-error? Or just be silent?

Robert suggested:

>     Lars> How does it work in org-mode?
>
> The same as anywhere else: it cycles the visibility of the headings
> downbuffer.

I guess that makes sense?  I don't use outlining, though, so I don't
really know whether that would be surprising behaviour in outline mode,
though.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Fri, 16 Oct 2020 08:26:02 GMT) Full text and rfc822 format available.

Message #119 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Stefan Kangas <stefan <at> marxist.se>, Yuan Fu <casouri <at> gmail.com>,
 41130 <at> debbugs.gnu.org, 41198 <at> debbugs.gnu.org, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#41198: bug#41130: bug#41198: 27.0.60; [PATCH] heading
 cycling command for outline
Date: Fri, 16 Oct 2020 10:25:09 +0200
>>>>> On Fri, 16 Oct 2020 06:59:37 +0200, Lars Ingebrigtsen <larsi <at> gnus.org> said:

    Lars> Yuan Fu <casouri <at> gmail.com> writes:
    >> Do you suggest to change it to a user-error? Or just be silent?

    Lars> Robert suggested:

    Lars> How does it work in org-mode?
    >> 
    >> The same as anywhere else: it cycles the visibility of the headings
    >> downbuffer.

    Lars> I guess that makes sense?  I don't use outlining, though, so I don't
    Lars> really know whether that would be surprising behaviour in outline mode,
    Lars> though.

I donʼt think Iʼd find it surprising. Of course we could fix this by
just adding "* " to the first line of NEWS :-)

Robert
-- 




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Fri, 16 Oct 2020 08:27:02 GMT) Full text and rfc822 format available.

Message #122 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Yuan Fu <casouri <at> gmail.com>
Cc: Stefan Kangas <stefan <at> marxist.se>, Lars Ingebrigtsen <larsi <at> gnus.org>,
 41130 <at> debbugs.gnu.org, 41198 <at> debbugs.gnu.org
Subject: Re: bug#41130: bug#41198: 27.0.60; [PATCH] heading cycling command
 for outline
Date: Fri, 16 Oct 2020 11:20:41 +0300
>> Now finally org keys are available in etc/NEWS, nice!
>> But typing S-TAB at the beginning of etc/NEWS signals the error:
>>
>>  Debugger entered--Lisp error: (error "Before first heading")
>>    signal(error ("Before first heading"))
>>
>> This is not how org-mode works - S-TAB doesn't fail before first heading
>> in org-mode.
>
> Do you suggest to change it to a user-error? Or just be silent?

To imitate org-mode, maybe outline-mode could temporarily (i.e. by
using save-excursion) navigate to the first heading before running
the rest of outline-cycle-buffer when it's before first heading?

Thank you for this nice feature!




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Fri, 16 Oct 2020 19:28:01 GMT) Full text and rfc822 format available.

Message #125 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: Stefan Kangas <stefan <at> marxist.se>, Lars Ingebrigtsen <larsi <at> gnus.org>,
 41130 <at> debbugs.gnu.org, 41198 <at> debbugs.gnu.org
Subject: Re: bug#41130: bug#41198: 27.0.60; [PATCH] heading cycling command
 for outline
Date: Fri, 16 Oct 2020 15:27:33 -0400
[Message part 1 (text/plain, inline)]

> On Oct 16, 2020, at 4:20 AM, Juri Linkov <juri <at> linkov.net> wrote:
> 
>>> Now finally org keys are available in etc/NEWS, nice!
>>> But typing S-TAB at the beginning of etc/NEWS signals the error:
>>> 
>>> Debugger entered--Lisp error: (error "Before first heading")
>>>   signal(error ("Before first heading"))
>>> 
>>> This is not how org-mode works - S-TAB doesn't fail before first heading
>>> in org-mode.
>> 
>> Do you suggest to change it to a user-error? Or just be silent?
> 
> To imitate org-mode, maybe outline-mode could temporarily (i.e. by
> using save-excursion) navigate to the first heading before running
> the rest of outline-cycle-buffer when it's before first heading?


This patch should make outline behaves like org: S-TAB always cycle the whole buffer, regardless where is the point. TAB cycles a heading, and does nothing if point is before the first heading.

Yuan

[outline-fix.patch (application/octet-stream, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Sat, 17 Oct 2020 06:37:02 GMT) Full text and rfc822 format available.

Message #128 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Yuan Fu <casouri <at> gmail.com>
Cc: Stefan Kangas <stefan <at> marxist.se>, 41130 <at> debbugs.gnu.org,
 41198 <at> debbugs.gnu.org, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#41130: bug#41198: 27.0.60; [PATCH] heading cycling command
 for outline
Date: Sat, 17 Oct 2020 08:36:47 +0200
Yuan Fu <casouri <at> gmail.com> writes:

> This patch should make outline behaves like org: S-TAB always cycle
> the whole buffer, regardless where is the point. TAB cycles a heading,
> and does nothing if point is before the first heading.

I think the behaviour makes sense, but the implementation isn't ideal:

[...]

> +  (condition-case nil
> +      (pcase (outline--cycle-state)
> +        ('hide-all
> +         (if (outline-has-subheading-p)
> +             (progn (outline-show-children)
> +                    (message "Only headings"))
> +           (outline-show-subtree)
> +           (message "Show all")))
> +        ('headings-only
> +         (outline-show-subtree)
> +         (message "Show all"))
> +        ('show-all
> +         (outline-hide-subtree)
> +         (message "Hide all")))
> +    ;; If error: "Before first heading" occurs, ignore it.
> +    (error nil)))

This is basically an `ignore-errors' around a whole bunch of code, used
as a program flow mechanism, and that's always awkward, because it hides
real errors in the code.

Altering the functions to not error out in these situations would be
better.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Sat, 17 Oct 2020 20:52:01 GMT) Full text and rfc822 format available.

Message #131 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Stefan Kangas <stefan <at> marxist.se>, Yuan Fu <casouri <at> gmail.com>,
 41130 <at> debbugs.gnu.org, 41198 <at> debbugs.gnu.org
Subject: Re: bug#41130: bug#41198: 27.0.60; [PATCH] heading cycling command
 for outline
Date: Sat, 17 Oct 2020 23:30:06 +0300
>> +  (condition-case nil
>> +      (pcase (outline--cycle-state)
>> +        ('hide-all
>> +         (if (outline-has-subheading-p)
>> +             (progn (outline-show-children)
>> +                    (message "Only headings"))
>> +           (outline-show-subtree)
>> +           (message "Show all")))
>> +        ('headings-only
>> +         (outline-show-subtree)
>> +         (message "Show all"))
>> +        ('show-all
>> +         (outline-hide-subtree)
>> +         (message "Hide all")))
>> +    ;; If error: "Before first heading" occurs, ignore it.
>> +    (error nil)))
>
> This is basically an `ignore-errors' around a whole bunch of code, used
> as a program flow mechanism, and that's always awkward, because it hides
> real errors in the code.
>
> Altering the functions to not error out in these situations would be
> better.

Like 'outline-back-to-heading' has an optional argument 'invisible-ok',
maybe a new argument named 'error-ok' or 'outside-ok' could
be added to not error out when point is outside of the outline tree.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Sun, 18 Oct 2020 00:29:02 GMT) Full text and rfc822 format available.

Message #134 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: Stefan Kangas <stefan <at> marxist.se>, Lars Ingebrigtsen <larsi <at> gnus.org>,
 41130 <at> debbugs.gnu.org, 41198 <at> debbugs.gnu.org
Subject: Re: bug#41130: bug#41198: 27.0.60; [PATCH] heading cycling command
 for outline
Date: Sat, 17 Oct 2020 20:28:25 -0400

> On Oct 17, 2020, at 4:30 PM, Juri Linkov <juri <at> linkov.net> wrote:
> 
>>> +  (condition-case nil
>>> +      (pcase (outline--cycle-state)
>>> +        ('hide-all
>>> +         (if (outline-has-subheading-p)
>>> +             (progn (outline-show-children)
>>> +                    (message "Only headings"))
>>> +           (outline-show-subtree)
>>> +           (message "Show all")))
>>> +        ('headings-only
>>> +         (outline-show-subtree)
>>> +         (message "Show all"))
>>> +        ('show-all
>>> +         (outline-hide-subtree)
>>> +         (message "Hide all")))
>>> +    ;; If error: "Before first heading" occurs, ignore it.
>>> +    (error nil)))
>> 
>> This is basically an `ignore-errors' around a whole bunch of code, used
>> as a program flow mechanism, and that's always awkward, because it hides
>> real errors in the code.
>> 
>> Altering the functions to not error out in these situations would be
>> better.
> 
> Like 'outline-back-to-heading' has an optional argument 'invisible-ok',
> maybe a new argument named 'error-ok' or 'outside-ok' could
> be added to not error out when point is outside of the outline tree.

I can modify outline code to signal a signal (say ‘outline-before-first-heading) rather than an error, and handle that signal specifically. How’s that?

Yuan



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Sun, 18 Oct 2020 08:37:01 GMT) Full text and rfc822 format available.

Message #137 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Yuan Fu <casouri <at> gmail.com>
Cc: Stefan Kangas <stefan <at> marxist.se>, 41130 <at> debbugs.gnu.org,
 41198 <at> debbugs.gnu.org, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#41130: bug#41198: 27.0.60; [PATCH] heading cycling command
 for outline
Date: Sun, 18 Oct 2020 10:36:21 +0200
Yuan Fu <casouri <at> gmail.com> writes:

> I can modify outline code to signal a signal (say
> ‘outline-before-first-heading) rather than an error, and handle that
> signal specifically. How’s that?

Yes, that would also work.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Sun, 18 Oct 2020 20:24:02 GMT) Full text and rfc822 format available.

Message #140 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Stefan Kangas <stefan <at> marxist.se>, 41130 <at> debbugs.gnu.org,
 41198 <at> debbugs.gnu.org, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#41130: bug#41198: 27.0.60; [PATCH] heading cycling command
 for outline
Date: Sun, 18 Oct 2020 16:23:12 -0400
[Message part 1 (text/plain, inline)]

> On Oct 18, 2020, at 4:36 AM, Lars Ingebrigtsen <larsi <at> gnus.org> wrote:
> 
> Yuan Fu <casouri <at> gmail.com> writes:
> 
>> I can modify outline code to signal a signal (say
>> ‘outline-before-first-heading) rather than an error, and handle that
>> signal specifically. How’s that?
> 
> Yes, that would also work.
> 
> -- 
> (domestic pets only, the antidote for overdose, milk.)
>   bloggy blog: http://lars.ingebrigtsen.no

Here is the new patch.

Yuan

[outline-fix.patch (application/octet-stream, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41130; Package emacs. (Mon, 19 Oct 2020 08:46:02 GMT) Full text and rfc822 format available.

Message #143 received at 41130 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Yuan Fu <casouri <at> gmail.com>
Cc: Stefan Kangas <stefan <at> marxist.se>, 41130 <at> debbugs.gnu.org,
 41198 <at> debbugs.gnu.org, Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#41130: bug#41198: 27.0.60; [PATCH] heading cycling command
 for outline
Date: Mon, 19 Oct 2020 10:45:35 +0200
Yuan Fu <casouri <at> gmail.com> writes:

> Here is the new patch.

Thanks; looks good to me.  I've now pushed it to the trunk.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 13 Jan 2021 12:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 75 days ago.

Previous Next


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