Emacs lisp “shell-command-on-region”

后端 未结 3 1721
孤独总比滥情好
孤独总比滥情好 2021-02-04 01:25

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

3条回答
  •  长发绾君心
    2021-02-04 02:11

    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.

提交回复
热议问题