写“Hello World”在Emacs? [英] Writing "Hello World" in Emacs?
问题描述
这是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屋!