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

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

Re: How to detect words being added and removed to a buffer in a minor m


From: Jean Louis
Subject: Re: How to detect words being added and removed to a buffer in a minor mode?
Date: Mon, 21 Nov 2022 13:08:30 +0300
User-agent: Mutt/2.2.7+37 (a90f69b) (2022-09-02)

* Eric S Fraga <e.fraga@ucl.ac.uk> [2022-11-21 12:40]:
> On Saturday, 19 Nov 2022 at 20:44, Dmitrii Pisarenko wrote:
> > 1. How can I create an "event listener" (sorry for the non-Emacsian
> > terminology) which would be called whenever the user types something
> > in the buffer?
> 
> Naïvely (i.e. I may be totally ignorant of a proper solution), there is
> post-command-hook which can be used to process every single key event.

There are 2 conditions here, one is that user wish to see the number
of words visualy, other is that one wants to compare that once editing
is finished.

One need not see every single word counted. What if user enters 500
words at once, then it would be futil to slow down the process until
every single word has been counted.

It implies, one could invoke function with number of words each in a
while. 

In that case, one could use this function:

run-with-timer is an interactive byte-compiled Lisp function in
‘timer.el’.

(run-with-timer SECS REPEAT FUNCTION &rest ARGS)


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



reply via email to

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