title: How to implement 'shell-command-on-region-to-string' emacs/elisp function?
body: <p>I need to get a range (or whole range) of current buffer, run program to process the range as an input, get the result and to put the string at the end of the current buffer. </p>
  
  <p>I learned that <a href="https://stackoverflow.com/questions/3569501/how-to-get-the-start-end-of-the-current-buffer-info-with-emacs-elisp">shell-command-on-region</a> can process a region.</p>
  
  <p>I learned that <a href="https://stackoverflow.com/questions/3569461/filtering-result-from-running-start-process-in-emacs-elisp">shell-command-to-string</a> can store the result of the program to a string. </p>
  
  <p>Then, how can I implement 'shell-command-on-region-to-string'?</p>
  
  <pre><code>(defun shell-command-on-region-to-string (process &amp;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
  ))
  </code></pre>