unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Rethinking count-words-region
@ 2011-10-07 15:41 Chong Yidong
  2011-10-07 16:46 ` Jambunathan K
                   ` (4 more replies)
  0 siblings, 5 replies; 28+ messages in thread
From: Chong Yidong @ 2011-10-07 15:41 UTC (permalink / raw)
  To: emacs-devel

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).  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.

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).



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Rethinking count-words-region
  2011-10-07 15:41 Rethinking count-words-region Chong Yidong
@ 2011-10-07 16:46 ` Jambunathan K
  2011-10-08 16:53   ` Chong Yidong
  2011-10-07 18:08 ` Eli Zaretskii
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 28+ messages in thread
From: Jambunathan K @ 2011-10-07 16:46 UTC (permalink / raw)
  To: emacs-devel


> 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.

FWIW, what constitutes a word is also mode dependent. Here is a link
from the Orgmode mailing list.

http://thread.gmane.org/gmane.emacs.orgmode/37762/focus=38014

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

Let the function name have `statistics' or `stats' in it (for eg
 `region-stats'). This way it will be future compatible.

FWIW, LibreOffice reports following stats on a document:
1. No. of Pages
2. No. of Tables
3. No. of Graphics
4. No. of Paragraphs
5. No. of Words
6. No. of Characters
7. No. of Characters excluding spaces
8. No. of lines

-- 



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Rethinking count-words-region
  2011-10-07 15:41 Rethinking count-words-region Chong Yidong
  2011-10-07 16:46 ` Jambunathan K
@ 2011-10-07 18:08 ` Eli Zaretskii
  2011-10-07 20:51   ` Chong Yidong
  2011-10-07 20:29 ` Andreas Röhler
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 28+ messages in thread
From: Eli Zaretskii @ 2011-10-07 18:08 UTC (permalink / raw)
  To: Chong Yidong; +Cc: emacs-devel

> From: Chong Yidong <cyd@stupidchicken.com>
> Date: Fri, 07 Oct 2011 11:41:42 -0400
> 
> 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).  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.

What will such a change do to those who (like yours truly) disable
transient-mark-mode, which AFAIK means the region is never active?  I
do want to be able to count lines (if not words) in the region.

At the very least, the command should behave like before if
transient-mark-mode is disabled.



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Rethinking count-words-region
  2011-10-07 15:41 Rethinking count-words-region Chong Yidong
  2011-10-07 16:46 ` Jambunathan K
  2011-10-07 18:08 ` Eli Zaretskii
@ 2011-10-07 20:29 ` Andreas Röhler
  2011-10-07 20:55 ` Alan Mackenzie
  2011-10-08 16:52 ` Chong Yidong
  4 siblings, 0 replies; 28+ messages in thread
From: Andreas Röhler @ 2011-10-07 20:29 UTC (permalink / raw)
  To: emacs-devel

Am 07.10.2011 17:41, schrieb Chong Yidong:
> 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).  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.
>
> 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).
>
>

Hi,

simply "count-words", "count-lines" seems better for me.
A lot of other function restrict to region already, if active.
User may assume that.

When -region is mentioned explicitly, it should require it, not operate 
on the whole buffer.

Cheers,

Andreas




^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Rethinking count-words-region
  2011-10-07 18:08 ` Eli Zaretskii
@ 2011-10-07 20:51   ` Chong Yidong
  2011-10-07 20:55     ` Chong Yidong
  2011-10-08  6:22     ` Eli Zaretskii
  0 siblings, 2 replies; 28+ messages in thread
From: Chong Yidong @ 2011-10-07 20:51 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

> What will such a change do to those who (like yours truly) disable
> transient-mark-mode, which AFAIK means the region is never active?  I
> do want to be able to count lines (if not words) in the region.
>
> At the very least, the command should behave like before if
> transient-mark-mode is disabled.

