Fix 37bf05
* lisp/org.el (org-re-property): Fix regexp. Improve docstring. * testing/lisp/test-org-element.el (test-org-element/node-property): Update test. Thanks to Daimrod for reporting it. http://permalink.gmane.org/gmane.emacs.orgmode/90383
This commit is contained in:
parent
37bf0576f2
commit
2de0c1c3da
22
lisp/org.el
22
lisp/org.el
|
@ -6152,13 +6152,21 @@ Use `org-reduced-level' to remove the effect of `org-odd-levels'."
|
||||||
(defvar org-font-lock-keywords nil)
|
(defvar org-font-lock-keywords nil)
|
||||||
|
|
||||||
(defsubst org-re-property (property &optional literal allow-null)
|
(defsubst org-re-property (property &optional literal allow-null)
|
||||||
"Return a regexp matching a PROPERTY line.
|
"Return a regexp matching a PROPERTY line.
|
||||||
Match group 3 will be set to the value if it exists."
|
|
||||||
(concat "^\\(?4:[ \t]*\\)\\(?1::\\(?2:"
|
When optional argument LITERAL is non-nil, do not quote PROPERTY.
|
||||||
(if literal property (regexp-quote property))
|
This is useful when PROPERTY is a regexp. When ALLOW-NULL is
|
||||||
"\\):\\)\\(?:[ \t]+\\(?3:[^ \t\r\n].*?\\)\\)"
|
non-nil, match properties even without a value.
|
||||||
(and allow-null "?")
|
|
||||||
"\\(?5:[ \t]*\\)$"))
|
Match group 3 is set to the value when it exists. If there is no
|
||||||
|
value and ALLOW-NULL is non-nil, it is set to the empty string."
|
||||||
|
(concat
|
||||||
|
"^\\(?4:[ \t]*\\)"
|
||||||
|
(format "\\(?1::\\(?2:%s\\):\\)"
|
||||||
|
(if literal property (regexp-quote property)))
|
||||||
|
(if allow-null
|
||||||
|
"\\(?:\\(?3:$\\)\\|[ \t]+\\(?3:.*?\\)\\)\\(?5:[ \t]*\\)$"
|
||||||
|
"[ \t]+\\(?3:[^ \r\t\n]+.*?\\)\\(?5:[ \t]*\\)$")))
|
||||||
|
|
||||||
(defconst org-property-re
|
(defconst org-property-re
|
||||||
(org-re-property ".*?" 'literal t)
|
(org-re-property ".*?" 'literal t)
|
||||||
|
|
|
@ -1495,7 +1495,7 @@ e^{i\\pi}+1=0
|
||||||
(org-element-type (org-element-at-point)))))
|
(org-element-type (org-element-at-point)))))
|
||||||
;; Accept empty properties.
|
;; Accept empty properties.
|
||||||
(should
|
(should
|
||||||
(equal '(("foo" "value") ("bar" nil))
|
(equal '(("foo" "value") ("bar" ""))
|
||||||
(org-test-with-temp-text ":PROPERTIES:\n:foo: value\n:bar:\n:END:"
|
(org-test-with-temp-text ":PROPERTIES:\n:foo: value\n:bar:\n:END:"
|
||||||
(org-element-map (org-element-parse-buffer) 'node-property
|
(org-element-map (org-element-parse-buffer) 'node-property
|
||||||
(lambda (p)
|
(lambda (p)
|
||||||
|
|
Loading…
Reference in New Issue