From 1fbc7a424f703f86235c4c5b30caab6604b8feb7 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Tue, 17 Jan 2017 20:46:06 -0500 Subject: [PATCH] org-clone-subtree-with-time-shift: Fix SHIFT check * lisp/org.el (org-clone-subtree-with-time-shift): Don't choke on a blank SHIFT argument. * testing/lisp/test-org.el (test-org/clone-with-time-shift): Add test. This fixes a regression introduced by c31462f33. --- lisp/org.el | 8 ++++---- testing/lisp/test-org.el | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index ea123abe2..ea07cc077 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -8990,10 +8990,10 @@ with the original repeater." "Date shift per clone (e.g. +1w, empty to copy unchanged): ") ""))) ;No time shift (doshift - (or (not (org-string-nw-p shift)) - (string-match "\\`[ \t]*\\+?\\([0-9]+\\)\\([dwmy]\\)[ \t]*\\'" - shift) - (user-error "Invalid shift specification %s" shift)))) + (and (org-string-nw-p shift) + (or (string-match "\\`[ \t]*\\+?\\([0-9]+\\)\\([dwmy]\\)[ \t]*\\'" + shift) + (user-error "Invalid shift specification %s" shift))))) (goto-char end-of-tree) (unless (bolp) (insert "\n")) (let* ((end (point)) diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 8702aab3f..4d299a94d 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -1365,6 +1365,14 @@ (replace-regexp-in-string "\\( [.A-Za-z]+\\)\\( \\+[0-9][hdmwy]\\)?>" "" (buffer-string) nil nil 1)))) + ;; Clone with blank SHIFT argument. + (should + (string-prefix-p + "* H <2012-03-29" + (org-test-with-temp-text "* H <2012-03-29 Thu>" + (org-clone-subtree-with-time-shift 1 "") + (buffer-substring-no-properties (line-beginning-position 2) + (line-end-position 2))))) ;; Find time stamps before point. If SHIFT is not specified, ask ;; for a time shift. (should