all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* new org mode, changed folding behavior could be improved / more consistent
@ 2023-02-06 20:08 Laurenz Wiskott
  2023-02-06 20:44 ` Laurenz Wiskott
  2023-02-08 11:31 ` Ihor Radchenko
  0 siblings, 2 replies; 6+ messages in thread
From: Laurenz Wiskott @ 2023-02-06 20:08 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

org mode has apparently been rewritten somehow.  At least I noticed a few differences
after updating to the new Debian version.  For instance, it got much faster.  GREAT!

There is one feature however that I really miss: It used to be that I could add an entry
with a certain number of stars in the first line, and then 'org-global-cycle' using S-TAB
would allow to make all the headlines visible only up to that many stars.  For instance,
a file with


*** -
* 1
  Text 1
** 2
   Text 2
*** 3
    Text 3
**** 4
     Text 4

after one or two S-TAB (depending on the initial folding state) would look like

*** -
* 1
** 2
*** 3

without the 4-star headline visible.  If I remove one star in the first line and type
S-TAB once or twice, then it looks like

** -
* 1
** 2

I found that a convenient way of controlling the depth of the CONTENT view (I believe it
is called).  That does not work any more.  Typing S-TAB once or twice leads to the
CONTENTS view that shows all headlines, no matter how many stars and independently of the
first line.

I have read that I can get the desired behavior with a numerical argument.  So, I have a
work around.  GREAT!

However, I find it inconsistent, that 'org-global-cycle' and 'org-cycle' work
differently.  The latter shows the old behavior (GREAT!), but can apparently not be
controlled directly with a numerical argument, while for the former it is the other way
around.

I suggest, to enable the trick with the first line for both 'org-global-cycle' and
'org-cycle' and to also enable overwriting this with a numerical argument.

Here is an example for 'org-cycle'

* 1
*** -
** A
*** Aa
    Text
** B
*** Ba
**** Ba1
     Text

Typing TAB once or twice (depending on the initial folding state) on the main headline (*
1) yields the view:

* 1
*** -
** A
*** Aa
** B
*** Ba

If I remove one star in the second line (*** -), typing TAB yields

* 1
** -
** A
** B

So, that still works.  But a numerical argument has no effect.  However, I found that C-c
TAB (org-show-children) does this, but why not just numerical argument plus TAB, like for
S-TAB?

Anyhow, I am extremely grateful for the org-mode and I use it daily.  Thanks a lot.

Best,

Laurenz Wiskott.


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

* Re: new org mode, changed folding behavior could be improved / more consistent
  2023-02-06 20:08 new org mode, changed folding behavior could be improved / more consistent Laurenz Wiskott
@ 2023-02-06 20:44 ` Laurenz Wiskott
  2023-02-08 11:31 ` Ihor Radchenko
  1 sibling, 0 replies; 6+ messages in thread
From: Laurenz Wiskott @ 2023-02-06 20:44 UTC (permalink / raw)
  To: emacs-orgmode

PS: I use org-mode version 9.4

