emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master abd1642: Fix error codes in Tramp


From: Michael Albinus
Subject: [Emacs-diffs] master abd1642: Fix error codes in Tramp
Date: Sat, 22 Oct 2016 11:55:08 +0000 (UTC)

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

    Fix error codes in Tramp
    
    * lisp/net/tramp-compat.el (tramp-compat-user-error): New defsubst,
    taken from tramp.el.
    (tramp-file-missing): New defconst.
    
    * lisp/net/tramp.el (tramp-user-error): Remove it.
    (tramp-check-proper-method-and-host)
    (tramp-dissect-file-name, tramp-debug-message)
    (tramp-handle-shell-command):
    * lisp/net/tramp-adb.el (tramp-adb-handle-shell-command):
    * lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler):
    Use `tramp-compat-user-error'.
    
    * lisp/net/tramp.el (tramp-handle-insert-file-contents)
    (tramp-handle-load):
    * lisp/net/tramp-adb.el (tramp-adb-handle-file-local-copy):
    * lisp/net/tramp-gvfs.el (tramp-gvfs-handle-file-local-copy)
    * lisp/net/tramp-sh.el (tramp-sh-handle-file-local-copy):
    * lisp/net/tramp-smb.el (tramp-smb-handle-file-local-copy):
    Use `tramp-file-missing'.  (Bug#24714)
    
    * lisp/net/tramp-sh.el (tramp-sh-handle-add-name-to-file):
    * lisp/net/tramp-smb.el (tramp-smb-handle-make-symbolic-link):
    Use `file-already-exists'.
---
 lisp/net/tramp-adb.el    |    4 ++--
 lisp/net/tramp-compat.el |   17 +++++++++++++++--
 lisp/net/tramp-gvfs.el   |    4 ++--
 lisp/net/tramp-sh.el     |    5 +++--
 lisp/net/tramp-smb.el    |    4 ++--
 lisp/net/tramp.el        |   27 ++++++++++++---------------
 6 files changed, 36 insertions(+), 25 deletions(-)

diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index 3eb1bc4..259b1cb 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -571,7 +571,7 @@ Emacs dired can't find files."
   (with-parsed-tramp-file-name filename nil
     (unless (file-exists-p (file-truename filename))
       (tramp-error
-       v 'file-error
+       v tramp-file-missing
        "Cannot make local copy of non-existing file `%s'" filename))
     (let ((tmpfile (tramp-compat-make-temp-file filename)))
       (with-tramp-progress-reporter
@@ -897,7 +897,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are 
completely ignored."
     (when p
       (if (yes-or-no-p "A command is running.  Kill it? ")
          (ignore-errors (kill-process p))
-       (tramp-user-error p "Shell command in progress")))
+       (tramp-compat-user-error p "Shell command in progress")))
 
     (if current-buffer-p
        (progn
diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el
index e953170..4ebae79 100644
--- a/lisp/net/tramp-compat.el
+++ b/lisp/net/tramp-compat.el
@@ -23,8 +23,9 @@
 
 ;;; Commentary:
 
-;; Tramp's main Emacs version for development is Emacs 25.  This
-;; package provides compatibility functions for Emacs 23 and Emacs 24.
+;; Tramp's main Emacs version for development is Emacs 26.  This
+;; package provides compatibility functions for Emacs 23, Emacs 24 and
+;; Emacs 25.
 
 ;;; Code:
 
@@ -261,6 +262,13 @@ process."
           (memq (process-status process)
                 '(run open listen connect stop))))))
 
+;; `user-error' has appeared in Emacs 24.3.
+(defsubst tramp-compat-user-error (vec-or-proc format &rest args)
+  "Signal a pilot error."
+  (apply
+   'tramp-error vec-or-proc
+   (if (fboundp 'user-error) 'user-error 'error) format args))
+
 ;; `file-attribute-*' are introduced in Emacs 25.1.
 
 (if (fboundp 'file-attribute-type)
@@ -328,6 +336,11 @@ This is a string of ten letters or dashes as in ls -l."
 (unless (fboundp 'format-message)
   (defalias 'format-message 'format))
 
+;; `file-missing' is introduced in Emacs 26.
+(defconst tramp-file-missing
+  (if (get 'file-missing 'error-conditions) 'file-missing 'file-error)
+  "The error symbol for the `file-missing' error.")
+
 (add-hook 'tramp-unload-hook
          (lambda ()
            (unload-feature 'tramp-loaddefs 'force)
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index 3d8d366..637c2a7 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -541,7 +541,7 @@ Operations not mentioned here will be handled by the 
default Emacs primitives.")
 First arg specifies the OPERATION, second arg is a list of arguments to
 pass to the OPERATION."
   (unless tramp-gvfs-enabled
-    (tramp-user-error nil "Package `tramp-gvfs' not supported"))
+    (tramp-compat-user-error nil "Package `tramp-gvfs' not supported"))
   (let ((fn (assoc operation tramp-gvfs-file-name-handler-alist)))
     (if fn
        (save-match-data (apply (cdr fn) args))
@@ -1033,7 +1033,7 @@ file names."
     (let ((tmpfile (tramp-compat-make-temp-file filename)))
       (unless (file-exists-p filename)
        (tramp-error
-        v 'file-error
+        v tramp-file-missing
         "Cannot make local copy of non-existing file `%s'" filename))
       (copy-file filename tmpfile 'ok-if-already-exists 'keep-time)
       tmpfile)))
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 6196b15..555e371 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -1960,7 +1960,8 @@ tramp-sh-handle-file-name-all-completions: internal error 
accessing `%s': `%s'"
                     "File %s already exists; make it a new name anyway? "
                     newname)))
          (tramp-error
-          v2 'file-error "add-name-to-file: file %s already exists" newname))
+          v2 'file-already-exists
+          "add-name-to-file: file %s already exists" newname))
        (when ok-if-already-exists (setq ln (concat ln " -f")))
        (tramp-flush-file-property v2 (file-name-directory v2-localname))
        (tramp-flush-file-property v2 v2-localname)
@@ -3130,7 +3131,7 @@ the result will be a local, non-Tramp, file name."
   (with-parsed-tramp-file-name filename nil
     (unless (file-exists-p filename)
       (tramp-error
-       v 'file-error
+       v tramp-file-missing
        "Cannot make local copy of non-existing file `%s'" filename))
 
     (let* ((size (tramp-compat-file-attribute-size
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el
index fe24edb..0c8ecf4 100644
--- a/lisp/net/tramp-smb.el
+++ b/lisp/net/tramp-smb.el
@@ -902,7 +902,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are 
completely ignored."
   (with-parsed-tramp-file-name filename nil
     (unless (file-exists-p filename)
       (tramp-error
-       v 'file-error
+       v tramp-file-missing
        "Cannot make local copy of non-existing file `%s'" filename))
     (let ((tmpfile (tramp-compat-make-temp-file filename)))
       (with-tramp-progress-reporter
@@ -1125,7 +1125,7 @@ target of the symlink differ."
                   "File %s already exists; make it a new name anyway? "
                   linkname)))
        (tramp-error
-        v2 'file-error
+        v2 'file-already-exists
         "make-symbolic-link: file %s already exists" linkname))
       (unless (tramp-smb-get-cifs-capabilities v1)
        (tramp-error v2 'file-error "make-symbolic-link not supported"))
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 7af40a8..730972e 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -1068,13 +1068,6 @@ calling HANDLER.")
 
 ;;; Internal functions which must come first:
 
-;; `user-error' has appeared in Emacs 24.3.
-(defsubst tramp-user-error (vec-or-proc format &rest args)
-  "Signal a pilot error."
-  (apply
-   'tramp-error vec-or-proc
-   (if (fboundp 'user-error) 'user-error 'error) format args))
-
 ;; Conversion functions between external representation and
 ;; internal data structure.  Convenience functions for internal
 ;; data structure.
@@ -1230,13 +1223,14 @@ This is HOST, if non-nil. Otherwise, it is 
`tramp-default-host'."
        (methods (mapcar 'car tramp-methods)))
     (when (and method (not (member method methods)))
       (tramp-cleanup-connection vec)
-      (tramp-user-error vec "Unknown method \"%s\"" method))
+      (tramp-compat-user-error vec "Unknown method \"%s\"" method))
     (when (and (equal tramp-syntax 'ftp) host
               (or (null method) (get-text-property 0 'tramp-default method))
               (or (null user) (get-text-property 0 'tramp-default user))
               (member host methods))
       (tramp-cleanup-connection vec)
-      (tramp-user-error vec "Host name must not match method \"%s\"" host))))
+      (tramp-compat-user-error
+       vec "Host name must not match method \"%s\"" host))))
 
 (defun tramp-dissect-file-name (name &optional nodefault)
   "Return a `tramp-file-name' structure.
@@ -1246,7 +1240,8 @@ non-nil, the file name parts are not expanded to their 
default
 values."
   (save-match-data
     (let ((match (string-match (nth 0 tramp-file-name-structure) name)))
-      (unless match (tramp-user-error nil "Not a Tramp file name: \"%s\"" 
name))
+      (unless match
+       (tramp-compat-user-error nil "Not a Tramp file name: \"%s\"" name))
       (let ((method    (match-string (nth 1 tramp-file-name-structure) name))
            (user      (match-string (nth 2 tramp-file-name-structure) name))
            (host      (match-string (nth 3 tramp-file-name-structure) name))
@@ -1434,12 +1429,12 @@ ARGUMENTS to actually emit the message (if applicable)."
                     '("tramp-backtrace"
                       "tramp-compat-condition-case-unless-debug"
                       "tramp-compat-funcall"
+                      "tramp-compat-user-error"
                       "tramp-condition-case-unless-debug"
                       "tramp-debug-message"
                       "tramp-error"
                       "tramp-error-with-buffer"
-                      "tramp-message"
-                      "tramp-user-error")
+                      "tramp-message")
                     t)
                    "$")
                   fn)))
@@ -3035,7 +3030,8 @@ User is always nil."
       (unwind-protect
          (if (not (file-exists-p filename))
              (tramp-error
-              v 'file-error "File `%s' not found on remote host" filename)
+              v tramp-file-missing
+              "File `%s' not found on remote host" filename)
 
            (with-tramp-progress-reporter
                v 3 (format-message "Inserting `%s'" filename)
@@ -3160,7 +3156,8 @@ User is always nil."
         "File `%s' does not include a `.el' or `.elc' suffix" file)))
     (unless noerror
       (when (not (file-exists-p file))
-       (tramp-error v 'file-error "Cannot load nonexistent file `%s'" file)))
+       (tramp-error
+        v tramp-file-missing "Cannot load nonexistent file `%s'" file)))
     (if (not (file-exists-p file))
        nil
       (let ((tramp-message-show-message (not nomessage)))
@@ -3221,7 +3218,7 @@ User is always nil."
     (when p
       (if (yes-or-no-p "A command is running.  Kill it? ")
          (ignore-errors (kill-process p))
-       (tramp-user-error p "Shell command in progress")))
+       (tramp-compat-user-error p "Shell command in progress")))
 
     (if current-buffer-p
        (progn



reply via email to

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