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: Re: Cygwin patches Date: Sat, 21 Nov 2009 16:21:54 -0500 Message-ID: <4B0859F2.8080202@cornell.edu> References: <4B06F562.8060504@cornell.edu> <871vjs7tn4.fsf@stupidchicken.com> <4B071784.5030901@cornell.edu> <83my2gpa83.fsf@gnu.org> <4B07D914.8070608@cornell.edu> <836394oxr9.fsf@gnu.org> 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 1258841470 31555 80.91.229.12 (21 Nov 2009 22:11:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 21 Nov 2009 22:11:10 +0000 (UTC) Cc: cyd@stupidchicken.com, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Nov 21 23:11:02 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 1NBy9v-0003SB-5B for ged-emacs-devel@m.gmane.org; Sat, 21 Nov 2009 23:10:23 +0100 Original-Received: from localhost ([127.0.0.1]:47061 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NBxPV-0006NN-7U for ged-emacs-devel@m.gmane.org; Sat, 21 Nov 2009 16:22:25 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NBxPP-0006Lw-Dx for emacs-devel@gnu.org; Sat, 21 Nov 2009 16:22:19 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NBxPK-0006Hc-9s for emacs-devel@gnu.org; Sat, 21 Nov 2009 16:22:18 -0500 Original-Received: from [199.232.76.173] (port=60000 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NBxPK-0006HU-7E for emacs-devel@gnu.org; Sat, 21 Nov 2009 16:22:14 -0500 Original-Received: from granite1.mail.cornell.edu ([128.253.83.141]:38333 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 1NBxPH-0004a1-U4; Sat, 21 Nov 2009 16:22:12 -0500 Original-Received: from [127.0.0.1] (cpe-67-241-20-9.twcny.res.rr.com [67.241.20.9]) (authenticated bits=0) by authusersmtp.mail.cornell.edu (8.13.1/8.12.10) with ESMTP id nALLM5TH022695; Sat, 21 Nov 2009 16:22:06 -0500 (EST) User-Agent: Thunderbird 2.0.0.22 (Windows/20090605) In-Reply-To: <836394oxr9.fsf@gnu.org> X-Antivirus: avast! (VPS 091121-1, 11/21/2009), Outbound message X-Antivirus-Status: Clean 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:117457 Archived-At: On 11/21/2009 7:42 AM, Eli Zaretskii wrote: >>> I think that the right fix would be in browse-url-file-url, so that it >>> does return a correctly converted URL. Using cygstart directly in >>> browse-url-of-file deviates too much from what other platforms do -- >>> they all invoke the browser in browse-url. Such a deviation could >>> mean maintenance headaches in the future. For example, browse-url >>> takes care of setting the environment for the process being invoked, >>> while your patch short-circuits that for Cygwin. >> OK, that makes sense. I'll figure out how to patch browse-url-file-url >> instead. I have very little experience with emacs-lisp, so I'll need some help getting this right. Here's my first attempt: --- browse-url.el.orig 2009-11-21 12:33:40.000000000 -0500 +++ browse-url.el 2009-11-21 15:51:40.000000000 -0500 @@ -699,6 +699,10 @@ (defun browse-url-file-url (file) "Return the URL corresponding to FILE. Use variable `browse-url-filename-alist' to map filenames to URLs." + (if (eq system-type 'cygwin) + (let ((winfile (shell-command-to-string (concat + "cygpath -m " (shell-quote-argument file))))) + (setq file (concat "file://" (substring winfile 0 -1))))) (let ((coding (and (default-value 'enable-multibyte-characters) (or file-name-coding-system default-file-name-coding-system)))) Explanation: The cygpath command converts a unix-style file name (like /home/kbrown/index.html) to a Windows-style file name (like C:/cygwin/home/kbrown/index.html). I have to add "file://" in front for reasons I don't understand. (If I don't do this, "file:" gets added by the later code, with no slashes.) And I delete the last character to get rid of a final newline. When I try to test this in emacs 23.1, I get an error if: Wrong number of arguments: called-interactively-p, 1 The following additional patch, restoring something from the emacs 23.1 version of browse-url, fixes it: @@ -770,7 +774,7 @@ Prompts for a URL, defaulting to the URL at or before point. Variable `browse-url-browser-function' says which browser to use." (interactive (browse-url-interactive-arg "URL: ")) - (unless (called-interactively-p 'interactive) + (unless (interactive-p) (setq args (or args (list browse-url-new-window-flag)))) (let ((process-environment (copy-sequence process-environment))) ;; When connected to various displays, be careful to use the display of I don't know what's going on. Can you help? Thanks. Ken