emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Make org-paste-subtree more predictable and useful
@ 2023-01-17 20:14 Philipp Kiefer
  2023-01-18  8:04 ` Ihor Radchenko
  0 siblings, 1 reply; 8+ messages in thread
From: Philipp Kiefer @ 2023-01-17 20:14 UTC (permalink / raw)
  To: emacs-orgmode

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

Hello there, orgmode list, this is my first contribution here, so please be
gentle with me.

I've now used outlining software for the last twenty years at least and it
is my belief that when a user pastes headlines into an outline, they
usually want to make them either A) siblings of (i. e. paste them at the
same level as) or B) children of (i. e. paste them one level below) the
currently focused heading.

Unfortunately, org-paste-subtree currently attempts to "modify the level of
the subtree to make sure the tree fits in nicely at the yank position"
[from Org Manual]. For me, this has meant unpredictable results. As far as
I know, there is currently no way to use the command while making sure the
result will be A) or B) as desired. The user has to wait for the command to
do its "magic" and then move the headings around manually to achieve the
intended result.
With a numeric prefix argument or by yanking after a headline marker, the
user can specify the yank level. But how likely is it that a user will yank
headings to level five under a level two heading?

I can solve my problem with some additional code, in which I determine the
level of the heading at point and then have two functions to call for same
level or child level respectively, but it strikes me as odd that this is
not part of the default options.

My suggestion would be to make a fundamental change to how the command
works, prioritizing definite A) or B) type results over the current vague
"the tree fits in nicely" approach. IMHO the default should be to yank at
the same level as the focused heading. Then, if the C-u 0 numeric prefix
(which currently produces an error message) were used to yank at one level
below that (as subheadings of the focused heading), the functionality of
the other numeric prefixes to set the yank level could be preserved.

Thanks for considering!

Best regards,

Philipp

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

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

* Re: Make org-paste-subtree more predictable and useful
  2023-01-17 20:14 Make org-paste-subtree more predictable and useful Philipp Kiefer
@ 2023-01-18  8:04 ` Ihor Radchenko
  2023-01-18 15:41   ` Philipp Kiefer
  0 siblings, 1 reply; 8+ messages in thread
From: Ihor Radchenko @ 2023-01-18  8:04 UTC (permalink / raw)
  To: Philipp Kiefer; +Cc: emacs-orgmode

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

> Unfortunately, org-paste-subtree currently attempts to "modify the level of
> the subtree to make sure the tree fits in nicely at the yank position"
> [from Org Manual].
> ...
> My suggestion would be to make a fundamental change to how the command
> works, prioritizing definite A) or B) type results over the current vague
> "the tree fits in nicely" approach. IMHO the default should be to yank at
> the same level as the focused heading. Then, if the C-u 0 numeric prefix
> (which currently produces an error message) were used to yank at one level
> below that (as subheadings of the focused heading), the functionality of
> the other numeric prefixes to set the yank level could be preserved.

AFAIU, `org-paste-subtree' already does what you want for the most part.
See the function docstring:

    Paste the clipboard as a subtree, with modification of headline level.
    
    The entire subtree is promoted or demoted in order to match a new headline
    level.
    
    If the cursor is at the beginning of a headline, the same level as
    that headline is used to paste the tree.
    
    If not, the new level is derived from the *visible* headings
    before and after the insertion point, and taken to be the inferior headline
    level of the two.  So if the previous visible heading is level 3 and the
    next is level 4 (or vice versa), level 4 will be used for insertion.
    This makes sure that the subtree remains an independent subtree and does
    not swallow low level entries.

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