On Mon, Feb 06, 2023 at 09:08:16PM +0100, Laurenz Wiskott wrote:
> Hi,
> 
> org mode has apparently been rewritten somehow.  At least I noticed a few differences
> after updating to the new Debian version.  For instance, it got much faster.  GREAT!
> 
> There is one feature however that I really miss: It used to be that I could add an entry
> with a certain number of stars in the first line, and then 'org-global-cycle' using S-TAB
> would allow to make all the headlines visible only up to that many stars.  For instance,
> a file with
> 
> 
> *** -
> * 1
>   Text 1
> ** 2
>    Text 2
> *** 3
>     Text 3
> **** 4
>      Text 4
> 
> after one or two S-TAB (depending on the initial folding state) would look like
> 
> *** -
> * 1
> ** 2
> *** 3
> 
> without the 4-star headline visible.  If I remove one star in the first line and type
> S-TAB once or twice, then it looks like
> 
> ** -
> * 1
> ** 2
> 
> I found that a convenient way of controlling the depth of the CONTENT view (I believe it
> is called).  That does not work any more.  Typing S-TAB once or twice leads to the
> CONTENTS view that shows all headlines, no matter how many stars and independently of the
> first line.
> 
> I have read that I can get the desired behavior with a numerical argument.  So, I have a
> work around.  GREAT!
> 
> However, I find it inconsistent, that 'org-global-cycle' and 'org-cycle' work
> differently.  The latter shows the old behavior (GREAT!), but can apparently not be
> controlled directly with a numerical argument, while for the former it is the other way
> around.
> 
> I suggest, to enable the trick with the first line for both 'org-global-cycle' and
> 'org-cycle' and to also enable overwriting this with a numerical argument.
> 
> Here is an example for 'org-cycle'
> 
> * 1
> *** -
> ** A
> *** Aa
>     Text
> ** B
> *** Ba
> **** Ba1
>      Text
> 
> Typing TAB once or twice (depending on the initial folding state) on the main headline (*
> 1) yields the view:
> 
> * 1
> *** -
> ** A
> *** Aa
> ** B
> *** Ba
> 
> If I remove one star in the second line (*** -), typing TAB yields
> 
> * 1
> ** -
> ** A
> ** B
> 
> So, that still works.  But a numerical argument has no effect.  However, I found that C-c
> TAB (org-show-children) does this, but why not just numerical argument plus TAB, like for
> S-TAB?
> 
> Anyhow, I am extremely grateful for the org-mode and I use it daily.  Thanks a lot.
> 
> Best,
> 
> Laurenz Wiskott.


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

* Re: new org mode, changed folding behavior could be improved / more consistent
  2023-02-06 20:08 new org mode, changed folding behavior could be improved / more consistent Laurenz Wiskott
  2023-02-06 20:44 ` Laurenz Wiskott
@ 2023-02-08 11:31 ` Ihor Radchenko
       [not found]   ` <Y+OR/4eRUdrSJQ6P@curry>
  2023-03-29 13:00   ` new org mode, changed folding behavior could be improved / more consistent Ihor Radchenko
  1 sibling, 2 replies; 6+ messages in thread
From: Ihor Radchenko @ 2023-02-08 11:31 UTC (permalink / raw)
  To: Laurenz Wiskott; +Cc: emacs-orgmode

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

Laurenz Wiskott <laurenz.wiskott@rub.de> writes:

> There is one feature however that I really miss: It used to be that I could add an entry
> with a certain number of stars in the first line, and then 'org-global-cycle' using S-TAB
> would allow to make all the headlines visible only up to that many stars.  For instance,
> a file with
>
>
> *** -
> * 1
> ...
> after one or two S-TAB (depending on the initial folding state) would look like
>
> *** -
> * 1
> ** 2
> *** 3
>
> without the 4-star headline visible.  If I remove one star in the first line and type
> S-TAB once or twice, then it looks like
>
> ** -
> * 1
> ** 2
>
> I found that a convenient way of controlling the depth of the CONTENT view (I believe it
> is called).  That does not work any more.  Typing S-TAB once or twice leads to the
> CONTENTS view that shows all headlines, no matter how many stars and independently of the
> first line.

This was not documented and caused by implementation detail.

> Here is an example for 'org-cycle'
>
> * 1
> *** -
> ** A
> *** Aa
> ...
> Typing TAB once or twice (depending on the initial folding state) on the main headline (*
> 1) yields the view:
>
> * 1
> *** -
> ** A
> *** Aa
> ** B
> *** Ba

