unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Opening files from a command
@ 2008-11-01 20:28 Decebal
  2008-11-01 20:57 ` Rupert Swarbrick
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Decebal @ 2008-11-01 20:28 UTC (permalink / raw
  To: help-gnu-emacs

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.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Opening files from a command
  2008-11-01 20:28 Opening files from a command Decebal
@ 2008-11-01 20:57 ` Rupert Swarbrick
  2008-11-03 11:25   ` Xavier Maillard
  2008-11-01 21:07 ` Drew Adams
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Rupert Swarbrick @ 2008-11-01 20:57 UTC (permalink / raw
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1705 bytes --]

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 #2: Type: application/pgp-signature, Size: 314 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: Opening files from a command
  2008-11-01 20:28 Opening files from a command Decebal
  2008-11-01 20:57 ` Rupert Swarbrick
@ 2008-11-01 21:07 ` Drew Adams
  2008-11-01 21:20 ` Peter Dyballa
  2008-11-01 23:26 ` Paul R
  3 siblings, 0 replies; 8+ messages in thread
From: Drew Adams @ 2008-11-01 21:07 UTC (permalink / raw
  To: 'Decebal', help-gnu-emacs

> 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.

Sorry, but I don't understand you. I'm sure someone else does and will give you
a good answer.

It sounds like you're saying that you have Emacs open, and you use `grep'
outside Emacs (or in an Emacs shell buffer), and you then add the names of
grepped files that you want to edit to the kill ring, and you then paste those
names from the kill ring to, e.g., C-x C-f in order to open the files. Is that
right?

It's probably not what you mean, but if it is, then my answer would be to use
the _Emacs_ command `grep': `M-x grep'. See the Emacs manual, node `Grep
Searching'. Unless you have a very special need that doesn't match what Emacs
`grep' gives you, you'll appreciate using it, and you'll never go back.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Opening files from a command
  2008-11-01 20:28 Opening files from a command Decebal
  2008-11-01 20:57 ` Rupert Swarbrick
  2008-11-01 21:07 ` Drew Adams
@ 2008-11-01 21:20 ` Peter Dyballa
  2008-11-01 23:26 ` Paul R
  3 siblings, 0 replies; 8+ messages in thread
From: Peter Dyballa @ 2008-11-01 21:20 UTC (permalink / raw
  To: Decebal; +Cc: help-gnu-emacs


Am 01.11.2008 um 21:28 schrieb Decebal:

> Offcourse I could do:
>     emacs `grep ...` &

There is also emacsclient – once you've started emacs-server in GNU  
Emacs it will only open new buffers.

BTW, the grep function in GNU Emacs that creates the *grep* buffer  
has there hyper-links to the found files, line numbers. It's quite  
easy to click on these hyper-links ...

--
Greetings

   Pete

We have to expect it, otherwise we would be surprised.







^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Opening files from a command
  2008-11-01 20:28 Opening files from a command Decebal
                   ` (2 preceding siblings ...)
  2008-11-01 21:20 ` Peter Dyballa
@ 2008-11-01 23:26 ` Paul R
  3 siblings, 0 replies; 8+ messages in thread
From: Paul R @ 2008-11-01 23:26 UTC (permalink / raw
  To: Decebal; +Cc: help-gnu-emacs

On Sat, 1 Nov 2008 13:28:32 -0700 (PDT), Decebal <CLDWesterhof@gmail.com> said:

Decebal> Sometimes I like to edit files based on a certain criterium.

I think you are looking for M-x find-dired 
You need to know the usage of find command.

-- 
  Paul




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Opening files from a command
  2008-11-01 20:57 ` Rupert Swarbrick
@ 2008-11-03 11:25   ` Xavier Maillard
  2008-11-03 16:51     ` Johan Bockgård
  0 siblings, 1 reply; 8+ messages in thread
From: Xavier Maillard @ 2008-11-03 11:25 UTC (permalink / raw
  To: Rupert Swarbrick; +Cc: help-gnu-emacs

Hi,

[Pretty OT]

   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

Do you know an emacs-mode to automatically do the transcription
between an emacs macro like the one on the left to a more
textified version like the one on the right side ? Here the macro
is pretty basic but with more complex ones, it could help to have
such description on demand.

Regards,

	Xavier
-- 
http://www.gnu.org
http://www.april.org
http://www.lolica.org




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Opening files from a command
  2008-11-03 11:25   ` Xavier Maillard
@ 2008-11-03 16:51     ` Johan Bockgård
  2008-11-03 23:25       ` Xavier Maillard
  0 siblings, 1 reply; 8+ messages in thread
From: Johan Bockgård @ 2008-11-03 16:51 UTC (permalink / raw
  To: help-gnu-emacs

Xavier Maillard <xma@gnu.org> writes:

>    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
>
> Do you know an emacs-mode to automatically do the transcription
> between an emacs macro like the one on the left to a more
> textified version like the one on the right side ? Here the macro
> is pretty basic but with more complex ones, it could help to have
> such description on demand.

Like

    (format-kbd-macro
     (kbd
      "C-x (
         C-SPC C-e M-w C-a C-n
         C-x 4 f C-y <return>
         C-x o
       C-x )")
     t)

    =>

    "C-SPC                  ;; set-mark-command
    C-e                     ;; move-end-of-line
    M-w                     ;; kill-ring-save
    C-a                     ;; move-beginning-of-line
    C-n                     ;; next-line
    C-x 4 f                 ;; find-file-other-window
    C-y                     ;; yank
    RET                     ;; newline
    C-x o                   ;; other-window"

Cf. `edit-kbd-macro'.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Opening files from a command
  2008-11-03 16:51     ` Johan Bockgård
@ 2008-11-03 23:25       ` Xavier Maillard
  0 siblings, 0 replies; 8+ messages in thread
From: Xavier Maillard @ 2008-11-03 23:25 UTC (permalink / raw
  To: Johan Bockgård; +Cc: help-gnu-emacs


   Xavier Maillard <xma@gnu.org> writes:

   >    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
   >
   > Do you know an emacs-mode to automatically do the transcription
   > between an emacs macro like the one on the left to a more
   > textified version like the one on the right side ? Here the macro
   > is pretty basic but with more complex ones, it could help to have
   > such description on demand.

   Like

       (format-kbd-macro

   Cf. `edit-kbd-macro'.

Perfecto !

	Xavier
-- 
http://www.gnu.org
http://www.april.org
http://www.lolica.org




^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-11-03 23:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-01 20:28 Opening files from a command Decebal
2008-11-01 20:57 ` Rupert Swarbrick
2008-11-03 11:25   ` Xavier Maillard
2008-11-03 16:51     ` Johan Bockgård
2008-11-03 23:25       ` Xavier Maillard
2008-11-01 21:07 ` Drew Adams
2008-11-01 21:20 ` Peter Dyballa
2008-11-01 23:26 ` Paul R

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).