emacs 可以调用 shell 并执行命令——它们可以作用于 Emacs 缓冲区吗?
我用 Alt-! (Alt-Bang) 在 Emacs 中很多。我使用它的最重要的事情之一是
Alt-! cat $logfile | grep 'this' # show me one kind of event
或有时有
Alt-! cat $logfile | grep 'this' | wc -l # count that one event's occurrences
两件事:
1)此提示没有制表符完成:为什么不呢?
2) 如果我想扫描 Emacs 缓冲区之一而不是 $logfile,该怎么办?
I use Alt-! (Alt-Bang) a lot in Emacs. One of the big things I use it for is
Alt-! cat $logfile | grep 'this' # show me one kind of event
or sometimes
Alt-! cat $logfile | grep 'this' | wc -l # count that one event's occurrences
Two things:
1) No tab-completion from this prompt: why not?
2) What if instead of $logfile, I want to scan one of the Emacs buffers?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要扫描 Emacs 缓冲区,请使用
M-|
而不是M-!
:它将区域作为命令的输入传递。如果您希望命令的输出替换该区域,请使用M-1 M-|
。对于您提到的特定命令,如果您想查看所有匹配项,请使用 Mx grep 。或者您可以打开它并查看与
Mx 发生的匹配
。To scan an Emacs buffer, use
M-|
instead ofM-!
: it passes the region as input to the command. UseM-1 M-|
if you want the output of the command to replace the region.For the particular command you mention, use
M-x grep
if you want to see all matches. Or you can open it and see the matches withM-x occur
.Alt-|
所做的是带有(ny)数字前缀(例如 Cu 1 Alt-|)的 shell-command-on-region,该区域被结果替换,否则出现在新缓冲区中
Alt-|
does is shell-command-on-regionwith a(ny) numeric prefix (e.g. C-u 1 Alt-|) the region is replaced by the result, otherwise that appears in new buffer