It is a bug in `org-fold-show-children'. The reason your example works
has nothing to do with what the function intends to do.

Fix is attached.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-fold-show-children-Only-display-direct-children-.patch --]
[-- Type: text/x-patch, Size: 2859 bytes --]

From a5e8062b258fc7c4e4d4129278101a8d20bb43c4 Mon Sep 17 00:00:00 2001
Message-Id: <a5e8062b258fc7c4e4d4129278101a8d20bb43c4.1675855848.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@posteo.net>
Date: Wed, 8 Feb 2023 14:29:30 +0300
Subject: [PATCH] org-fold-show-children: Only display direct children by
 default

* lisp/org-fold.el (org-fold-show-children): Clarify the docstring
emphasizing that direct children are always displayed.  Fix
grandchildren being displayed when the first child has deeper level
than the next children.
---
 lisp/org-fold.el | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/lisp/org-fold.el b/lisp/org-fold.el
index 1b7ca22b0..f9c604155 100644
--- a/lisp/org-fold.el
+++ b/lisp/org-fold.el
@@ -419,20 +419,21 @@ (defun org-fold-show-siblings ()
 
 (defun org-fold-show-children (&optional level)
   "Show all direct subheadings of this heading.
-Prefix arg LEVEL is how many levels below the current level
-should be shown.  Default is enough to cause the following
-heading to appear."
+Prefix arg LEVEL is how many levels below the current level should be
+shown.  If direct subheadings are deeper than LEVEL, they are still
+displayed."
   (interactive "p")
   (unless (org-before-first-heading-p)
     (save-excursion
       (org-with-limited-levels (org-back-to-heading t))
       (let* ((current-level (funcall outline-level))
+             (parent-level current-level)
              (max-level (org-get-valid-level
-                         current-level
+                         parent-level
                          (if level (prefix-numeric-value level) 1)))
+             (min-level-direct-child most-positive-fixnum)
              (end (save-excursion (org-end-of-subtree t t)))
              (regexp-fmt "^\\*\\{%d,%s\\}\\(?: \\|$\\)")
-             (past-first-child nil)
              ;; Make sure to skip inlinetasks.
              (re (format regexp-fmt
                          current-level
@@ -448,11 +449,12 @@ (defun org-fold-show-children (&optional level)
         ;; MAX-LEVEL.  Since we want to display it anyway, adjust
         ;; MAX-LEVEL accordingly.
         (while (re-search-forward re end t)
-          (unless past-first-child
-            (setq re (format regexp-fmt
-                             current-level
-                             (max (funcall outline-level) max-level)))
-            (setq past-first-child t))
+          (setq current-level (funcall outline-level))
+          (when (< current-level min-level-direct-child)
+            (setq min-level-direct-child current-level
+                  re (format regexp-fmt
+                             parent-level
+                             (max min-level-direct-child max-level))))
           (org-fold-heading nil))))))
 
 (defun org-fold-show-subtree ()
-- 
2.39.1


[-- Attachment #3: Type: text/plain, Size: 225 bytes --]



-- 
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 related	[flat|nested] 6+ messages in thread

* Re: new org mode, changed folding behavior could be improved / more consistent
       [not found]       ` <Y+USPxfpI4FXeNuX@curry>
@ 2023-02-10 11:03         ` Ihor Radchenko
       [not found]           ` <Y+i5i7oQ8BdSfBmk@curry>
  0 siblings, 1 reply; 6+ messages in thread
From: Ihor Radchenko @ 2023-02-10 11:03 UTC (permalink / raw)
  To: Laurenz Wiskott; +Cc: emacs-orgmode

[ Adding Org ML back to CC ]

Laurenz Wiskott <laurenz.wiskott@rub.de> writes:

>> What about only enabling this feature when you pass "0" prefix argument:
>> C-u 0 S-<tab> ?
>
> I would like to avoid the extra key strokes, and I don't know why that should be needed.
> What could this first star-line be used for except to indicate a specific default
> unfolding depth?  So, I don't think anybody would use it without this intention, and
> therefore there is no need to introduce these extra key strokes.

People do all kinds of weird things including deeply nested entry on top.
I did not mean toggling, I did mean only having the proposed behavior
only with C-u 0 S-<TAB> key sequence.

In any case, I now reviewed the manual and I think that you can use
alternative approach to set which headings are visible in overview
folding state.

Try

#+STARTUP: show3levels
* 1
  Text 1
** 2
   Text 2
*** 3
    Text 3
**** 4
     Text 4

and then C-u C-u <TAB>

-- 
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] 6+ messages in thread

* [FR] Use empty ***** heading to indicate folding depth in org-cycle for a subtree (was: new org mode, changed folding behavior could be improved / more consistent)
       [not found]           ` <Y+i5i7oQ8BdSfBmk@curry>
@ 2023-02-13 15:02             ` Ihor Radchenko
  0 siblings, 0 replies; 6+ messages in thread
