[Top][All Lists]

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

master 73e8622: Add `permission-denied' error to Tramp

From: Michael Albinus
Subject: master 73e8622: Add `permission-denied' error to Tramp
Date: Tue, 21 Dec 2021 09:15:32 -0500 (EST)

branch: master
commit 73e862237d1db167d4f5712f95f68b8b17816ea9
Author: Michael Albinus <michael.albinus@gmx.de>
Commit: Michael Albinus <michael.albinus@gmx.de>

    Add `permission-denied' error to Tramp
    * lisp/net/tramp-compat.el (tramp-permission-denied): New defconst.
    (tramp-compat-permission-denied): New defsubst.
    * lisp/net/tramp.el (tramp-handle-access-file):
    * lisp/net/tramp-archive.el (tramp-archive-handle-copy-file): Use it.
 lisp/net/tramp-archive.el |  5 ++---
 lisp/net/tramp-compat.el  | 11 +++++++++++
 lisp/net/tramp.el         |  4 ++--
 3 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/lisp/net/tramp-archive.el b/lisp/net/tramp-archive.el
index b44a4e8..bba94f2 100644
--- a/lisp/net/tramp-archive.el
+++ b/lisp/net/tramp-archive.el
@@ -575,9 +575,8 @@ offered."
    preserve-uid-gid preserve-extended-attributes)
   "Like `copy-file' for file archives."
   (when (tramp-archive-file-name-p newname)
-    (tramp-error
-     (tramp-archive-dissect-file-name newname) 'file-error
-      "Permission denied: %s" newname))
+    (tramp-compat-permission-denied
+     (tramp-archive-dissect-file-name newname) newname))
    (tramp-archive-gvfs-file-name filename) newname ok-if-already-exists
    keep-date preserve-uid-gid preserve-extended-attributes))
diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el
index 627ff1e..1936d2a 100644
--- a/lisp/net/tramp-compat.el
+++ b/lisp/net/tramp-compat.el
@@ -272,6 +272,17 @@ CONDITION can also be a list of error conditions."
                          (car components))
                 (cdr components)))))))
+;; `permission-denied' is introduced in Emacs 29.1.
+(defconst tramp-permission-denied
+  (if (get 'permission-denied 'error-conditions) 'permission-denied 
+  "The error symbol for the `permission-denied' error.")
+(defsubst tramp-compat-permission-denied (vec file)
+  "Emit the `permission-denied' error."
+  (if (get 'permission-denied 'error-conditions)
+      (tramp-error vec tramp-permission-denied file)
+    (tramp-error vec tramp-permission-denied "Permission denied: %s" file)))
 (dolist (elt (all-completions "tramp-compat-" obarray 'functionp))
   (put (intern elt) 'tramp-suppress-trace t))
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 940e25e..7dc3dd7 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -3363,8 +3363,8 @@ User is always nil."
             (if (file-directory-p filename)
                 #'file-accessible-directory-p #'file-readable-p)
-         (tramp-error
-          v 'file-error (format "%s: Permission denied, %s" string filename)))
+         (tramp-compat-permission-denied
+          v (format "%s: Permission denied, %s" string filename)))
        v 'file-missing
        (format "%s: No such file or directory, %s" string filename)))))

reply via email to

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