Built into emacs and invoked using M-= is elisp code to cound characters,
words, and lines in the buffer. I have need to count paragraphs, too, and
found a working solution on stackexchange. I'm sharing it here in case I'm
not the only one who needs this capability and hasn't already obtained a
solution.
In ~/.emacs add the following:
;; Count paragraphs in buffer
(defun count-paragraphs (start end)
"Return number of paragraphs between START and END."
(save-excursion
(save-restriction
(narrow-to-region start end)
(goto-char (point-min))
(- (buffer-size) (forward-paragraph (buffer-size))))))
(defun count-paragraphs-region-or-buffer ()
"Report number of paragraphs in the region (if it's active) or the entire
(declare (interactive-only count-paragraphs))
(interactive)
(let ((paragraphs (if (use-region-p)
(count-paragraphs (region-beginning) (region-end))
(count-paragraphs (point-min) (point-max)))))
(message "%s has %d paragraph%s"
(if (use-region-p) "Region" "Buffer")
paragraphs
(if (> paragraphs 1) "s" ""))))
and save the modified file. The next time you invoke emacs and have a buffer
for which you want a count of paragraphs, place the word, 'start', (without
quotes, of course) as the first line and the word, 'end', as the last line.
then run M-x count-paragraphs. Works great!
Rich
_______________________________________________
PLUG mailing list
[email protected]
http://lists.pdxlinux.org/mailman/listinfo/plug