Mercurial > emacs
comparison lisp/net/browse-url.el @ 111697:ff6a7e607408
Introduce a new `browse-url-mailto-function' variable for mailto: URLs.
author | Lars Magne Ingebrigtsen <larsi@gnus.org> |
---|---|
date | Wed, 24 Nov 2010 07:29:06 +0100 |
parents | 3cd0a7a068d5 |
children | 3aa1279e9141 |
comparison
equal
deleted
inserted
replaced
111696:c63f96430f63 | 111697:ff6a7e607408 |
---|---|
214 :group 'external | 214 :group 'external |
215 :group 'comm) | 215 :group 'comm) |
216 | 216 |
217 ;;;###autoload | 217 ;;;###autoload |
218 (defcustom browse-url-browser-function | 218 (defcustom browse-url-browser-function |
219 `(("\\`mailto:" . browse-url-mail) | 219 (cond |
220 ("." . | 220 ((memq system-type '(windows-nt ms-dos cygwin)) |
221 ,(cond | 221 'browse-url-default-windows-browser) |
222 ((memq system-type '(windows-nt ms-dos cygwin)) | 222 ((memq system-type '(darwin)) |
223 'browse-url-default-windows-browser) | 223 'browse-url-default-macosx-browser) |
224 ((memq system-type '(darwin)) 'browse-url-default-macosx-browser) | 224 (t |
225 (t 'browse-url-default-browser)))) | 225 'browse-url-default-browser)) |
226 "Function to display the current buffer in a WWW browser. | 226 "Function to display the current buffer in a WWW browser. |
227 This is used by the `browse-url-at-point', `browse-url-at-mouse', and | 227 This is used by the `browse-url-at-point', `browse-url-at-mouse', and |
228 `browse-url-of-file' commands. | 228 `browse-url-of-file' commands. |
229 | 229 |
230 If the value is not a function it should be a list of pairs | 230 If the value is not a function it should be a list of pairs |
263 (alist :tag "Regexp/function association list" | 263 (alist :tag "Regexp/function association list" |
264 :key-type regexp :value-type function)) | 264 :key-type regexp :value-type function)) |
265 :version "24.1" | 265 :version "24.1" |
266 :group 'browse-url) | 266 :group 'browse-url) |
267 | 267 |
268 (defcustom browse-url-mailto-function 'browse-url-mail | |
269 "Function to display mailto: links. | |
270 This variable uses the same syntax as the | |
271 `browse-url-browser-function' variable. If the | |
272 `browse-url-mailto-function' variable is nil, that variable will | |
273 be used instead." | |
274 :type '(choice | |
275 (function-item :tag "Emacs Mail" :value browse-url-mail) | |
276 (function-item :tag "None" nil)) | |
277 :version "24.1" | |
278 :group 'browse-url) | |
279 | |
268 (defcustom browse-url-netscape-program "netscape" | 280 (defcustom browse-url-netscape-program "netscape" |
269 ;; Info about netscape-remote from Karl Berry. | 281 ;; Info about netscape-remote from Karl Berry. |
270 "The name by which to invoke Netscape. | 282 "The name by which to invoke Netscape. |
271 | 283 |
272 The free program `netscape-remote' from | 284 The free program `netscape-remote' from |
778 | 790 |
779 ;;;###autoload | 791 ;;;###autoload |
780 (defun browse-url (url &rest args) | 792 (defun browse-url (url &rest args) |
781 "Ask a WWW browser to load URL. | 793 "Ask a WWW browser to load URL. |
782 Prompts for a URL, defaulting to the URL at or before point. Variable | 794 Prompts for a URL, defaulting to the URL at or before point. Variable |
783 `browse-url-browser-function' says which browser to use." | 795 `browse-url-browser-function' says which browser to use. |
796 If the URL is a mailto: URL, consult `browse-url-mailto-function' | |
797 first, if that exists." | |
784 (interactive (browse-url-interactive-arg "URL: ")) | 798 (interactive (browse-url-interactive-arg "URL: ")) |
785 (unless (called-interactively-p 'interactive) | 799 (unless (called-interactively-p 'interactive) |
786 (setq args (or args (list browse-url-new-window-flag)))) | 800 (setq args (or args (list browse-url-new-window-flag)))) |
787 (let ((process-environment (copy-sequence process-environment))) | 801 (let ((process-environment (copy-sequence process-environment)) |
802 (function (or (and (string-match "\\`mailto:" url) | |
803 browse-url-mailto-function) | |
804 browse-url-browser-function))) | |
788 ;; When connected to various displays, be careful to use the display of | 805 ;; When connected to various displays, be careful to use the display of |
789 ;; the currently selected frame, rather than the original start display, | 806 ;; the currently selected frame, rather than the original start display, |
790 ;; which may not even exist any more. | 807 ;; which may not even exist any more. |
791 (if (stringp (frame-parameter (selected-frame) 'display)) | 808 (if (stringp (frame-parameter (selected-frame) 'display)) |
792 (setenv "DISPLAY" (frame-parameter (selected-frame) 'display))) | 809 (setenv "DISPLAY" (frame-parameter (selected-frame) 'display))) |
793 (if (and (consp browse-url-browser-function) | 810 (if (and (consp function) |
794 (not (functionp browse-url-browser-function))) | 811 (not (functionp function))) |
795 ;; The `function' can be an alist; look down it for first match | 812 ;; The `function' can be an alist; look down it for first match |
796 ;; and apply the function (which might be a lambda). | 813 ;; and apply the function (which might be a lambda). |
797 (catch 'done | 814 (catch 'done |
798 (dolist (bf browse-url-browser-function) | 815 (dolist (bf function) |
799 (when (string-match (car bf) url) | 816 (when (string-match (car bf) url) |
800 (apply (cdr bf) url args) | 817 (apply (cdr bf) url args) |
801 (throw 'done t))) | 818 (throw 'done t))) |
802 (error "No browse-url-browser-function matching URL %s" | 819 (error "No browse-url-browser-function matching URL %s" |
803 url)) | 820 url)) |
804 ;; Unbound symbols go down this leg, since void-function from | 821 ;; Unbound symbols go down this leg, since void-function from |
805 ;; apply is clearer than wrong-type-argument from dolist. | 822 ;; apply is clearer than wrong-type-argument from dolist. |
806 (apply browse-url-browser-function url args)))) | 823 (apply function url args)))) |
807 | 824 |
808 ;;;###autoload | 825 ;;;###autoload |
809 (defun browse-url-at-point (&optional arg) | 826 (defun browse-url-at-point (&optional arg) |
810 "Ask a WWW browser to load the URL at or before point. | 827 "Ask a WWW browser to load the URL at or before point. |
811 Doesn't let you edit the URL like `browse-url'. Variable | 828 Doesn't let you edit the URL like `browse-url'. Variable |