Function: kimport:count-paragraphs

kimport:count-paragraphs is an interactive and byte-compiled function defined in kimport.el.

Signature

(kimport:count-paragraphs)

Documentation

Return the number of paragraphs in the buffer based on paragraph-separate.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/kotl/kimport.el
;;; ************************************************************************
;;; Private functions
;;; ************************************************************************

(defun kimport:count-paragraphs ()
  "Return the number of paragraphs in the buffer based on `paragraph-separate'."
  (interactive)
  (let ((count 0) (in-between))
    (save-excursion
      (goto-char (point-min))
      (if (or (looking-at paragraph-separate)
	      (looking-at "[ \t]*\\S-"))
	  ;; Don't count this first paragraph since there typically will be
	  ;; an extra match at the end of the buffer due to blank lines.
	  (setq in-between t))
      (while (zerop (forward-line 1))
	(if (looking-at paragraph-separate)
	    (if (not in-between)
		(setq count (1+ count)
		      in-between t))
	  (setq in-between nil)))
      count)))