;;; browse-url.el --- pass a URL to a WWW browser
;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-;; 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+;; 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
;; Author: Denis Howe <dbh@doc.ic.ac.uk>
;; Maintainer: FSF
;; applies.
("^/\\([^:@]+@\\)?\\([^:]+\\):/*" . "ftp://\\1\\2/")
,@(if (memq system-type '(windows-nt ms-dos cygwin))
- '(("^\\([a-zA-Z]:\\)[\\/]" . "file:\\1/")
+ '(("^\\([a-zA-Z]:\\)[\\/]" . "file:///\\1/")
("^[\\/][\\/]+" . "file://")))
("^/+" . "file:///"))
"An alist of (REGEXP . STRING) pairs used by `browse-url-of-file'.
(defun browse-url-url-encode-chars (text chars)
"URL-encode the chars in TEXT that match CHARS.
-CHARS is a regexp-like character alternative (e.g., \"[,)$]\")."
+CHARS is a regexp-like character alternative (e.g., \"[)$]\")."
(let ((encoded-text (copy-sequence text))
(s 0))
(while (setq s (string-match chars encoded-text s))
(defun browse-url-encode-url (url)
"Escape annoying characters in URL.
-The annoying characters are those that can mislead a webbrowser
-regarding its parameter treatment. For instance, `,' can
-be misleading because it could be used to separate URLs."
- (browse-url-url-encode-chars url "[,)$]"))
+The annoying characters are those that can mislead a web browser
+regarding its parameter treatment."
+ ;; FIXME: Is there an actual example of a web browser getting
+ ;; confused? (This used to encode commas, but at least Firefox
+ ;; handles commas correctly and doesn't accept encoded commas.)
+ (browse-url-url-encode-chars url "[)$]"))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; URL input
(defun browse-url-file-url (file)
"Return the URL corresponding to FILE.
Use variable `browse-url-filename-alist' to map filenames to URLs."
+ ;; De-munge Cygwin filenames before passing them to Windows browser.
+ (if (eq system-type 'cygwin)
+ (let ((winfile (with-output-to-string
+ (call-process "cygpath" nil standard-output
+ nil "-m" file))))
+ (setq file (substring winfile 0 -1))))
(let ((coding (and (default-value 'enable-multibyte-characters)
(or file-name-coding-system
default-file-name-coding-system))))
(defun browse-url-default-windows-browser (url &optional new-window)
(interactive (browse-url-interactive-arg "URL: "))
- (if (eq system-type 'ms-dos)
- (if dos-windows-version
- (shell-command (concat "start " (shell-quote-argument url)))
- (error "Browsing URLs is not supported on this system"))
- (w32-shell-execute "open" url)))
+ (cond ((eq system-type 'ms-dos)
+ (if dos-windows-version
+ (shell-command (concat "start " (shell-quote-argument url)))
+ (error "Browsing URLs is not supported on this system")))
+ ((eq system-type 'cygwin)
+ (call-process "cygstart" nil nil nil url))
+ (t (w32-shell-execute "open" url))))
(defun browse-url-default-macosx-browser (url &optional new-window)
(interactive (browse-url-interactive-arg "URL: "))