title: calling shell from emacs
body: <p>I have an executable file that can be used from the terminal command line.</p>
  
  <p><code>$ foo "bar"</code>
  which returns a single line of text</p>
  
  <p>I would like to be able to call this function while editing files.</p>
  
  <p>I can see that I can do the following </p>
  
  <p><code>M-! ~/Library/yolo/bin/foo "bar"</code>
  and I get exactly what I am looking for.</p>
  
  <p>So I am trying to write a function that I can then bind to keys. But I am stumped.</p>
  
  <pre><code>(setq foobar-path "~/Library/yolo/bin/foo ")
  (defun foo-bar (func)
    (shell-command (concat foobar-path func)))
  
  (global-set-key (kbd "M-p") foo-bar)
  </code></pre>
  
  <p>but I know (emacs is telling me) that I am way way off.</p>
  
  <p>What I would ideally end up with is a keybinding that can send a line of code (like evaluate last expression) to the external function and display the return at the bottom of the screen in the message bar.</p>
  
  <p>Any hints?</p>