X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/49866ff8d4e211851f01ef76fa7b4d6762596611..4382021fc15f8a52c9dd12bacb7c75dbeb562302:/lisp/net/browse-url.el diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el index 70388e56ab..b3276ef9c4 100644 --- a/lisp/net/browse-url.el +++ b/lisp/net/browse-url.el @@ -1,7 +1,7 @@ ;;; 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 ;; Maintainer: FSF @@ -22,8 +22,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. ;;; Commentary: @@ -680,6 +680,10 @@ interactively. Turn the filename into a URL with function (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)) @@ -713,7 +717,8 @@ narrowed." (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)))) @@ -755,17 +760,23 @@ Prompts for a URL, defaulting to the URL at or before point. Variable (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) @@ -799,6 +810,8 @@ to use." ;; --- Default MS-Windows browser --- +(defvar dos-windows-version) + (defun browse-url-default-windows-browser (url &optional new-window) (interactive (browse-url-interactive-arg "URL: ")) (if (eq system-type 'ms-dos) @@ -861,7 +874,9 @@ xterm, MMM, and then W3." ((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 @@ -1216,11 +1231,11 @@ used instead of `browse-url-new-window-flag'." (save-buffer) (kill-buffer nil) ;; Send signal SIGUSR to Mosaic - (message "Signalling Mosaic...") + (message "Signaling Mosaic...") (signal-process pid 'SIGUSR1) ;; Or you could try: ;; (call-process "kill" nil 0 nil "-USR1" (int-to-string pid)) - (message "Signalling Mosaic...done") + (message "Signaling Mosaic...done") ) ;; Mosaic not running - start it (message "Starting %s..." browse-url-mosaic-program)