emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Clone tree backwards in time
@ 2019-01-10  4:26 Scott Randby
  2019-01-14  1:23 ` Yasushi SHOJI
  0 siblings, 1 reply; 8+ messages in thread
From: Scott Randby @ 2019-01-10  4:26 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

On occasion, I need to clone a tree backwards in time. I tried using something like -2d (instead of the usual +2d) without success. Is there a way to clone backwards in time?

Scott Randby

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

* Re: Clone tree backwards in time
  2019-01-10  4:26 Clone tree backwards in time Scott Randby
@ 2019-01-14  1:23 ` Yasushi SHOJI
  2019-01-15 19:05   ` Scott Randby
  0 siblings, 1 reply; 8+ messages in thread
From: Yasushi SHOJI @ 2019-01-14  1:23 UTC (permalink / raw)
  To: Scott Randby; +Cc: emacs-org list

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

Hi,

On Thu, Jan 10, 2019 at 1:28 PM Scott Randby <srandby@gmail.com> wrote:
> On occasion, I need to clone a tree backwards in time. I tried using something like -2d (instead of the usual +2d) without success. Is there a way to clone backwards in time?

How about this?
-- 
            yashi

[-- Attachment #2: 0001-clone-Allow-time-shift-in-backward.patch --]
[-- Type: text/x-patch, Size: 1678 bytes --]

From 5d421e09f80dde295bbd4541059f5d432dce2c59 Mon Sep 17 00:00:00 2001
From: Yasushi SHOJI <yasushi.shoji@gmail.com>
Date: Mon, 14 Jan 2019 10:19:50 +0900
Subject: [PATCH] clone: Allow time shift in backward

Make org-clone-subtree-with-time-shift accept a negative value to
shift the timestamp in backward.
---
 lisp/org.el              |  2 +-
 testing/lisp/test-org.el | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index 0b090ee39..19b1946a0 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -8451,7 +8451,7 @@ with the original repeater."
 		"")))			;No time shift
 	 (doshift
 	  (and (org-string-nw-p shift)
-	       (or (string-match "\\`[ \t]*\\+?\\([0-9]+\\)\\([dwmy]\\)[ \t]*\\'"
+	       (or (string-match "\\`[ \t]*\\([\\+\\-]?[0-9]+\\)\\([dwmy]\\)[ \t]*\\'"
 				 shift)
 		   (user-error "Invalid shift specification %s" shift)))))
     (goto-char end-of-tree)
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 976b7d8d6..db34a03c2 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -1496,6 +1496,18 @@
 	    (replace-regexp-in-string
 	     "\\( [.A-Za-z]+\\)\\( \\+[0-9][hdmwy]\\)?>" "" (buffer-string)
 	     nil nil 1))))
