branch: externals/org commit 15c73854583e500725aba56edda4f93ce45d8ccd Author: Kyle Meyer <k...@kyleam.com> Commit: Kyle Meyer <k...@kyleam.com>
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 <felipebar...@protonmail.com> Link: https://orgmode.org/list/urqRSSSRsE8In5xtAPBR8AZalNGUCBkwwVV8ujNSN8_AOyh0reiE8XMrY6eviTBYUsV5fCF5GyJAtw7FB8xo-XBPPpYHOnP0zQuce4odhI8=@protonmail.com --- lisp/org.el | 3 ++- testing/lisp/test-org.el | 26 +++++++++++++++++++++++++- 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