On reflection, I think the Bug#9429 change to count-words-region is
misguided.  If we want to be consistent with other parts of Emacs, like
ispell-word/ispell-region, we need two separate commands:

 - A count-*-region command that counts in the region, using
   (interactive "r").  Even if Transient Mark mode is active and the
   region is not active, it counts in the inactive region.  This is like
   ispell-region.

 - A count-* command that usually counts in the buffer.  If
   use-region-p, it counts in the region.  This is like ispell-word.



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Rethinking count-words-region
  2011-10-07 15:41 Rethinking count-words-region Chong Yidong
                   ` (2 preceding siblings ...)
  2011-10-07 20:29 ` Andreas Röhler
@ 2011-10-07 20:55 ` Alan Mackenzie
  2011-10-08 16:52 ` Chong Yidong
  4 siblings, 0 replies; 28+ messages in thread
From: Alan Mackenzie @ 2011-10-07 20:55 UTC (permalink / raw)
  To: Chong Yidong; +Cc: emacs-devel

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).



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Rethinking count-words-region
  2011-10-07 20:51   ` Chong Yidong
@ 2011-10-07 20:55     ` Chong Yidong
  2011-10-08 17:58       ` Andreas Röhler
  2011-10-08  6:22     ` Eli Zaretskii
  1 sibling, 1 reply; 28+ messages in thread
From: Chong Yidong @ 2011-10-07 20:55 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Chong Yidong <cyd@stupidchicken.com> writes:

>  - A count-*-region command that counts in the region, using
>    (interactive "r").  Even if Transient Mark mode is active and the
>    region is not active, it counts in the inactive region.  This is like
>    ispell-region.
>
>  - A count-* command that usually counts in the buffer.  If
>    use-region-p, it counts in the region.  This is like ispell-word.

And I guess we can call these commands count-words-region and
count-words, even if they also provide information about lines and
characters.



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Rethinking count-words-region
  2011-10-07 20:51   ` Chong Yidong
  2011-10-07 20:55     ` Chong Yidong
@ 2011-10-08  6:22     ` Eli Zaretskii
  1 sibling, 0 replies; 28+ messages in thread
From: Eli Zaretskii @ 2011-10-08  6:22 UTC (permalink / raw)
  To: Chong Yidong; +Cc: emacs-devel

> From: Chong Yidong <cyd@stupidchicken.com>
> Cc: emacs-devel@gnu.org
> Date: Fri, 07 Oct 2011 16:51:19 -0400
> 
> On reflection, I think the Bug#9429 change to count-words-region is
> misguided.  If we want to be consistent with other parts of Emacs, like
> ispell-word/ispell-region, we need two separate commands:
> 
>  - A count-*-region command that counts in the region, using
>    (interactive "r").  Even if Transient Mark mode is active and the
>    region is not active, it counts in the inactive region.  This is like
>    ispell-region.
> 
>  - A count-* command that usually counts in the buffer.  If
>    use-region-p, it counts in the region.  This is like ispell-word.

That'd be fine with me.



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Rethinking count-words-region
  2011-10-07 15:41 Rethinking count-words-region Chong Yidong
                   ` (3 preceding siblings ...)
  2011-10-07 20:55 ` Alan Mackenzie
@ 2011-10-08 16:52 ` Chong Yidong
  2011-10-08 17:51   ` Andreas Röhler
  2011-10-08 20:04   ` Juri Linkov
  4 siblings, 2 replies; 28+ messages in thread
From: Chong Yidong @ 2011-10-08 16:52 UTC (permalink / raw)
  To: emacs-devel

Thanks for the various feedback.  I've now changed count-words-region
back to operating solely on the region.  The command now also reports
the number of lines and characters, making it a superset of the old
count-lines-region.  Hence, count-lines-region is now an alias for
count-words-region.  The M-= binding was updated accordingly.

