comparison lisp/net/browse-url.el @ 105667:f14d7d76a8f2

(browse-url): Identify alist with "consp and not functionp" and let all other things go down the `apply' leg, as suggested by Stefan. (Further to bug#4531.)
author Kevin Ryde <user42@zip.com.au>
date Sun, 18 Oct 2009 23:55:16 +0000
parents 1e211a362b04
children 26baacb565b0
comparison
equal deleted inserted replaced
105666:933cd581fbcf 105667:f14d7d76a8f2
776 ;; When connected to various displays, be careful to use the display of 776 ;; When connected to various displays, be careful to use the display of
777 ;; the currently selected frame, rather than the original start display, 777 ;; the currently selected frame, rather than the original start display,
778 ;; which may not even exist any more. 778 ;; which may not even exist any more.
779 (if (stringp (frame-parameter (selected-frame) 'display)) 779 (if (stringp (frame-parameter (selected-frame) 'display))
780 (setenv "DISPLAY" (frame-parameter (selected-frame) 'display))) 780 (setenv "DISPLAY" (frame-parameter (selected-frame) 'display)))
781 ;; Send any symbol to `apply', not just fboundp ones, since void-function 781 (if (and (consp browse-url-browser-function)
782 ;; from apply is clearer than wrong-type-argument from dolist. 782 (not (functionp browse-url-browser-function)))
783 (if (or (symbolp browse-url-browser-function) 783 ;; The `function' can be an alist; look down it for first match
784 (functionp browse-url-browser-function)) 784 ;; and apply the function (which might be a lambda).
785 (apply browse-url-browser-function url args) 785 (catch 'done
786 ;; The `function' can be an alist; look down it for first match 786 (dolist (bf browse-url-browser-function)
787 ;; and apply the function (which might be a lambda). 787 (when (string-match (car bf) url)
788 (catch 'done 788 (apply (cdr bf) url args)
789 (dolist (bf browse-url-browser-function) 789 (throw 'done t)))
790 (when (string-match (car bf) url) 790 (error "No browse-url-browser-function matching URL %s"
791 (apply (cdr bf) url args) 791 url))
792 (throw 'done t))) 792 ;; Unbound symbols go down this leg, since void-function from
793 (error "No browse-url-browser-function matching URL %s" 793 ;; apply is clearer than wrong-type-argument from dolist.
794 url))))) 794 (apply browse-url-browser-function url args))))
795 795
796 ;;;###autoload 796 ;;;###autoload
797 (defun browse-url-at-point (&optional arg) 797 (defun browse-url-at-point (&optional arg)
798 "Ask a WWW browser to load the URL at or before point. 798 "Ask a WWW browser to load the URL at or before point.
799 Doesn't let you edit the URL like `browse-url'. Variable 799 Doesn't let you edit the URL like `browse-url'. Variable