emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Bug: org-clone-subtree-with-time-shift not asking for time-shift
@ 2017-01-16 11:48 Karl Voit
  2017-01-16 14:50 ` Karl Voit
  2017-01-16 17:56 ` Kyle Meyer
  0 siblings, 2 replies; 10+ messages in thread
From: Karl Voit @ 2017-01-16 11:48 UTC (permalink / raw)
  To: emacs-orgmode

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 too had issues with not being asked for a time-shift but I was not
able to determine that this is related to cursor location when
org-clone-subtree-with-time-shift is invoked.

Here are my test cases:

*** [2017-02-28 Mi] no time-shift with cursor after [

*** <2017-02-28 Mi> no time-shift with cursor after <

*** <2017-02-28 Wed> no time-shift with cursor after <

*** <2017-02-28 Wed 09:00-10:00> no time-shift with cursor after <

*** no time-shift with cursor after [
SCHEDULED: <2017-01-16 Mon>
:PROPERTIES:
:CREATED:  [2017-01-16 Mon 12:32]
:END:

*** no time-shift with cursor after <
SCHEDULED: <2017-01-16 Mon>

"no time-shift with cursor after X" means that when the cursor is
placed before the character X, no time-shift is being asked. If the
cursor is on X or after X, the user gets asked to enter a time-shift
as desired.

Following test case works independent of the cursor position:

*** <2017-01-16 Mon> time-shift works
:PROPERTIES:
:CREATED:  [2017-01-16 Mon 12:29]
:END:

I do thing that this is a bug and not a hidden feature.


Org mode version 9.0.1 (release_9.0.1-55-g51efd7)

-- 
get mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML into Org-mode:
       > get Memacs from https://github.com/novoid/Memacs <
Personal Information Management > http://Karl-Voit.at/tags/pim/
Emacs-related > http://Karl-Voit.at/tags/emacs/

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

* Re: Bug: org-clone-subtree-with-time-shift not asking for time-shift
  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
  1 sibling, 0 replies; 10+ messages in thread
From: Karl Voit @ 2017-01-16 14:50 UTC (permalink / raw)
  To: emacs-orgmode

* Karl Voit <devnull@Karl-Voit.at> wrote:
>
> 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.

He is using Org-mode version 8.2.10.

-- 
get mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML into Org-mode:
       > get Memacs from https://github.com/novoid/Memacs <
Personal Information Management > http://Karl-Voit.at/tags/pim/
Emacs-related > http://Karl-Voit.at/tags/emacs/

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

* Re: Bug: org-clone-subtree-with-time-shift not asking for time-shift
  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
  2017-01-16 21:31   ` Nicolas Goaziou
  1 sibling, 1 reply; 10+ messages in thread
From: Kyle Meyer @ 2017-01-16 17:56 UTC (permalink / raw)
  To: Karl Voit; +Cc: Karl Voit, emacs-orgmode

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

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

* Re: Bug: org-clone-subtree-with-time-shift not asking for time-shift
  2017-01-16 17:56 ` Kyle Meyer
@ 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
  0 siblings, 2 replies; 10+ messages in thread
From: Nicolas Goaziou @ 2017-01-16 21:31 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: Karl Voit, Karl Voit, emacs-orgmode

Hello,

Kyle Meyer <kyle@kyleam.com> writes:

> 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>

Thank you. I applied your patch with an additional check.

Regards,

-- 
Nicolas Goaziou

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

* Re: Bug: org-clone-subtree-with-time-shift not asking for time-shift (FIXED)
  2017-01-16 21:31   ` Nicolas Goaziou
@ 2017-01-16 22:07     ` Karl Voit
  2017-01-16 22:23     ` Bug: org-clone-subtree-with-time-shift not asking for time-shift Kyle Meyer
  1 sibling, 0 replies; 10+ messages in thread
From: Karl Voit @ 2017-01-16 22:07 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

* Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
>
> Kyle Meyer <kyle@kyleam.com> writes:
>
>> Subject: [PATCH] org-clone-subtree-with-time-shift: Fix timestamp search
>
> Thank you. I applied your patch with an additional check.

I pulled the fix from "maint" and I re-tested my test cases: issue
is fixed at my side.

Thanks Kyle and Nicolas - another example of true awesomeness of
this community!

-- 
get mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML into Org-mode:
       > get Memacs from https://github.com/novoid/Memacs <
Personal Information Management > http://Karl-Voit.at/tags/pim/
Emacs-related > http://Karl-Voit.at/tags/emacs/

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

* Re: Bug: org-clone-subtree-with-time-shift not asking for time-shift
  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     ` Kyle Meyer
  2017-01-16 22:30       ` Karl Voit
  1 sibling, 1 reply; 10+ messages in thread
From: Kyle Meyer @ 2017-01-16 22:23 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Karl Voit, Karl Voit, emacs-orgmode

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Thank you. I applied your patch with an additional check.

Thanks.  The additional check looks good, as it replaces an error with a
more appropriate user-error and gives an error message that is a bit
more specific.

However, the re-positioning of the org-back-to-heading call seems
problematic because the call is now wrapped in a save-excursion, but the
downstream code expects point to be at the beginning of the heading.

When I call org-clone-subtree-with-time-shift with point at the end of

    *** heading <2017-02-28 Wed>

I get the following error:

    Debugger entered--Lisp error: (error "Before first headline at position 1 in buffer  *temp*")
      signal(error ("Before first headline at position 1 in buffer  *temp*"))
      error("Before first headline at position %d in buffer %s" 1 #<buffer  *temp*>)
      (condition-case nil (outline-back-to-heading invisible-ok) (error (error "Before first headline at position %d in buffer %s" (point) (current-buffer))))
      org-back-to-heading(t)
      org-end-of-subtree(t t)
      (save-excursion (org-end-of-subtree t t))
      (outline-flag-region (point) (save-excursion (org-end-of-subtree t t)) nil)
      org-show-subtree()
      [...]
      org-clone-subtree-with-time-shift(2)
      funcall-interactively(org-clone-subtree-with-time-shift 2)
      call-interactively(org-clone-subtree-with-time-shift nil nil)
      command-execute(org-clone-subtree-with-time-shift)

I think this is because beg isn't set to the beginning of the heading.

But given Karl's recent email saying that the changes in maint fixed his
test cases, maybe I'm missing something ...

--
Kyle

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

* Re: Bug: org-clone-subtree-with-time-shift not asking for time-shift
  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
  0 siblings, 1 reply; 10+ messages in thread
From: Karl Voit @ 2017-01-16 22:30 UTC (permalink / raw)
  To: emacs-orgmode

* Kyle Meyer <kyle@kyleam.com> wrote:
>
> Thanks.  The additional check looks good, as it replaces an error with a
> more appropriate user-error and gives an error message that is a bit
> more specific.
>
> However, the re-positioning of the org-back-to-heading call seems
> problematic because the call is now wrapped in a save-excursion, but the
> downstream code expects point to be at the beginning of the heading.
>
> When I call org-clone-subtree-with-time-shift with point at the end of
>
>     *** heading <2017-02-28 Wed>
> I get the following error:
>     Debugger entered--Lisp error: (error "Before first headline at position 1 in buffer  *temp*")
[...]
> I think this is because beg isn't set to the beginning of the heading.
>
> But given Karl's recent email saying that the changes in maint fixed his
> test cases, maybe I'm missing something ...

I have to excuse myself: I tested not good enough: I only tested my
cases for being asked for the time-shift and not finished executing
the cases.

You're right, I can confirm your issue. I get "Before first headline
at position 1 in buffer  *temp*" as well.

-- 
get mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML into Org-mode:
       > get Memacs from https://github.com/novoid/Memacs <
Personal Information Management > http://Karl-Voit.at/tags/pim/
Emacs-related > http://Karl-Voit.at/tags/emacs/

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

* Re: Bug: org-clone-subtree-with-time-shift not asking for time-shift
  2017-01-16 22:30       ` Karl Voit
@ 2017-01-17  8:54         ` Nicolas Goaziou
  2017-01-18  2:42           ` Kyle Meyer
  0 siblings, 1 reply; 10+ messages in thread
From: Nicolas Goaziou @ 2017-01-17  8:54 UTC (permalink / raw)
  To: Karl Voit; +Cc: Karl Voit, emacs-orgmode

Hello,

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

> * Kyle Meyer <kyle@kyleam.com> wrote:
>>
>> Thanks.  The additional check looks good, as it replaces an error with a
>> more appropriate user-error and gives an error message that is a bit
>> more specific.
>>
>> However, the re-positioning of the org-back-to-heading call seems
>> problematic because the call is now wrapped in a save-excursion, but the
>> downstream code expects point to be at the beginning of the heading.
>>
>> When I call org-clone-subtree-with-time-shift with point at the end of
>>
>>     *** heading <2017-02-28 Wed>
>> I get the following error:
>>     Debugger entered--Lisp error: (error "Before first headline at position 1 in buffer  *temp*")
> [...]
>> I think this is because beg isn't set to the beginning of the heading.
>>
>> But given Karl's recent email saying that the changes in maint fixed his
>> test cases, maybe I'm missing something ...
>
> I have to excuse myself: I tested not good enough: I only tested my
> cases for being asked for the time-shift and not finished executing
> the cases.
>
> You're right, I can confirm your issue. I get "Before first headline
> at position 1 in buffer  *temp*" as well.

Fixed (hopefully) this time.

Thank you.

Regards,

-- 
Nicolas Goaziou

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

* Re: Bug: org-clone-subtree-with-time-shift not asking for time-shift
  2017-01-17  8:54         ` Nicolas Goaziou
@ 2017-01-18  2:42           ` Kyle Meyer
  2017-01-18 11:11             ` Nicolas Goaziou
  0 siblings, 1 reply; 10+ messages in thread
From: Kyle Meyer @ 2017-01-18  2:42 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Karl Voit, Karl Voit, emacs-orgmode

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

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

[...]

>> You're right, I can confirm your issue. I get "Before first headline
>> at position 1 in buffer  *temp*" as well.
>
> Fixed (hopefully) this time.

Yes, c31462f33 resolved the issue.  That commit also introduced a
regression: a blank string passed as the SHIFT argument causes an error.
I've followed up with 1fbc7a424 to restore the previous behavior.

Thanks.

--
Kyle

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

* Re: Bug: org-clone-subtree-with-time-shift not asking for time-shift
  2017-01-18  2:42           ` Kyle Meyer
@ 2017-01-18 11:11             ` Nicolas Goaziou
  0 siblings, 0 replies; 10+ messages in thread
From: Nicolas Goaziou @ 2017-01-18 11:11 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: Karl Voit, Karl Voit, emacs-orgmode

Hello,

Kyle Meyer <kyle@kyleam.com> writes:

> Yes, c31462f33 resolved the issue.  That commit also introduced a
> regression: a blank string passed as the SHIFT argument causes an error.
> I've followed up with 1fbc7a424 to restore the previous behavior.

Indeed. Thank you.

Regards,

-- 
Nicolas Goaziou

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

end of thread, other threads:[~2017-01-18 11:11 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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).