Mercurial > emacs
comparison lisp/net/browse-url.el @ 106208:c89e7ab6a9d6
* net/browse-url.el (browse-url-filename-alist): On Windows, add
two slashes to the "file:" prefix.
(browse-url-file-url): De-munge Cygwin filenames before passing
them to Windows browser.
(browse-url-default-windows-browser): Use call-process.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Mon, 23 Nov 2009 20:58:55 +0000 |
parents | 64f03bed7d67 |
children | 15eb515afd85 |
comparison
equal
deleted
inserted
replaced
106207:936dfb675acf | 106208:c89e7ab6a9d6 |
---|---|
442 ;; The above loses the username to avoid the browser prompting for | 442 ;; The above loses the username to avoid the browser prompting for |
443 ;; it in anonymous cases. If it's not anonymous the next regexp | 443 ;; it in anonymous cases. If it's not anonymous the next regexp |
444 ;; applies. | 444 ;; applies. |
445 ("^/\\([^:@]+@\\)?\\([^:]+\\):/*" . "ftp://\\1\\2/") | 445 ("^/\\([^:@]+@\\)?\\([^:]+\\):/*" . "ftp://\\1\\2/") |
446 ,@(if (memq system-type '(windows-nt ms-dos cygwin)) | 446 ,@(if (memq system-type '(windows-nt ms-dos cygwin)) |
447 '(("^\\([a-zA-Z]:\\)[\\/]" . "file:\\1/") | 447 '(("^\\([a-zA-Z]:\\)[\\/]" . "file:///\\1/") |
448 ("^[\\/][\\/]+" . "file://"))) | 448 ("^[\\/][\\/]+" . "file://"))) |
449 ("^/+" . "file:///")) | 449 ("^/+" . "file:///")) |
450 "An alist of (REGEXP . STRING) pairs used by `browse-url-of-file'. | 450 "An alist of (REGEXP . STRING) pairs used by `browse-url-of-file'. |
451 Any substring of a filename matching one of the REGEXPs is replaced by | 451 Any substring of a filename matching one of the REGEXPs is replaced by |
452 the corresponding STRING using `replace-match', not treating STRING | 452 the corresponding STRING using `replace-match', not treating STRING |
697 (run-hooks 'browse-url-of-file-hook)) | 697 (run-hooks 'browse-url-of-file-hook)) |
698 | 698 |
699 (defun browse-url-file-url (file) | 699 (defun browse-url-file-url (file) |
700 "Return the URL corresponding to FILE. | 700 "Return the URL corresponding to FILE. |
701 Use variable `browse-url-filename-alist' to map filenames to URLs." | 701 Use variable `browse-url-filename-alist' to map filenames to URLs." |
702 ;; De-munge Cygwin filenames before passing them to Windows browser. | |
703 (if (eq system-type 'cygwin) | |
704 (let ((winfile (with-output-to-string | |
705 (call-process "cygpath" nil standard-output | |
706 nil "-m" file)))) | |
707 (setq file (substring winfile 0 -1)))) | |
702 (let ((coding (and (default-value 'enable-multibyte-characters) | 708 (let ((coding (and (default-value 'enable-multibyte-characters) |
703 (or file-name-coding-system | 709 (or file-name-coding-system |
704 default-file-name-coding-system)))) | 710 default-file-name-coding-system)))) |
705 (if coding (setq file (encode-coding-string file coding)))) | 711 (if coding (setq file (encode-coding-string file coding)))) |
706 (setq file (browse-url-url-encode-chars file "[*\"()',=;?% ]")) | 712 (setq file (browse-url-url-encode-chars file "[*\"()',=;?% ]")) |
833 (cond ((eq system-type 'ms-dos) | 839 (cond ((eq system-type 'ms-dos) |
834 (if dos-windows-version | 840 (if dos-windows-version |
835 (shell-command (concat "start " (shell-quote-argument url))) | 841 (shell-command (concat "start " (shell-quote-argument url))) |
836 (error "Browsing URLs is not supported on this system"))) | 842 (error "Browsing URLs is not supported on this system"))) |
837 ((eq system-type 'cygwin) | 843 ((eq system-type 'cygwin) |
838 (shell-command (concat "cygstart " (shell-quote-argument url)))) | 844 (call-process "cygstart" nil nil nil url)) |
839 (t (w32-shell-execute "open" url)))) | 845 (t (w32-shell-execute "open" url)))) |
840 | 846 |
841 (defun browse-url-default-macosx-browser (url &optional new-window) | 847 (defun browse-url-default-macosx-browser (url &optional new-window) |
842 (interactive (browse-url-interactive-arg "URL: ")) | 848 (interactive (browse-url-interactive-arg "URL: ")) |
843 (start-process (concat "open " url) nil "open" url)) | 849 (start-process (concat "open " url) nil "open" url)) |