The previous count-words-region behavior is assigned to a new
`count-words' command, which acts on the region if use-region-p and on
the buffer otherwise.  This currently has no binding; C-= is the obvious
candidate, or we could reassign `C-x l'.  But that can be settled after
the release, I think.



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Rethinking count-words-region
  2011-10-07 16:46 ` Jambunathan K
@ 2011-10-08 16:53   ` Chong Yidong
  2011-10-08 18:00     ` Andreas Röhler
  0 siblings, 1 reply; 28+ messages in thread
From: Chong Yidong @ 2011-10-08 16:53 UTC (permalink / raw)
  To: emacs-devel

Jambunathan K <kjambunathan@gmail.com> writes:

> FWIW, what constitutes a word is also mode dependent.

Yes, in the future I think we need to provide a count-words-function for
mode-dependent word counts.



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Rethinking count-words-region
  2011-10-08 16:52 ` Chong Yidong
@ 2011-10-08 17:51   ` Andreas Röhler
  2011-10-08 20:04   ` Juri Linkov
  1 sibling, 0 replies; 28+ messages in thread
From: Andreas Röhler @ 2011-10-08 17:51 UTC (permalink / raw)
  To: Chong Yidong; +Cc: Emacs developers

Am 08.10.2011 18:52, schrieb Chong Yidong:
[  ... ]

  Hence, count-lines-region is now an alias for
> count-words-region.

Hi Chong,

the other changes announced are reasonable for me, thanks.

However, count-lines-region is quite another item than count-words-region.

Why not let them just do what their name is saying?

Andreas





^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Rethinking count-words-region
  2011-10-07 20:55     ` Chong Yidong
@ 2011-10-08 17:58       ` Andreas Röhler
  2011-10-08 18:11         ` Drew Adams
  0 siblings, 1 reply; 28+ messages in thread
From: Andreas Röhler @ 2011-10-08 17:58 UTC (permalink / raw)
  To: emacs-devel; +Cc: Chong Yidong

Am 07.10.2011 22:55, schrieb Chong Yidong:
> Chong Yidong<cyd@stupidchicken.com>  writes:
[ ... ]   use-region-p, it counts in the region.  This is like ispell-word.
>
> And I guess we can call these commands count-words-region and
> count-words, even if they also provide information about lines and
> characters.
>
>

Hi,

think that's definitely the wrong path.

Its very important to express with command-names what they are doing.

If we have a command returning more than one thing, this must be spoken 
out, not done silently.

if you want a combined command, reporting words-lines-chars,

name it that, or give an abbreviation wlc while explaining it for example.

Suggest to avoid unexpected multitudes,

thanks,

Andreas










^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Rethinking count-words-region
  2011-10-08 16:53   ` Chong Yidong
@ 2011-10-08 18:00     ` Andreas Röhler
  0 siblings, 0 replies; 28+ messages in thread
From: Andreas Röhler @ 2011-10-08 18:00 UTC (permalink / raw)
  To: emacs-devel; +Cc: Chong Yidong

Am 08.10.2011 18:53, schrieb Chong Yidong:
> Jambunathan K<kjambunathan@gmail.com>  writes:
>
>> FWIW, what constitutes a word is also mode dependent.
>
> Yes, in the future I think we need to provide a count-words-function for
> mode-dependent word counts.
>
>

don't we have that already?

a word is a word is a word is a word.

that's all.

Let the mode decide, what a word is and respect that. :)



^ permalink raw reply	[flat|nested] 28+ messages in thread

* RE: Rethinking count-words-region
  2011-10-08 17:58       ` Andreas Röhler
@ 2011-10-08 18:11         ` Drew Adams
  2011-10-08 18:23           ` Chong Yidong
  0 siblings, 1 reply; 28+ messages in thread
From: Drew Adams @ 2011-10-08 18:11 UTC (permalink / raw)
  To: 'Andreas Röhler', emacs-devel; +Cc: 'Chong Yidong'

> think that's definitely the wrong path.
> Its very important to express with command-names what they are doing.
> If we have a command returning more than one thing, this must 
> be spoken out, not done silently.

