Function: org-element-drawer-parser

org-element-drawer-parser is a byte-compiled function defined in org-element.el.gz.

Signature

(org-element-drawer-parser LIMIT AFFILIATED)

Documentation

Parse a drawer.

LIMIT bounds the search. AFFILIATED is a list of which CAR is the buffer position at the beginning of the first affiliated keyword and CDR is a plist of affiliated keywords along with their value.

Return a new syntax node of drawer type containing :drawer-name,
:begin, :end, :contents-begin, :contents-end, :post-blank
and :post-affiliated properties.

Assume point is at beginning of drawer.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-element.el.gz
;;;; Drawer

(defun org-element-drawer-parser (limit affiliated)
  "Parse a drawer.

LIMIT bounds the search.  AFFILIATED is a list of which CAR is
the buffer position at the beginning of the first affiliated
keyword and CDR is a plist of affiliated keywords along with
their value.

Return a new syntax node of `drawer' type containing `:drawer-name',
`:begin', `:end', `:contents-begin', `:contents-end', `:post-blank'
and `:post-affiliated' properties.

Assume point is at beginning of drawer."
  (let ((case-fold-search t))
    (if (not (save-excursion
               (goto-char (min limit (line-end-position)))
               (re-search-forward "^[ \t]*:END:[ \t]*$" limit t)))
	;; Incomplete drawer: parse it as a paragraph.
	(org-element-paragraph-parser limit affiliated)
      (save-excursion
	(let* ((drawer-end-line (match-beginning 0))
	       (name
                (progn
                  (looking-at org-element-drawer-re)
		  (org-element--get-cached-string (match-string-no-properties 1))))
	       (begin (car affiliated))
	       (post-affiliated (point))
	       ;; Empty drawers have no contents.
	       (contents-begin (progn (forward-line)
				      (and (< (point) drawer-end-line)
					   (point))))
	       (contents-end (and contents-begin drawer-end-line))
	       (pos-before-blank (progn (goto-char drawer-end-line)
					(forward-line)
					(point)))
	       (end (progn (skip-chars-forward " \r\t\n" limit)
			   (if (eobp) (point) (line-beginning-position)))))
	  (org-element-create
           'drawer
	   (nconc
	    (list :begin begin
		  :end end
		  :drawer-name name
		  :contents-begin contents-begin
		  :contents-end contents-end
		  :post-blank (count-lines pos-before-blank end)
		  :post-affiliated post-affiliated)
	    (cdr affiliated))))))))