emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: simple useful functions


From: Thierry Volpiatto
Subject: Re: simple useful functions
Date: Sat, 30 Oct 2010 12:55:00 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2.50 (gnu/linux)

Tak Ota <address@hidden> writes:

> Thanks for the quick feedback.
>
> Thu, 28 Oct 2010 20:39:38 -0700: "Stephen J. Turnbull" <address@hidden> 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 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]