1+

No reason to gratuitously introduce confusion.  Sometimes we cannot avoid it,
and names are never perfect.  But this is counter-productive.  Please DTRT, one
way or another.

If you define a command that does multiple things, then try to find a name that
expresses that.  If the multiple things are completely different from each
other, then they might not belong together in the same command.

In this case, the command reports a certain number of counts, which is fine.
The name should reflect that.




^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Rethinking count-words-region
  2011-10-08 18:11         ` Drew Adams
@ 2011-10-08 18:23           ` Chong Yidong
  2011-10-08 18:25             ` Drew Adams
  2011-10-08 18:40             ` Andreas Röhler
  0 siblings, 2 replies; 28+ messages in thread
From: Chong Yidong @ 2011-10-08 18:23 UTC (permalink / raw)
  To: Drew Adams; +Cc: 'Andreas Röhler', emacs-devel

"Drew Adams" <drew.adams@oracle.com> writes:

> If you define a command that does multiple things, then try to find a
> name that expresses that.

The old count-lines-region also reported a character count, and Unix's
`wc' also reports lines and characters.  I suggest living with it.



^ permalink raw reply	[flat|nested] 28+ messages in thread

* RE: Rethinking count-words-region
  2011-10-08 18:23           ` Chong Yidong
@ 2011-10-08 18:25             ` Drew Adams
  2011-10-08 18:29               ` Alan Mackenzie
  2011-10-08 18:40             ` Andreas Röhler
  1 sibling, 1 reply; 28+ messages in thread
From: Drew Adams @ 2011-10-08 18:25 UTC (permalink / raw)
  To: 'Chong Yidong'; +Cc: 'Andreas Röhler', emacs-devel

> > If you define a command that does multiple things, then try 
> > to find a name that expresses that.
> 
> The old count-lines-region also reported a character count, and Unix's
> `wc' also reports lines and characters.  I suggest living with it.

2 (or 3) wrongs don't make a right. ;-)




^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Rethinking count-words-region
  2011-10-08 18:25             ` Drew Adams
@ 2011-10-08 18:29               ` Alan Mackenzie
  2011-10-08 19:04                 ` Lars Ingebrigtsen
  2011-10-08 19:28                 ` Juri Linkov
  0 siblings, 2 replies; 28+ messages in thread
From: Alan Mackenzie @ 2011-10-08 18:29 UTC (permalink / raw)
  To: Drew Adams
  Cc: 'Chong Yidong', 'Andreas Röhler',
	emacs-devel

Hi, everybody.

On Sat, Oct 08, 2011 at 11:25:31AM -0700, Drew Adams wrote:
> > > If you define a command that does multiple things, then try 
> > > to find a name that expresses that.

> > The old count-lines-region also reported a character count, and
> > Unix's `wc' also reports lines and characters.  I suggest living
> > with it.

> 2 (or 3) wrongs don't make a right. ;-)

How about `count-lwc' and `count-lwc-region'?  These names are short,
accurate, mnemonic and are reminiscent of the *nix `wc'.

-- 
Alan Mackenzie (Nuremberg, Germany).



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Rethinking count-words-region
  2011-10-08 18:23           ` Chong Yidong
  2011-10-08 18:25             ` Drew Adams
@ 2011-10-08 18:40             ` Andreas Röhler
  1 sibling, 0 replies; 28+ messages in thread
From: Andreas Röhler @ 2011-10-08 18:40 UTC (permalink / raw)
  To: Chong Yidong; +Cc: Drew Adams, emacs-devel

Am 08.10.2011 20:23, schrieb Chong Yidong:
> "Drew Adams"<drew.adams@oracle.com>  writes:
>
>> If you define a command that does multiple things, then try to find a
>> name that expresses that.
>
> The old count-lines-region also reported a character count,

this function has been buggy for long
See http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7115"


  and Unix's
