From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ken Brown Newsgroups: gmane.emacs.devel Subject: browse-url/w32-shell-execute problems on cygwin Date: Wed, 17 Jun 2009 11:47:30 -0400 Message-ID: <4A391012.1060306@cornell.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1245253864 12674 80.91.229.12 (17 Jun 2009 15:51:04 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 17 Jun 2009 15:51:04 +0000 (UTC) To: Emacs Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jun 17 17:51:01 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MGxPg-000233-7w for ged-emacs-devel@m.gmane.org; Wed, 17 Jun 2009 17:51:00 +0200 Original-Received: from localhost ([127.0.0.1]:48403 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MGxPf-00035C-O6 for ged-emacs-devel@m.gmane.org; Wed, 17 Jun 2009 11:50:59 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MGxMU-0000ZD-Jn for emacs-devel@gnu.org; Wed, 17 Jun 2009 11:47:42 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MGxMQ-0000XE-8M for emacs-devel@gnu.org; Wed, 17 Jun 2009 11:47:42 -0400 Original-Received: from [199.232.76.173] (port=56040 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MGxMQ-0000X8-3d for emacs-devel@gnu.org; Wed, 17 Jun 2009 11:47:38 -0400 Original-Received: from granite1.mail.cornell.edu ([128.253.83.141]:54874 helo=authusersmtp.mail.cornell.edu) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MGxMP-0007UB-KU for emacs-devel@gnu.org; Wed, 17 Jun 2009 11:47:37 -0400 Original-Received: from [128.84.234.191] (markov.math.cornell.edu [128.84.234.191]) (authenticated bits=0) by authusersmtp.mail.cornell.edu (8.13.1/8.12.10) with ESMTP id n5HFlHv5011131 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Wed, 17 Jun 2009 11:47:18 -0400 (EDT) User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) X-detected-operating-system: by monty-python.gnu.org: Solaris 9 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:111553 Archived-At: 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