* Re: Make org-paste-subtree more predictable and useful
  2023-01-18  8:04 ` Ihor Radchenko
@ 2023-01-18 15:41   ` Philipp Kiefer
  2023-01-19  9:44     ` Ihor Radchenko
  0 siblings, 1 reply; 8+ messages in thread
From: Philipp Kiefer @ 2023-01-18 15:41 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

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

Thanks for addressing my concern, Ihor.

So I can force same-level yank by navigating to the beginning of the 
current headline before calling org-paste-subtree, I see. However, I 
still do not see a way to force it to paste one level below the current 
headline, i. e. to add the trees on the clipboard as child-subtrees or 
the current heading.

My best bet currently is probably to create a blank child heading, add 
some text (there seems to be a glitch turning the blank heading into an 
empty line when pasting with point on the blank dummy heading when it 
has no text), go back to the beginning of the line, then paste the 
subtrees at the level of the dummy heading, navigate back to the dummy 
heading and delete it. I'd really rather not have to do all that to 
achieve my simple goal of pasting subtrees at child level.

As for the claim that the current procedure "makes sure that the subtree 
remains an independent subtree and does not swallow low level entries.", 
either I don't understand it or it isn't true. If I have a level 2 
heading below which is a level 5 heading and I paste subtrees with point 
on the level 2 heading, the level 5 heading is subsumed under the last 
subtree yanked from the clipboard in all cases.

Best,

Philipp

On 18.01.2023 09:04, Ihor Radchenko wrote:
> Philipp Kiefer<phil.kiefer@gmail.com>  writes:
>
>> Unfortunately, org-paste-subtree currently attempts to "modify the level of
>> the subtree to make sure the tree fits in nicely at the yank position"
>> [from Org Manual].
>> ...
>> My suggestion would be to make a fundamental change to how the command
>> works, prioritizing definite A) or B) type results over the current vague
>> "the tree fits in nicely" approach. IMHO the default should be to yank at
>> the same level as the focused heading. Then, if the C-u 0 numeric prefix
>> (which currently produces an error message) were used to yank at one level
>> below that (as subheadings of the focused heading), the functionality of
>> the other numeric prefixes to set the yank level could be preserved.
> AFAIU, `org-paste-subtree' already does what you want for the most part.
> See the function docstring:
>
>      Paste the clipboard as a subtree, with modification of headline level.
>      
>      The entire subtree is promoted or demoted in order to match a new headline
>      level.
>      
>      If the cursor is at the beginning of a headline, the same level as
>      that headline is used to paste the tree.
>      
>      If not, the new level is derived from the *visible* headings
>      before and after the insertion point, and taken to be the inferior headline
>      level of the two.  So if the previous visible heading is level 3 and the
>      next is level 4 (or vice versa), level 4 will be used for insertion.
>      This makes sure that the subtree remains an independent subtree and does
>      not swallow low level entries.
>

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

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

* Re: Make org-paste-subtree more predictable and useful
  2023-01-18 15:41   ` Philipp Kiefer
@ 2023-01-19  9:44     ` Ihor Radchenko
  2023-01-19 17:31       ` Philipp Kiefer
  0 siblings, 1 reply; 8+ messages in thread
From: Ihor Radchenko @ 2023-01-19  9:44 UTC (permalink / raw)
  To: Philipp Kiefer; +Cc: emacs-orgmode

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

> Thanks for addressing my concern, Ihor.
>
> So I can force same-level yank by navigating to the beginning of the 
> current headline before calling org-paste-subtree, I see. However, I 
> still do not see a way to force it to paste one level below the current 
> headline, i. e. to add the trees on the clipboard as child-subtrees or 
> the current heading.
>
> My best bet currently is probably to create a blank child heading, add 
> some text (there seems to be a glitch turning the blank heading into an 
> empty line when pasting with point on the blank dummy heading when it 
> has no text), go back to the beginning of the line, then paste the 
> subtrees at the level of the dummy heading, navigate back to the dummy 
> heading and delete it. I'd really rather not have to do all that to 
> achieve my simple goal of pasting subtrees at child level.

Just paste the subtree and press C-S-<right> to demote it immediately.
It would not save you many keystrokes if there was yet another prefix
argument.

> As for the claim that the current procedure "makes sure that the subtree 
> remains an independent subtree and does not swallow low level entries.", 
> either I don't understand it or it isn't true. If I have a level 2 
> heading below which is a level 5 heading and I paste subtrees with point 
> on the level 2 heading, the level 5 heading is subsumed under the last 
> subtree yanked from the clipboard in all cases.

Sorry, but I cannot reproduce.
Could you please provide detailed instructions about what you did?

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

* Re: Make org-paste-subtree more predictable and useful
  2023-01-19  9:44     ` Ihor Radchenko