> `wc' also reports lines and characters.


So Emacs can't do more and better then Unix ages ago?

   I suggest living with it.
>




^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Rethinking count-words-region
  2011-10-08 18:29               ` Alan Mackenzie
@ 2011-10-08 19:04                 ` Lars Ingebrigtsen
  2011-10-08 19:28                 ` Juri Linkov
  1 sibling, 0 replies; 28+ messages in thread
From: Lars Ingebrigtsen @ 2011-10-08 19:04 UTC (permalink / raw)
  To: emacs-devel

Alan Mackenzie <acm@muc.de> writes:

> How about `count-lwc' and `count-lwc-region'?  These names are short,
> accurate, mnemonic and are reminiscent of the *nix `wc'.

I suggest stopping this absurd discussion.  The change Chong did is
the right thing to do.

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/




^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Rethinking count-words-region
  2011-10-08 18:29               ` Alan Mackenzie
  2011-10-08 19:04                 ` Lars Ingebrigtsen
@ 2011-10-08 19:28                 ` Juri Linkov
  1 sibling, 0 replies; 28+ messages in thread
From: Juri Linkov @ 2011-10-08 19:28 UTC (permalink / raw)
  To: Alan Mackenzie
  Cc: 'Chong Yidong', 'Andreas Röhler', Drew Adams,
	emacs-devel

> How about `count-lwc' and `count-lwc-region'?  These names are short,
> accurate, mnemonic and are reminiscent of the *nix `wc'.

Oh, no, not another TLA ;-)

`wc' was a poorly chosen name for the shell command, it stands
for "Water Closet" and counts everything besides words: newlines,
characters, bytes, longest lines.  It's analogous to the "Kitchen Sink",
so let's name the corresponding Emacs commands `M-x ks' :-)



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Rethinking count-words-region
  2011-10-08 16:52 ` Chong Yidong
  2011-10-08 17:51   ` Andreas Röhler
@ 2011-10-08 20:04   ` Juri Linkov
  2011-10-08 20:46     ` Chong Yidong
  2011-10-08 20:49     ` Drew Adams
  1 sibling, 2 replies; 28+ messages in thread
From: Juri Linkov @ 2011-10-08 20:04 UTC (permalink / raw)
  To: Chong Yidong; +Cc: emacs-devel

> The previous count-words-region behavior is assigned to a new
> `count-words' command, which acts on the region if use-region-p and on
> the buffer otherwise.

