[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: simple useful functions
From: |
Tak Ota |
Subject: |
Re: simple useful functions |
Date: |
Mon, 1 Nov 2010 17:40:10 -0700 |
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 <address@hidden> wrote:
> 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.
>
> > > (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
- Re: simple useful functions,
Tak Ota <=
- Re: simple useful functions, Stephen J. Turnbull, 2010/11/01
- Re: simple useful functions, Tak Ota, 2010/11/03
- Re: simple useful functions, Stephen J. Turnbull, 2010/11/03
- Re: simple useful functions, Tak Ota, 2010/11/03
- collect-string (was: simple useful functions), Stefan Monnier, 2010/11/04