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.
This commit is contained in:
Michael Albinus 2016-08-10 12:10:26 +02:00
parent 5115743b67
commit c2664aaab6
3 changed files with 11 additions and 1 deletions

View 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

View 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:

View 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)