emacsclient --eval 支持从 STDIN 输入表达式

刚才看 emacsclient.c 发现 --eval 选项可以不要参数,试了下是从 STDIN 读入的,比如求字符串 'hi’ 的值

~$ emacsclient --eval
"'hi'"
"'hi'"

这么写可以不用跟 Shell 的引号搅在一块儿

~$ emacsclient --eval "\"'hi'\""
"'hi'"
~$ emacsclient --eval '"'"'""hi""'"'"'
"'hi'"
3 个赞

这个嘛用heredoc也行的:

 ~ emacsclient --eval << EOF
heredoc> "'hi'"
heredoc> EOF
"'hi'"
1 个赞

我以为这是新特性,emacs --eval 也快了吧。去 blame 了一下 emacsclient 的代码,看看是什么时候改的,结果发现 15 年前就是这样了 :broken_heart:

1 个赞