1

Here is an interesting discovery. Copy the following text into a buffer:

'hello world'
'नमस्कार नमस्कार'

One can see that there are four words, two on line 1 and two on line 2.

Emacs count these as six words! Two on line 1 and four on line 2!

In case if it matters, I am using Doom Emacs v 2.0.9, Emacs v 26.3.

How do I set things right?

  • 1
    Can't reproduce with GNU Emacs 26.3 (build 1, i686-pc-linux-gnu, GTK+ Version 3.14.5) of 2019-09-04. count-words-region tells: The region has 4 words. – Andreas Röhler Jan 17 at 9:55
  • @AndreasRöhler see answer of devcom – jue Jan 17 at 11:35
  • @jue Checked with org- and text-mode: always 4 words with GNU Emacs 28.0.50 (build 1, i686-pc-linux-gnu, GTK+ Version 3.14.5) of 2020-01-10. BTW maybe the single-quotes produce some single-word count in certain environments? – Andreas Röhler Jan 18 at 15:06
1

The problem is with the second line which Emacs sometimes treats as four words. I can reproduce this in Vanilla Emacs 26.3 and 28.1. If I copy your text into the Emacs scratch buffer or into a .el file I get the correct count. If I copy the text into an org file or text file, the count is incorrect. This persuades me that this is likely a bug which has to do with the way Emacs treats the Hindi script, in which case I would file a bug report. First I would check my dot Emacs for language specific and environment settings and remove any you have specifically added.

| improve this answer | |
  • I can reproduce this with Emacs v25.1. – jue Jan 17 at 11:35
  • 1
    M-x report-emacs-bug – Drew Jan 17 at 17:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.