Selaa lähdekoodia

Merge branch 'maint'

Conflicts:
	lisp/org-element.el
Nicolas Goaziou 11 vuotta sitten
vanhempi
commit
3960ed07e6
2 muutettua tiedostoa jossa 22 lisäystä ja 1 poistoa
  1. 11 1
      lisp/org-element.el
  2. 11 0
      testing/lisp/test-org-element.el

+ 11 - 1
lisp/org-element.el

@@ -5766,7 +5766,17 @@ Providing it allows for quicker computation."
 	   (if (and (>= origin (point)) (< origin (line-end-position)))
 	       (narrow-to-region (point) (line-end-position))
 	     (throw 'objects-forbidden element))))
-	;; All other locations cannot contain objects: bail out.
+	;; At a planning line, if point is at a timestamp, return it,
+	;; otherwise, return element.
+	((eq type 'planning)
+	 (dolist (p '(:closed :deadline :scheduled))
+	   (let ((timestamp (org-element-property p element)))
+	     (when (and timestamp
+			(<= (org-element-property :begin timestamp) origin)
+			(> (org-element-property :end timestamp) origin))
+	       (throw 'objects-forbidden timestamp))))
+	 ;; All other locations cannot contain objects: bail out.
+	 (throw 'objects-forbidden element))
 	(t (throw 'objects-forbidden element)))
        (goto-char (point-min))
        (let* ((restriction (org-element-restriction type))

+ 11 - 0
testing/lisp/test-org-element.el

@@ -2990,6 +2990,17 @@ Paragraph \\alpha."
        (org-test-with-temp-text "| a | b {{{macro}}} |"
 	 (progn (search-forward "b")
 		(org-element-type (org-element-context))))))
+  ;; Find objects in planning lines.
+  (should
+   (eq 'timestamp
+       (org-test-with-temp-text "* H\n  SCHEDULED: <2012-03-29 thu.>"
+	 (search-forward "2012")
+	 (org-element-type (org-element-context)))))
+  (should-not
+   (eq 'timestamp
+       (org-test-with-temp-text "* H\n  SCHEDULED: <2012-03-29 thu.>"
+	 (search-forward "SCHEDULED")
+	 (org-element-type (org-element-context)))))
   ;; Find objects in document keywords.
   (should
    (eq 'macro