mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-12-28 10:56:57 +00:00
org-element: Fix parsing when a keyword follows the commented line
* lisp/org-element.el (org-element-comment-parser): Fix parsing when a keyword follows the commented line. * testing/lisp/test-org-element.el: Add test.
This commit is contained in:
parent
28582bfa0f
commit
eb2eacf91d
@ -1358,17 +1358,24 @@ Assume point is at comment beginning."
|
||||
(save-excursion
|
||||
(let* ((keywords (org-element--collect-affiliated-keywords))
|
||||
(begin (car keywords))
|
||||
value
|
||||
;; Match first line with a loose regexp since it might as
|
||||
;; well be an ill-defined keyword.
|
||||
(value (prog2 (looking-at "[ \t]*#\\+? ?")
|
||||
(buffer-substring-no-properties
|
||||
(match-end 0) (line-end-position))
|
||||
(forward-line)))
|
||||
(com-end
|
||||
;; Get comments ending.
|
||||
(progn
|
||||
(while (and (< (point) limit) (looking-at "[ \t]*# ?"))
|
||||
(while (and (< (point) limit) (looking-at "[ \t]*#\\( \\|$\\)"))
|
||||
;; Accumulate lines without leading hash and first
|
||||
;; whitespace.
|
||||
(setq value
|
||||
(concat value
|
||||
"\n"
|
||||
(buffer-substring-no-properties
|
||||
(match-end 0) (progn (forward-line) (point))))))
|
||||
(match-end 0) (line-end-position))))
|
||||
(forward-line))
|
||||
(point)))
|
||||
(end (progn (goto-char com-end)
|
||||
(skip-chars-forward " \r\t\n" limit)
|
||||
|
@ -288,7 +288,7 @@ CLOCK: [2012-01-01 sun. 00:01]--[2012-01-01 sun. 00:02] => 0:01"
|
||||
:value
|
||||
(org-test-with-temp-text "# No blank\n# One blank"
|
||||
(org-element-map (org-element-parse-buffer) 'comment 'identity nil t)))
|
||||
"No blank\n One blank"))
|
||||
"No blank\n One blank"))
|
||||
;; Comment with blank lines.
|
||||
(should
|
||||
(equal
|
||||
@ -300,7 +300,20 @@ CLOCK: [2012-01-01 sun. 00:01]--[2012-01-01 sun. 00:02] => 0:01"
|
||||
;; Keywords without colons are treated as comments.
|
||||
(should
|
||||
(org-test-with-temp-text "#+wrong_keyword something"
|
||||
(org-element-map (org-element-parse-buffer) 'comment 'identity))))
|
||||
(org-element-map (org-element-parse-buffer) 'comment 'identity)))
|
||||
;; Do not mix comments and keywords.
|
||||
(should
|
||||
(eq 1
|
||||
(org-test-with-temp-text "#+keyword: value\n# comment\n#+keyword: value"
|
||||
(length (org-element-map
|
||||
(org-element-parse-buffer) 'comment 'identity)))))
|
||||
(should
|
||||
(equal "comment"
|
||||
(org-test-with-temp-text "#+keyword: value\n# comment\n#+keyword: value"
|
||||
(org-element-property
|
||||
:value
|
||||
(org-element-map
|
||||
(org-element-parse-buffer) 'comment 'identity nil t))))))
|
||||
|
||||
|
||||
;;;; Comment Block
|
||||
|
Loading…
Reference in New Issue
Block a user