One problem: when I type `M-=', it fails with:

  Debugger entered--Lisp error: (mark-inactive)
    call-interactively(count-words-region nil nil)

That's because I customized `mark-even-if-inactive' to `nil'
(to avoid its dangerous behavior when it's non-nil).

Maybe `count-words-region' should take care of this case?

Better yet to bind `M-=' to a new command with a general name
like suggested `count-stats' that will take care of different
region activation cases and report all possible counts.



^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Rethinking count-words-region
  2011-10-08 20:04   ` Juri Linkov
@ 2011-10-08 20:46     ` Chong Yidong
  2011-10-08 21:09       ` Juri Linkov
  2011-10-08 20:49     ` Drew Adams
  1 sibling, 1 reply; 28+ messages in thread
From: Chong Yidong @ 2011-10-08 20:46 UTC (permalink / raw)
  To: Juri Linkov; +Cc: emacs-devel

Juri Linkov <juri@jurta.org> writes:

> One problem: when I type `M-=', it fails with:
>
>   Debugger entered--Lisp error: (mark-inactive)
>     call-interactively(count-words-region nil nil)
>
> That's because I customized `mark-even-if-inactive' to `nil'
> (to avoid its dangerous behavior when it's non-nil).

In the past, M-= ignored `mark-even-if-inactive' even though it was
working with the region, so arguably the new behavior is more correct.
It doesn't seem clean to make an exception for this particular usage of
the inactive mark, but not others.

Seems like what you want is `count-words', not `count-words-region'.



^ permalink raw reply	[flat|nested] 28+ messages in thread

* RE: Rethinking count-words-region
  2011-10-08 20:04   ` Juri Linkov
  2011-10-08 20:46     ` Chong Yidong
@ 2011-10-08 20:49     ` Drew Adams
  2011-10-08 21:12       ` Juri Linkov
  1 sibling, 1 reply; 28+ messages in thread
From: Drew Adams @ 2011-10-08 20:49 UTC (permalink / raw)
  To: 'Juri Linkov', 'Chong Yidong'; +Cc: emacs-devel

> Better yet to bind `M-=' to a new command with a general name
> like suggested `count-stats' that will take care of different
> region activation cases and report all possible counts.

1+ for changing the name.

And I propose we get rid of any default binding for the command.
Users can bind it if they like.

This is a waste of (a) a good, repeatable chord (just hold it down), (b) one
that is also usable in a terminal (via `ESC ='), and (c) one that is mnemonic
for lots of things that involve _equality_ or _comparison_.  `=' is not mnemonic
for _counting_ anything.

This command does not need to be bound to a key by default - anymore than, say,
`cd'.  It happens to still hang around from a time when there were more keys to
spare and fewer useful commands that we might want to bind.




^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Rethinking count-words-region
  2011-10-08 20:46     ` Chong Yidong
@ 2011-10-08 21:09       ` Juri Linkov
  0 siblings, 0 replies; 28+ messages in thread
From: Juri Linkov @ 2011-10-08 21:09 UTC (permalink / raw)
  To: Chong Yidong; +Cc: emacs-devel

> In the past, M-= ignored `mark-even-if-inactive' even though it was
> working with the region, so arguably the new behavior is more correct.
> It doesn't seem clean to make an exception for this particular usage of
> the inactive mark, but not others.

Yes, this is a general problem, e.g. I can't use
`M-|' (`shell-command-on-region') on the whole buffer when
there is no active region.  This could be improved in 24.2.




^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Rethinking count-words-region
  2011-10-08 20:49     ` Drew Adams
@ 2011-10-08 21:12       ` Juri Linkov
  2011-10-08 21:33         ` Drew Adams
  0 siblings, 1 reply; 28+ messages in thread
From: Juri Linkov @ 2011-10-08 21:12 UTC (permalink / raw)
  To: Drew Adams; +Cc: 'Chong Yidong', emacs-devel

> It happens to still hang around from a time when there were more keys
> to spare and fewer useful commands that we might want to bind.

A good way to make more available keybindings is to turn an existing key
into the key prefix like:

`M-= ='   count-stats
`M-= w'   count-words
`M-= l'   count-lines
`M-= c'   count-chars

`M-= r w'   count-region-words
`M-= r l'   count-region-lines
`M-= r c'   count-region-chars



^ permalink raw reply	[flat|nested] 28+ messages in thread

* RE: Rethinking count-words-region
  2011-10-08 21:12       ` Juri Linkov
@ 2011-10-08 21:33         ` Drew Adams
  2011-10-09  0:57           ` chad
  0 siblings, 1 reply; 28+ messages in thread
From: Drew Adams @ 2011-10-08 21:33 UTC (permalink / raw)
  To: 'Juri Linkov'; +Cc: 'Chong Yidong', emacs-devel

> A good way to make more available keybindings is to turn an 
> existing key into the key prefix like:
> 
> `M-= ='   count-stats
> `M-= w'   count-words
> `M-= l'   count-lines
> `M-= c'   count-chars
> 
> `M-= r w'   count-region-words
> `M-= r l'   count-region-lines
> `M-= r c'   count-region-chars

Not _that_ key (`M-='), anyway.
Which part of this did you not understand:

d> This is a waste of:
d> (a) a good, repeatable chord (just hold it down),
d> (b) one that is also usable in a terminal (via `ESC ='), and
d> (c) one that is mnemonic for lots of things that involve _equality_
d>     or _comparison_.  `=' is not mnemonic for _counting_ anything.

E.g., I personally use `C-=' as a prefix key, so I agree with you about the
value of that.  But I use it for commands that _compare_ something:

C-= w           compare-windows
C-= d           diff
C-= f           ediff-files
C-= e           ediff-files
C-= b           ediff-buffers

(And yes, I do feel wasteful that I use a repeatable key, `C-=', for commands
that do not take advantage of its repeatability.  But anyway, those are my own
bindings, not default bindings for Emacs.)

Similarly, M-= would be something to use for a set of commands that compare
things or that otherwise involve equality.  But certainly not for commands that
_count_.

FWIW, I'm not against a command that counts several different things at once.  I
don't think it deserves/needs a default key binding, however - users can bind it
if they wish.

And I certainly don't think that we need to waste multiple key sequences, by
default, for various counting commands.  (Seven key sequences!?  Even on a
prefix key that's a waste.)

It's not just because we _can_ bind some key that we should or we have to.  Far
from it.  Leave `M-=' for a good future use.  Leave it for users, for now.

Just one opinion, of course.




^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: Rethinking count-words-region
  2011-10-08 21:33         ` Drew Adams
@ 2011-10-09  0:57           ` chad
  2011-10-09  1:05             ` Drew Adams
  0 siblings, 1 reply; 28+ messages in thread
From: chad @ 2011-10-09  0:57 UTC (permalink / raw)
  To: Emacs devel

I don't know if we want to remove the M-= binding or not, but it certainly ought to be in the menus, and I don't see it. I'd suggest in the _Tools_ menu, in the top section, under `Count Words'.

*Chad




^ permalink raw reply	[flat|nested] 28+ messages in thread

* RE: Rethinking count-words-region
  2011-10-09  0:57           ` chad
@ 2011-10-09  1:05             ` Drew Adams
  0 siblings, 0 replies; 28+ messages in thread
From: Drew Adams @ 2011-10-09  1:05 UTC (permalink / raw)
  To: 'chad', 'Emacs devel'

> I don't know if we want to remove the M-= binding or not, but 
> it certainly ought to be in the menus, and I don't see it. 
> I'd suggest in the _Tools_ menu, in the top section, under 
> `Count Words'.

1+ for adding to a menu.  But with a better name that indicates more what it
does.




^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2011-10-09  1:05 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-07 15:41 Rethinking count-words-region Chong Yidong
2011-10-07 16:46 ` Jambunathan K
2011-10-08 16:53   ` Chong Yidong
2011-10-08 18:00     ` Andreas Röhler
2011-10-07 18:08 ` Eli Zaretskii
2011-10-07 20:51   ` Chong Yidong
2011-10-07 20:55     ` Chong Yidong
2011-10-08 17:58       ` Andreas Röhler
2011-10-08 18:11         ` Drew Adams
2011-10-08 18:23           ` Chong Yidong
2011-10-08 18:25             ` Drew Adams
2011-10-08 18:29               ` Alan Mackenzie
2011-10-08 19:04                 ` Lars Ingebrigtsen
2011-10-08 19:28                 ` Juri Linkov
2011-10-08 18:40             ` Andreas Röhler
2011-10-08  6:22     ` Eli Zaretskii
2011-10-07 20:29 ` Andreas Röhler
2011-10-07 20:55 ` Alan Mackenzie
2011-10-08 16:52 ` Chong Yidong
2011-10-08 17:51   ` Andreas Röhler
2011-10-08 20:04   ` Juri Linkov
2011-10-08 20:46     ` Chong Yidong
2011-10-08 21:09       ` Juri Linkov
2011-10-08 20:49     ` Drew Adams
2011-10-08 21:12       ` Juri Linkov
2011-10-08 21:33         ` Drew Adams
2011-10-09  0:57           ` chad
2011-10-09  1:05             ` Drew Adams

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).