使用EmacsClient创建一个带文本的新缓冲区 [英] Creating a new buffer with text using EmacsClient

查看:81
本文介绍了使用EmacsClient创建一个带文本的新缓冲区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个程序可以发送文本到任何其他程序进行进一步的分析(如sed,grep等)。我希望将数据发送到Emacs,并在那里进行分析。我该怎么办? EmacsClient默认采用文件名,这是一个不是文件的数据字符串,我真的不想创建和删除文件,只是为了将数据发送到Emacs。



EmacsClient有一个eval命令行选项,让您执行lisp代码而不是打开的文件。有没有一个简单的lisp函数,将打开一个新的缓冲区给定的文本?



编辑:我正在寻找类似的东西:



emacsclientw.exe -eval(open-new-buffer'hello world')



一个新的缓冲区会自动出现与hello world一词。我不知道如何设置缓冲区的名称。希望自动编号。

解决方案

这样做你要的是:

  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?.

这篇关于使用EmacsClient创建一个带文本的新缓冲区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