0

I read this post but I have a little problem with the following code (I am using Emacs 24.3 and Cygwin and I don't know Lisp):

(defun open-in-browser()
  "Open buffer in browser, unless it is not a file. Then fail silently (ouch)."
  (interactive)
  (if (buffer-file-name)
      (let ((filename (buffer-file-name)))
        (shell-command (concat "start firefox.exe \"file://" filename "\"")))))

My shell-command is bash. I changed the last line to

(shell-command (concat "cygstart d:/program/fox/firefox.exe ...
  • Opening d:/documents/test.html works well.

  • Opening d:/documents/my notes/test.html does not work. I get the following error in Firefox:

    Can not find file d:/documents/my

I think bash is missing the space in my notes. How can I fix it?

Community
  • 1
  • 1
yyymin
  • 1
  • 1

2 Answers2

0

emacs buffer file open ex) d:/documents/test.html ;;work good emacs buffer file open ex) d:/documents/my notes/test.html ;;not work

It's failing because of the whitespace. You can read a good description of how Bash interprets whitespace here: https://unix.stackexchange.com/a/108663/84118

Community
  • 1
  • 1
cognoscente
  • 88
  • 1
  • 8
0

In the shell command, change filename to (shell-quote-argument filename)

phils
  • 71,335
  • 11
  • 153
  • 198