浏览代码

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 <richard.lawrence@berkeley.edu>
<http://permalink.gmane.org/gmane.emacs.orgmode/92728>
Nicolas Goaziou 10 年之前
父节点
当前提交
4375a941cc
共有 2 个文件被更改,包括 59 次插入15 次删除
  1. 13 15
      lisp/org.el
  2. 46 0
      testing/lisp/test-org.el

+ 13 - 15
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")))

+ 46 - 0
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<point>** H2 :tag2:"
 	    (cdr (assoc "ALLTAGS" (org-entry-properties nil "ALLTAGS"))))))
+  (should
+   (equal ":tag1:tag2:"
+	  (org-test-with-temp-text "* H :tag1:\n<point>** H2 :tag2:"
+	    (cdr (assoc "ALLTAGS" (org-entry-properties))))))
   (should-not
    (org-test-with-temp-text "* H"
      (cdr (assoc "ALLTAGS" (org-entry-properties nil "ALLTAGS")))))
@@ -2690,6 +2714,13 @@ Text.
 		  (org-blocker-hook
 		   '(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"
@@ -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")))))