写“Hello World”在Emacs? [英] Writing "Hello World" in Emacs?

查看:164
本文介绍了写“Hello World”在Emacs?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Emacs Lisp中编写一些Unix脚本。然而,似乎没有一个干净的方式写入STDOUT,所以我可以将结果重定向到一个文件或管道输出到另一个命令。 print 函数在输出字符串周围放置双引号,所以我得到Hello world!,而不是 Hello world!



这是emacs脚本。

 
#!/ usr / bin / emacs --script
;;
;;从Unix shell运行:./hello.el> x.txt
;;
(Hello world!我正在写给STDERR)
(打印Hello world!我正在写STDOUT但我在引用)
(insert你好世界!我正在写一个Emacs缓冲区)
(写文件y.txt)

以下是我想如何调用它。

 
hello.el> x.txt
hello.el | wc


解决方案

似乎你想要 princ 而不是 print 。所以,基本上:



(Hello world!我正在写STDOUT,但我没有引用!)



但是,一个注意事项是 princ 不会自动终止输出与 \\\


I would like to write a few Unix scripts in Emacs Lisp. However, there doesn't seem to be a clean way to write to STDOUT so I can redirect the results to a file or pipe the output to another command. The print function places double quotes around the output strings so I get "Hello world!" instead of Hello world!.

Here's the emacs script.

#!/usr/bin/emacs --script
;;
;; Run me from a Unix shell: ./hello.el > x.txt
;;
(message "Hello world!  I'm writing to STDERR.")
(print "Hello world!  I'm writing to STDOUT but I'm in quotes")
(insert "Hello world!  I'm writing to an Emacs buffer")
(write-file "y.txt")

And here's how I would like to call it.

hello.el > x.txt
hello.el | wc

解决方案

Seems like you want princ instead of print. So, basically:

(princ "Hello world! I'm writing to STDOUT but I'm not in quotes!")

However, one caveat is that princ does not automatically terminate the output with \n.

这篇关于写“Hello World”在Emacs?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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