emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/ssh-deploy 664f52c 072/133: Improved missing async func


From: Stefan Monnier
Subject: [elpa] externals/ssh-deploy 664f52c 072/133: Improved missing async function error and replaced require with autoload
Date: Sat, 27 Mar 2021 14:48:46 -0400 (EDT)

branch: externals/ssh-deploy
commit 664f52c264801653eabaad015cbed011a8e191cd
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>

    Improved missing async function error and replaced require with autoload
---
 ssh-deploy-diff-mode.el |  2 --
 ssh-deploy-test.el      |  2 --
 ssh-deploy.el           | 42 +++++++++++++++++++-----------------------
 3 files changed, 19 insertions(+), 27 deletions(-)

diff --git a/ssh-deploy-diff-mode.el b/ssh-deploy-diff-mode.el
index 39c3d21..52abf6f 100644
--- a/ssh-deploy-diff-mode.el
+++ b/ssh-deploy-diff-mode.el
@@ -170,7 +170,6 @@
 
 (defun ssh-deploy-diff-mode--copy-b (parts)
   "Perform an download of remote-path to local-path based on PARTS from 
section B or section BOTH."
-  (require 'ssh-deploy)
   (let* ((section (nth 1 parts))
          (file-name (nth 0 parts))
          (root-local (file-truename (nth 2 parts)))
@@ -214,7 +213,6 @@
 
 (defun ssh-deploy-diff-mode--open (parts)
   "Perform a open file action based on PARTS from section A or section B."
-  (require 'ssh-deploy)
   (let* ((section (nth 1 parts))
          (file-name (nth 0 parts))
          (root-local (file-truename (nth 2 parts)))
diff --git a/ssh-deploy-test.el b/ssh-deploy-test.el
index a1a9dc0..bd36006 100644
--- a/ssh-deploy-test.el
+++ b/ssh-deploy-test.el
@@ -46,8 +46,6 @@
 (defun ssh-deploy-test--download ()
   "Test downloads."
 
-  (require 'ediff-util)
-
   (let ((directory-a (expand-file-name "test-a/"))
         (directory-b (expand-file-name "test-b/")))
 
diff --git a/ssh-deploy.el b/ssh-deploy.el
index ce3197c..373b689 100644
--- a/ssh-deploy.el
+++ b/ssh-deploy.el
@@ -133,10 +133,15 @@
 
 ;;; Code:
 
+(autoload 'ediff-same-file-contents "ediff-util")
+(autoload 'string-remove-prefix "subr-x")
+(autoload 'eshell "eshell")
+(autoload 'shell "shell")
 
 (autoload 'ssh-deploy-diff-mode "ssh-deploy-diff-mode")
 (autoload 'ssh-deploy-hydra "ssh-deploy-hydra")
 
+
 (defgroup ssh-deploy nil
   "Upload, download, difference, browse and terminal handler for files and 
directories on remote hosts via Tramp."
   :group 'tools
@@ -287,18 +292,19 @@
 
 (defun ssh-deploy--async-process (start &optional finish async-with-threads)
   "Asynchronously do START and then optionally do FINISH, use multi-treading 
if ASYNC-WITH-THREADS is above 0 otherwise use multi processes via async.el."
-  (if (and (fboundp 'make-thread)
-           async-with-threads
+  (if (and async-with-threads
            (> async-with-threads 0))
-      (make-thread (lambda()
-                     (let ((ssh-deploy-async 0)
-                           (ssh-deploy-async-with-threads 0)
-                           (ssh-deploy-on-explicit-save 0)
-                           (ssh-deploy-automatically-detect-remote-changes 0))
-                       (if start
-                           (let ((result (funcall start)))
-                             (if finish
-                                 (funcall finish result)))))))
+      (if (fboundp 'make-thread)
+          (make-thread (lambda()
+                         (let ((ssh-deploy-async 0)
+                               (ssh-deploy-async-with-threads 0)
+                               (ssh-deploy-on-explicit-save 0)
+                               (ssh-deploy-automatically-detect-remote-changes 
0))
+                           (if start
+                               (let ((result (funcall start)))
+                                 (if finish
+                                     (funcall finish result)))))))
+        (display-warning 'ssh-deploy "make-thread function are not 
available!"))
     (if (fboundp 'async-start)
         (when start
           (let ((ftp-netrc nil))
@@ -311,10 +317,11 @@
                      (ssh-deploy-on-explicit-save 0)
                      (ssh-deploy-automatically-detect-remote-changes 0))
                  (if ftp-netrc
+                     ;; Pass ange-ftp setting to asynchronous process
                      (defvar ange-ftp-netrc-filename ftp-netrc))
                  (funcall start)))
              finish)))
-      (display-warning 'ssh-deploy "Neither make-thread nor async-start 
functions are available!"))))
+      (display-warning 'ssh-deploy "async-start functions are not 
available!"))))
 
 (defun ssh-deploy--mode-line-set-status-and-update (status &optional filename)
   "Set the mode line STATUS in optionally in buffer visiting FILENAME."
@@ -416,7 +423,6 @@
           (when (> ssh-deploy-verbose 0) (message "Uploading file '%s' to 
'%s'.. (asynchronously)" path-local path-remote))
           (ssh-deploy--async-process
            (lambda()
-             (require 'ediff-util)
              (if (fboundp 'ediff-same-file-contents)
                  (if (or (> force 0) (not (file-exists-p path-remote)) (and 
(file-exists-p revision-path) (ediff-same-file-contents revision-path 
path-remote)))
                      (progn
@@ -449,7 +455,6 @@
     (ssh-deploy--mode-line-set-status-and-update ssh-deploy--status-uploading)
     (if file-or-directory
         (progn
-          (require 'ediff-util)
           (if (fboundp 'ediff-same-file-contents)
               (if (or (> force 0)
                       (not (file-exists-p path-remote))
@@ -515,7 +520,6 @@
 (defun ssh-deploy--diff-directories-data (directory-a directory-b exclude-list)
   "Find difference between DIRECTORY-A and DIRECTORY-B but exclude paths 
matching EXCLUDE-LIST."
   ;; (message "Comparing a: %s to b: %s" directory-a directory-b)
-  (require 'subr-x)
   (if (fboundp 'string-remove-prefix)
       (if (and (file-directory-p directory-a)
                (file-directory-p directory-b))
@@ -596,7 +600,6 @@
              files-b-relative-list)
 
             ;; Collect files that differ in contents and have equal contents
-            (require 'ediff-util)
             (when (fboundp 'ediff-same-file-contents)
               (mapc
                (lambda (file)
@@ -679,7 +682,6 @@
 ;;;###autoload
 (defun ssh-deploy-diff-files (file-a file-b)
   "Find difference between FILE-A and FILE-B."
-  (require 'ediff-util)
   (if (fboundp 'ediff-same-file-contents)
       (progn
         (message "Comparing file '%s' to '%s'.." file-a file-b)
@@ -750,7 +752,6 @@
                            (lambda()
                              (if (file-exists-p path-remote)
                                  (progn
-                                   (require 'ediff-util)
                                    (if (fboundp 'ediff-same-file-contents)
                                        (if (ediff-same-file-contents 
revision-path path-remote)
                                            (list 0 (format "Remote file '%s' 
has not changed. (asynchronously)" path-remote) path-local)
@@ -779,7 +780,6 @@
                       ;; Does remote file exist?
                       (if (file-exists-p path-remote)
                           (progn
-                            (require 'ediff-util)
                             (if (fboundp 'ediff-same-file-contents)
                                 (if (ediff-same-file-contents revision-path 
path-remote)
                                     (when (> ssh-deploy-verbose 0) (message 
"Remote file '%s' has not changed. (synchronously)" path-remote))
@@ -804,7 +804,6 @@
                            ;; Does remote file exist?
                            (if (file-exists-p path-remote)
                                (progn
-                                 (require 'ediff-util)
                                  (if (fboundp 'ediff-same-file-contents)
                                      (if (ediff-same-file-contents path-local 
path-remote)
                                          (progn
@@ -831,7 +830,6 @@
                     ;; Does remote file exist?
                     (if (file-exists-p path-remote)
                         (progn
-                          (require 'ediff-util)
                           (if (fboundp 'ediff-same-file-contents)
                               (if (ediff-same-file-contents path-local 
path-remote)
                                   (progn
@@ -989,7 +987,6 @@
     (when (and (ssh-deploy--file-is-in-path-p path-local root-local)
                (ssh-deploy--file-is-included-p path-local exclude-list))
       (let ((path-remote (expand-file-name (ssh-deploy--get-relative-path 
root-local path-local) root-remote)))
-        (require 'eshell)
         (message "Opening eshell on '%s'.." path-remote)
         (let ((default-directory path-remote))
           (defvar eshell-buffer-name)
@@ -1005,7 +1002,6 @@
     (when (and (ssh-deploy--file-is-in-path-p path-local root-local)
                (ssh-deploy--file-is-included-p path-local exclude-list))
       (let ((path-remote (expand-file-name (ssh-deploy--get-relative-path 
root-local path-local) root-remote)))
-        (require 'shell)
         (message "Opening eshell on '%s'.." path-remote)
         (let ((default-directory path-remote)
               (explicit-shell-file-name ssh-deploy-remote-shell-executable))



reply via email to

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