summaryrefslogtreecommitdiff
path: root/test/lisp/net
diff options
context:
space:
mode:
authorJim Porter <jporterbugs@gmail.com>2021-11-15 13:33:07 +0100
committerMichael Albinus <michael.albinus@gmx.de>2021-11-15 13:33:07 +0100
commitbf505a63f98ed61934a8fb81ec65c96859606b6e (patch)
treedf91fd6e5fe4150b273234e9dd13c833706e4267 /test/lisp/net
parentcff1702a52d9f116d9180a1a1597130474574fd8 (diff)
downloademacs-bf505a63f98ed61934a8fb81ec65c96859606b6e.tar.gz
emacs-bf505a63f98ed61934a8fb81ec65c96859606b6e.tar.bz2
emacs-bf505a63f98ed61934a8fb81ec65c96859606b6e.zip
Support abbreviating home directory of Tramp filenames
* doc/lispref/files.texi (Magic File Names): Mention 'abbreviate-file-name' in the list of magic file name handlers. * etc/NEWS: Announce the change. * lisp/files.el (file-name-non-special): * lisp/net/tramp.el (tramp-file-name-for-operation): * lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist): * lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist): * lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler-alist): Add 'abbreviate-file-name'. * lisp/files.el (directory-abbrev-make-regexp): (directory-abbrev-apply): New functions. (abbreviate-file-name): Check for file name handler. * test/lisp/net/tramp-tests.el (tramp-test07-abbreviate-file-name): New test.
Diffstat (limited to 'test/lisp/net')
-rw-r--r--test/lisp/net/tramp-tests.el25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 52c6159dc12..698d18b5282 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -2289,6 +2289,31 @@ This checks also `file-name-as-directory', `file-name-directory',
(should (string-equal (file-name-directory file) file))
(should (string-equal (file-name-nondirectory file) "")))))))
+(ert-deftest tramp-test07-abbreviate-file-name ()
+ "Check that Tramp abbreviates file names correctly."
+ (skip-unless (tramp--test-enabled))
+ (skip-unless (tramp--test-emacs29-p))
+
+ (let* ((remote-host (file-remote-p tramp-test-temporary-file-directory))
+ (home-dir (expand-file-name (concat remote-host "~"))))
+ ;; Check home-dir abbreviation.
+ (should (equal (abbreviate-file-name (concat home-dir "/foo/bar"))
+ (concat remote-host "~/foo/bar")))
+ (should (equal (abbreviate-file-name (concat remote-host
+ "/nowhere/special"))
+ (concat remote-host "/nowhere/special")))
+ ;; Check `directory-abbrev-alist' abbreviation.
+ (let ((directory-abbrev-alist
+ `((,(concat "\\`" (regexp-quote home-dir) "/foo")
+ . ,(concat home-dir "/f"))
+ (,(concat "\\`" (regexp-quote remote-host) "/nowhere")
+ . ,(concat remote-host "/nw")))))
+ (should (equal (abbreviate-file-name (concat home-dir "/foo/bar"))
+ (concat remote-host "~/f/bar")))
+ (should (equal (abbreviate-file-name (concat remote-host
+ "/nowhere/special"))
+ (concat remote-host "/nw/special"))))))
+
(ert-deftest tramp-test07-file-exists-p ()
"Check `file-exist-p', `write-region' and `delete-file'."
(skip-unless (tramp--test-enabled))