Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: add total word count in mode-line #16

Open
prosoitos opened this issue Apr 6, 2018 · 5 comments
Open

Feature request: add total word count in mode-line #16

prosoitos opened this issue Apr 6, 2018 · 5 comments

Comments

@prosoitos
Copy link

The package wc-mode has a sweet way of displaying the total word count in the mode line. The problem is that this mode is limited and counts every word. org-wc does a better job at not counting some elements (e.g. comments). But it would be really convenient to have the total count show in the mode-line.

@tesujimath
Copy link
Owner

Hmm. How often should it update? Counting a large buffer is not instantaneous!

@tesujimath
Copy link
Owner

I think the right way to do this would be a single scan of the whole buffer on loading the file, then deltas according to what is happening in the buffer. That's a fairly serious piece of work to get that right, so I don't think I'll be tackling that any time soon. A PR would of course be very welcome, but continual rescanning of the whole buffer sounds undesirable to me.

@prosoitos
Copy link
Author

prosoitos commented Apr 7, 2018

I will have a look at how wc-mode does it. Some kind of merge between both modes would be ideal for me (I am not really interested in the tree count feature and only really care about whole buffer counts. The reason I am very interested in your mode is because it is the only one that is attempting to only count relevant words in org 🙂)

@gvol
Copy link
Contributor

gvol commented May 14, 2018

I tried to do something similar a few years ago for NaNoWriMo: https://bitbucket.org/gvol/nanowrimo.el/src/default/nanowrimo.el
At that time wc-mode didn't exist, so I don't know how it's feature set compares. In the end I stopped using it because I spent too much time looking at it, and not enough time typing. :-)

It uses (or at least can) use org-wc to do the actual counting. I haven't done NaNoWriMo since then, so it may have bitrotted a bit, but I would gladly accept pull requests, and will try to get to bug reports/feature requests in a timely fashion.

@jjhankins
Copy link

You can set the wc-count-words function to call org-word-count-aux like this:

(setq wc-count-words-function
      (lambda (rstart rend)
        (if (eq major-mode 'org-mode)
            (org-word-count-aux rstart rend)
          (if (boundp 'count-words)
              (count-words rstart rend)
            (how-many "\\w+" rstart rend)))))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants