Creating a new buffer with text using EmacsClient

前端 未结 2 1651
别跟我提以往
别跟我提以往 2021-02-09 12:59

I have a program that can send text to any other program for further analysis (eg sed, grep, etc). I would like it to send the data to Emacs and do analysis there. How would I

2条回答
  •  天命终不由人
    2021-02-09 13:50

    This does what you ask for:

    emacsclient -e '(open-buffer-with "some\nstuff\nhere")'
    
    (defun open-buffer-with (txt)
      "create a new buffer, insert txt"
      (pop-to-buffer (get-buffer-create (generate-new-buffer-name "something")))
      (insert txt))
    

    Obviously you can customize open-buffer-with to do what you want.

    There's a similar question you might want to look at: How do I get basic App<->Emacs integration?.

提交回复
热议问题