emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Kyle Meyer <kyle@kyleam.com>
To: Karl Voit <devnull@Karl-Voit.at>
Cc: Karl Voit <news1142@Karl-Voit.at>, emacs-orgmode@gnu.org
Subject: Re: Bug: org-clone-subtree-with-time-shift not asking for time-shift
Date: Mon, 16 Jan 2017 12:56:01 -0500	[thread overview]
Message-ID: <87h94yga8e.fsf@kyleam.com> (raw)
In-Reply-To: <2017-01-16T12-42-31@devnull.Karl-Voit.at> (Karl Voit's message of "Mon, 16 Jan 2017 12:48:38 +0100")

Karl Voit <devnull@Karl-Voit.at> writes:

> Hi!
>
> I wrote a blog article on how I am using Org with recurring events
> or tasks:
> http://karl-voit.at/2017/01/15/org-clone-subtree-with-time-shift/
>
> As Michael Maurer stated in a comment below,
> org-clone-subtree-with-time-shift does not ask for time-shift
> depending on the location of the cursor.

I think org-back-to-heading should be called before the timestamp
search:

--8<---------------cut here---------------start------------->8---
Subject: [PATCH] org-clone-subtree-with-time-shift: Fix timestamp search

* lisp/org.el (org-clone-subtree-with-time-shift): Move to the
  beginning of the heading before the timestamp search so that the
  user will be prompted for a time shift even if point is after the
  timestamp.

This also prevents an "Invalid search bound" error if point is on the
blank line following a body-less heading:

   * single line <2017-02-28 Wed>
    <point here>

Reported-by: Karl Voit <devnull@Karl-Voit.at>
<http://permalink.gmane.org/gmane.emacs.orgmode/111456>
---
 lisp/org.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index 3c27f642a..f0ff80f68 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -8976,6 +8976,7 @@ (defun org-clone-subtree-with-time-shift (n &optional shift)
 remove the repeater from a subtree and create a shifted clone
 with the original repeater."
   (interactive "nNumber of clones to produce: ")
+  (org-back-to-heading t)
   (let ((shift
 	 (or shift
 	     (if (and (not (equal current-prefix-arg '(4)))
@@ -9005,7 +9006,6 @@ (defun org-clone-subtree-with-time-shift (n &optional shift)
 				     ("m" . month) ("y" . year))))))
     (when (eq shift-what 'week) (setq shift-n (* 7 shift-n) shift-what 'day))
     (setq nmin 1 nmax n)
-    (org-back-to-heading t)
     (setq beg (point))
     (setq idprop (org-entry-get nil "ID"))
     (org-end-of-subtree t t)
-- 
2.11.0

--8<---------------cut here---------------end--------------->8---

-- 
Kyle

  parent reply	other threads:[~2017-01-16 17:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-16 11:48 Bug: org-clone-subtree-with-time-shift not asking for time-shift Karl Voit
2017-01-16 14:50 ` Karl Voit
2017-01-16 17:56 ` Kyle Meyer [this message]
2017-01-16 21:31   ` Nicolas Goaziou
2017-01-16 22:07     ` Bug: org-clone-subtree-with-time-shift not asking for time-shift (FIXED) Karl Voit
2017-01-16 22:23     ` Bug: org-clone-subtree-with-time-shift not asking for time-shift Kyle Meyer
2017-01-16 22:30       ` Karl Voit
2017-01-17  8:54         ` Nicolas Goaziou
2017-01-18  2:42           ` Kyle Meyer
2017-01-18 11:11             ` Nicolas Goaziou

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=87h94yga8e.fsf@kyleam.com \
    --to=kyle@kyleam.com \
    --cc=devnull@Karl-Voit.at \
    --cc=emacs-orgmode@gnu.org \
    --cc=news1142@Karl-Voit.at \
    /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).