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: Fri, 29 Oct 2010 11:13:46 -0700 Organization: Sony Electronics Inc. Message-ID: <20101029.111346.113803171.Takaaki.Ota@am.sony.com> References: <20101028.115615.04128253.Takaaki.Ota@am.sony.com> <87k4l1r7k5.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 1288376113 23113 80.91.229.12 (29 Oct 2010 18:15:13 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 29 Oct 2010 18:15:13 +0000 (UTC) Cc: emacs-devel@gnu.org To: Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Oct 29 20:15:12 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 1PBtTr-0001L2-F3 for ged-emacs-devel@m.gmane.org; Fri, 29 Oct 2010 20:15:11 +0200 Original-Received: from localhost ([127.0.0.1]:59021 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PBtTq-0004EX-Lq for ged-emacs-devel@m.gmane.org; Fri, 29 Oct 2010 14:15:10 -0400 Original-Received: from [140.186.70.92] (port=41799 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PBtTh-0004Cm-AB for emacs-devel@gnu.org; Fri, 29 Oct 2010 14:15:02 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PBtTf-00034a-EC for emacs-devel@gnu.org; Fri, 29 Oct 2010 14:15:01 -0400 Original-Received: from tx2ehsobe004.messaging.microsoft.com ([65.55.88.14]:24448 helo=TX2EHSOBE008.bigfish.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PBtTf-000346-9X for emacs-devel@gnu.org; Fri, 29 Oct 2010 14:14:59 -0400 Original-Received: from mail148-tx2-R.bigfish.com (10.9.14.246) by TX2EHSOBE008.bigfish.com (10.9.40.28) with Microsoft SMTP Server id 14.1.225.8; Fri, 29 Oct 2010 18:14:58 +0000 Original-Received: from mail148-tx2 (localhost.localdomain [127.0.0.1]) by mail148-tx2-R.bigfish.com (Postfix) with ESMTP id DCF55818251; Fri, 29 Oct 2010 18:14:57 +0000 (UTC) X-SpamScore: -27 X-BigFish: VPS-27(zz1418M1432N98dN1447Rzz1202hzz8275dhz2fh2a8h61h) Original-Received: from mail148-tx2 (localhost.localdomain [127.0.0.1]) by mail148-tx2 (MessageSwitch) id 1288376028633827_25334; Fri, 29 Oct 2010 18:13:48 +0000 (UTC) Original-Received: from TX2EHSMHS038.bigfish.com (unknown [10.9.14.243]) by mail148-tx2.bigfish.com (Postfix) with ESMTP id D0FCD11E8056; Fri, 29 Oct 2010 18:13:47 +0000 (UTC) Original-Received: from mail7.fw-bc.sony.com (160.33.98.74) by TX2EHSMHS038.bigfish.com (10.9.99.138) with Microsoft SMTP Server (TLS) id 14.0.482.44; Fri, 29 Oct 2010 18:13:45 +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 o9TIDihI020437 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Fri, 29 Oct 2010 18:13:44 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 o9TIDheS020728; Fri, 29 Oct 2010 18:13:43 GMT In-Reply-To: <87k4l1r7k5.fsf@uwakimon.sk.tsukuba.ac.jp> X-Telephone: +1-858-942-3239 X-Fax------: +1-858-942-9142 X-SnailMail: 16530 Via Esprillo, MZ7205, San Diego, CA 92127 X-Mailer: Mew-6.3.50 on Emacs-23.2.1 (i386-mingw-nt6.1.7600 built on 2010-06-30) X-Reverse-DNS: mail7.fw-bc.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:132175 Archived-At: 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