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: Re: how-many/count-matches for non-interactive use Date: 16 Oct 2004 23:49:32 +0200 Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Message-ID: <87y8i6ib9v.fsf@oak.pohoyda.family> References: <87pt3m5vqk.fsf@oak.pohoyda.family> <874qkwmr5w.fsf@oak.pohoyda.family> <87hdowuhhb.fsf@oak.pohoyda.family> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1097963426 24125 80.91.229.6 (16 Oct 2004 21:50:26 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 16 Oct 2004 21:50:26 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Oct 16 23:50:18 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 1CIwRO-0002zO-00 for ; Sat, 16 Oct 2004 23:50:18 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CIwYa-000193-QT for ged-emacs-devel@m.gmane.org; Sat, 16 Oct 2004 17:57:44 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CIwYT-00018x-CQ for emacs-devel@gnu.org; Sat, 16 Oct 2004 17:57:37 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CIwYT-00018l-1n for emacs-devel@gnu.org; Sat, 16 Oct 2004 17:57:37 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CIwYS-00018i-O1 for emacs-devel@gnu.org; Sat, 16 Oct 2004 17:57:36 -0400 Original-Received: from [213.165.64.20] (helo=mail.gmx.net) by monty-python.gnu.org with smtp (Exim 4.34) id 1CIwQu-0004Vl-Ok for emacs-devel@gnu.org; Sat, 16 Oct 2004 17:49:49 -0400 Original-Received: (qmail 25709 invoked by uid 65534); 16 Oct 2004 21:49:35 -0000 Original-Received: from p50842B35.dip0.t-ipconnect.de (EHLO www2.gmx.net) (80.132.43.53) by mail.gmx.net (mp002) with SMTP; 16 Oct 2004 23:49:35 +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 i9GLnXjO000631; Sat, 16 Oct 2004 23:49:34 +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 i9GLnXPV000628; Sat, 16 Oct 2004 23:49:33 +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: rms@gnu.org In-Reply-To: Original-Lines: 74 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:28492 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:28492 Richard Stallman writes: > > Since it is using Lisp code, you just do it with more Lisp code. Add > > a t to the list in a place that corresponds to where the new extra arg > > gets its value. > > Like this? > > It looks right to me, assuming that keep-lines-read-args > returns a list of one element (which it currently does). > You might instead do (list (car (keep-lines-read-args...)) nil nil t) > to make it clear you're taking just one arg value from that. Yes, I was considering that style too. So here it goes. Would somebody please install the change? Thank you. 2004-10-16 Alexander Pohoyda (tiny change) * replace.el (how-many): New VERBOSE argument, which is used to suppress the message for non-interactive use. 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 16 Oct 2004 20:12:49 -0000 @@ -457,8 +457,8 @@ (progn (forward-line 1) (point))))))) -(defun how-many (regexp &optional rstart rend) - "Print number of matches for REGEXP following point. +(defun how-many (regexp &optional rstart rend verbose) + "Return the number of matches for REGEXP following point. If REGEXP contains upper case characters (excluding those preceded by `\\'), the matching is case-sensitive. @@ -467,10 +467,14 @@ 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." +end of the buffer. + +If VERBOSE is t (or the function is called interactively), issue a message +with the number of matches." (interactive - (keep-lines-read-args "How many matches for (regexp): ")) + (list (car (keep-lines-read-args "How many matches for (regexp): ")) + nil nil t)) (save-excursion (if rstart (goto-char (min rstart rend)) @@ -490,7 +494,8 @@ (if (= opoint (point)) (forward-char 1) (setq count (1+ count)))) - (message "%d occurrences" count)))) + (when verbose (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