lisp/url/url-handlers.el (url-handler-regexp): Declare.
[bpt/emacs.git] / lisp / url / url-handlers.el
index 133f40a..f731f61 100644 (file)
@@ -1,7 +1,6 @@
 ;;; url-handlers.el --- file-name-handler stuff for URL loading
 
-;; Copyright (C) 1996, 1997, 1998, 1999, 2004,
-;;   2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+;; Copyright (C) 1996-1999, 2004-2012  Free Software Foundation, Inc.
 
 ;; Keywords: comm, data, processes, hypermedia
 
 ;; verify-visited-file-modtime
 ;; write-region
 
-(defvar url-handler-regexp
-  "\\`\\(https?\\|ftp\\|file\\|nfs\\)://"
-  "*A regular expression for matching  URLs handled by file-name-handler-alist.
-Some valid URL protocols just do not make sense to visit interactively
-\(about, data, info, irc, mailto, etc\).  This regular expression
-avoids conflicts with local files that look like URLs \(Gnus is
-particularly bad at this\).")
+(defvar url-handler-regexp) ; defined below to avoid recursive load (revno:108572)
 
 ;;;###autoload
 (define-minor-mode url-handler-mode
-  "Use URL to handle URL-like file names."
+  "Toggle using `url' library for URL filenames (URL Handler mode).
+With a prefix argument ARG, enable URL Handler mode if ARG is
+positive, and disable it otherwise.  If called from Lisp, enable
+the mode if ARG is omitted or nil."
   :global t :group 'url
-  (if (not (boundp 'file-name-handler-alist))
-      ;; Can't be turned ON anyway.
-      (setq url-handler-mode nil)
-    ;; Remove old entry, if any.
-    (setq file-name-handler-alist
-         (delq (rassq 'url-file-handler file-name-handler-alist)
-               file-name-handler-alist))
-    (if url-handler-mode
-       (push (cons url-handler-regexp 'url-file-handler)
-             file-name-handler-alist))))
+  ;; Remove old entry, if any.
+  (setq file-name-handler-alist
+       (delq (rassq 'url-file-handler file-name-handler-alist)
+             file-name-handler-alist))
+  (if url-handler-mode
+      (push (cons url-handler-regexp 'url-file-handler)
+           file-name-handler-alist)))
+
+(defcustom url-handler-regexp "\\`\\(https?\\|ftp\\|file\\|nfs\\)://"
+  "Regular expression for URLs handled by `url-handler-mode'.
+When URL Handler mode is enabled, this regular expression is
+added to `file-name-handler-alist'.
+
+Some valid URL protocols just do not make sense to visit
+interactively \(about, data, info, irc, mailto, etc\).  This
+regular expression avoids conflicts with local files that look
+like URLs \(Gnus is particularly bad at this\)."
+  :group 'url
+  :type 'regexp
+  :set (lambda (symbol value)
+        (let ((enable url-handler-mode))
+          (url-handler-mode 0)
+          (set-default symbol value)
+          (if enable
+              (url-handler-mode)))))
 
 (defun url-run-real-handler (operation args)
   (let ((inhibit-file-name-handlers (cons 'url-file-handler
@@ -132,7 +143,7 @@ the arguments that would have been passed to OPERATION."
        (hooked nil))
     (if (and fn (fboundp fn))
        (setq hooked t
-             val (apply fn args))
+             val (save-match-data (apply fn args)))
       (setq hooked nil
            val (url-run-real-handler operation args)))
     (url-debug 'handlers "%s %S%S => %S" (if hooked "Hooked" "Real")
@@ -215,7 +226,8 @@ the arguments that would have been passed to OPERATION."
 
 ;; The actual implementation
 ;;;###autoload
-(defun url-copy-file (url newname &optional ok-if-already-exists keep-time)
+(defun url-copy-file (url newname &optional ok-if-already-exists
+                         keep-time preserve-uid-gid)
   "Copy URL to NEWNAME.  Both args must be strings.
 Signals a `file-already-exists' error if file NEWNAME already exists,
 unless a third argument OK-IF-ALREADY-EXISTS is supplied and non-nil.
@@ -223,6 +235,7 @@ A number as third arg means request confirmation if NEWNAME already exists.
 This is what happens in interactive use with M-x.
 Fourth arg KEEP-TIME non-nil means give the new file the same
 last-modified time as the old one.  (This works on only some systems.)
+Fifth arg PRESERVE-UID-GID is ignored.
 A prefix arg makes KEEP-TIME non-nil."
   (if (and (file-exists-p newname)
           (not ok-if-already-exists))
@@ -323,5 +336,4 @@ They count bytes from the beginning of the body."
 
 (provide 'url-handlers)
 
-;; arch-tag: 7300b99c-cc83-42ff-9147-79b2723c62ac
 ;;; url-handlers.el ends here