all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* browse-url/w32-shell-execute problems on cygwin
@ 2009-06-17 15:47 Ken Brown
  2009-06-17 16:06 ` Jason Rumney
  0 siblings, 1 reply; 9+ messages in thread
From: Ken Brown @ 2009-06-17 15:47 UTC (permalink / raw)
  To: Emacs

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.

Thanks.

Ken





^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-06-18 12:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-17 15:47 browse-url/w32-shell-execute problems on cygwin Ken Brown
2009-06-17 16:06 ` Jason Rumney
2009-06-17 16:14   ` Ken Brown
2009-06-17 18:02   ` Ken Brown
2009-06-17 21:30     ` Ken Brown
2009-06-17 21:44       ` Chong Yidong
2009-06-18  1:29         ` Ken Brown
2009-06-17 22:23   ` David Robinow
2009-06-18 12:46     ` Ken Brown

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.