;;; browse-url.el --- pass a URL to a WWW browser
-;; Copyright (C) 1995, 96, 97, 98, 99, 2000, 2001, 2005
-;; Free Software Foundation, Inc.
+;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+;; 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
;; Author: Denis Howe <dbh@doc.ic.ac.uk>
;; Maintainer: FSF
(defun browse-url-file-url (file)
"Return the URL corresponding to FILE.
Use variable `browse-url-filename-alist' to map filenames to URLs."
+ (let ((coding (and default-enable-multibyte-characters
+ (or file-name-coding-system
+ default-file-name-coding-system))))
+ (if coding (setq file (encode-coding-string file coding))))
;; URL-encode special chars, do % first
(let ((s 0))
(while (setq s (string-match "%" file s))
(setq browse-url-temp-file-name
(convert-standard-filename
(make-temp-file
- (expand-file-name "burl" browse-url-temp-dir)))))
+ (expand-file-name "burl" browse-url-temp-dir)
+ nil ".html"))))
(setq file-name browse-url-temp-file-name)
(write-region (point-min) (point-max) file-name nil 'no-message)))
(browse-url-of-file file-name))))
(interactive (browse-url-interactive-arg "URL: "))
(unless (interactive-p)
(setq args (or args (list browse-url-new-window-flag))))
- (if (functionp browse-url-browser-function)
- (apply browse-url-browser-function url args)
- ;; The `function' can be an alist; look down it for first match
- ;; and apply the function (which might be a lambda).
- (catch 'done
- (dolist (bf browse-url-browser-function)
- (when (string-match (car bf) url)
- (apply (cdr bf) url args)
- (throw 'done t)))
- (error "No browse-url-browser-function matching URL %s"
- url))))
+ (let ((process-environment (copy-sequence process-environment)))
+ ;; When connected to various displays, be careful to use the display of
+ ;; the currently selected frame, rather than the original start display,
+ ;; which may not even exist any more.
+ (if (stringp (frame-parameter (selected-frame) 'display))
+ (setenv "DISPLAY" (frame-parameter (selected-frame) 'display)))
+ (if (functionp browse-url-browser-function)
+ (apply browse-url-browser-function url args)
+ ;; The `function' can be an alist; look down it for first match
+ ;; and apply the function (which might be a lambda).
+ (catch 'done
+ (dolist (bf browse-url-browser-function)
+ (when (string-match (car bf) url)
+ (apply (cdr bf) url args)
+ (throw 'done t)))
+ (error "No browse-url-browser-function matching URL %s"
+ url)))))
;;;###autoload
(defun browse-url-at-point (&optional arg)
((executable-find "tellw3b") 'browse-url-iximosaic)
((executable-find browse-url-xterm-program) 'browse-url-lynx-xterm)
((executable-find "mmm") 'browse-url-mmm)
- (t 'browse-url-w3))
+ ((locate-library "w3") 'browse-url-w3)
+ (t
+ (lambda (&ignore args) (error "No usable browser found"))))
url args))
;;;###autoload