help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Opening files from a command


From: Rupert Swarbrick
Subject: Re: Opening files from a command
Date: Sat, 01 Nov 2008 20:57:41 +0000
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.60 (gnu/linux)

Decebal <CLDWesterhof@gmail.com> writes:

> Sometimes I like to edit files based on a certain criterium. I use for
> example a grep command. I use this from a shell in Emacs. (I have to
> work with kshell, which does not have tab-expansion. This is why I am
> working from a shell in Emacs.) At this moment I am putting those
> filenames one by one in the kill-ring and open them. But is there a
> better way?
>
> Offcourse I could do:
>     emacs `grep ...` &
> but this opens an new Emacs session. I would prefer not to open a new
> session.

One solution might be to (in your M-x shell buffer) use an invocation
like

  grep -Ril <blah> <path>

This will give you a list of files (which presumably you were doing
inside the backticks above), which will be listed one per line in your
buffer.

There's no doubt clever elisp hackery you can do next, but I'd be
inclined to use a keyboard macro:

C-x (                          ;; Start macro
  C-SPC C-e M-w C-a C-n        ;; Put line on kill-ring
  C-x 4 f C-y <return>         ;; Open that file in a different window
  C-x o                        ;; Go back to the shell buffer
C-x )                          ;; End macro

(note that I tried this, then used view-lossage). Anyhoo, you should
then be able to do C-x e and repeat.

You may wish to either write some elisp or save that macro if you need
to do this more often. It occurs to me that the other option, rather
than pulling up a separate window, is find-file-noselect. But that
really does make more sense from elisp.

The other thing I'd point out is that M-x rgrep and friends give you
output in a cleverly modified Compile buffer, with internal "hyperlinks"
to the matching files.

Rupert

Attachment: pgpqPukfDSqog.pgp
Description: PGP signature


reply via email to

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