From c2664aaab68759ebd8cfb615c1f2fd73f065caa7 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Wed, 10 Aug 2016 12:10:26 +0200 Subject: [PATCH] Add compatibility layer for `temporary-file-directory-function' * 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 | 6 ++++++ lisp/net/tramp.el | 3 ++- test/lisp/net/tramp-tests.el | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el index 348f9b8468c..b2f91016585 100644 --- a/lisp/net/tramp-compat.el +++ b/lisp/net/tramp-compat.el @@ -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 diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 29dd7038c09..429cd3646dc 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -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: diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index af705f6ce67..1735693cc21 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -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) -- 2.39.2