summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2021-02-25 00:02:41 -0500
committerKyle Meyer <kyle@kyleam.com>2021-02-25 00:05:51 -0500
commit15c73854583e500725aba56edda4f93ce45d8ccd (patch)
tree1035983e8ea3c4bb04e0ac24bca4088a864c4c67
parent9e98e9a731daf7bc11985edae29d01203027dcd0 (diff)
downloadorg-mode-15c73854583e500725aba56edda4f93ce45d8ccd.tar.gz
org-clone-subtree-with-time-shift: Support hour time shift
* lisp/org.el (org-clone-subtree-with-time-shift): Support hour time shift. * testing/lisp/test-org.el (test-org/clone-with-time-shift): Add tests. Suggested-by: Felipe Barros <felipebarros@protonmail.com> Link: https://orgmode.org/list/urqRSSSRsE8In5xtAPBR8AZalNGUCBkwwVV8ujNSN8_AOyh0reiE8XMrY6eviTBYUsV5fCF5GyJAtw7FB8xo-XBPPpYHOnP0zQuce4odhI8=@protonmail.com
-rw-r--r--lisp/org.el3
-rw-r--r--testing/lisp/test-org.el26
2 files changed, 27 insertions, 2 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 7d87334..0059656 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -7906,7 +7906,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]+\\)\\([hdwmy]\\)[ \t]*\\'"
shift)
(user-error "Invalid shift specification %s" shift)))))
(goto-char end-of-tree)
@@ -7916,6 +7916,7 @@ with the original repeater."
(shift-n (and doshift (string-to-number (match-string 1 shift))))
(shift-what (pcase (and doshift (match-string 2 shift))
(`nil nil)
+ ("h" 'hour)
("d" 'day)
("w" (setq shift-n (* 7 shift-n)) 'day)
("m" 'month)
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 78cd295..2d727ba 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -1804,7 +1804,31 @@
(lambda (&rest args) "+1d")))
(org-clone-subtree-with-time-shift 1))
(buffer-substring-no-properties (line-beginning-position 2)
- (line-end-position 2))))))
+ (line-end-position 2)))))
+ ;; Hour shift.
+ (should
+ (equal "\
+* H1\n<2015-06-21 20:00>
+* H1\n<2015-06-21 23:00>
+* H1\n<2015-06-22 02:00>
+"
+ (org-test-with-temp-text "* H1\n<2015-06-21 Sun 20:00>"
+ (org-clone-subtree-with-time-shift 2 "+3h")
+ (replace-regexp-in-string
+ "\\( [.A-Za-z]+\\)\\( [0-9][0-9]:[0-9][0-9]\\)?>" ""
+ (buffer-substring-no-properties (point-min) (point-max))
+ nil nil 1))))
+ (should
+ (equal "\
+* H1\n<2015-06-21 20:00>
+* H1\n<2015-06-21 18:00>
+"
+ (org-test-with-temp-text "* H1\n<2015-06-21 Sun 20:00>"
+ (org-clone-subtree-with-time-shift 1 "-2h")
+ (replace-regexp-in-string
+ "\\( [.A-Za-z]+\\)\\( [0-9][0-9]:[0-9][0-9]\\)?>" ""
+ (buffer-substring-no-properties (point-min) (point-max))
+ nil nil 1)))))
;;; Fixed-Width Areas