如何实施';将区域上的shell命令转换为字符串';emacs/elisp功能?

如何实施';将区域上的shell命令转换为字符串';emacs/elisp功能?,emacs,elisp,Emacs,Elisp,我需要得到当前缓冲区的一个范围(或整个范围),运行程序将该范围作为输入进行处理,得到结果并将字符串放在当前缓冲区的末尾 我学会了如何处理一个区域 我学会了将程序的结果存储到字符串中 那么,如何实现“区域到字符串上的shell命令” (defun shell-command-on-region-to-string (process &optional b e) (interactive) (let ((b (if mark-active (min (point) (mark))

我需要得到当前缓冲区的一个范围(或整个范围),运行程序将该范围作为输入进行处理,得到结果并将字符串放在当前缓冲区的末尾

我学会了如何处理一个区域

我学会了将程序的结果存储到字符串中

那么,如何实现“区域到字符串上的shell命令”

(defun shell-command-on-region-to-string (process &optional b e) 
  (interactive)
  (let ((b (if mark-active (min (point) (mark)) (point-min)))
        (e (if mark-active (max (point) (mark)) (point-max))))

  ?? (shell-command-on-region b e process (current-buffer) t)
  ?? how to store the return of a process to a string
  ?? how to insert the result at the end of current buffer
))
(defun shell-command-on-region-to-string (start end command)
  (with-output-to-string
    (shell-command-on-region start end command standard-output)))

(defun shell-command-on-region-with-output-to-end-of-buffer (start end command)
  (interactive
   (let ((command (read-shell-command "Shell command on region: ")))
     (if (use-region-p)
         (list (region-beginning) (region-end) command)
       (list (point-min) (point-max) command))))
  (save-excursion
    (goto-char (point-max))
    (insert (shell-command-on-region-to-string start end command))))