假设我在文件中包含此文本:
/home is where the heart is.
Run Code Online (Sandbox Code Playgroud)
例如,如果我选择/home文本,使用C-spc,有没有办法将它发送到ls,那么最终是否会执行ls /home?M-|不起作用.
据我所知,没有办法直接在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))))))
Run Code Online (Sandbox Code Playgroud)