summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleh Krehel <ohwoeowho@gmail.com>2015-10-19 14:00:24 +0200
committerOleh Krehel <ohwoeowho@gmail.com>2015-10-19 14:03:58 +0200
commit481719fbd5751aaa9c672b762cb43aea8ee986b0 (patch)
tree78a50ada38007efe1f803dbc42b4a48600fda8b6
parenta709aed145e2e95db60835495126f351828e27dd (diff)
downloadorg-mode-481719fbd5751aaa9c672b762cb43aea8ee986b0.tar.gz
Clear non-repeated SCHEDULED when marking a repeated DEADLINE done
* lisp/org.el (org-auto-repeat-maybe): When a TODO has a DEADLINE that's repeatable, but SCHEDULED that isn't repeatable, clear the SCHEDULED after setting the current repeat to DONE. The repeatable SCHEDULED will be re-scheduled as before. Reference: http://stackoverflow.com/questions/18123972/emacs-org-mode-clear-non-repeated-scheduled-time-when-deadline-is-repeated
-rwxr-xr-xlisp/org.el14
1 files changed, 9 insertions, 5 deletions
diff --git a/lisp/org.el b/lisp/org.el
index f26ee69..a5183aa 100755
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -13245,12 +13245,15 @@ This function is run automatically after each state change to a DONE state."
(setq type (if (match-end 1) org-scheduled-string
(if (match-end 3) org-deadline-string "Plain:"))
ts (match-string (if (match-end 2) 2 (if (match-end 4) 4 0))))
- (when (string-match "\\([.+]\\)?\\(\\+[0-9]+\\)\\([hdwmy]\\)" ts)
- (setq n (string-to-number (match-string 2 ts))
+ (if (not (string-match "\\([.+]\\)?\\(\\+[0-9]+\\)\\([hdwmy]\\)" ts))
+ (org-remove-timestamp-with-keyword org-scheduled-string)
+ (setq n (string-to-number (match-string 2 ts))
what (match-string 3 ts))
(if (equal what "w") (setq n (* n 7) what "d"))
- (if (and (equal what "h") (not (string-match "[0-9]\\{1,2\\}:[0-9]\\{2\\}" ts)))
- (user-error "Cannot repeat in Repeat in %d hour(s) because no hour has been set" n))
+ (if (and (equal what "h")
+ (not (string-match "[0-9]\\{1,2\\}:[0-9]\\{2\\}" ts)))
+ (user-error
+ "Cannot repeat in Repeat in %d hour(s) because no hour has been set" n))
;; Preparation, see if we need to modify the start date for the change
(when (match-end 1)
(setq time (save-match-data (org-time-string-to-time ts)))
@@ -13277,7 +13280,8 @@ This function is run automatically after each state change to a DONE state."
(org-at-timestamp-p t)
(setq ts (match-string 1))
(string-match "\\([.+]\\)?\\(\\+[0-9]+\\)\\([hdwmy]\\)" ts))))
- (save-excursion (org-timestamp-change n (cdr (assoc what whata)) nil t))
+ (save-excursion
+ (org-timestamp-change n (cdr (assoc what whata)) nil t))
(setq msg (concat msg type " " org-last-changed-timestamp " "))))
(setq org-log-post-message msg)
(message "%s" msg))))