unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Bob Newell <bobnewell@bobnewell.net>
To: "Pravles Redneсkoff" <pravles@pm.me>
Cc: help-gnu-emacs@gnu.org
Subject: Re: How to detect words being added and removed to a buffer in a minor mode?
Date: Sat, 19 Nov 2022 17:10:31 -1000	[thread overview]
Message-ID: <CADoYgq806LHVxbiRBy+5WyS5QS0ABEBhtOKNNSy95QBJ+573HQ@mail.gmail.com> (raw)
In-Reply-To: <SkO7fkMSL-au9yYO5Xk5YrHuSBbM2mx36Fx4y964ak7UNP_wFy8FgEn_miE0Xx142g68yswZvuQVozqCaMNbCD-mny7SundkXZ2xZaxjIVA=@pm.me>

This might provide some of what you want although perhaps not all.

https://github.com/emacsmirror/nanowrimo



On Sat, Nov 19, 2022, 10:46 Pravles Redneсkoff via Users list for the GNU
Emacs text editor <help-gnu-emacs@gnu.org> wrote:

> Hello!
>
> I want to create a minor mode which allows you to see the number of words
> in a buffer.
>
> I want it to work in the following way:
>
> 1. User enters "M-x pwc-set-counter" and sets the word counter to a
> particular number.
> 2. Whenever a word is added to a buffer, the word counter is incremented.
> 3. Whenever a word is removed from a buffer, the word counter is
> decremented.
> 4. As long as the minor mode is active, the value of the word counter is
> visible in the mode line (same place where current row and column are shown
> in some modes).
>
> Restrictions:
>
> 1. This minor mode should work for text (Org mode) buffers with up to 3000
> words (i. e. we are NOT talking gigabytes of text).
> 2. This minor mode must be compatible with the evil and Org mode.
>
> How is the minor mode I want to develop different from existing solutions?
>
> I want to be able to count words that I wrote on a particular day.
>
> Imagine I have a goal of writing at least 1000 words per day. When I begin
> to write on a new day, I reset the word counter to zero. Then I write in
> one buffer and see the progress in the modeline. Then I may switch to a
> different buffer (a different chapter), manually change the word counter
> and continue to work.
>
> What I want to implement is the word counter from Scrivener which shows
> you the number of words you wrote today across different chapters. It also
> shows you a visual representatio of the percentage of the daily quota.
>
> As far as I know, none of the existing Emacs word counters offers this
> functionality.
>
> Questions:
>
> 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?
> 2. Are there existing functions that count the words in the current buffer
> which I can reuse in my minor mode?
>
> Thanks in advance
>
> Pravles


  parent reply	other threads:[~2022-11-20  3:10 UTC|newest]

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

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=CADoYgq806LHVxbiRBy+5WyS5QS0ABEBhtOKNNSy95QBJ+573HQ@mail.gmail.com \
    --to=bobnewell@bobnewell.net \
    --cc=help-gnu-emacs@gnu.org \
    --cc=pravles@pm.me \
    /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).