+  ;; Clone repeating once in backward.
+  (should
+   (equal "\
+* H1\n<2015-06-21>
+* H1\n<2015-06-19>
+* H1\n<2015-06-17 +1w>
+"
+	  (org-test-with-temp-text "* H1\n<2015-06-21 Sun +1w>"
+	    (org-clone-subtree-with-time-shift 1 "-2d")
+	    (replace-regexp-in-string
+	     "\\( [.A-Za-z]+\\)\\( \\+[0-9][hdmwy]\\)?>" "" (buffer-string)
+	     nil nil 1))))
   ;; Clone non-repeating zero times.
   (should
    (equal "\
-- 
2.20.1


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

* Re: Clone tree backwards in time
  2019-01-14  1:23 ` Yasushi SHOJI
@ 2019-01-15 19:05   ` Scott Randby
  2019-01-16 14:06     ` Yasushi SHOJI
  0 siblings, 1 reply; 8+ messages in thread
From: Scott Randby @ 2019-01-15 19:05 UTC (permalink / raw)
  To: Yasushi SHOJI, emacs-org list

On 1/13/19 8:23 PM, Yasushi SHOJI wrote:
> On Thu, Jan 10, 2019 at 1:28 PM Scott Randby <srandby@gmail.com> wrote:
>> On occasion, I need to clone a tree backwards in time. I tried using something like -2d (instead of the usual +2d) without success. Is there a way to clone backwards in time?
> 
> How about this?

Unfortunately, I don't have the knowledge needed to test your patch, but it seems good to me. Any possibility of testing this and maybe incorporating it into Org?

Scott
 

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

* Re: Clone tree backwards in time
  2019-01-15 19:05   ` Scott Randby
@ 2019-01-16 14:06     ` Yasushi SHOJI
  2019-01-18 17:56       ` Nicolas Goaziou
  0 siblings, 1 reply; 8+ messages in thread
From: Yasushi SHOJI @ 2019-01-16 14:06 UTC (permalink / raw)
  To: Scott Randby; +Cc: emacs-org list

Hi,

Unfortunately, I don't have write permission to the repo.  So we need
to ask one of the maintainers to merge it.
I can put it in my personal github repo, if that helps.
-- 
             yashi

On Wed, Jan 16, 2019 at 4:05 AM Scott Randby <srandby@gmail.com> wrote:
>
> On 1/13/19 8:23 PM, Yasushi SHOJI wrote:
> > On Thu, Jan 10, 2019 at 1:28 PM Scott Randby <srandby@gmail.com> wrote:
> >> On occasion, I need to clone a tree backwards in time. I tried using something like -2d (instead of the usual +2d) without success. Is there a way to clone backwards in time?
> >
> > How about this?
>
> Unfortunately, I don't have the knowledge needed to test your patch, but it seems good to me. Any possibility of testing this and maybe incorporating it into Org?
>
> Scott
>

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

* Re: Clone tree backwards in time
  2019-01-16 14:06     ` Yasushi SHOJI
@ 2019-01-18 17:56       ` Nicolas Goaziou
  2019-01-21  9:09         ` Yasushi SHOJI
  0 siblings, 1 reply; 8+ messages in thread
From: Nicolas Goaziou @ 2019-01-18 17:56 UTC (permalink / raw)
  To: Yasushi SHOJI; +Cc: Scott Randby, emacs-org list

Hello,

Yasushi SHOJI <yasushi.shoji@gmail.com> writes:

> Unfortunately, I don't have write permission to the repo.  So we need
> to ask one of the maintainers to merge it.

Sure. Could you also add an entry in ORG NEWS on that feature?

Note you can also ask for write permission to Bastien, if you're
interested.

Regards,

-- 
Nicolas Goaziou

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

* Re: Clone tree backwards in time
  2019-01-18 17:56       ` Nicolas Goaziou
@ 2019-01-21  9:09         ` Yasushi SHOJI
  2019-01-21 17:49           ` Nicolas Goaziou
  0 siblings, 1 reply; 8+ messages in thread
From: Yasushi SHOJI @ 2019-01-21  9:09 UTC (permalink / raw)
  To: Yasushi SHOJI, Scott Randby, emacs-org list

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

Hi Nicolas,

On Sat, Jan 19, 2019 at 2:56 AM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
> Yasushi SHOJI <yasushi.shoji@gmail.com> writes:
>
> > Unfortunately, I don't have write permission to the repo.  So we need
> > to ask one of the maintainers to merge it.
>
> Sure. Could you also add an entry in ORG NEWS on that feature?

Done.

> Note you can also ask for write permission to Bastien, if you're
> interested.

If you don't mind reviewing my patches via email, I'm just OK without it.
-- 
          yashi

[-- Attachment #2: 0001-org-clone-Allow-time-shift-in-backward.patch --]
[-- Type: text/x-patch, Size: 2587 bytes --]

From 852385892a293e2a3479846a3f96e98678ba93d3 Mon Sep 17 00:00:00 2001
From: Yasushi SHOJI <yasushi.shoji@gmail.com>
Date: Mon, 14 Jan 2019 10:19:50 +0900
Subject: [PATCH] org-clone: Allow time shift in backward

Make `org-clone-subtree-with-time-shift` accept a negative value to
shift the timestamp in backward.

Reported-by: Scott Randby <srandby@gmail.com>
<http://lists.gnu.org/r/emacs-orgmode/2019-01/msg00151.html>

Signed-off-by: Yasushi SHOJI <yasushi.shoji@gmail.com>
---
 etc/ORG-NEWS             |  5 +++++
 lisp/org.el              |  2 +-
 testing/lisp/test-org.el | 12 ++++++++++++
 3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index e06d0c09b..4821cfa85 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -104,6 +104,11 @@ A 'native option was added to org-highlight-latex-and-related. It
 matches the same structures than 'latex but it calls
 org-src-font-lock-fontify-block instead, thus bringing about full
 LaTeX font locking.
+*** ~org-clone-subtree-with-time-shift~ learnt to shift backward in time
+=<C-c C-x c>= (~org-clone-subtree-with-time-shift~) now takes a
+negative value as a valid repeater to shift time stamps in backward
+in cloned subtrees.  You can give, for example, ‘-3d’ to shift three
+days in the past.
 
 ** New functions
 *** ~org-dynamic-block-insert-dblock~
diff --git a/lisp/org.el b/lisp/org.el
index 5c11de7b6..e71ba73e6 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -8452,7 +8452,7 @@ with the original repeater."
 		"")))			;No time shift
 	 (doshift
 	  (and (org-string-nw-p shift)
-	       (or (string-match "\\`[ \t]*\\+?\\([0-9]+\\)\\([dwmy]\\)[ \t]*\\'"
+	       (or (string-match "\\`[ \t]*\\([\\+\\-]?[0-9]+\\)\\([dwmy]\\)[ \t]*\\'"
 				 shift)
 		   (user-error "Invalid shift specification %s" shift)))))
     (goto-char end-of-tree)
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 976b7d8d6..db34a03c2 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -1496,6 +1496,18 @@
 	    (replace-regexp-in-string
 	     "\\( [.A-Za-z]+\\)\\( \\+[0-9][hdmwy]\\)?>" "" (buffer-string)
 	     nil nil 1))))
