gpt4 book ai didi

emacs - 使用 emacs 将文本作为参数传递给外部程序

转载 作者:行者123 更新时间:2023-12-04 22:15:46 25 4
gpt4 key购买 nike

假设我在文件中有此文本:

/home is where the heart is.

例如,如果我使用 C-spc 选择 /home 文本,是否有办法将其发送到 ls,以便最终 if 会执行 ls /homeM-| 不起作用。

最佳答案

据我所知,在 Emacs 中没有办法直接做到这一点。但在 elisp 的帮助下,一切皆有可能:

(defun region-as-argument-to-command (cmd)
(interactive "sCommand: ")
(shell-command
(format
"%s %s"
cmd
(shell-quote-argument
(buffer-substring (region-beginning)
(region-end))))))

关于emacs - 使用 emacs 将文本作为参数传递给外部程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6843675/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com