From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Alexander Pohoyda Newsgroups: gmane.emacs.devel Subject: how-many/count-matches for non-interactive use Date: 13 Oct 2004 20:16:51 +0200 Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Message-ID: <87pt3m5vqk.fsf@oak.pohoyda.family> References: <1096006177.432792.29828.nullmailer@Update.UU.SE> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1097691516 14893 80.91.229.6 (13 Oct 2004 18:18:36 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 13 Oct 2004 18:18:36 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Oct 13 20:18:23 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CHnhf-0004eT-00 for ; Wed, 13 Oct 2004 20:18:23 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CHnoi-0002k8-69 for ged-emacs-devel@m.gmane.org; Wed, 13 Oct 2004 14:25:40 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CHnoR-0002io-Cg for emacs-devel@gnu.org; Wed, 13 Oct 2004 14:25:23 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CHnoQ-0002iQ-B1 for emacs-devel@gnu.org; Wed, 13 Oct 2004 14:25:22 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CHnoQ-0002hz-0D for emacs-devel@gnu.org; Wed, 13 Oct 2004 14:25:22 -0400 Original-Received: from [213.165.64.20] (helo=mail.gmx.net) by monty-python.gnu.org with smtp (Exim 4.34) id 1CHngG-0007TX-L5 for emacs-devel@gnu.org; Wed, 13 Oct 2004 14:16:56 -0400 Original-Received: (qmail 26903 invoked by uid 65534); 13 Oct 2004 18:16:54 -0000 Original-Received: from p508431AA.dip0.t-ipconnect.de (EHLO www2.gmx.net) (80.132.49.170) by mail.gmx.net (mp008) with SMTP; 13 Oct 2004 20:16:54 +0200 X-Authenticated: #14602519 Original-Received: from oak.pohoyda.family (localhost [127.0.0.1]) by www2.gmx.net (8.12.10/8.12.10) with ESMTP id i9DIGqpS000514 for ; Wed, 13 Oct 2004 20:16:52 +0200 (CEST) (envelope-from alexander.pohoyda@gmx.net) Original-Received: (from apog@localhost) by oak.pohoyda.family (8.12.10/8.12.10/Submit) id i9DIGpVG000511; Wed, 13 Oct 2004 20:16:51 +0200 (CEST) (envelope-from alexander.pohoyda@gmx.net) X-Authentication-Warning: oak.pohoyda.family: apog set sender to alexander.pohoyda@gmx.net using -f Original-To: emacs-devel@gnu.org In-Reply-To: <1096006177.432792.29828.nullmailer@Update.UU.SE> Original-Lines: 30 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:28361 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:28361 The `how-many' function is not especially friendly for non-interactive use, because is issues a message. Is there a better way to count matches from a lisp program? How about this patch? Index: replace.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/replace.el,v retrieving revision 1.171 diff -u -r1.171 replace.el --- replace.el 30 May 2004 21:50:35 -0000 1.171 +++ replace.el 13 Oct 2004 18:14:35 -0000 @@ -490,7 +490,9 @@ (if (= opoint (point)) (forward-char 1) (setq count (1+ count)))) - (message "%d occurrences" count)))) + (if (interactive-p) + (message "%d occurrences" count) + count)))) (defvar occur-mode-map -- Alexander Pohoyda PGP Key fingerprint: 7F C9 CC 5A 75 CD 89 72 15 54 5F 62 20 23 C6 44