summaryrefslogtreecommitdiff
path: root/lisp/url/url-handlers.el
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2014-04-01 14:41:56 +0200
committerMichael Albinus <michael.albinus@gmx.de>2014-04-01 14:41:56 +0200
commit8def287539f38f1f95ef54e866b80f44c9c76b5b (patch)
treea5ebe25499294828455287ebe95aa3afad8ab9bd /lisp/url/url-handlers.el
parenta7ab7bc038e1e53f4e8e4b65125b5c64c548c407 (diff)
downloademacs-8def287539f38f1f95ef54e866b80f44c9c76b5b.tar.gz
Pass some protocols to Tramp, like ssh and friends.
* url-tramp.el: New file. * url-handlers.el (url-handler-regexp): Add ssh, scp, rsync and telnet. Add :version. (url-file-handler): Call `url-tramp-file-handler' if appropriate.
Diffstat (limited to 'lisp/url/url-handlers.el')
-rw-r--r--lisp/url/url-handlers.el40
1 files changed, 25 insertions, 15 deletions
diff --git a/lisp/url/url-handlers.el b/lisp/url/url-handlers.el
index ecf56e786b5..9a05746ebff 100644
--- a/lisp/url/url-handlers.el
+++ b/lisp/url/url-handlers.el
@@ -112,7 +112,7 @@ the mode if ARG is omitted or nil."
(push (cons url-handler-regexp 'url-file-handler)
file-name-handler-alist)))
-(defcustom url-handler-regexp "\\`\\(https?\\|ftp\\|file\\|nfs\\)://"
+(defcustom url-handler-regexp "\\`\\(https?\\|ftp\\|file\\|nfs\\|ssh\\|scp\\|rsync\\|telnet\\)://"
"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'.
@@ -123,6 +123,7 @@ regular expression avoids conflicts with local files that look
like URLs \(Gnus is particularly bad at this\)."
:group 'url
:type 'regexp
+ :version "24.5"
:set (lambda (symbol value)
(let ((enable url-handler-mode))
(url-handler-mode 0)
@@ -142,20 +143,29 @@ like URLs \(Gnus is particularly bad at this\)."
"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."
- (let ((fn (get operation 'url-file-handlers))
- (val nil)
- (hooked nil))
- (if (and (not fn) (intern-soft (format "url-%s" operation))
- (fboundp (intern-soft (format "url-%s" operation))))
- (error "Missing URL handler mapping for %s" operation))
- (if fn
- (setq hooked t
- 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")
- operation args val)
- val))
+ ;; Check, whether there are arguments we want pass to Tramp.
+ (if (catch :do
+ (dolist (url (cons default-directory args))
+ (and (member
+ (url-type (url-generic-parse-url (and (stringp 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 nil)
+ (hooked nil))
+ (if (and (not fn) (intern-soft (format "url-%s" operation))
+ (fboundp (intern-soft (format "url-%s" operation))))
+ (error "Missing URL handler mapping for %s" operation))
+ (if fn
+ (setq hooked t
+ 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")
+ operation args val)
+ val)))
(defun url-file-handler-identity (&rest args)
;; Identity function