From 492b31d977c63a90ac703aebf7120a96026f93ef Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Tue, 29 Jan 2019 17:25:36 +0100 Subject: [PATCH] ; Tramp cleanup * lisp/net/tramp-adb.el (tramp-adb-maybe-open-connection): Handle `non-essential'. * lisp/net/tramp-archive.el: Increase `max-specpdl-size' when loading tramp-gvfs. * lisp/net/tramp-rclone.el (tramp-rclone-mounted-p): Reorder for better traces. (tramp-rclone-maybe-open-connection): Handle `non-essential'. * lisp/net/tramp-sh.el (tramp-sh-handle-copy-directory) (tramp-find-inline-encoding): Simplify check. * lisp/net/tramp-smb.el (tramp-smb-handle-insert-directory) (tramp-smb-handle-insert-directory): Simplify check. * lisp/net/tramp-sudoedit.el (tramp-sudoedit-action-sudo): Simplify check. (tramp-sudoedit-maybe-open-connection): Handle `non-essential'. * lisp/net/tramp.el (tramp-handle-load, tramp-wait-for-regexp): Simplify check. (tramp-action-login, tramp-action-password, tramp-action-yesno) (tramp-action-yn, tramp-action-terminal): Return explicitly t. (tramp-process-one-action, tramp-process-actions): Adapt docstring. --- lisp/net/tramp-adb.el | 8 +++++++ lisp/net/tramp-archive.el | 5 +++- lisp/net/tramp-rclone.el | 30 ++++++++++++++--------- lisp/net/tramp-sh.el | 6 ++--- lisp/net/tramp-smb.el | 4 ++-- lisp/net/tramp-sudoedit.el | 11 ++++++++- lisp/net/tramp.el | 49 ++++++++++++++++++++++++++++---------- 7 files changed, 83 insertions(+), 30 deletions(-) diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index 372ce154149..d45695cbecc 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el @@ -1300,6 +1300,14 @@ connection if a previous connection has died for some reason." (tramp-error vec 'file-error "Cannot switch to user `%s'" user)) (unless (process-live-p p) + ;; During completion, don't reopen a new connection. We check + ;; this for the process related to `tramp-buffer-name'; + ;; otherwise `start-file-process' wouldn't run ever when + ;; `non-essential' is non-nil. + (when (and (tramp-completion-mode-p) + (null (get-process (tramp-buffer-name vec)))) + (throw 'non-essential 'non-essential)) + (save-match-data (when (and p (processp p)) (delete-process p)) (if (zerop (length device)) diff --git a/lisp/net/tramp-archive.el b/lisp/net/tramp-archive.el index e4a7b157a02..f975ccfcfa8 100644 --- a/lisp/net/tramp-archive.el +++ b/lisp/net/tramp-archive.el @@ -108,7 +108,10 @@ ;;; Code: (eval-when-compile (require 'cl-lib)) -(require 'tramp-gvfs) +;; Sometimes, compilation fails with "Variable binding depth exceeds +;; max-specpdl-size". +(eval-and-compile + (let ((max-specpdl-size (* 2 max-specpdl-size))) (require 'tramp-gvfs))) (autoload 'dired-uncache "dired") (autoload 'url-tramp-convert-url-to-tramp "url-tramp") diff --git a/lisp/net/tramp-rclone.el b/lisp/net/tramp-rclone.el index bc48d4d3a85..3db8f1d8af7 100644 --- a/lisp/net/tramp-rclone.el +++ b/lisp/net/tramp-rclone.el @@ -467,19 +467,19 @@ file names." (when (tramp-get-connection-process vec) ;; We cannot use `with-connection-property', because we don't want ;; to cache a nil result. - (or (tramp-get-connection-property - (tramp-get-connection-process vec) "mounted" nil) + (unless (tramp-get-connection-property + (tramp-get-connection-process vec) "mounted" nil) + (let* ((default-directory temporary-file-directory) + (mount (shell-command-to-string "mount -t fuse.rclone"))) + (tramp-message vec 6 "%s" "mount -t fuse.rclone") + (tramp-message vec 6 "\n%s" mount) (tramp-set-connection-property (tramp-get-connection-process vec) "mounted" - (let* ((default-directory temporary-file-directory) - (mount (shell-command-to-string "mount -t fuse.rclone"))) - (tramp-message vec 6 "%s" "mount -t fuse.rclone") - (tramp-message vec 6 "\n%s" mount) - (when (string-match - (format - "^\\(%s:\\S-*\\)" (regexp-quote (tramp-file-name-host vec))) - mount) - (match-string 1 mount))))))) + (when (string-match + (format + "^\\(%s:\\S-*\\)" (regexp-quote (tramp-file-name-host vec))) + mount) + (match-string 1 mount))))))) (defun tramp-rclone-flush-directory-cache (vec) "Flush directory cache of VEC mount." @@ -544,6 +544,14 @@ connection if a previous connection has died for some reason." (if (zerop (length host)) (tramp-error vec 'file-error "Storage %s not connected" host)) + ;; During completion, don't reopen a new connection. We check + ;; this for the process related to `tramp-buffer-name'; + ;; otherwise `start-file-process' wouldn't run ever when + ;; `non-essential' is non-nil. + (when (and (tramp-completion-mode-p) + (null (get-process (tramp-buffer-name vec)))) + (throw 'non-essential 'non-essential)) + ;; We need a process bound to the connection buffer. Therefore, ;; we create a dummy process. Maybe there is a better solution? (unless (get-buffer-process (tramp-get-connection-buffer vec)) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index e4ea9ecb9f6..5ed75132753 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -1931,7 +1931,7 @@ tramp-sh-handle-file-name-all-completions: internal error accessing `%s': `%s'" (setq newname (expand-file-name (file-name-nondirectory dirname) newname))) - (when (not (file-directory-p (file-name-directory newname))) + (unless (file-directory-p (file-name-directory newname)) (make-directory (file-name-directory newname) parents)) (tramp-do-copy-or-rename-file-out-of-band 'copy dirname newname keep-date)) @@ -4458,7 +4458,7 @@ Goes through the list `tramp-local-coding-commands' and ;; actually check the output it gives. And also, when ;; redirecting "mimencode" output to /dev/null, then as root ;; it might change the permissions of /dev/null! - (when (not (stringp rem-enc)) + (unless (stringp rem-enc) (let ((name (symbol-name rem-enc))) (while (string-match "-" name) (setq name (replace-match "_" nil t name))) @@ -4471,7 +4471,7 @@ Goes through the list `tramp-local-coding-commands' and vec (format "%s