+  ;; Clone repeating once in backward.
+  (should
+   (equal "\
+* H1\n<2015-06-21>
+* H1\n<2015-06-19>
+* H1\n<2015-06-17 +1w>
+"
+	  (org-test-with-temp-text "* H1\n<2015-06-21 Sun +1w>"
+	    (org-clone-subtree-with-time-shift 1 "-2d")
+	    (replace-regexp-in-string
+	     "\\( [.A-Za-z]+\\)\\( \\+[0-9][hdmwy]\\)?>" "" (buffer-string)
+	     nil nil 1))))
   ;; Clone non-repeating zero times.
   (should
    (equal "\
-- 
2.20.1


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

* Re: Clone tree backwards in time
  2019-01-21  9:09         ` Yasushi SHOJI
@ 2019-01-21 17:49           ` Nicolas Goaziou
  2019-01-21 18:02             ` Scott Randby
  0 siblings, 1 reply; 8+ messages in thread
From: Nicolas Goaziou @ 2019-01-21 17:49 UTC (permalink / raw)
  To: Yasushi SHOJI; +Cc: Scott Randby, emacs-org list

Hello,

Yasushi SHOJI <yasushi.shoji@gmail.com> writes:

> Done.

Thank you. Applied now.

> If you don't mind reviewing my patches via email, I'm just OK without
> it.

Fair enough.

Regards,

-- 
Nicolas Goaziou

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

* Re: Clone tree backwards in time
  2019-01-21 17:49           ` Nicolas Goaziou
@ 2019-01-21 18:02             ` Scott Randby
  0 siblings, 0 replies; 8+ messages in thread
From: Scott Randby @ 2019-01-21 18:02 UTC (permalink / raw)
  To: Yasushi SHOJI, emacs-org list

On 1/21/19 12:49 PM, Nicolas Goaziou wrote:
> Hello,
> 
> Yasushi SHOJI <yasushi.shoji@gmail.com> writes:
> 
>> Done.
> 
> Thank you. Applied now.

Yasushi: Thank you for your patch.

Scott

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

end of thread, other threads:[~2019-01-21 18:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-10  4:26 Clone tree backwards in time Scott Randby
2019-01-14  1:23 ` Yasushi SHOJI
2019-01-15 19:05   ` Scott Randby
2019-01-16 14:06     ` Yasushi SHOJI
2019-01-18 17:56       ` Nicolas Goaziou
2019-01-21  9:09         ` Yasushi SHOJI
2019-01-21 17:49           ` Nicolas Goaziou
2019-01-21 18:02             ` Scott Randby

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