emacs-devel
[Top][All Lists]
Advanced

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

Re: Cygwin patches


From: Ken Brown
Subject: Re: Cygwin patches
Date: Sat, 21 Nov 2009 16:21:54 -0500
User-agent: Thunderbird 2.0.0.22 (Windows/20090605)

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




reply via email to

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