forked from mirrors/org-mode
org-element: Fix inlinetask parsing
* lisp/org-element.el (org-element-inlinetask-parser): Do not infloop when parsing property drawer in an inlinetask. * testing/lisp/test-org-element.el (test-org-element/headline-properties): Add test. Thanks to Aaron Ecay for reporting it. http://permalink.gmane.org/gmane.emacs.orgmode/88133
This commit is contained in:
parent
2824502e2e
commit
49f3c6e558
|
@ -1003,34 +1003,6 @@ Assume point is at beginning of the inline task."
|
|||
(and (re-search-forward org-outline-regexp-bol limit t)
|
||||
(org-looking-at-p "END[ \t]*$")
|
||||
(line-beginning-position))))
|
||||
(standard-props
|
||||
;; Find property drawer associated to current inlinetask
|
||||
;; and extract properties.
|
||||
;;
|
||||
;; Upcase property names. It avoids confusion between
|
||||
;; properties obtained through property drawer and default
|
||||
;; properties from the parser (e.g. `:end' and :END:)
|
||||
(when task-end
|
||||
(let (plist)
|
||||
(save-excursion
|
||||
(while (and (null plist)
|
||||
(re-search-forward
|
||||
org-property-start-re task-end t))
|
||||
(let ((d (org-element-at-point)))
|
||||
(when (eq (org-element-type d) 'property-drawer)
|
||||
(let ((end (org-element-property :contents-end d)))
|
||||
(when end
|
||||
(forward-line)
|
||||
(while (< (point) end)
|
||||
(looking-at org-property-re)
|
||||
(setq plist
|
||||
(plist-put
|
||||
plist
|
||||
(intern
|
||||
(concat ":" (upcase (match-string 2))))
|
||||
(org-match-string-no-properties 3)))
|
||||
(forward-line)))))))
|
||||
plist))))
|
||||
(time-props
|
||||
;; Read time properties on the line below the inlinetask
|
||||
;; opening string.
|
||||
|
@ -1060,6 +1032,43 @@ Assume point is at beginning of the inline task."
|
|||
(point)))
|
||||
(end (progn (skip-chars-forward " \r\t\n" limit)
|
||||
(if (eobp) (point) (line-beginning-position))))
|
||||
(standard-props
|
||||
;; Find property drawer associated to current inlinetask
|
||||
;; and extract properties.
|
||||
;;
|
||||
;; HACK: Calling `org-element-at-point' triggers a parsing
|
||||
;; of this inlinetask and, thus, an infloop. To avoid the
|
||||
;; problem, we extract contents of the inlinetask and
|
||||
;; parse them in a new buffer.
|
||||
;;
|
||||
;; Upcase property names. It avoids confusion between
|
||||
;; properties obtained through property drawer and default
|
||||
;; properties from the parser (e.g. `:end' and :END:)
|
||||
(when contents-begin
|
||||
(let ((contents (buffer-substring contents-begin contents-end))
|
||||
plist)
|
||||
(with-temp-buffer
|
||||
(let ((org-inhibit-startup t)) (org-mode))
|
||||
(insert contents)
|
||||
(goto-char (point-min))
|
||||
(while (and (null plist)
|
||||
(re-search-forward
|
||||
org-property-start-re task-end t))
|
||||
(let ((d (org-element-at-point)))
|
||||
(when (eq (org-element-type d) 'property-drawer)
|
||||
(let ((end (org-element-property :contents-end d)))
|
||||
(when end
|
||||
(forward-line)
|
||||
(while (< (point) end)
|
||||
(when (looking-at org-property-re)
|
||||
(setq plist
|
||||
(plist-put
|
||||
plist
|
||||
(intern
|
||||
(concat ":" (upcase (match-string 2))))
|
||||
(org-match-string-no-properties 3))))
|
||||
(forward-line))))))))
|
||||
plist)))
|
||||
(inlinetask
|
||||
(list 'inlinetask
|
||||
(nconc
|
||||
|
|
|
@ -1004,6 +1004,15 @@ Some other text
|
|||
(should-not
|
||||
(org-test-with-temp-text "* Headline\n:PROPERTIES:\n:foo: bar\n:END:"
|
||||
(org-element-property :foo (org-element-at-point))))
|
||||
;; Also parse properties associated in inlinetasks.
|
||||
(when (featurep 'org-inlinetask)
|
||||
(should
|
||||
(org-test-with-temp-text "*************** Inlinetask
|
||||
:PROPERTIES:
|
||||
:foo: bar
|
||||
:END:
|
||||
*************** END"
|
||||
(org-element-property :FOO (org-element-at-point)))))
|
||||
;; Do not find property drawer in a verbatim area.
|
||||
(should-not
|
||||
(org-test-with-temp-text
|
||||
|
|
Loading…
Reference in New Issue