forked from mirrors/org-mode
org-element: Fix `quote-section' detection and parsing
* contrib/lisp/org-element.el (org-element-quote-section-parser): Assume point is at quote-section beginning. (org-element-guess-type): Move point to section beginning before calling for quote-section parser. (org-element-parse-elements, org-element-current-element): Correctly detect and parse quote section.
This commit is contained in:
parent
6c9c6eff05
commit
c2fd307df3
|
@ -1291,26 +1291,22 @@ CONTENTS is nil."
|
||||||
|
|
||||||
Return a list whose car is `quote-section' and cdr is a plist
|
Return a list whose car is `quote-section' and cdr is a plist
|
||||||
containing `:begin', `:end', `:value' and `:post-blank'
|
containing `:begin', `:end', `:value' and `:post-blank'
|
||||||
keywords."
|
keywords.
|
||||||
|
|
||||||
|
Assume point is at beginning of the section."
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(let* ((begin (progn (org-back-to-heading t)
|
(let* ((begin (point))
|
||||||
(forward-line)
|
|
||||||
(org-skip-whitespace)
|
|
||||||
(point-at-bol)))
|
|
||||||
(end (progn (org-with-limited-levels (outline-next-heading))
|
(end (progn (org-with-limited-levels (outline-next-heading))
|
||||||
(point)))
|
(point)))
|
||||||
(pos-before-blank (progn (skip-chars-backward " \r\t\n")
|
(pos-before-blank (progn (skip-chars-backward " \r\t\n")
|
||||||
(forward-line)
|
(forward-line)
|
||||||
(point)))
|
(point)))
|
||||||
(value (unless (= begin end)
|
(value (buffer-substring-no-properties begin pos-before-blank)))
|
||||||
(buffer-substring-no-properties begin pos-before-blank))))
|
|
||||||
`(quote-section
|
`(quote-section
|
||||||
(:begin ,begin
|
(:begin ,begin
|
||||||
:end ,end
|
:end ,end
|
||||||
:value ,value
|
:value ,value
|
||||||
:post-blank ,(if value
|
:post-blank ,(count-lines pos-before-blank end))))))
|
||||||
(count-lines pos-before-blank end)
|
|
||||||
0))))))
|
|
||||||
|
|
||||||
(defun org-element-quote-section-interpreter (quote-section contents)
|
(defun org-element-quote-section-interpreter (quote-section contents)
|
||||||
"Interpret QUOTE-SECTION element as Org syntax.
|
"Interpret QUOTE-SECTION element as Org syntax.
|
||||||
|
@ -2716,6 +2712,11 @@ point is in a section in priority."
|
||||||
(let (case-fold-search)
|
(let (case-fold-search)
|
||||||
(string-match (format "^%s\\(?: \\|$\\)" org-quote-string)
|
(string-match (format "^%s\\(?: \\|$\\)" org-quote-string)
|
||||||
headline))))
|
headline))))
|
||||||
|
;; Move to section beginning.
|
||||||
|
(org-back-to-heading t)
|
||||||
|
(forward-line)
|
||||||
|
(org-skip-whitespace)
|
||||||
|
(beginning-of-line)
|
||||||
'quote-section)
|
'quote-section)
|
||||||
;; Any buffer position not at an headline or in a quote section
|
;; Any buffer position not at an headline or in a quote section
|
||||||
;; is inside a section, provided function is actively looking for
|
;; is inside a section, provided function is actively looking for
|
||||||
|
@ -3154,7 +3155,11 @@ Elements are accumulated into ACC."
|
||||||
;; At a plain list, switch to item mode. At an
|
;; At a plain list, switch to item mode. At an
|
||||||
;; headline, switch to section mode. Any other
|
;; headline, switch to section mode. Any other
|
||||||
;; element turns off special modes.
|
;; element turns off special modes.
|
||||||
(case (car element) (plain-list 'item) (headline 'section))
|
(case (car element)
|
||||||
|
(plain-list 'item)
|
||||||
|
(headline (if (org-element-get-property :quotedp element)
|
||||||
|
'quote-section
|
||||||
|
'section)))
|
||||||
(org-element-get-property :structure element)
|
(org-element-get-property :structure element)
|
||||||
granularity visible-only (reverse element)))
|
granularity visible-only (reverse element)))
|
||||||
;; Case 3. Else, just accumulate ELEMENT.
|
;; Case 3. Else, just accumulate ELEMENT.
|
||||||
|
@ -3208,12 +3213,7 @@ more restrictive."
|
||||||
((org-with-limited-levels (org-at-heading-p))
|
((org-with-limited-levels (org-at-heading-p))
|
||||||
(org-element-headline-parser))
|
(org-element-headline-parser))
|
||||||
;; Quote section.
|
;; Quote section.
|
||||||
((let ((headline (ignore-errors (nth 4 (org-heading-components)))))
|
((eq special 'quote-section) (org-element-quote-section-parser))
|
||||||
(and headline
|
|
||||||
(let (case-fold-search)
|
|
||||||
(string-match (format "^%s\\(?: \\|$\\)" org-quote-string)
|
|
||||||
headline))))
|
|
||||||
(org-element-quote-section-parser))
|
|
||||||
;; Section.
|
;; Section.
|
||||||
((eq special 'section) (org-element-section-parser))
|
((eq special 'section) (org-element-section-parser))
|
||||||
;; Non-recursive block.
|
;; Non-recursive block.
|
||||||
|
|
Loading…
Reference in a new issue