From 4375a941cc7513442cc9f72b51c85d7346af1826 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Tue, 18 Nov 2014 10:11:35 +0100 Subject: [PATCH] Fix SCHEDULED property retrieval * lisp/org.el (org-entry-properties): Fix storing SCHEDULED property when specific argument is not specified. * testing/lisp/test-org.el (test-org/entry-properties): Add test. Reported-by: Richard Lawrence --- lisp/org.el | 28 +++++++++++++--------------- testing/lisp/test-org.el | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 15 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index aaa09d84a..8fa895817 100755 --- a/lisp/org.el +++ b/lisp/org.el @@ -15629,25 +15629,23 @@ strings." (forward-line) (when (org-looking-at-p org-planning-line-re) (end-of-line) - (let ((bol (line-beginning-position))) - ;; Backward compatibility: time keywords used to be - ;; configurable (before 8.3). Make sure we get the - ;; correct keyword. - (dolist (k (if (not specific) - (list org-closed-string - org-deadline-string - org-scheduled-string) - (list (cond ((string= specific "CLOSED") - org-closed-string) - ((string= specific "DEADLINE") - org-deadline-string) - (t org-scheduled-string))))) + (let ((bol (line-beginning-position)) + ;; Backward compatibility: time keywords used to + ;; be configurable (before 8.3). Make sure we + ;; get the correct keyword. + (key-assoc `(("CLOSED" . ,org-closed-string) + ("DEADLINE" . ,org-deadline-string) + ("SCHEDULED" . ,org-scheduled-string)))) + (dolist (pair (if specific (list (assoc specific key-assoc)) + key-assoc)) (save-excursion - (when (search-backward k bol t) + (when (search-backward (cdr pair) bol t) (goto-char (match-end 0)) (skip-chars-forward " \t") (and (looking-at org-ts-regexp-both) - (push (cons specific (match-string 0)) props))))))) + (push (cons (car pair) + (org-match-string-no-properties 0)) + props))))))) (when specific (throw 'exit props))) (when (or (not specific) (member specific '("TIMESTAMP" "TIMESTAMP_IA"))) diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index f48e8b117..cacfd8de2 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -2642,11 +2642,19 @@ Text. (equal "* H" (org-test-with-temp-text "* TODO H" (cdr (assoc "ITEM" (org-entry-properties nil "ITEM")))))) + (should + (equal "* H" + (org-test-with-temp-text "* TODO H" + (cdr (assoc "ITEM" (org-entry-properties)))))) ;; Get "TODO" property. (should (equal "TODO" (org-test-with-temp-text "* TODO H" (cdr (assoc "TODO" (org-entry-properties nil "TODO")))))) + (should + (equal "TODO" + (org-test-with-temp-text "* TODO H" + (cdr (assoc "TODO" (org-entry-properties)))))) (should-not (org-test-with-temp-text "* H" (assoc "TODO" (org-entry-properties nil "TODO")))) @@ -2655,6 +2663,10 @@ Text. (equal "A" (org-test-with-temp-text "* [#A] H" (cdr (assoc "PRIORITY" (org-entry-properties nil "PRIORITY")))))) + (should + (equal "A" + (org-test-with-temp-text "* [#A] H" + (cdr (assoc "PRIORITY" (org-entry-properties)))))) (should-not (org-test-with-temp-text "* H" (assoc "PRIORITY" (org-entry-properties nil "PRIORITY")))) @@ -2663,6 +2675,10 @@ Text. (org-test-with-temp-text-in-file "* H\nParagraph" (org-file-equal-p (cdr (assoc "FILE" (org-entry-properties nil "FILE"))) (buffer-file-name)))) + (should + (org-test-with-temp-text-in-file "* H\nParagraph" + (org-file-equal-p (cdr (assoc "FILE" (org-entry-properties))) + (buffer-file-name)))) (should-not (org-test-with-temp-text "* H\nParagraph" (cdr (assoc "FILE" (org-entry-properties nil "FILE"))))) @@ -2671,6 +2687,10 @@ Text. (equal ":tag1:tag2:" (org-test-with-temp-text "* H :tag1:tag2:" (cdr (assoc "TAGS" (org-entry-properties nil "TAGS")))))) + (should + (equal ":tag1:tag2:" + (org-test-with-temp-text "* H :tag1:tag2:" + (cdr (assoc "TAGS" (org-entry-properties)))))) (should-not (org-test-with-temp-text "* H" (cdr (assoc "TAGS" (org-entry-properties nil "TAGS"))))) @@ -2679,6 +2699,10 @@ Text. (equal ":tag1:tag2:" (org-test-with-temp-text "* H :tag1:\n** H2 :tag2:" (cdr (assoc "ALLTAGS" (org-entry-properties nil "ALLTAGS")))))) + (should + (equal ":tag1:tag2:" + (org-test-with-temp-text "* H :tag1:\n** H2 :tag2:" + (cdr (assoc "ALLTAGS" (org-entry-properties)))))) (should-not (org-test-with-temp-text "* H" (cdr (assoc "ALLTAGS" (org-entry-properties nil "ALLTAGS"))))) @@ -2691,6 +2715,13 @@ Text. '(org-block-todo-from-children-or-siblings-or-parent))) (cdr (assoc "BLOCKED" (org-entry-properties nil "BLOCKED"))))))) (should + (equal "t" + (org-test-with-temp-text "* Blocked\n** DONE one\n** TODO two" + (let ((org-enforce-todo-dependencies t) + (org-blocker-hook + '(org-block-todo-from-children-or-siblings-or-parent))) + (cdr (assoc "BLOCKED" (org-entry-properties))))))) + (should (equal "" (org-test-with-temp-text "* Blocked\n** DONE one\n** DONE two" (let ((org-enforce-todo-dependencies t)) @@ -2701,6 +2732,11 @@ Text. "[2012-03-29 thu.]" (org-test-with-temp-text "* H\nCLOSED: [2012-03-29 thu.]" (cdr (assoc "CLOSED" (org-entry-properties nil "CLOSED")))))) + (should + (equal + "[2012-03-29 thu.]" + (org-test-with-temp-text "* H\nCLOSED: [2012-03-29 thu.]" + (cdr (assoc "CLOSED" (org-entry-properties)))))) (should-not (org-test-with-temp-text "* H" (cdr (assoc "CLOSED" (org-entry-properties nil "CLOSED"))))) @@ -2709,6 +2745,11 @@ Text. "<2014-03-04 tue.>" (org-test-with-temp-text "* H\nDEADLINE: <2014-03-04 tue.>" (cdr (assoc "DEADLINE" (org-entry-properties nil "DEADLINE")))))) + (should + (equal + "<2014-03-04 tue.>" + (org-test-with-temp-text "* H\nDEADLINE: <2014-03-04 tue.>" + (cdr (assoc "DEADLINE" (org-entry-properties)))))) (should-not (org-test-with-temp-text "* H" (cdr (assoc "DEADLINE" (org-entry-properties nil "DEADLINE"))))) @@ -2717,6 +2758,11 @@ Text. "<2014-03-04 tue.>" (org-test-with-temp-text "* H\nSCHEDULED: <2014-03-04 tue.>" (cdr (assoc "SCHEDULED" (org-entry-properties nil "SCHEDULED")))))) + (should + (equal + "<2014-03-04 tue.>" + (org-test-with-temp-text "* H\nSCHEDULED: <2014-03-04 tue.>" + (cdr (assoc "SCHEDULED" (org-entry-properties)))))) (should-not (org-test-with-temp-text "* H" (cdr (assoc "SCHEDULED" (org-entry-properties nil "SCHEDULED"))))) -- 2.11.4.GIT