From: Ihor Radchenko @ 2023-02-13 15:02 UTC (permalink / raw)
  To: Laurenz Wiskott; +Cc: emacs-orgmode


[ Adding Org ML back to CC ]

Please, use reply-all in future when replying to emails in the mailing
list. Otherwise, the discussion will not be seen by other Org developers
and interested users.

Laurenz Wiskott <laurenz.wiskott@rub.de> writes:

>> #+STARTUP: show3levels
>
> trick does not seem to work with version 9.5.2 yet.  It would also open the whole file.

Indeed, I am talking about the latest Org.

> But what I want is to TAB on a headline, and it only opens up to some predefined depth.
> 'ESC 3 SHIFT-TAB' does the trick for level 3, for instance.  With my proposal, using an
> initial line with three stars, I currently save the 'ESC 3 SHIFT-'.  I know it is
> considered unintended behavior.  But nobody seems to have complained about this 'bug',
> thus I suggest to just leave it in there and recover it also on the global level, where
> it currently does not work anymore.  But anyhow, if you don't like it, I can also live
> with 'ESC 3 SHIFT-TAB' instead of jut 'TAB'.

Note that you may achieve what you want in personal config with appropriate `org-cycle-hook'.

I am renaming this to feature request. I see not great need to add and
_maintain_ this feature, unless more people are interested.

The suggested idea, AFAIU, is

* Top heading
empty heading indicating to what level 'children cycle state is
revealing the headings.
***
** Sub 1 <displayed on cycle>
*** Sub 1.1 <also displayed, as indicated by first ***>
*** Sub 1.1.1 <not displayed>
** Sub 2 <displayed>

If one starts from

* Top heading...

and <TAB>

it is suggested to display

* Top heading
empty heading indicating to what level 'children cycle state is
revealing the headings.
***
** Sub 1
*** Sub 1.1...
** Sub 2

instead of current behavior with

* Top heading
empty heading indicating to what level 'children cycle state is
revealing the headings.
***
** Sub 1...
** Sub 2

-- 
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] 6+ messages in thread

* Re: new org mode, changed folding behavior could be improved / more consistent
  2023-02-08 11:31 ` Ihor Radchenko
       [not found]   ` <Y+OR/4eRUdrSJQ6P@curry>
@ 2023-03-29 13:00   ` Ihor Radchenko
  1 sibling, 0 replies; 6+ messages in thread
From: Ihor Radchenko @ 2023-03-29 13:00 UTC (permalink / raw)
  To: Laurenz Wiskott; +Cc: emacs-orgmode

Ihor Radchenko <yantar92@posteo.net> writes:

> It is a bug in `org-fold-show-children'. The reason your example works
> has nothing to do with what the function intends to do.
>
> Fix is attached.
> From a5e8062b258fc7c4e4d4129278101a8d20bb43c4 Mon Sep 17 00:00:00 2001
> Message-Id: <a5e8062b258fc7c4e4d4129278101a8d20bb43c4.1675855848.git.yantar92@posteo.net>
> From: Ihor Radchenko <yantar92@posteo.net>
> Date: Wed, 8 Feb 2023 14:29:30 +0300
> Subject: [PATCH] org-fold-show-children: Only display direct children by
>  default

Applied, onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=05ae26897

-- 
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] 6+ messages in thread

end of thread, other threads:[~2023-03-29 13:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-06 20:08 new org mode, changed folding behavior could be improved / more consistent Laurenz Wiskott
2023-02-06 20:44 ` Laurenz Wiskott
2023-02-08 11:31 ` Ihor Radchenko
     [not found]   ` <Y+OR/4eRUdrSJQ6P@curry>
     [not found]     ` <874jrvccwo.fsf@localhost>
     [not found]       ` <Y+USPxfpI4FXeNuX@curry>
2023-02-10 11:03         ` Ihor Radchenko
     [not found]           ` <Y+i5i7oQ8BdSfBmk@curry>
2023-02-13 15:02             ` [FR] Use empty ***** heading to indicate folding depth in org-cycle for a subtree (was: new org mode, changed folding behavior could be improved / more consistent) Ihor Radchenko
2023-03-29 13:00   ` new org mode, changed folding behavior could be improved / more consistent Ihor Radchenko

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.