title: Escaping spaces when calling (buffer-file-name) in emacs
body: <p>So, I had a question about getting word count to work properly in emacs LaTeX mode (auctex, actually, but never mind.) <a href="https://superuser.com/questions/125027/word-count-for-latex-within-emacs">That was answered fine</a>. Then I found I had trouble when the <code>(buffer-file-name)</code> included spaces. This made it mess up. <a href="https://superuser.com/questions/159412/escaping-spaces-in-emacs-perl">This problem was got around too</a>. Now the problem is that the solution breaks when there AREN'T any spaces.</p>
  
  <p>So currently I have two emacs commands:</p>
  
  <pre><code>(defun latex-word-count ()
    (interactive)
    (shell-command (concat "/usr/local/bin/texcount.pl "
                           "-inc "
                       (shell-quote-argument (concat "'" (buffer-file-name) "'")))))
  </code></pre>
  
  <p>this works when there is a space in the containing folder.</p>
  
  <pre><code>(defun latex-word-c-nospace ()
    (interactive)
    (shell-command (concat "/usr/local/bin/texcount.pl "
               "-inc "
               (shell-quote-argument (buffer-file-name)))))
  </code></pre>
  
  <p>This works when there is no space in the containing folder name.
  (OK so the indenting is a little screwey, but whatever)</p>
  
  <p>My question: is there some way to have the same function work in both cases? <a href="https://superuser.com/questions/159412/escaping-spaces-in-emacs-perl/159495#159495">This answer</a> suggests the problem is with texcount rather than emacs. Is there a way to do this without messing about with texcount.pl? Or is my best bet to poke texcount.pl in the way Chris Johnsen suggested on SU?</p>