@ 2023-01-19 17:31       ` Philipp Kiefer
  2023-01-20 10:12         ` [BUG] org-paste-subtree level when point is in the middle of a heading (was: Make org-paste-subtree more predictable and useful) Ihor Radchenko
  2023-01-20 10:21         ` [FR] Add C-u and C-u C-u prefix arguments to org-paste-subtree " Ihor Radchenko
  0 siblings, 2 replies; 8+ messages in thread
From: Philipp Kiefer @ 2023-01-19 17:31 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

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

I've uploaded two screencasts to illustrate the issues described in my 
last message:

1. Org Mode-paste subtree low-level item swallowed: 
https://imgur.com/a/CZ5lDaH . This relates to what I assume the passage 
from the manual is trying to say should not happen:

"makes sure that the subtree
remains an independent subtree and does not swallow low level entries."

2. Org Mode-paste subtree on empty heading glitch: 
https://imgur.com/a/AT5pDj6 . See my last message.

Further, you suggest I use C-S-<right> to demote the subtree after 
pasting it at the same level as the subtree at point. But what if I used 
a numerical prefix argument to copy or cut several subtrees, maybe 5 or 
10? Not very convenient at all to demote them all by hand...

I still hold that pasting headings / subtress either at the same level 
or at the child level of the target heading is part of the bread and 
butter of outline editing and should be as straightforward as possible. 
I'm rather sure the current numeric prefixes of org-paste-subtree to 
select a distinct level at which to paste are needed / used much less 
frequently than a "paste at child level" prefix (maybe C-u C-u?) would 
be if it was implemented.

Best

Philipp


On 19.01.2023 10:44, Ihor Radchenko wrote:
> Philipp Kiefer<phil.kiefer@gmail.com>  writes:
>
>> Thanks for addressing my concern, Ihor.
>>
>> So I can force same-level yank by navigating to the beginning of the
>> current headline before calling org-paste-subtree, I see. However, I
>> still do not see a way to force it to paste one level below the current
>> headline, i. e. to add the trees on the clipboard as child-subtrees or
>> the current heading.
>>
>> My best bet currently is probably to create a blank child heading, add
>> some text (there seems to be a glitch turning the blank heading into an
>> empty line when pasting with point on the blank dummy heading when it
>> has no text), go back to the beginning of the line, then paste the
>> subtrees at the level of the dummy heading, navigate back to the dummy
>> heading and delete it. I'd really rather not have to do all that to
>> achieve my simple goal of pasting subtrees at child level.
> Just paste the subtree and press C-S-<right> to demote it immediately.
> It would not save you many keystrokes if there was yet another prefix
> argument.
>
>> As for the claim that the current procedure "makes sure that the subtree
>> remains an independent subtree and does not swallow low level entries.",
>> either I don't understand it or it isn't true. If I have a level 2
>> heading below which is a level 5 heading and I paste subtrees with point
>> on the level 2 heading, the level 5 heading is subsumed under the last
>> subtree yanked from the clipboard in all cases.
> Sorry, but I cannot reproduce.
> Could you please provide detailed instructions about what you did?
>

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

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

* [BUG] org-paste-subtree level when point is in the middle of a heading (was: Make org-paste-subtree more predictable and useful)
  2023-01-19 17:31       ` Philipp Kiefer
@ 2023-01-20 10:12         ` Ihor Radchenko
  2023-01-20 10:21         ` [FR] Add C-u and C-u C-u prefix arguments to org-paste-subtree " Ihor Radchenko
  1 sibling, 0 replies; 8+ messages in thread
From: Ihor Radchenko @ 2023-01-20 10:12 UTC (permalink / raw)
  To: Philipp Kiefer; +Cc: emacs-orgmode

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

> 1. Org Mode-paste subtree low-level item swallowed: 
> https://imgur.com/a/CZ5lDaH . This relates to what I assume the passage 
> from the manual is trying to say should not happen:
>
> "makes sure that the subtree
> remains an independent subtree and does not swallow low level entries."

Confirmed. But what would be the expected behavior here? Inserting
before the heading at point? After?

Steps to reproduce:

1. Create a file

**** 1.1.1.1
**** 1.1.1.2
* 3
** 3.1
*** 3.1.<point>1
************ low-level item
*** 3.1.2
*** 3.1.3

2. Copy the first two headings
3. Move point as indicated
4. M-x org-paste-subtree

Observed: 1.* headings inserted after 3.1.1 and before "low-level-item",
thus breaking the sub-tree.

> 2. Org Mode-paste subtree on empty heading glitch: 
> https://imgur.com/a/AT5pDj6 . See my last message.

