emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Christian Barthel <bch@online.de>
To: emacs-orgmode@gnu.org
Subject: org-clone-subtree-with-time-shift with reverse order
Date: Wed, 10 Apr 2024 22:10:10 +0200	[thread overview]
Message-ID: <87le5lyo65.fsf@shell.onfire.org> (raw)

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

I'd like to suggest adding a new prefix arg i.e.
`C-u C-u org-clone-subtree-with-item-shift' to reverse
the order of newly created / cloned siblings.  Would
that be of interest for other orgmode users?

Diff file is attached.

--
Christian Barthel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org.el-prepend.patch --]
[-- Type: text/x-diff, Size: 1443 bytes --]

diff -u --label \#\<buffer\ org.el.gz\> --label \#\<buffer\ org.el\> /tmp/buffer-content-gd7Tiz /tmp/buffer-content-QbeeNi
--- #<buffer org.el.gz>
+++ #<buffer org.el>
@@ -7342,7 +7342,11 @@
 As described above, N+1 clones are produced when the original
 subtree has a repeater.  Setting N to 0, then, can be used to
 remove the repeater from a subtree and create a shifted clone
-with the original repeater."
+with the original repeater.
+
+The new siblings will normally be appended.  When using `C-u C-u'
+prefix argument, the siblings will be prepended.
+"
   (interactive "nNumber of clones to produce: ")
   (unless (wholenump n) (user-error "Invalid number of replications %s" n))
   (when (org-before-first-heading-p) (user-error "No subtree to clone"))
@@ -7388,7 +7392,7 @@
 	(setq nmin 0)
 	(setq nmax (1+ nmax))
 	(setq n-no-remove nmax))
-      (goto-char end)
+      (goto-char (if (equal current-prefix-arg '(16)) beg end))
       (cl-loop for n from nmin to nmax do
 	       (insert
 		;; Prepare clone.
@@ -7418,7 +7422,8 @@
 			  (goto-char (match-beginning 0))
 			  (when (looking-at "<[^<>\n]+\\( +[.+]?\\+[0-9]+[hdwmy]\\)")
 			    (delete-region (match-beginning 1) (match-end 1)))))))
-		  (buffer-string)))))
+		  (buffer-string)))
+	       (if (equal current-prefix-arg '(16)) (goto-char beg))))
     (goto-char beg)))

 ;;; Outline path

Diff finished.  Wed Apr 10 11:42:21 2024

             reply	other threads:[~2024-04-10 20:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-10 20:10 Christian Barthel [this message]
2024-04-11 14:07 ` org-clone-subtree-with-time-shift with reverse order Ihor Radchenko
2024-04-14  8:59   ` Christian Barthel
2024-04-14 13:17     ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87le5lyo65.fsf@shell.onfire.org \
    --to=bch@online.de \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).