0

I use Alt-! (Alt-Bang) a lot in Emacs. One of the big things I use it for is

Alt-! cat $logfile | grep 'this' # show me one kind of event

or sometimes

Alt-! cat $logfile | grep 'this' | wc -l # count that one event's occurrences

Two things:

1) No tab-completion from this prompt: why not?

2) What if instead of $logfile, I want to scan one of the Emacs buffers?

1
  • Which version of Emacs are you using? I have tab completion from the shell-command prompt. (tab is bound to minibuffer-complete-shell-command) Commented Aug 24, 2010 at 21:35

2 Answers 2

3

To scan an Emacs buffer, use M-| instead of M-!: it passes the region as input to the command. Use M-1 M-| if you want the output of the command to replace the region.

For the particular command you mention, use M-x grep if you want to see all matches. Or you can open it and see the matches with M-x occur.

Sign up to request clarification or add additional context in comments.

Comments

1

Alt-| does is shell-command-on-region

with a(ny) numeric prefix (e.g. C-u 1 Alt-|) the region is replaced by the result, otherwise that appears in new buffer

1 Comment

n.b. C-u provides a default value (4^n when you press C-u n times), so when the number is irrelevant, or just needs to be some positive integer, you needn't use C-u 1 when you can just use C-u on its own (or M-1 or C-1).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.