Fixed, on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=c92769a50

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

* [FR] Add C-u and C-u C-u prefix arguments to org-paste-subtree (was: Make org-paste-subtree more predictable and useful)
  2023-01-19 17:31       ` Philipp Kiefer
  2023-01-20 10:12         ` [BUG] org-paste-subtree level when point is in the middle of a heading (was: Make org-paste-subtree more predictable and useful) Ihor Radchenko
@ 2023-01-20 10:21         ` Ihor Radchenko
  2023-01-20 19:27           ` Philipp Kiefer
  1 sibling, 1 reply; 8+ messages in thread
From: Ihor Radchenko @ 2023-01-20 10:21 UTC (permalink / raw)
  To: Philipp Kiefer; +Cc: emacs-orgmode

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

> Further, you suggest I use C-S-<right> to demote the subtree after 
> pasting it at the same level as the subtree at point. But what if I used 
> a numerical prefix argument to copy or cut several subtrees, maybe 5 or 
> 10? Not very convenient at all to demote them all by hand...
>
> I still hold that pasting headings / subtress either at the same level 
> or at the child level of the target heading is part of the bread and 
> butter of outline editing and should be as straightforward as possible. 
> I'm rather sure the current numeric prefixes of org-paste-subtree to 
> select a distinct level at which to paste are needed / used much less 
> frequently than a "paste at child level" prefix (maybe C-u C-u?) would 
> be if it was implemented.

Could you please provide concrete ideas what C-u/C-u C-u should do?
In particular, how it will interact with point located at heading,
at heading beginning, at empty heading, or inside a heading section.

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

* Re: [FR] Add C-u and C-u C-u prefix arguments to org-paste-subtree (was: Make org-paste-subtree more predictable and useful)
  2023-01-20 10:21         ` [FR] Add C-u and C-u C-u prefix arguments to org-paste-subtree " Ihor Radchenko
@ 2023-01-20 19:27           ` Philipp Kiefer
  0 siblings, 0 replies; 8+ messages in thread
From: Philipp Kiefer @ 2023-01-20 19:27 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode


On 20.01.2023 11:21, Ihor Radchenko wrote:
> Philipp Kiefer <phil.kiefer@gmail.com> writes:
>
>> Further, you suggest I use C-S-<right> to demote the subtree after
>> pasting it at the same level as the subtree at point. But what if I used
>> a numerical prefix argument to copy or cut several subtrees, maybe 5 or
>> 10? Not very convenient at all to demote them all by hand...
>>
>> I still hold that pasting headings / subtress either at the same level
>> or at the child level of the target heading is part of the bread and
>> butter of outline editing and should be as straightforward as possible.
>> I'm rather sure the current numeric prefixes of org-paste-subtree to
>> select a distinct level at which to paste are needed / used much less
>> frequently than a "paste at child level" prefix (maybe C-u C-u?) would
>> be if it was implemented.
> Could you please provide concrete ideas what C-u/C-u C-u should do?
> In particular, how it will interact with point located at heading,
> at heading beginning, at empty heading, or inside a heading section.
To be honest, I don't see much need for fine-grained special cases. I'd 
be very happy with C-u yanking at the level of the heading at point and 
C-u C-u yanking at one level below that, regardless of the exact 
position of point. I realize that would mean C-u doubling what can 
already be done by calling org-paste-subtree with point at the beginning 
of a heading but accessing both options (paste as sibling or child) with 
a single or repeat C-u seems more consistent to me than having one 
depend on position and getting at the other via the command prefix.

Thanks a lot for your dedication in working on this!


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

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

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-17 20:14 Make org-paste-subtree more predictable and useful Philipp Kiefer
2023-01-18  8:04 ` Ihor Radchenko
2023-01-18 15:41   ` Philipp Kiefer
2023-01-19  9:44     ` Ihor Radchenko
2023-01-19 17:31       ` Philipp Kiefer
2023-01-20 10:12         ` [BUG] org-paste-subtree level when point is in the middle of a heading (was: Make org-paste-subtree more predictable and useful) Ihor Radchenko
2023-01-20 10:21         ` [FR] Add C-u and C-u C-u prefix arguments to org-paste-subtree " Ihor Radchenko
2023-01-20 19:27           ` 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).