[Top][All Lists]

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

Re: Rethinking count-words-region

From: Alan Mackenzie
Subject: Re: Rethinking count-words-region
Date: Fri, 7 Oct 2011 20:55:23 +0000
User-agent: Mutt/1.5.21 (2010-09-15)

Hi, Yidong.

On Fri, Oct 07, 2011 at 11:41:42AM -0400, Chong Yidong wrote:
> The command `count-words-region', newly introduced for Emacs 24, is
> inconsistent with the pre-existing `count-lines-region'.  If no region
> is active, the former reports the number of words in the buffer
> (implemented in Bug#9429).

That is horrible.  Functions should do what their names say.
`count-lines-region' should count the lines in the region.  Period.  Is
this so difficult to grasp?

How about renaming the above function `count-lines' and defining
`count-lines-region' properly.

Some of us don't use transient-mark-mode.

> The latter always reports the number of lines in the region, whether or
> not it is active.

> The two ought to be consistent.  The behavior of `count-words-region' is
> the better one, I think, even if adopting it incurs some backward
> incompatibility.

I think it is more about naming than functionality.  It seems (up to) six
functions are called for: `count-{lines,words}-{,region,buffer}'.  With
this approach, the above problem evaporates.

> But going beyond this, instead of introducing a separate
> `count-words-region' command, why not fold this functionality into
> `count-lines-region'?  After all, `count-lines-region' already reports
> the number of characters, and there's space for it to report the number
> of words too.  And it has a convenient binding in M-=, whereas
> `count-words-region' has no default binding.

> Maybe we could rename the combined function something like `count-text'
> (better suggestions welcome).

"wc", like the raiser of bug #9429 suggested.  But please, please, please,
if the function has "region" in its name, make it work on the region.

Alan Mackenzie (Nuremberg, Germany).

reply via email to

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