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: simple useful functions Date: Mon, 1 Nov 2010 17:40:10 -0700 Message-ID: <20101101.174010.322416312.Takaaki.Ota@am.sony.com> References: <20101028.115615.04128253.Takaaki.Ota@am.sony.com> <87k4l1r7k5.fsf@uwakimon.sk.tsukuba.ac.jp> <20101029.111346.113803171.Takaaki.Ota@am.sony.com> 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 1288658429 8941 80.91.229.12 (2 Nov 2010 00:40:29 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 2 Nov 2010 00:40:29 +0000 (UTC) Cc: emacs-devel@gnu.org To: Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Nov 02 01:40:25 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 1PD4vI-0002bz-Qv for ged-emacs-devel@m.gmane.org; Tue, 02 Nov 2010 01:40:25 +0100 Original-Received: from localhost ([127.0.0.1]:47292 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PD4vI-0000F3-Ad for ged-emacs-devel@m.gmane.org; Mon, 01 Nov 2010 20:40:24 -0400 Original-Received: from [140.186.70.92] (port=58560 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PD4vC-0000Ei-Ej for emacs-devel@gnu.org; Mon, 01 Nov 2010 20:40:19 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PD4vB-00050E-Bq for emacs-devel@gnu.org; Mon, 01 Nov 2010 20:40:18 -0400 Original-Received: from tx2ehsobe001.messaging.microsoft.com ([65.55.88.11]:4733 helo=TX2EHSOBE001.bigfish.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PD4vB-000508-7Q for emacs-devel@gnu.org; Mon, 01 Nov 2010 20:40:17 -0400 Original-Received: from mail101-tx2-R.bigfish.com (10.9.14.244) by TX2EHSOBE001.bigfish.com (10.9.40.21) with Microsoft SMTP Server id 14.1.225.8; Tue, 2 Nov 2010 00:40:15 +0000 Original-Received: from mail101-tx2 (localhost.localdomain [127.0.0.1]) by mail101-tx2-R.bigfish.com (Postfix) with ESMTP id B996E1A883B0; Tue, 2 Nov 2010 00:40:15 +0000 (UTC) X-SpamScore: -27 X-BigFish: VPS-27(zz1418M1432N98dN1447Rzz1202hzz8275bh8275dhz2fh2a8h61h) Original-Received: from mail101-tx2 (localhost.localdomain [127.0.0.1]) by mail101-tx2 (MessageSwitch) id 1288658415529477_4484; Tue, 2 Nov 2010 00:40:15 +0000 (UTC) Original-Received: from TX2EHSMHS004.bigfish.com (unknown [10.9.14.254]) by mail101-tx2.bigfish.com (Postfix) with ESMTP id 748031A40054; Tue, 2 Nov 2010 00:40:15 +0000 (UTC) Original-Received: from mail7.fw-bc.sony.com (160.33.98.74) by TX2EHSMHS004.bigfish.com (10.9.99.104) with Microsoft SMTP Server (TLS) id 14.1.225.8; Tue, 2 Nov 2010 00:40:15 +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 oA20eDOJ030418 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Tue, 2 Nov 2010 00:40:13 GMT Original-Received: from localhost (tak-vaio-z790.am.sony.com [43.191.18.92]) by mail1x.bc.in.sel.sony.com (Switch-3.4.2/Switch-3.4.2) with ESMTP id oA20eCHn013712; Tue, 2 Nov 2010 00:40:12 GMT In-Reply-To: <20101029.111346.113803171.Takaaki.Ota@am.sony.com> X-Mailer: Mew-6.3.50 on Emacs-23.2.1 (i386-mingw-nt6.1.7600 built on 2010-06-30) 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:132262 Archived-At: Could you teach me how to perform collect-string equivalent operation with occur mode? -Tak Fri, 29 Oct 2010 11:13:46 -0700: Tak Ota wrote: > Thanks for the quick feedback. > > Thu, 28 Oct 2010 20:39:38 -0700: "Stephen J. Turnbull" wrote: > > > Tak Ota writes: > > > If you think the following two functions are universally useful please > > > consider incorporating them in simple.el or any appropriate package. > > > If not disregard. > > > > > > -Tak > > > > > > (defun collect-string (regexp &optional num) > > > "Collect strings of REGEXP (or optional NUM paren) from the > > > current buffer into a collection buffer." > > > > What does this do that M-x occur doesn't do? Could it be added to > > occur or to occur-mode? > > I don't think you can perform M-1 M-x collect-string with an input > string of (defun \([^ ]+\) > > It's handy to collect function names from source code or make a list > of image URLs from a given HTML file and so on. > > Correct me if I'm wrong. To my understanding occur is like running > grep to the current buffer while collect-string is running a special > case of sed or awk to the current buffer. > > > > (defun source (script &optional shell keep-current-directory) > > > "Source the specified shell script. > > > Source the shell SCRIPT and import the environment into this > > > emacs. The optional SHELL specifies the shell other than the > > > default `shell-file-name'. When KEEP-CURRENT-DIRECTORY is nil, > > > which is the default, the current directory is temporarily > > > changed to the directory where the script resides while sourcing > > > the script." > > > > Probably this should be in the "shell-" namespace. > > I agree. That makes sense. > > > I can see why the side effect of importing the environment might be > > useful, but I think that should be explicit in the name. > > > > > (call-process shell nil t nil "-c" (concat "source " script "; printenv")) > > > > Isn't "." rather than "source" the portable idiom here? > > You are correct. "." is better. > > -Tak