* how-many to number?
@ 2005-09-28 12:40 Albert Reiner
2005-09-28 13:35 ` rgb
0 siblings, 1 reply; 5+ messages in thread
From: Albert Reiner @ 2005-09-28 12:40 UTC (permalink / raw)
Hi,
I am sure there must be a simple way to get the number of occurrences
of some regular expression in some region as a number. However, the
only thing I could find was count-matches / how-many, but that only
prints a message in the minibuffer.
A trivial example:
(how-many "\\b\\w+\\b" (point-min) (point-max))
returns a string like "88 occurrences", but how can I get at the
integer 88 instead? I would then want to do some simple arithmetic on
it.
Thanks in advance,
Albert.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: how-many to number?
2005-09-28 12:40 how-many to number? Albert Reiner
@ 2005-09-28 13:35 ` rgb
2005-09-28 14:00 ` Albert Reiner
0 siblings, 1 reply; 5+ messages in thread
From: rgb @ 2005-09-28 13:35 UTC (permalink / raw)
> (how-many "\\b\\w+\\b" (point-min) (point-max))
>
> returns a string like "88 occurrences", but how can I get at the
> integer 88 instead? I would then want to do some simple arithmetic on
> it.
C-h f how-many <ret>
Print and return number of matches for regexp following point.
When called from Lisp and interactive is omitted or nil, *just return
the number, do not print it*; if interactive is t, the function behaves
in all respects has if it had been called interactively.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: how-many to number?
2005-09-28 13:35 ` rgb
@ 2005-09-28 14:00 ` Albert Reiner
2005-09-29 3:15 ` Neon Absentius
[not found] ` <mailman.9034.1127965324.20277.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 5+ messages in thread
From: Albert Reiner @ 2005-09-28 14:00 UTC (permalink / raw)
["rgb" <rbielaws@i1.net>, 28 Sep 2005 06:35:26 -0700]:
> C-h f how-many <ret>
>
> Print and return number of matches for regexp following point.
> When called from Lisp and interactive is omitted or nil, *just return
> the number, do not print it*; if interactive is t, the function behaves
> in all respects has if it had been called interactively.
Thanks; I don't get this on GNU Emacs 21.3.1 (i386-redhat-linux-gnu, X
toolkit, Xaw3d scroll bars) of 2005-02-04 on bugs.build.redhat.com:
,----[ C-h f how-many RET ]
| how-many is an interactive compiled Lisp function in `replace'.
| (how-many REGEXP &optional RSTART REND)
|
| Print number of matches for REGEXP following point.
|
| If REGEXP contains upper case characters (excluding those preceded by `\'),
| the matching is case-sensitive.
|
| Second and third arg RSTART and REND specify the region to operate on.
|
| Interactively, in Transient Mark mode when the mark is active, operate
| on the contents of the region. Otherwise, operate from point to the
| end of the buffer.
`----
So I guess that changed recently. My current work-around:
(read (how-many "\\b\\w+\\b" (point-min) (point-max)))
, which is ugly but seems to work.
Thanks for your help,
Albert.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: how-many to number?
2005-09-28 14:00 ` Albert Reiner
@ 2005-09-29 3:15 ` Neon Absentius
[not found] ` <mailman.9034.1127965324.20277.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 5+ messages in thread
From: Neon Absentius @ 2005-09-29 3:15 UTC (permalink / raw)
On Wed, Sep 28, 2005 at 04:00:38PM +0200, Albert Reiner wrote:
> So I guess that changed recently.
I think it is changed only on CVS. Emacs 21.4.1 has the old version.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: how-many to number?
[not found] ` <mailman.9034.1127965324.20277.help-gnu-emacs@gnu.org>
@ 2005-09-29 13:17 ` Albert Reiner
0 siblings, 0 replies; 5+ messages in thread
From: Albert Reiner @ 2005-09-29 13:17 UTC (permalink / raw)
[Neon Absentius <absent@sdf.lonestar.org>, Thu, 29 Sep 2005 03:15:59 +0000]:
> On Wed, Sep 28, 2005 at 04:00:38PM +0200, Albert Reiner wrote:
>
> > So I guess that changed recently.
>
> I think it is changed only on CVS. Emacs 21.4.1 has the old version.
Thanks for the confirmation / clarification,
Albert.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-09-29 13:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-28 12:40 how-many to number? Albert Reiner
2005-09-28 13:35 ` rgb
2005-09-28 14:00 ` Albert Reiner
2005-09-29 3:15 ` Neon Absentius
[not found] ` <mailman.9034.1127965324.20277.help-gnu-emacs@gnu.org>
2005-09-29 13:17 ` Albert Reiner
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).