]> git.eshelyaron.com Git - emacs.git/commitdiff
Add compatibility layer for `temporary-file-directory-function'
authorMichael Albinus <michael.albinus@gmx.de>
Wed, 10 Aug 2016 10:10:26 +0000 (12:10 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Wed, 10 Aug 2016 10:10:26 +0000 (12:10 +0200)
* lisp/net/tramp-compat.el
(tramp-compat-temporary-file-directory-function): New defalias.

* lisp/net/tramp.el (tramp-handle-make-nearby-temp-file): Use it.

* test/lisp/net/tramp-tests.el (tramp-test32-make-nearby-temp-file):
Skip for older Emacs versions.

lisp/net/tramp-compat.el
lisp/net/tramp.el
test/lisp/net/tramp-tests.el

index 348f9b8468cd585c2b68b68de4bc7ba901680b01..b2f910165852f0aff120e41c449505172b853589 100644 (file)
@@ -118,6 +118,12 @@ Add the extension of F, if existing."
         (extension (file-name-extension f t)))
     (make-temp-file prefix dir-flag extension)))
 
+;; `temporary-file-directory' as function is introduced with Emacs 25.2.
+(defalias 'tramp-compat-temporary-file-directory-function
+  (if (fboundp 'temporary-file-directory)
+      'temporary-file-directory
+    'tramp-handle-temporary-file-directory))
+
 ;; PRESERVE-EXTENDED-ATTRIBUTES has been introduced with Emacs 24.1
 ;; (as PRESERVE-SELINUX-CONTEXT), and renamed in Emacs 24.3.
 (defun tramp-compat-copy-file
index 29dd7038c09cad82abe7744d322de4972ff50adb..429cd3646dc0bc77bd4d117c345dcfee14c689df 100644 (file)
@@ -3996,7 +3996,8 @@ ALIST is of the form ((FROM . TO) ...)."
 
 (defun tramp-handle-make-nearby-temp-file (prefix &optional dir-flag suffix)
   "Like `make-nearby-temp-file' for Tramp files."
-  (let ((temporary-file-directory (temporary-file-directory)))
+  (let ((temporary-file-directory
+        (tramp-compat-temporary-file-directory-function)))
     (make-temp-file prefix dir-flag suffix)))
 
 ;;; Compatibility functions section:
index af705f6ce678983e3f30339aa2bdcad963597b9f..1735693cc21d2c1e4ba56a88f0afba22ed05c3ca 100644 (file)
@@ -1934,9 +1934,12 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
       (ignore-errors (delete-file tmp-name1))
       (ignore-errors (delete-directory tmp-name2 'recursive)))))
 
+;; The functions have been introduced in Emacs 25.2.
 (ert-deftest tramp-test32-make-nearby-temp-file ()
   "Check `make-nearby-temp-file' and `temporary-file-directory'."
   (skip-unless (tramp--test-enabled))
+  (skip-unless
+   (and (fboundp 'make-nearby-temp-file) (fboundp 'temporary-file-directory)))
 
   (let ((default-directory tramp-test-temporary-file-directory)
        tmp-file)