[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
counting chars in buffer
From: |
Emanuel Berg |
Subject: |
counting chars in buffer |
Date: |
Mon, 12 Jun 2017 20:53:39 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) |
How would one do that?
Using 'wc -c' on the file isn't allowed as I've
heard some systems (?) don't come with that.
Here are two suggestions:
(require 'cl-lib)
(defun count-chars ()
(interactive)
(save-excursion
(let ((start (point-min))
(end (point-max))
(chars 0) )
(goto-char start)
(while (< (point) end)
(forward-char)
(cl-incf chars) )
chars) ))
;; (count-chars)
(defun count-chars-2 ()
(interactive)
(length (buffer-string) ))
;; (count-chars-2)
One could also do a DWIM function which acts on
the region if there, otherwise the whole buffer...
--
underground experts united
http://user.it.uu.se/~embe8573
- counting chars in buffer,
Emanuel Berg <=