[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: shell-command-on-region but with command line arguments
From: |
Bruno Barbier |
Subject: |
Re: shell-command-on-region but with command line arguments |
Date: |
Wed, 09 Nov 2022 08:53:46 +0100 |
Luca Ferrari <fluca1978@gmail.com> writes:
> The problem is that I'm using (shell-command-on-region) that does not
> allow me to insert arguments to the command, and I don't know how the
> command is effectively invoked (e.g., piping the region to standard
> input, using a temporary file) so I'm not able to "append" my
> arguments.
The command will receive the region as its standard input (see the help
of the command shell-command-on-region):
"Execute string COMMAND in inferior shell with region as input."
Couldn't you just customize your own shell command string ?
Something like:
(defun my-on-region (where how)
(interactive "sWhere: \nsHow: \n")
(let ((b (if mark-active (min (point) (mark)) (point-min)))
(e (if mark-active (max (point) (mark)) (point-max)))
;; Build a command that uses the arguments WHERE and
;; HOW, and also display the standard input.
(perl (format "echo \"BEGIN Where=%s, How=%s\"; cat; echo
\"\nEND\""
(shell-quote-argument where)
(shell-quote-argument how))))
(shell-command-on-region b e perl)))
Bruno