unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Eric S Fraga <e.fraga@ucl.ac.uk>
Cc: help-gnu-emacs@gnu.org
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	[thread overview]
Message-ID: <Y3tOHlm5pHhNhJyv@protected.localdomain> (raw)
In-Reply-To: <87zgckhcit.fsf@ucl.ac.uk>

* 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	other threads:[~2022-11-21 10:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-19 20:44 How to detect words being added and removed to a buffer in a minor mode? Dmitrii Pisarenko
2022-11-21  9:39 ` Eric S Fraga
2022-11-21 10:08   ` Jean Louis [this message]
2022-11-21 10:34     ` Emanuel Berg
2022-11-21 11:27     ` Eric S Fraga
2022-11-21 12:40       ` Emanuel Berg
2022-11-21 17:17     ` Marcin Borkowski
2022-11-21 17:21       ` Marcin Borkowski
2022-11-21 18:56       ` [External] : " Drew Adams
2022-11-22 15:33       ` Emanuel Berg
2022-11-26  6:14         ` Marcin Borkowski
2022-11-26 14:51           ` Emanuel Berg
  -- strict thread matches above, loose matches on Subject: below --
2022-11-19 20:45 Pravles Redneсkoff via Users list for the GNU Emacs text editor
2022-11-20  3:10 ` Bob Newell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y3tOHlm5pHhNhJyv@protected.localdomain \
    --to=bugs@gnu.support \
    --cc=e.fraga@ucl.ac.uk \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).