help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [External] : Re: How to detect words being added and removed to a bu


From: Drew Adams
Subject: RE: [External] : Re: How to detect words being added and removed to a buffer in a minor mode?
Date: Mon, 21 Nov 2022 18:56:18 +0000

> Would a mode which displays the number of words in the current buffer
> whenever you stop typing for a few seconds be enough?  (I am not sure
> how exactly you want to obtain the "number of words typed in today".)

I already mentioned that you can get this for
free in the mode-line, from redisplay, using
library modeline-region.el.

Well, you get it automatically for the active
region, not the whole buffer.  To see it for
the full buffer at any time, just use `C-x C-x'.

If someone is interested in instead showing it
always for the full buffer (not only when it's
the active region), that's easily done by
tweaking the source code.
__

Attached is such a quick tweaking (could be
simplified).  I just added an option,
`mlr-use-whole-buffer-flag' for this.  Set
it to non-nil to continually get full-buffer
(or narrowed-buffer) counts instead of
active-region counts.

Essentially all I did was change uses of
(region-beginning) and (region-end) to
(point-min) and (point-max), and test the
added option for which pair to use.

Just replace the same definitions in
modeline-region.el with the versions in the
attached.

(I won't change the library this way, as I
don't think it's generally useful.)

If all you care about is the number of words
in the buffer, you can considerably pare
down the code - the result will be small.

Attachment: throw-modeline-region-BUFFER.el
Description: throw-modeline-region-BUFFER.el


reply via email to

[Prev in Thread] Current Thread [Next in Thread]