emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Suggestion to increase usefulness of TAB key / 'org-cycle' function
@ 2023-04-28  8:49 Philipp Kiefer
  2023-04-28  9:45 ` Fraga, Eric
  0 siblings, 1 reply; 9+ messages in thread
From: Philipp Kiefer @ 2023-04-28  8:49 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1305 bytes --]

To quote from the Org Manual:
"Org greatly simplifies the use of outlines by compressing the entire show
and hide functionalities into a single command, org-cycle, which is bound
to the TAB key."

Well, it could simplify things a good deal further if, on issuing the
command when point is *not* on a parent heading, (non-global) org-cycle
would instead fold the subtree that point is in, i. e. do
'outline-up-heading' and 'hide-subtree' on the parent heading. This would
make collapsing subtrees a lot easier and quicker as it could be done from
any non-parent position inside a tree. It is very noticeable when
collapsing multiple adjacent trees in succession.

Currently, hitting TAB when not on a parent heading merely returns an
'EMPTY ENTRY' message - not useful at all. 'Outline-up-heading' (C-c C-u)
has to be called manually each time before hitting TAB to achieve what the
user is most likely attempting to do anyway.

Personally, I doubt this change in behaviour would break much for users,
unless one were to assume that there is a lot of Elisp code out there that
relies on 'org-cycle' doing nothing in such cases, incurring the 'EMPTY
ENTRY' reprimand to boot, rather than first checking whether point is on a
parent heading. I don't see any drawbacks when 'org-cycle' is used
interactively.

[-- Attachment #2: Type: text/html, Size: 1429 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Suggestion to increase usefulness of TAB key / 'org-cycle' function
  2023-04-28  8:49 Suggestion to increase usefulness of TAB key / 'org-cycle' function Philipp Kiefer
@ 2023-04-28  9:45 ` Fraga, Eric
  2023-04-28 15:17   ` Philipp Kiefer
  0 siblings, 1 reply; 9+ messages in thread
From: Fraga, Eric @ 2023-04-28  9:45 UTC (permalink / raw)
  To: Philipp Kiefer; +Cc: emacs-orgmode@gnu.org

Hi Philipp,

On Friday, 28 Apr 2023 at 10:49, Philipp Kiefer wrote:
> Well, it could simplify things a good deal further if, on issuing the
> command when point is *not* on a parent heading, (non-global)
> org-cycle would instead fold the subtree that point is in, i. e. do
> 'outline-up-heading' and 'hide-subtree' on the parent heading. 

You could always bind TAB to your own command that does this.  As an
illustration, I have TAB bound to my own function that invokes
completion instead unless I'm on an org heading!

--8<---------------cut here---------------start------------->8---
(defun esf/complete-or-indent ()
  (interactive)
  (cond
   ;; ((eq 'message-mode major-mode)
   ;;  (message-tab))
   ((and (eq 'message-mode major-mode)
         (message-point-in-header-p)
         (looking-back "^\\(To\\|B?[Cc]c\\): *.*" (line-beginning-position))) 
    (if (looking-back " ")
        (progn
          (message "try inserting alias abbrev")
          (insert (symbol-value (intern-soft (completing-read "Expand alias: " mail-abbrevs nil t) mail-abbrevs))))
      (progn
        (message "try eudc")
        (eudc-expand-try-all))))
   ((eq 'message-mode major-mode)
    (completion-at-point))
   ((org-table-p)
    (org-cycle))
   ((looking-back "[ \t\n]")
    (if (eq 'org-mode major-mode)
        (if (looking-back "^\\(\\*+ \\| *|\\)[^\\n]*")     ;a heading or table line
            (org-cycle)
          (indent-for-tab-command)
          )
      (indent-for-tab-command))
    )
   (t
    ;;(consult-company)
    (completion-at-point)
    )))
--8<---------------cut here---------------end--------------->8---

You could use a similar (and much simpler) approach to get what you
want.

HTH,
eric

-- 
: Eric S Fraga, with org release_9.6.4-335-ge065b5 in Emacs 30.0.50

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Suggestion to increase usefulness of TAB key / 'org-cycle' function
  2023-04-28  9:45 ` Fraga, Eric
