0

Following instructions here:-

https://www.emacswiki.org/emacs/ExecuteExternalCommand

which says:

Using the whole buffer If you are programming using an interpreted language, such as Perl or Python, or a shell script, such as BASH, you might want to run your entire program through the interpreter. To do that, use C-x h (mark-whole-buffer), then use M-| to send all of the buffer text to the interpreter.

As a simple test I created a new buffer which consisted of:

mkdir /test

then pressed C-x h followed by M-| but /test did not get created.

What am I missing?

12
  • M-| is bound to shell-command-on-region, which pipes the region selected through the shell command given in the mini-buffer. Your region text is provided on stdin of the shell command and stdout is shown on the mini buffer. The region and is being replaced by stdout of the shell command if you use the prefix argumanet like C-U M-|.
    – rsp
    Commented Oct 3, 2023 at 12:16
  • E.g. try entering wc as the shell command, and you'll get the idea.
    – phils
    Commented Oct 3, 2023 at 13:17
  • I can't get C-U M-| to work. Can I bind a Fn key to such a function?
    – balanga
    Commented Oct 3, 2023 at 13:17
  • 1
    And for clarity in case you're still confused, none of this is for interpreting the contents of the buffer as shell commands.
    – phils
    Commented Oct 3, 2023 at 13:59
  • 2
    Well, you can if you pipe the contents of the buffer into the shell itself, e,g. with the mkdir example, C-x h M-| bash RET.
    – NickD
    Commented Oct 3, 2023 at 18:51

0

Your Answer

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

Browse other questions tagged or ask your own question.