emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master c2664aa 2/2: Add compatibility layer for `temporary


From: Michael Albinus
Subject: [Emacs-diffs] master c2664aa 2/2: Add compatibility layer for `temporary-file-directory-function'
Date: Wed, 10 Aug 2016 10:10:36 +0000 (UTC)

branch: master
commit c2664aaab68759ebd8cfb615c1f2fd73f065caa7
Author: Michael Albinus <address@hidden>
Commit: Michael Albinus <address@hidden>

    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 348f9b8..b2f9101 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 29dd703..429cd36 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 af705f6..1735693 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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]