Function: org-element-comment-parser

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

Signature

(org-element-comment-parser LIMIT)

Documentation

Parse a comment.

LIMIT bounds the search.

Return a list whose CAR is comment and CDR is a plist containing :begin, :end, :value, :post-blank,
:post-affiliated keywords.

Assume point is at comment beginning.

Source Code

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

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

LIMIT bounds the search.

Return a list whose CAR is `comment' and CDR is a plist
containing `:begin', `:end', `:value', `:post-blank',
`:post-affiliated' keywords.

Assume point is at comment beginning."
  (save-excursion
    (let* ((begin (point))
	   (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]*#\\( \\|$\\)"))
		;; Accumulate lines without leading hash and first
		;; whitespace.
		(setq value
		      (concat value
			      "\n"
			      (buffer-substring-no-properties
			       (match-end 0) (line-end-position))))
		(forward-line))
	      (point)))
	   (end (progn (goto-char com-end)
		       (skip-chars-forward " \r\t\n" limit)
		       (if (eobp) (point) (line-beginning-position)))))
      (list 'comment
	    (list :begin begin
		  :end end
		  :value value
		  :post-blank (count-lines com-end end)
		  :post-affiliated begin)))))