From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thierry Volpiatto Newsgroups: gmane.emacs.devel Subject: Re: simple useful functions Date: Sat, 30 Oct 2010 12:55:00 +0200 Organization: ThierryVolpiatto Message-ID: <87r5f8ympn.fsf@tux.homenetwork> 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 X-Trace: dough.gmane.org 1288436208 29714 80.91.229.12 (30 Oct 2010 10:56:48 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 30 Oct 2010 10:56:48 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Oct 30 12:56:47 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 1PC979-0003Zy-1d for ged-emacs-devel@m.gmane.org; Sat, 30 Oct 2010 12:56:47 +0200 Original-Received: from localhost ([127.0.0.1]:58286 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PC978-00007Q-Ha for ged-emacs-devel@m.gmane.org; Sat, 30 Oct 2010 06:56:46 -0400 Original-Received: from [140.186.70.92] (port=52027 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PC972-00007L-5I for emacs-devel@gnu.org; Sat, 30 Oct 2010 06:56:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PC970-0002dK-8L for emacs-devel@gnu.org; Sat, 30 Oct 2010 06:56:40 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:37965) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PC96z-0002cp-SL for emacs-devel@gnu.org; Sat, 30 Oct 2010 06:56:38 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1PC96v-0003Us-5p for emacs-devel@gnu.org; Sat, 30 Oct 2010 12:56:33 +0200 Original-Received: from 67.211.85-79.rev.gaoland.net ([79.85.211.67]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 30 Oct 2010 12:56:33 +0200 Original-Received: from thierry.volpiatto by 67.211.85-79.rev.gaoland.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 30 Oct 2010 12:56:33 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 67 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 67.211.85-79.rev.gaoland.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2.50 (gnu/linux) Cancel-Lock: sha1:LEqbPD7x8+NOCjVErcE45M3wYYk= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) 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:132184 Archived-At: Tak Ota writes: > 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. Have a look at ioccur.el that does what you want but is incremental, allow changing search method during session (regexp/litteral) is faster than occur and many other things. http://mercurial.intuxication.org/hg/ioccur >> > (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 > > > -- A+ Thierry Get my Gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 59F29997