Function: nndoc-dissect-buffer

nndoc-dissect-buffer is a byte-compiled function defined in nndoc.el.gz.

Signature

(nndoc-dissect-buffer)

Documentation

Go through the document and partition it into heads/bodies/articles.

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/nndoc.el.gz
(defun nndoc-dissect-buffer ()
  "Go through the document and partition it into heads/bodies/articles."
  (let ((i 0)
	(first t)
	art-begin head-begin head-end body-begin body-end)
    (setq nndoc-dissection-alist nil)
    (with-current-buffer nndoc-current-buffer
      (goto-char (point-min))
      ;; Remove blank lines.
      (while (eq (following-char) ?\n)
	(delete-char 1))
      (when nndoc-pre-dissection-function
	(save-excursion
	  (funcall nndoc-pre-dissection-function)))
      (if nndoc-dissection-function
	  (funcall nndoc-dissection-function)
	;; Find the beginning of the file.
	(when nndoc-file-begin
	  (nndoc-search nndoc-file-begin))
	;; Go through the file.
	(while (if (and first nndoc-first-article)
		   (nndoc-search nndoc-first-article)
		 (if art-begin
		     (goto-char art-begin)
		   (nndoc-article-begin)))
	  (setq first nil
		art-begin nil)
	  (cond (nndoc-head-begin-function
		 (funcall nndoc-head-begin-function))
		(nndoc-head-begin
		 (nndoc-search nndoc-head-begin)))
	  (if (or (eobp)
		  (and nndoc-file-end
		       (looking-at nndoc-file-end)))
	      (goto-char (point-max))
	    (setq head-begin (point))
	    (nndoc-search (or nndoc-head-end "^$"))
	    (setq head-end (point))
	    (if nndoc-body-begin-function
		(funcall nndoc-body-begin-function)
	      (nndoc-search (or nndoc-body-begin "^\n")))
	    (setq body-begin (point))
	    (or (and nndoc-body-end-function
		     (funcall nndoc-body-end-function))
		(and nndoc-body-end
		     (nndoc-search nndoc-body-end))
		(and (nndoc-article-begin)
		     (setq art-begin (point)))
		(progn
		  (goto-char (point-max))
		  (when nndoc-file-end
		    (and (re-search-backward nndoc-file-end nil t)
			 (beginning-of-line)))))
	    (setq body-end (point))
	    (push (list (cl-incf i) head-begin head-end body-begin body-end
			(count-lines body-begin body-end))
		  nndoc-dissection-alist)))))
    (setq nndoc-dissection-alist (nreverse nndoc-dissection-alist))))