diff options
author | Yasushi SHOJI <yasushi.shoji@gmail.com> | 2019-01-14 10:19:50 +0900 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2019-01-21 18:47:49 +0100 |
commit | 4a076ed545e517d90564bb4a9e25aee09d51b803 (patch) | |
tree | 59a5a5b04f71efcda392f3b9a24449b147a58370 | |
parent | c7e306d665fadc827fac42d0500855d19ebb89c0 (diff) | |
download | org-mode-4a076ed545e517d90564bb4a9e25aee09d51b803.tar.gz |
Allow cloning subtrees while shifting them backward in time
* lisp/org.el (org-clone-subtree-with-time-shift): Accept a negative
value to shift the timestamp backward in time.
* testing/lisp/test-org.el (test-org/clone-with-time-shift): Add test.
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>
-rw-r--r-- | etc/ORG-NEWS | 5 | ||||
-rw-r--r-- | lisp/org.el | 2 | ||||
-rw-r--r-- | testing/lisp/test-org.el | 12 |
3 files changed, 18 insertions, 1 deletions
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index e06d0c0..4821cfa 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 5c11de7..e71ba73 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 976b7d8..db34a03 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 "\ |