@ 2023-04-28 15:17   ` Philipp Kiefer
  2023-04-28 17:41     ` Dr. Arne Babenhauserheide
  0 siblings, 1 reply; 9+ messages in thread
From: Philipp Kiefer @ 2023-04-28 15:17 UTC (permalink / raw)
  To: Org Mode List

[-- Attachment #1: Type: text/plain, Size: 2464 bytes --]

Thanks, Eric, I am aware of customization options.

My suggestion was aimed at improving the out-of-the-box experience of (new)
Org users by extending the usefulness of 'org-cycle' by folding the subtree
at point from anywhere inside it that is not itself a parent item rather
than doing nothing at all in those positions. I've used two flavours of
dedicated outlining software for many years and both have easy shortcuts to
fold the current subtree from any position - it is a frequently used action.



Fraga, Eric <e.fraga@ucl.ac.uk> schrieb am Fr., 28. Apr. 2023, 11:45:

> Hi Philipp,
>
> On Friday, 28 Apr 2023 at 10:49, Philipp Kiefer wrote:
> > Well, it could simplify things a good deal further if, on issuing the
> > command when point is *not* on a parent heading, (non-global)
> > org-cycle would instead fold the subtree that point is in, i. e. do
> > 'outline-up-heading' and 'hide-subtree' on the parent heading.
>
> You could always bind TAB to your own command that does this.  As an
> illustration, I have TAB bound to my own function that invokes
> completion instead unless I'm on an org heading!
>
> --8<---------------cut here---------------start------------->8---
> (defun esf/complete-or-indent ()
>   (interactive)
>   (cond
>    ;; ((eq 'message-mode major-mode)
>    ;;  (message-tab))
>    ((and (eq 'message-mode major-mode)
>          (message-point-in-header-p)
>          (looking-back "^\\(To\\|B?[Cc]c\\): *.*"
> (line-beginning-position)))
>     (if (looking-back " ")
>         (progn
>           (message "try inserting alias abbrev")
>           (insert (symbol-value (intern-soft (completing-read "Expand
> alias: " mail-abbrevs nil t) mail-abbrevs))))
>       (progn
>         (message "try eudc")
>         (eudc-expand-try-all))))
>    ((eq 'message-mode major-mode)
>     (completion-at-point))
>    ((org-table-p)
>     (org-cycle))
>    ((looking-back "[ \t\n]")
>     (if (eq 'org-mode major-mode)
>         (if (looking-back "^\\(\\*+ \\| *|\\)[^\\n]*")     ;a heading or
> table line
>             (org-cycle)
>           (indent-for-tab-command)
>           )
>       (indent-for-tab-command))
>     )
>    (t
>     ;;(consult-company)
>     (completion-at-point)
>     )))
> --8<---------------cut here---------------end--------------->8---
>
> You could use a similar (and much simpler) approach to get what you
> want.
>
> HTH,
> eric
>
> --
> : Eric S Fraga, with org release_9.6.4-335-ge065b5 in Emacs 30.0.50

[-- Attachment #2: Type: text/html, Size: 3270 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Suggestion to increase usefulness of TAB key / 'org-cycle' function
  2023-04-28 15:17   ` Philipp Kiefer
@ 2023-04-28 17:41     ` Dr. Arne Babenhauserheide
  2023-04-28 22:28       ` Esteban Ordóñez
  2023-04-30 17:17       ` Philipp Kiefer
  0 siblings, 2 replies; 9+ messages in thread
From: Dr. Arne Babenhauserheide @ 2023-04-28 17:41 UTC (permalink / raw)
  To: Philipp Kiefer; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1170 bytes --]


Philipp Kiefer <phil.kiefer@gmail.com> writes:

> Thanks, Eric, I am aware of customization options.
>
> My suggestion was aimed at improving the out-of-the-box experience of (new) Org users by extending the usefulness of 'org-cycle' by
> folding the subtree at point from anywhere inside it that is not itself a parent item rather than doing nothing at all in those positions.
> I've used two flavours of dedicated outlining software for many years and both have easy shortcuts to fold the current subtree from
> any position - it is a frequently used action.

Do I understand you correctly that you mean tab should cycle visibility
in this case?

* headline
some text
CURSOR IS HERE
- a list

For me tab is useful as it is, because it indents whatever I am writing
right now.

That could be a list-item or a source-block or a verse.

Org is not just for outlining but also for full-blown writing, and that
would be disrupted if tab were to fold the entry away that I’m currently
writing in.

That said: C-c C-t or M-x outline-hide-body

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 1125 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Suggestion to increase usefulness of TAB key / 'org-cycle' function
  2023-04-28 17:41     ` Dr. Arne Babenhauserheide
@ 2023-04-28 22:28       ` Esteban Ordóñez
  2023-04-28 23:19         ` Dr. Arne Babenhauserheide
  2023-04-30 17:17       ` Philipp Kiefer
  1 sibling, 1 reply; 9+ messages in thread
From: Esteban Ordóñez @ 2023-04-28 22:28 UTC (permalink / raw)
  To: emacs-orgmode

Hello Doctor.

> That said: C-c C-t or M-x outline-hide-body

C-c C-t
is org-todo, not outline-hide-body.

Thanks for the clarification.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Suggestion to increase usefulness of TAB key / 'org-cycle' function
  2023-04-28 22:28       ` Esteban Ordóñez
@ 2023-04-28 23:19         ` Dr. Arne Babenhauserheide
  0 siblings, 0 replies; 9+ messages in thread
From: Dr. Arne Babenhauserheide @ 2023-04-28 23:19 UTC (permalink / raw)
  To: Esteban Ordóñez; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 357 bytes --]


Esteban Ordóñez <quiliro@riseup.net> writes:

> Hello Doctor.
>
>> That said: C-c C-t or M-x outline-hide-body
>
> C-c C-t
> is org-todo, not outline-hide-body.

I guess I customized that …

> Thanks for the clarification.

Glad to :-)

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 1125 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Suggestion to increase usefulness of TAB key / 'org-cycle' function
  2023-04-28 17:41     ` Dr. Arne Babenhauserheide
  2023-04-28 22:28       ` Esteban Ordóñez
@ 2023-04-30 17:17       ` Philipp Kiefer
  2023-05-01 18:45         ` Ihor Radchenko
  1 sibling, 1 reply; 9+ messages in thread
From: Philipp Kiefer @ 2023-04-30 17:17 UTC (permalink / raw)
  To: Dr. Arne Babenhauserheide; +Cc: emacs-orgmode


On 28.04.2023 19:41, Dr. Arne Babenhauserheide wrote:
> Philipp Kiefer <phil.kiefer@gmail.com> writes:
>> My suggestion was aimed at improving the out-of-the-box experience of (new) Org users by extending the usefulness of 'org-cycle' by
>> folding the subtree at point from anywhere inside it that is not itself a parent item rather than doing nothing at all in those positions.
>> I've used two flavours of dedicated outlining software for many years and both have easy shortcuts to fold the current subtree from
>> any position - it is a frequently used action.
> Do I understand you correctly that you mean tab should cycle visibility
> in this case?
>
> * headline
> some text
> CURSOR IS HERE
> - a list
Yes, I suggested that in those cases, org-cycle should fold the subtree 
point is in, i. e. fold up to the next parent heading above.
> For me tab is useful as it is, because it indents whatever I am writing
> right now.
>
> That could be a list-item or a source-block or a verse.
>
> Org is not just for outlining but also for full-blown writing, and that
> would be disrupted if tab were to fold the entry away that I’m currently
> writing in.

Hm, for me, TAB does not currently seem to do any indenting anywhere in 
an Org file. Have you changed anything from the default configuration? 
Or maybe I did and forgot about it... But I can find any reference to / 
binding for unmodified tab in my init.el. If so, is this indenting 
handled by 'org-cycle' or is the binding of Tab to 'org-cycle' somehow 
selective based on where in an Org file point is positioned?

If people use tab for indentation in Org out of the box when not on 
headings (which it has never done for me, I think), my suggestion would 
indeed be moot.

> That said: C-c C-t or M-x outline-hide-body

I tried out this command, but it does not do what I have in mind 
(folding subtrees from a non-parent position, not hiding non-heading text).

If tab really does indent in Org files in the default configuration when 
not on a heading, I'd limit my suggestion to the following:

Make 'org-fold-hide-subtree' and / or 'outline-hide-subtree' work from 
anywhere inside a subtree that is not itself a parent heading - not just 
when positioned on the parent heading of the subtree point is in.

Best,

Philipp



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Suggestion to increase usefulness of TAB key / 'org-cycle' function
  2023-04-30 17:17       ` Philipp Kiefer
@ 2023-05-01 18:45         ` Ihor Radchenko
  2023-05-01 20:31           ` Philipp Kiefer
  0 siblings, 1 reply; 9+ messages in thread
From: Ihor Radchenko @ 2023-05-01 18:45 UTC (permalink / raw)
  To: Philipp Kiefer; +Cc: Dr. Arne Babenhauserheide, emacs-orgmode

Philipp Kiefer <phil.kiefer@gmail.com> writes:

>> Do I understand you correctly that you mean tab should cycle visibility
>> in this case?
>>
>> * headline
>> some text
>> CURSOR IS HERE
>> - a list
> Yes, I suggested that in those cases, org-cycle should fold the subtree 
> point is in, i. e. fold up to the next parent heading above.

To get this, just customize `org-cycle-emulate-tab' to nil.

> Hm, for me, TAB does not currently seem to do any indenting anywhere in 
> an Org file.

It just means that <TAB> is not configured to do anything in your Emacs.
By default, the Org's fallback is `org-cycle-emulate-tab' or whatever
global <TAB> is bound to.

> If people use tab for indentation in Org out of the box when not on 
> headings (which it has never done for me, I think), my suggestion would 
> indeed be moot.

<TAB> does a lot of staff. Just read through `org-cycle' docstring.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Suggestion to increase usefulness of TAB key / 'org-cycle' function
  2023-05-01 18:45         ` Ihor Radchenko
@ 2023-05-01 20:31           ` Philipp Kiefer
  0 siblings, 0 replies; 9+ messages in thread
From: Philipp Kiefer @ 2023-05-01 20:31 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Dr. Arne Babenhauserheide, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1007 bytes --]

I see. Thank you for your very helpful reply!

On 01.05.2023 20:45, Ihor Radchenko wrote:
> Philipp Kiefer<phil.kiefer@gmail.com>  writes:
>
>>> Do I understand you correctly that you mean tab should cycle visibility
>>> in this case?
>>>
>>> * headline
>>> some text
>>> CURSOR IS HERE
>>> - a list
>> Yes, I suggested that in those cases, org-cycle should fold the subtree
>> point is in, i. e. fold up to the next parent heading above.
> To get this, just customize `org-cycle-emulate-tab' to nil.
>
>> Hm, for me, TAB does not currently seem to do any indenting anywhere in
>> an Org file.
> It just means that <TAB> is not configured to do anything in your Emacs.
> By default, the Org's fallback is `org-cycle-emulate-tab' or whatever
> global <TAB> is bound to.
>
>> If people use tab for indentation in Org out of the box when not on
>> headings (which it has never done for me, I think), my suggestion would
>> indeed be moot.
> <TAB> does a lot of staff. Just read through `org-cycle' docstring.
>

[-- Attachment #2: Type: text/html, Size: 2018 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-05-01 20:33 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-28  8:49 Suggestion to increase usefulness of TAB key / 'org-cycle' function Philipp Kiefer
2023-04-28  9:45 ` Fraga, Eric
2023-04-28 15:17   ` Philipp Kiefer
2023-04-28 17:41     ` Dr. Arne Babenhauserheide
2023-04-28 22:28       ` Esteban Ordóñez
2023-04-28 23:19         ` Dr. Arne Babenhauserheide
2023-04-30 17:17       ` Philipp Kiefer
2023-05-01 18:45         ` Ihor Radchenko
2023-05-01 20:31           ` Philipp Kiefer

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).