all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ken Brown <kbrown@cornell.edu>
To: Emacs <emacs-devel@gnu.org>
Subject: browse-url/w32-shell-execute problems on cygwin
Date: Wed, 17 Jun 2009 11:47:30 -0400	[thread overview]
Message-ID: <4A391012.1060306@cornell.edu> (raw)

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





             reply	other threads:[~2009-06-17 15:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-17 15:47 Ken Brown [this message]
2009-06-17 16:06 ` browse-url/w32-shell-execute problems on cygwin 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A391012.1060306@cornell.edu \
    --to=kbrown@cornell.edu \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.