Function: url-file-handler

url-file-handler is an autoloaded and byte-compiled function defined in url-handlers.el.gz.

Signature

(url-file-handler OPERATION &rest ARGS)

Documentation

Function called from the file-name-handler-alist routines.

OPERATION is what needs to be done (file-exists-p, etc.). ARGS are the arguments that would have been passed to OPERATION.

Source Code

;; Defined in /usr/src/emacs/lisp/url/url-handlers.el.gz
;;;###autoload
(defun url-file-handler (operation &rest args)
  "Function called from the `file-name-handler-alist' routines.
OPERATION is what needs to be done (`file-exists-p', etc.).
ARGS are the arguments that would have been passed to OPERATION."
  ;; Avoid recursive load.
  (if (and load-in-progress url-file-handler-load-in-progress)
      (url-run-real-handler operation args)
    (let ((url-file-handler-load-in-progress load-in-progress))
      ;; Check, whether there are arguments we want pass to Tramp.
      (if (catch :do
            (dolist (url (cons default-directory args))
              (and (stringp url)
                   (member (url-type (url-generic-parse-url url))
                           url-tramp-protocols)
                   (throw :do t))))
          (apply #'url-tramp-file-handler operation args)
        ;; Otherwise, let's do the job.
        (let ((fn (get operation 'url-file-handlers))
              val)
          (if (and (not fn)
                   (fboundp (intern-soft (format "url-%s" operation))))
              (error "Missing URL handler mapping for %s" operation))
          (setq val (if fn (save-match-data (apply fn args))
                      (url-run-real-handler operation args)))
          (url-debug 'handlers "%s %S%S => %S" (if fn "Hooked" "Real")
                     operation args val)
          val)))))