From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tak Ota Newsgroups: gmane.emacs.devel Subject: Re: collect-string Date: Wed, 1 Dec 2010 17:59:42 -0800 Message-ID: <20101201.175942.507258633.Takaaki.Ota@am.sony.com> References: <20101109.181250.505612453.Takaaki.Ota@am.sony.com> <20101129.181453.300448974.Takaaki.Ota@am.sony.com> <8762vf5qkv.fsf@uwakimon.sk.tsukuba.ac.jp> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1291255209 31742 80.91.229.12 (2 Dec 2010 02:00:09 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 2 Dec 2010 02:00:09 +0000 (UTC) Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Dec 02 03:00:01 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PNySi-0004KC-KA for ged-emacs-devel@m.gmane.org; Thu, 02 Dec 2010 03:00:00 +0100 Original-Received: from localhost ([127.0.0.1]:51171 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PNySh-0003KI-V0 for ged-emacs-devel@m.gmane.org; Wed, 01 Dec 2010 20:59:56 -0500 Original-Received: from [140.186.70.92] (port=41630 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PNySZ-0003By-Uu for emacs-devel@gnu.org; Wed, 01 Dec 2010 20:59:49 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PNySX-0003xT-IF for emacs-devel@gnu.org; Wed, 01 Dec 2010 20:59:47 -0500 Original-Received: from va3ehsobe006.messaging.microsoft.com ([216.32.180.16]:53557 helo=VA3EHSOBE008.bigfish.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PNySX-0003xP-F4 for emacs-devel@gnu.org; Wed, 01 Dec 2010 20:59:45 -0500 Original-Received: from mail50-va3-R.bigfish.com (10.7.14.238) by VA3EHSOBE008.bigfish.com (10.7.40.28) with Microsoft SMTP Server id 14.1.225.8; Thu, 2 Dec 2010 01:59:43 +0000 Original-Received: from mail50-va3 (localhost.localdomain [127.0.0.1]) by mail50-va3-R.bigfish.com (Postfix) with ESMTP id D4F561BC05E7; Thu, 2 Dec 2010 01:59:43 +0000 (UTC) X-SpamScore: -22 X-BigFish: VPS-22(zz1432N98dN1447Rzz1202hzzz2fh2a8h691h668h61h) X-Forefront-Antispam-Report: KIP:(null); UIP:(null); IPVD:NLI; H:mail7.fw-bc.sony.com; RD:mail7.fw-bc.sony.com; EFVD:NLI Original-Received: from mail50-va3 (localhost.localdomain [127.0.0.1]) by mail50-va3 (MessageSwitch) id 129125518383579_10216; Thu, 2 Dec 2010 01:59:43 +0000 (UTC) Original-Received: from VA3EHSMHS021.bigfish.com (unknown [10.7.14.246]) by mail50-va3.bigfish.com (Postfix) with ESMTP id 119DA5B0051; Thu, 2 Dec 2010 01:59:43 +0000 (UTC) Original-Received: from mail7.fw-bc.sony.com (160.33.98.74) by VA3EHSMHS021.bigfish.com (10.7.99.31) with Microsoft SMTP Server (TLS) id 14.1.225.8; Thu, 2 Dec 2010 01:59:42 +0000 Original-Received: from mail1x.bc.in.sel.sony.com ([43.144.65.112]) by mail7.fw-bc.sony.com (Switch-3.4.2/Switch-3.3.2mp) with ESMTP id oB21xeHH004624 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Thu, 2 Dec 2010 01:59:40 GMT Original-Received: from localhost (tak-vaio-z1290-043191017095.am.sony.com [43.191.17.95]) by mail1x.bc.in.sel.sony.com (Switch-3.4.2/Switch-3.4.2) with ESMTP id oB21xddP020613; Thu, 2 Dec 2010 01:59:39 GMT In-Reply-To: <8762vf5qkv.fsf@uwakimon.sk.tsukuba.ac.jp> X-Mailer: Mew-6.3.50 on Emacs-23.2.90.1 (i386-mingw-nt6.1.7600 built on 2010-11-22) X-OriginatorOrg: am.sony.com X-detected-operating-system: by eggs.gnu.org: Windows 2000 SP2+, XP SP1+ (seldom 98) 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: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:133295 Archived-At: Hi Stephen, Thanks for the comments. Mon, 29 Nov 2010 21:27:12 -0800: "Stephen J. Turnbull" wrote: > Tak Ota writes: > > > > ! When prefix argument is provided without a number (`C-u' alone as > > > ! prefix) the matching strings are collected into the `*Occur*' > > > ! buffer. When COLLECT is zero the entire matched strings are > > > ! collected otherwise COLLECTth pair of parenthesized match in the > > > ! REGEXP is collected." > > I don't think this describes the behavior of the prefix argument > correctly (you will be prompted for a number, IIUC). What happens > when the prefix argument is a number? I modified the description slightly. > > > ! (defun multi-occur-in-matching-buffers (bufregexp regexp &optional allbufs collect) > > > "Show all lines matching REGEXP in buffers specified by BUFREGEXP. > > > Normally BUFREGEXP matches against each buffer's visited file name, > > > but if you specify a prefix argument, it matches against the buffer name. > > The COLLECT argument is undocumented. I just replicated the same paragraph from occur to multi-occur and multi-occur-in-matching-buffers below. I added some examples to demonstrate how this feature is useful for some tasks. *** ../../../d/pub/emacs/emacs-23.2.90/lisp/replace.el Tue Oct 12 15:43:12 2010 --- replace.el Wed Dec 1 17:55:58 2010 *************** *** 527,532 **** --- 527,535 ---- Maximum length of the history list is determined by the value of `history-length', which see.") + (defvar last-collect-number 0 + "The last parenthesized expression number.") + (defun read-regexp (prompt &optional default-value) "Read regexp as a string using the regexp history and some useful defaults. Prompt for a regular expression with PROMPT (without a colon and *************** *** 1031,1037 **** (list (read-regexp "List lines matching regexp" (car regexp-history)) (when current-prefix-arg ! (prefix-numeric-value current-prefix-arg)))) (defun occur-rename-buffer (&optional unique-p interactive-p) "Rename the current *Occur* buffer to *Occur: original-buffer-name*. --- 1034,1044 ---- (list (read-regexp "List lines matching regexp" (car regexp-history)) (when current-prefix-arg ! (prefix-numeric-value current-prefix-arg)) ! (and current-prefix-arg ! (listp current-prefix-arg) ! (setq last-collect-number ! (read-number "Collect" last-collect-number))))) (defun occur-rename-buffer (&optional unique-p interactive-p) "Rename the current *Occur* buffer to *Occur: original-buffer-name*. *************** *** 1050,1056 **** "*") (or unique-p (not interactive-p))))) ! (defun occur (regexp &optional nlines) "Show all lines in the current buffer containing a match for REGEXP. This function can not handle matches that span more than one line. --- 1057,1063 ---- "*") (or unique-p (not interactive-p))))) ! (defun occur (regexp &optional nlines collect) "Show all lines in the current buffer containing a match for REGEXP. This function can not handle matches that span more than one line. *************** *** 1064,1078 **** \\\\[describe-mode] in that buffer will explain how. If REGEXP contains upper case characters (excluding those preceded by `\\') ! and `search-upper-case' is non-nil, the matching is case-sensitive." (interactive (occur-read-primary-args)) ! (occur-1 regexp nlines (list (current-buffer)))) ! (defun multi-occur (bufs regexp &optional nlines) "Show all lines in buffers BUFS containing a match for REGEXP. This function acts on multiple buffers; otherwise, it is exactly like `occur'. When you invoke this command interactively, you must specify ! the buffer names that you want, one by one." (interactive (cons (let* ((bufs (list (read-buffer "First buffer to search: " --- 1071,1105 ---- \\\\[describe-mode] in that buffer will explain how. If REGEXP contains upper case characters (excluding those preceded by `\\') ! and `search-upper-case' is non-nil, the matching is case-sensitive. ! ! When the prefix argument is a list (you type `C-u' alone without ! a number) the matching strings are collected into the `*Occur*' ! buffer. When COLLECT is zero the entire matched strings are ! collected, which is not very useful, otherwise COLLECTth pair of ! parenthesized match in REGEXP is collected. For example, ! providing \"defun \\(\\S +\\)\" for REGEXP and 1 for COLLECT ! collects all the function names in the lisp program. Another ! example, \" > Aside to the maintainers: the ALLBUFS argument could use further > clarification, but that's not Tak's responsibility. That's right :) -Tak