0

I want to send the region to a python subprocess on stdin, using command as the argument of python -c [command]. Further I want to insert the result into the current buffer if I have called the function with a prefix argument.

Here's what I've tried:

(defun abcdef/python-region (prefix command &optional b e)
  "Call python with `command' and send region on stdin. 
  Insert result if prefix present."
  (interactive "Psr")
  (call-process-region b e "python" prefix t "-c" command))

When I try calling it interactively with M-x abcdef/python-region I get Wrong type argument: stringp, t.


Related question here.

Drew
  • 29,895
  • 7
  • 74
  • 104
Hatshepsut
  • 5,962
  • 8
  • 44
  • 80

1 Answers1

1

I don't quite see how you'd get that particular error, but your interactive form isn't providing the arguments you need.

It should look something like this:

(interactive "P\nsCommand: \nr")

Usually the argument of ‘interactive’ is a string containing a code letter followed optionally by a prompt. (Some code letters do not use I/O to get the argument and do not use prompts.) To pass several arguments to the command, concatenate the individual strings, separating them by newline characters.

C-hf interactive

phils
  • 71,335
  • 11
  • 153
  • 198