[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

browse-url/w32-shell-execute problems on cygwin

From: Ken Brown
Subject: browse-url/w32-shell-execute problems on cygwin
Date: Wed, 17 Jun 2009 11:47:30 -0400
User-agent: Thunderbird (Windows/20090302)

In browse-url.el, browse-url-browser-function is set to browse-url-default-windows-browser on cygwin. But the definition of browse-url-default-windows-browser uses w32-shell-execute, which is defined in w32fns.c and is not included in the cygwin build. My personal workaround for years has been the following:

;; Minimal replacement for w32-shell-execute under Cygwin.
(defun w32-shell-execute (operation document &optional parameters show-flag)
  (if (string-equal operation "open")
    (shell-command (concat "cygstart " (shell-quote-argument document)))))

(Note: For those not familiar with cygstart, it is a cygwin utility that will launch anything that you can type in the "Start Menu" -> "Run" box in windows. For example, typing 'cygstart "http://google.com";' in a cygwin shell will open the default windows browser and go to google.)

This has always sufficed for my purposes, though I suppose it would be better to implement other operations besides "open" or, at least, give a "not implemented" error if there's an attempt to use some other operation.

Now that I am cygwin's emacs maintainer, I would like to replace this personal workaround by a suitable change to the emacs sources. Can someone more knowledgeable than I am propose or apply a patch so that cygwin users won't get an error when they try to use browse-url? One option would be to implement w32-shell-execute. Another would be to redefine browse-url-default-windows-browser so that, in cygwin, it simply calls cygstart on the URL. Maybe there's a better solution.

Second problem: browse-url-of-file doesn't work right under cygwin because it relies on browse-url-file-url to convert the file name to a URL; but the URL it returns is not in a form that a windows browser can understand. For example, evaluating

  (browse-url-file-url "/home/kbrown/html/index.html")

yields "file:/home/kbrown/html/index.html", but (on my system) it would need to be "file://d:/cygwin-1.7/home/kbrown/html/index.html" for the windows browser to be able to handle it.

My personal workaround has been to bypass browse-url-file-url completely and instead modify browse-url-of-file:

-  (browse-url (browse-url-file-url file))
+  (w32-shell-execute "open" file)

The point here is that there is no need to convert the file name to a URL; the cygwin shell command 'cygstart "/home/kbrown/html/index.html"' does the job.

Again, I would appreciate it if someone could find a way to fix the problem in the emacs sources. If you could even just give me some pointers as to what approach would be acceptable, I could probably provide a patch.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]