diff options
author | Nicolas Petton <nicolas@petton.fr> | 2018-03-13 22:07:08 +0100 |
---|---|---|
committer | Nicolas Petton <nicolas@petton.fr> | 2018-03-18 20:47:35 +0100 |
commit | 6d2b50a2451a9d7aae040cb82040c2211df75c85 (patch) | |
tree | d6beb72fc8f9da6e350cc056fa9d49b0be525560 /lisp/url/url-handlers.el | |
parent | 9942734c75c7b78efba41204432533cd3fe3b419 (diff) | |
download | emacs-6d2b50a2451a9d7aae040cb82040c2211df75c85.tar.gz |
Add URL handler for file-name-directory (Bug#30444)
* lisp/url/url-handlers.el (url-handler-file-name-directory): New
function which handles special cases for `file-name-directory' and
URLs.
* test/lisp/url/url-handlers-test.el: New file. Add tests for
`url-handler-file-name-directory'.
Diffstat (limited to 'lisp/url/url-handlers.el')
-rw-r--r-- | lisp/url/url-handlers.el | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lisp/url/url-handlers.el b/lisp/url/url-handlers.el index 7d0320cb5b1..17c76cff75a 100644 --- a/lisp/url/url-handlers.el +++ b/lisp/url/url-handlers.el @@ -186,6 +186,7 @@ the arguments that would have been passed to OPERATION." (put 'file-name-absolute-p 'url-file-handlers (lambda (&rest ignored) t)) (put 'expand-file-name 'url-file-handlers 'url-handler-expand-file-name) (put 'directory-file-name 'url-file-handlers 'url-handler-directory-file-name) +(put 'file-name-directory 'url-file-handlers 'url-handler-file-name-directory) (put 'unhandled-file-name-directory 'url-file-handlers 'url-handler-unhandled-file-name-directory) (put 'file-remote-p 'url-file-handlers 'url-handler-file-remote-p) ;; (put 'file-name-as-directory 'url-file-handlers 'url-handler-file-name-as-directory) @@ -231,6 +232,14 @@ the arguments that would have been passed to OPERATION." ;; a local process. nil))) +(defun url-handler-file-name-directory (dir) + (let ((url (url-generic-parse-url dir))) + ;; Do not attempt to handle `file' URLs which are local. + (if (and (not (equal (url-type url) "file")) + (string-empty-p (url-filename url))) + (url-handler-file-name-directory (concat dir "/")) + (url-run-real-handler 'file-name-directory (list dir))))) + (defun url-handler-file-remote-p (filename &optional identification _connected) (let ((url (url-generic-parse-url filename))) (if (and (url-type url) (not (equal (url-type url) "file"))) |