In GNU Emacs, I want to run a program, figlet, on the currently selected text. I then want to comment the region which is produced.
I have figured out how to do it using
It is not a very good idea to use an interactive command like shell-command-on-region
in a lisp program. You should use call-process-region instead:
(defun figlet-region (&optional b e)
(interactive "r")
(call-process-region b e "figlet" t t)
(comment-region (mark) (point)))
It should be more resilient against various user options.