[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ssh-deploy 1af0208 045/173: Cleaned up code structure a
From: |
Stefan Monnier |
Subject: |
[elpa] externals/ssh-deploy 1af0208 045/173: Cleaned up code structure and isolated functions |
Date: |
Sat, 20 Oct 2018 10:36:28 -0400 (EDT) |
branch: externals/ssh-deploy
commit 1af02081443f389f90ccf9c2aabeb6816a5868f2
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
Cleaned up code structure and isolated functions
---
ssh-deploy.el | 72 ++++++++++++++++++++++++++---------------------------------
1 file changed, 32 insertions(+), 40 deletions(-)
diff --git a/ssh-deploy.el b/ssh-deploy.el
index 7d44d33..2421662 100644
--- a/ssh-deploy.el
+++ b/ssh-deploy.el
@@ -3,8 +3,8 @@
;; Author: Christian Johansson <github.com/cjohansson>
;; Maintainer: Christian Johansson <github.com/cjohansson>
;; Created: 5 Jul 2016
-;; Modified: 18 Nov 2016
-;; Version: 1.40
+;; Modified: 20 Nov 2016
+;; Version: 1.41
;; Keywords: tools, convenience
;; URL: https://github.com/cjohansson/emacs-ssh-deploy
@@ -103,16 +103,18 @@
:type 'boolean
:group 'ssh-deploy)
-(defun ssh-deploy--browse-remote (local-root remote-root-string path)
+;;;### autoload
+(defun ssh-deploy-browse-remote (local-root remote-root-string path)
"Browse relative to LOCAL-ROOT on REMOTE-ROOT-STRING the path PATH in
`dired-mode`."
(if (ssh-deploy--file-is-in-path path local-root)
(let ((remote-path (concat remote-root-string
(ssh-deploy--get-relative-path local-root path))))
(let ((remote-root (ssh-deploy--parse-remote remote-path)))
(let ((command (concat "/" (alist-get 'protocol remote-root) ":"
(alist-get 'username remote-root) "@" (alist-get 'server remote-root) ":"
(alist-get 'path remote-root))))
(message "Opening '%s' for browsing on remote host.." command)
- (dired command))))))
+ (dired command))))))
-(defun ssh-deploy--remote-terminal (remote-host-string)
+;;;### autoload
+(defun ssh-deploy-remote-terminal (remote-host-string)
"Opens REMOTE-HOST-STRING in terminal."
(let ((remote-root (ssh-deploy--parse-remote remote-host-string)))
(if (string= (alist-get 'protocol remote-root) "ssh")
@@ -128,8 +130,7 @@
(run-hook-with-args 'tramp-term-after-initialized-hook
hostname)
(message "tramp-term initialized")))))
(message "tramp-term is not installed."))
- (if (string= (alist-get 'protocol remote-root) "ftp")
- (ssh-deploy-browse-remote-handler)))))
+ (message "Remote terminal is only available for ssh protocol"))))
(defun ssh-deploy--remote-terminal-ssh (remote-root)
"Opens REMOTE-ROOT in tramp terminal."
@@ -154,8 +155,9 @@
"Return a string for the relative path based on ROOT and PATH."
(replace-regexp-in-string root "" path))
-(defun ssh-deploy--diff (local-root remote-root-string path)
- "Find differences relative to the roots LOCAL-ROOT with REMOTE-ROOT-STRING
via ssh and the path PATH."
+;;;### autoload
+(defun ssh-deploy-diff (local-root remote-root-string path &optional debug)
+ "Find differences relative to the roots LOCAL-ROOT with REMOTE-ROOT-STRING
via ssh and the path PATH, DEBUG enables feedback message."
(let ((file-or-directory (file-regular-p path)))
(if (ssh-deploy--file-is-in-path path local-root)
(progn
@@ -173,7 +175,7 @@
(ztree-diff path command))
(message "ztree-diff is not installed.")
)))))))
- (if ssh-deploy-debug
+ (if debug
(message "Path '%s' is not in the root '%s'" path local-root)))))
(defun ssh-deploy--parse-remote (string)
@@ -202,20 +204,9 @@
(and (not (null string))
(not (zerop (length string)))))
-(defun ssh-deploy--run-shell-command (command)
- "Run COMMAND in asynchronous mode."
- (message "Shell command: '%s'" command)
- (let ((proc (start-process-shell-command "process" nil command)))
- (set-process-filter proc (lambda(proc output)(message "%s"
(replace-regexp-in-string "\^M" "\n" output))))
- (set-process-sentinel proc (lambda(proc output)
- (if (string= (symbol-name (process-status
proc)) "exit")
- (if (= (process-exit-status proc) 0)
- (message "Successfully ran shell
command.")
- (message "Failed to run shell
command.")))))))
-
-(defun ssh-deploy--download (remote local local-root)
- "Download REMOTE to LOCAL with the LOCAL-ROOT via tramp."
- (if (and ssh-deploy-async (fboundp 'async-start))
+(defun ssh-deploy--download (remote local local-root async)
+ "Download REMOTE to LOCAL with the LOCAL-ROOT via tramp, ASYNC determines if
transfer should be asynchrous or not."
+ (if (and async (fboundp 'async-start))
(ssh-deploy--download-via-tramp-async remote local local-root)
(ssh-deploy--download-via-tramp remote local local-root)))
@@ -297,23 +288,24 @@
(copy-directory remote-path (file-name-directory (directory-file-name
local)) t t)
(message "Download '%s' finished" local)))))
-(defun ssh-deploy--upload (local remote local-root)
- "Upload LOCAL to REMOTE and LOCAL-ROOT via tramp."
- (if (and ssh-deploy-async (fboundp 'async-start))
+(defun ssh-deploy--upload (local remote local-root async)
+ "Upload LOCAL to REMOTE and LOCAL-ROOT via tramp, ASYNC determines if
transfer should be asynchrous ot not."
+ (if (and async (fboundp 'async-start))
(ssh-deploy--upload-via-tramp-async local remote local-root)
(ssh-deploy--upload-via-tramp local remote local-root)))
-(defun ssh-deploy (local-root remote-root upload-or-download path)
- "Upload/Download file or directory relative to the roots LOCAL-ROOT with
REMOTE-ROOT via ssh or ftp according to UPLOAD-OR-DOWNLOAD and the path PATH."
+;;;### autoload
+(defun ssh-deploy (local-root remote-root upload-or-download path debug async)
+ "Upload/Download file or directory relative to the roots LOCAL-ROOT with
REMOTE-ROOT via ssh or ftp according to UPLOAD-OR-DOWNLOAD and the path PATH,
DEBUG enables some feedback messages and ASYNC determines if transfers should
be asynchrous or not."
(if (ssh-deploy--file-is-in-path path local-root)
(progn
(let ((file-or-directory (file-regular-p path)))
(let ((remote-path (concat remote-root
(ssh-deploy--get-relative-path local-root path))))
(let ((connection (ssh-deploy--parse-remote remote-path)))
(if (not (null upload-or-download))
- (ssh-deploy--upload path connection local-root)
- (ssh-deploy--download connection path local-root))))))
- (if ssh-deploy-debug
+ (ssh-deploy--upload path connection local-root async)
+ (ssh-deploy--download connection path local-root async))))))
+ (if debug
(message "Path '%s' is not in the root '%s'" path local-root))))
;;;### autoload
@@ -323,11 +315,11 @@
(if (ssh-deploy--is-not-empty-string buffer-file-name)
(let ((local-path (file-truename buffer-file-name))
(local-root (file-truename ssh-deploy-root-local)))
- (ssh-deploy local-root ssh-deploy-root-remote t local-path))
+ (ssh-deploy local-root ssh-deploy-root-remote t local-path
ssh-deploy-debug ssh-deploy-async))
(if (ssh-deploy--is-not-empty-string default-directory)
(let ((local-path (file-truename default-directory))
(local-root (file-truename ssh-deploy-root-local)))
- (ssh-deploy local-root ssh-deploy-root-remote t local-path))))))
+ (ssh-deploy local-root ssh-deploy-root-remote t local-path
ssh-deploy-debug ssh-deploy-async))))))
;;;### autoload
(defun ssh-deploy-download-handler ()
@@ -336,11 +328,11 @@
(if (ssh-deploy--is-not-empty-string buffer-file-name)
(let ((local-path (file-truename buffer-file-name))
(local-root (file-truename ssh-deploy-root-local)))
- (ssh-deploy local-root ssh-deploy-root-remote nil local-path))
+ (ssh-deploy local-root ssh-deploy-root-remote nil local-path
ssh-deploy-debug ssh-deploy-async))
(if (ssh-deploy--is-not-empty-string default-directory)
(let ((local-path (file-truename default-directory))
(local-root (file-truename ssh-deploy-root-local)))
- (ssh-deploy local-root ssh-deploy-root-remote nil
local-path))))))
+ (ssh-deploy local-root ssh-deploy-root-remote nil local-path
ssh-deploy-debug ssh-deploy-async))))))
;;;### autoload
(defun ssh-deploy-diff-handler ()
@@ -349,17 +341,17 @@
(if (ssh-deploy--is-not-empty-string buffer-file-name)
(let ((local-path (file-truename buffer-file-name))
(local-root (file-truename ssh-deploy-root-local)))
- (ssh-deploy--diff local-root ssh-deploy-root-remote local-path))
+ (ssh-deploy-diff local-root ssh-deploy-root-remote local-path
ssh-deploy-debug))
(if (ssh-deploy--is-not-empty-string default-directory)
(let ((local-path (file-truename default-directory))
(local-root (file-truename ssh-deploy-root-local)))
- (ssh-deploy--diff local-root ssh-deploy-root-remote
local-path))))))
+ (ssh-deploy-diff local-root ssh-deploy-root-remote local-path
ssh-deploy-debug))))))
;;;### autoload
(defun ssh-deploy-remote-terminal-handler ()
"Open remote host in tramp terminal it is configured for SSH deployment."
(if (ssh-deploy--is-not-empty-string ssh-deploy-root-remote)
- (ssh-deploy--remote-terminal ssh-deploy-root-remote)))
+ (ssh-deploy-remote-terminal ssh-deploy-root-remote)))
;;;### autoload
(defun ssh-deploy-browse-remote-handler ()
@@ -367,7 +359,7 @@
(if (and (ssh-deploy--is-not-empty-string ssh-deploy-root-local)
(ssh-deploy--is-not-empty-string ssh-deploy-root-remote)
(ssh-deploy--is-not-empty-string default-directory))
(let ((local-path (file-truename default-directory))
(local-root (file-truename ssh-deploy-root-local)))
- (ssh-deploy--browse-remote local-root ssh-deploy-root-remote
local-path))))
+ (ssh-deploy-browse-remote local-root ssh-deploy-root-remote
local-path))))
(provide 'ssh-deploy)
;;; ssh-deploy.el ends here
- [elpa] externals/ssh-deploy 89fb82a 038/173: Fixed bug when downloading via SSH to a local path containing whitespaces, (continued)
- [elpa] externals/ssh-deploy 89fb82a 038/173: Fixed bug when downloading via SSH to a local path containing whitespaces, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 965c68f 028/173: Centralized asynchronous shell commands., Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy e6e1ad8 039/173: Updated version and modified date, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 2257f95 029/173: Fixed upload and downloads of root directories where local root directory name differs from remote root directory name., Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 560ff1d 037/173: Added TRAMP functions and improved messages., Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy a86091c 032/173: Broken down diff function into multiple functions to easily add new protocols., Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 1e58dc3 040/173: SSH deployment now works via TRAMP instead of SCP, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 4a2f947 053/173: Fixed bug where missing remote file used wrong logic, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 61a16be 047/173: Merged remote, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy d599659 015/173: Added support for opening remote terminals, uploads/downloads/differences of directories, browsing remote hosts and fixed a bug where paths with special chars were not handled correctly., Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 1af0208 045/173: Cleaned up code structure and isolated functions,
Stefan Monnier <=
- [elpa] externals/ssh-deploy 740c27d 054/173: Fixed message when no base revision exists and remote file equals local file, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy ac7aff8 052/173: Asynchronous detection of remote changes doesn't use any synchronous action, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy d4953c7 049/173: Fixed upload/download of root directory with different names, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 2d2c380 033/173: Implemented FTP via cURL but haven't tested it yet., Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy f36ffce 059/173: Added MELPA Stable link, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 29cf0b2 061/173: Added force handler in documentation, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 3ea14de 062/173: Improved README for forced uploads, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy a1ea2c2 025/173: Improved description of complex connections, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 828aca3 022/173: Local path and local root is now evaluated based on their truenames., Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy d40d817 027/173: Now displaying asynchrous process output., Stefan Monnier, 2018/10/20