]> code.delx.au - gnu-emacs/blobdiff - lisp/url/url-methods.el
Update copyright year to 2015
[gnu-emacs] / lisp / url / url-methods.el
index 57b9db602e1ce63b528ed91692b192e6f7c598b3..a4f711b7004bafc223ad3f8e4eb42a3007ddf110 100644 (file)
@@ -1,7 +1,6 @@
 ;;; url-methods.el --- Load URL schemes as needed
 
-;; Copyright (C) 1996, 1997, 1998, 1999, 2004,
-;;   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 1996-1999, 2004-2015 Free Software Foundation, Inc.
 
 ;; Keywords: comm, data, processes, hypermedia
 
@@ -24,9 +23,6 @@
 
 ;;; Code:
 
-(eval-when-compile
-  (require 'cl))
-
 ;; This loads up some of the small, silly URLs that I really don't
 ;; want to bother putting in their own separate files.
 (require 'url-parse)
@@ -63,7 +59,9 @@
 
 (defun url-scheme-default-loader (url &optional callback cbargs)
   "Signal an error for an unknown URL scheme."
-  (error "Unkown URL scheme: %s" (url-type url)))
+  (error "Unknown URL scheme: %s" (url-type url)))
+
+(defvar url-scheme--registering-proxy nil)
 
 (defun url-scheme-register-proxy (scheme)
   "Automatically find a proxy for SCHEME and put it in `url-proxy-services'."
@@ -71,7 +69,8 @@
         (env-proxy (or (getenv (upcase env-var))
                        (getenv (downcase env-var))))
         (cur-proxy (assoc scheme url-proxy-services))
-        (urlobj nil))
+        (urlobj nil)
+        (url-scheme--registering-proxy t))
 
     ;; If env-proxy is an empty string, treat it as if it were nil
     (when (and (stringp env-proxy)
@@ -80,7 +79,7 @@
 
     ;; Store any proxying information - this will not overwrite an old
     ;; entry, so that people can still set this information in their
-    ;; .emacs file
+    ;; init file
     (cond
      (cur-proxy nil)                   ; Keep their old settings
      ((null env-proxy) nil)            ; No proxy setup
@@ -119,29 +118,32 @@ it has not already been loaded."
        (let* ((stub (concat "url-" scheme))
               (loader (intern stub)))
          (condition-case ()
-             (require loader)
+             ;; url-https.el was merged into url-http because of 8+3
+             ;; filename limitations, so we have to do this dance.
+             (require (if (equal "https" scheme) 'url-http loader))
            (error nil))
          (if (fboundp loader)
              (progn
                ;; Found the module to handle <scheme> URLs
-               (url-scheme-register-proxy scheme)
+               (unless url-scheme--registering-proxy
+                 (url-scheme-register-proxy scheme))
                (setq desc (list 'name scheme
                                 'loader loader))
                (dolist (cell url-scheme-methods)
                  (let ((symbol (intern-soft (format "%s-%s" stub (car cell))))
                        (type (cdr cell)))
                    (if symbol
-                       (case type
-                         (function
+                       (pcase type
+                         (`function
                           ;; Store the symbol name of a function
                           (if (fboundp symbol)
                               (setq desc (plist-put desc (car cell) symbol))))
-                         (variable
+                         (`variable
                           ;; Store the VALUE of a variable
                           (if (boundp symbol)
                               (setq desc (plist-put desc (car cell)
                                                     (symbol-value symbol)))))
-                         (otherwise
+                         (_
                           (error "Malformed url-scheme-methods entry: %S"
                                  cell))))))
                (puthash scheme desc url-scheme-registry)))))
@@ -150,5 +152,4 @@ it has not already been loaded."
 
 (provide 'url-methods)
 
-;; arch-tag: 336863f8-5a07-4906-9be5-b3c6bcebbe67
 ;;; url-methods.el ends here