更新时间:2023-11-30 14:29:40
这样做你要的是:
emacsclient -e'(open-buffer-withsome\\\
stuff\\\
here)'
(defun open-buffer-with(txt )
创建一个新的缓冲区,插入txt
(pop-to-buffer(get-buffer-create(generate-new-buffer-namesomething)))
txt))
显然,您可以自定义 open-buffer-with
做你想要的。
有一个类似的问题你可能会看:如何获取基本的App - - Emacs集成?。
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 do that? EmacsClient takes a filename by default, this is a data string not a file and I really don't want to create and delete files just to send data to Emacs.
EmacsClient has an "eval" command-line option that let's you execute lisp code instead of open files. Is there a simple lisp function that will open a new buffer with the given text?
Edit: I'm looking for something like:
emacsclientw.exe -eval (open-new-buffer 'hello world')
And a new buffer would automatically appear with the word "hello world". I'm not sure how the name of the buffer would be set. Hopefully something auto-numbered.
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?.