Prechádzať zdrojové kódy

org-element: Fix docstring, add tests

* lisp/org-element.el (org-element-headline-parser,
  org-element-inlinetask-parser): Fix docstring.
* testing/lisp/test-org-element.el: Add tests.

This follows ae5932282d44742d932d40136edf441bc18609a9.
Nicolas Goaziou 12 rokov pred
rodič
commit
a385c6e0e4
2 zmenil súbory, kde vykonal 39 pridanie a 10 odobranie
  1. 4 4
      lisp/org-element.el
  2. 35 6
      testing/lisp/test-org-element.el

+ 4 - 4
lisp/org-element.el

@@ -736,8 +736,8 @@ containing `:raw-value', `:title', `:begin', `:end',
 `:commentedp' and `:footnote-section-p' keywords.
 
 The plist also contains any property set in the property drawer,
-with its name in lowercase, the underscores replaced with hyphens
-and colons at the beginning (i.e. `:custom-id').
+with its name in upper cases and colons added at the
+beginning (i.e. `:CUSTOM_ID').
 
 When RAW-SECONDARY-P is non-nil, headline's title will not be
 parsed as a secondary string, but as a plain string instead.
@@ -912,8 +912,8 @@ containing `:title', `:begin', `:end', `:hiddenp',
 `:scheduled', `:deadline', `:closed' and `:post-blank' keywords.
 
 The plist also contains any property set in the property drawer,
-with its name in lowercase, the underscores replaced with hyphens
-and colons at the beginning (i.e. `:custom-id').
+with its name in upper cases and colons added at the
+beginning (i.e. `:CUSTOM_ID').
 
 When optional argument RAW-SECONDARY-P is non-nil, inline-task's
 title will not be parsed as a secondary string, but as a plain

+ 35 - 6
testing/lisp/test-org-element.el

@@ -874,6 +874,17 @@ Some other text
 	;; Test tag removal.
 	(should (equal (org-element-property :tags headline) '("test")))))))
 
+(ert-deftest test-org-element/headline-properties ()
+  "Test properties from property drawer."
+  ;; All properties from property drawer have their symbol upper
+  ;; cased.
+  (should
+   (org-test-with-temp-text "* Headline\n:PROPERTIES:\n:foo: bar\n:END:"
+     (org-element-property :FOO (org-element-at-point))))
+  (should-not
+   (org-test-with-temp-text "* Headline\n:PROPERTIES:\n:foo: bar\n:END:"
+     (org-element-property :foo (org-element-at-point)))))
+
 
 ;;;; Horizontal Rule
 
@@ -943,8 +954,8 @@ Some other text
 	  (org-test-with-temp-text "*************** TODO Task"
 	    (org-element-property
 	     :todo-keyword
-	     (org-element-map
-	      (org-element-parse-buffer) 'inlinetask 'identity nil t))))))
+	     (org-element-map (org-element-parse-buffer) 'inlinetask
+	       'identity nil t))))))
       ;; Planning info.
       (should
        (equal
@@ -954,8 +965,7 @@ Some other text
 DEADLINE: <2012-03-29 thu.>"
 	  (org-element-property
 	   :deadline
-	   (org-element-map
-	    (org-element-parse-buffer) 'inlinetask 'identity nil t)))))
+	   (org-element-map (org-element-parse-buffer) 'inlinetask 'identity nil t)))))
       ;; Priority.
       (should
        (equal
@@ -965,7 +975,7 @@ DEADLINE: <2012-03-29 thu.>"
 	  (org-element-property
 	   :priority
 	   (org-element-map
-	    (org-element-parse-buffer) 'inlinetask 'identity nil t)))))
+	       (org-element-parse-buffer) 'inlinetask 'identity nil t)))))
       ;; Tags.
       (should
        (equal
@@ -975,7 +985,26 @@ DEADLINE: <2012-03-29 thu.>"
 	  (org-element-property
 	   :tags
 	   (org-element-map
-	    (org-element-parse-buffer) 'inlinetask 'identity nil t))))))))
+	       (org-element-parse-buffer) 'inlinetask 'identity nil t)))))
+      ;; Regular properties are accessed through upper case keywords.
+      (should
+       (org-test-with-temp-text "
+*************** Task
+:PROPERTIES:
+:foo: bar
+:END:
+*************** END"
+	 (forward-line)
+	 (org-element-property :FOO (org-element-at-point))))
+      (should-not
+       (org-test-with-temp-text "
+*************** Task
+:PROPERTIES:
+:foo: bar
+:END:
+*************** END"
+	 (forward-line)
+	 (org-element-property :foo (org-element-at-point)))))))
 
 
 ;;;; Italic