[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ssh-deploy bf86728 068/173: Added deploy command
From: |
Stefan Monnier |
Subject: |
[elpa] externals/ssh-deploy bf86728 068/173: Added deploy command |
Date: |
Sat, 20 Oct 2018 10:36:32 -0400 (EDT) |
branch: externals/ssh-deploy
commit bf867283a80590ccf210aec2dfdfaba098207401
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
Added deploy command
---
README.md | 5 ++--
ssh-deploy.el | 77 +++++++++++++++++++++++++++++++++++++++++++++++++----------
2 files changed, 67 insertions(+), 15 deletions(-)
diff --git a/README.md b/README.md
index eb56149..0c304fa 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# `emacs-ssh-deploy`
[![MELPA](http://melpa.org/packages/ssh-deploy-badge.svg)](http://melpa.org/#/ssh-deploy)
[![MELPA
Stable](http://stable.melpa.org/packages/ssh-deploy-badge.svg)](http://stable.melpa.org/#/ssh-deploy)
-The `ssh-deploy` plug-in for Emacs makes it possible to effortlessly deploy
local files and directories to remote hosts via SSH and FTP. It also makes it
possible to define remote paths per directory and whether or not you want to
deploy on explicit save actions or not and whether you want transfers to be
asynchronous or not. For asynchronous transfers you need a setup which doesn't
require a interactive authorization. The plug-in also enables manual upload and
download of files and dire [...]
+The `ssh-deploy` plug-in for Emacs makes it possible to effortlessly deploy
local files and directories to remote hosts via SSH and FTP. It also makes it
possible to define remote paths per directory and whether or not you want to
deploy on explicit save actions or not and whether you want transfers to be
asynchronous or not. For asynchronous transfers you need a setup which doesn't
require a interactive authorization. The plug-in also enables manual upload and
download of files and dire [...]
`ssh-deploy` works with `DirectoryVariables` so you can have different deploy
setups in different ways for different folders.
@@ -62,7 +62,7 @@ You can remove the `add-to-list` line if you installed via
`MELPA` repository.
* Restart Emacs
* Now when you save a file somewhere under the directory
`/Users/username/Web/MySite/`, the script will launch and deploy the file with
the remote server.
-* If you press `C-c C-z x` and the current buffer is a file, you will launch a
`ediff` session showing differences between local file and remote file via
`tramp`, or if current buffer is a directory it will show differences with
remote directory using `ztree-diff` via `tramp`.
+* If you press `C-c C-z x` and the current buffer is a file, you will launch a
`ediff` session showing differences between local file and remote file via
`tramp`, or if current buffer is a directory it will show a error that
directories are not yet supported for differences.
* If you press `C-c C-z f` you will **force** upload local file or directory
to remote host even if they have external changes.
* If you press `C-c C-z u` you will upload local file or directory to remote
host.
* If you press `C-c C-z d` you will download the current file or directory
from remote host and then reload current buffer.
@@ -91,6 +91,5 @@ Host remote-host
* <https://github.com/jwiegley/use-package>
* <https://www.emacswiki.org/emacs/EdiffMode>
* <http://melpa.org/>
-* <https://github.com/fourier/ztree>
* <https://github.com/randymorris/tramp-term.el>
* <https://github.com/jwiegley/emacs-async>
diff --git a/ssh-deploy.el b/ssh-deploy.el
index 7634e9f..838a657 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: 5 May 2017
-;; Version: 1.52
+;; Modified: 6 May 2017
+;; Version: 1.53
;; Keywords: tools, convenience
;; URL: https://github.com/cjohansson/emacs-ssh-deploy
@@ -29,12 +29,12 @@
;;; Commentary:
-;; `ssh-deploy' enables automatic deploys on explicit-save, manual uploads,
-;; downloads, differences, remote terminals, detection of remote changes and
remote directory browsing via TRAMP.
-;; To do this it progressively uses `tramp', `tramp-term', `ediff', `async`
and `ztree'.
+;; `ssh-deploy' enables automatic deploys on explicit-save, manual uploads,
renaming,
+;; downloads, file differences, remote terminals, detection of remote changes
and remote directory browsing via TRAMP.
+;; To do this it progressively uses `tramp', `tramp-term', `ediff' and `async'.
;; By setting the variables (globally or per directory):
;; `ssh-deploy-root-local',`ssh-deploy-root-remote',
`ssh-deploy-on-explicit-save'
-;; you can setup a directory for SSH or FTP deployment.
+;; you can setup a directory for `SSH' or `FTP' deployment.
;;
;; For asynchronous transfers you need to setup `~/.netrc' or equivalent for
automatic authentication.
;;
@@ -55,7 +55,8 @@
;; (global-set-key (kbd "C-c C-z d") (lambda()
(interactive)(ssh-deploy-download-handler) ))
;; (global-set-key (kbd "C-c C-z x") (lambda()
(interactive)(ssh-deploy-diff-handler) ))
;; (global-set-key (kbd "C-c C-z t") (lambda()
(interactive)(ssh-deploy-remote-terminal-handler) ))
-;; (global-set-key (kbd "C-c C-z r") (lambda()
(interactive)(ssh-deploy-remote-changes-handler) ))
+;; (global-set-key (kbd "C-c C-z r") (lambda()
(interactive)(ssh-deploy-rename-handler) ))
+;; (global-set-key (kbd "C-c C-z e") (lambda()
(interactive)(ssh-deploy-remote-changes-handler) ))
;; (global-set-key (kbd "C-c C-z b") (lambda()
(interactive)(ssh-deploy-browse-remote-handler) ))
;;
;; An illustrative example for `SSH' deployment,
/Users/Chris/Web/Site1/.dir.locals.el
@@ -173,6 +174,38 @@
(and (not (null string))
(not (zerop (length string)))))
+(defun ssh-deploy--rename (old-path new-path local-root remote-root async
debug)
+ "Rename OLD-PATH to NEW-PATH relative to LOCAL-ROOT as well as on
REMOTE-ROOT, do it asynchronously if ASYNC is non-nil, debug if DEBUG is
non-nil."
+ (if (and (ssh-deploy--file-is-in-path old-path local-root)
+ (ssh-deploy--file-is-in-path new-path local-root)
+ (ssh-deploy--file-is-included old-path)
+ (ssh-deploy--file-is-included new-path))
+ (progn
+ (let ((file-or-directory (file-regular-p old-path)))
+ (let ((old-remote-path (concat remote-root
(ssh-deploy--get-relative-path local-root old-path)))
+ (new-remote-path (concat remote-root
(ssh-deploy--get-relative-path local-root new-path))))
+ (rename-file old-path new-path t)
+ (if (file-regular-p new-path)
+ (progn
+ (rename-buffer new-path)
+ (set-buffer-modified-p nil)
+ (set-visited-file-name new-path))
+ (dired new-path))
+ (message "Renamed '%s' -> '%s'." old-path new-path)
+ (if (and async (fboundp 'async-start))
+ (progn
+ (async-start
+ `(lambda()
+ (rename-file ,old-remote-path ,new-remote-path t)
+ (list ,old-remote-path ,new-remote-path))
+ (lambda(files)
+ (message "Asynchronously renamed '%s' -> '%s'." (nth 0
files) (nth 1 files)))))
+ (progn
+ (rename-file old-remote-path new-remote-path t)
+ (message "Synchronously renamed '%s' -> '%s'." old-remote-path
new-remote-path))))))
+ (if debug
+ (message "Path '%s' or '%s' is not in the root '%s' or is excluded
from it." old-path new-path local-root))))
+
(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))
@@ -493,6 +526,30 @@
(ssh-deploy-diff local-root ssh-deploy-root-remote local-path
ssh-deploy-debug))))))
;;;### autoload
+(defun ssh-deploy-rename-handler ()
+ "Rename current file or directory."
+ (if (and (ssh-deploy--is-not-empty-string ssh-deploy-root-local)
+ (ssh-deploy--is-not-empty-string ssh-deploy-root-remote))
+ (if (and (ssh-deploy--is-not-empty-string buffer-file-name)
+ (file-exists-p buffer-file-name))
+ (let* ((old-local-path (file-truename buffer-file-name))
+ (local-root (file-truename ssh-deploy-root-local))
+ (basename (file-name-nondirectory old-local-path))
+ (new-local-path-tmp (read-file-name "New file name:"
(file-name-directory old-local-path) basename nil basename))
+ (new-local-path (file-truename new-local-path-tmp))
+ (not (string= old-local-path new-local-path)))
+ (ssh-deploy--rename old-local-path new-local-path local-root
ssh-deploy-root-remote ssh-deploy-async ssh-deploy-debug))
+ (if (and (ssh-deploy--is-not-empty-string default-directory)
+ (file-exists-p default-directory))
+ (let* ((old-local-path (file-truename default-directory))
+ (local-root (file-truename ssh-deploy-root-local))
+ (basename (file-name-nondirectory old-local-path))
+ (new-local-path-tmp (read-file-name "New directory name:"
(file-name-directory old-local-path) basename nil basename))
+ (new-local-path (file-truename new-local-path-tmp))
+ (not (string= old-local-path new-local-path)))
+ (ssh-deploy--rename old-local-path new-local-path local-root
ssh-deploy-root-remote ssh-deploy-async ssh-deploy-debug))))))
+
+;;;### autoload
(defun ssh-deploy-remote-terminal-handler ()
"Open remote host in tramp terminal it is configured for deployment."
(if (ssh-deploy--is-not-empty-string ssh-deploy-root-remote)
@@ -529,11 +586,7 @@
(ediff path command)))
(message "Function ediff-same-file-contents is
missing.")))
(progn
- (if (fboundp 'ztree-diff)
- (progn
- (message "Comparing directory '%s' to '%s'.." path
command)
- (ztree-diff path command))
- (message "ztree-diff is not installed."))))))))
+ (message "Unfortunately directory differences are not yet
implemented.")))))))
(if debug
(message "Path '%s' is not in the root '%s' or is excluded from it."
path local-root)))))
- [elpa] externals/ssh-deploy 4fbe568 084/173: Updated hydra example to prevent lazy loading of package, (continued)
- [elpa] externals/ssh-deploy 4fbe568 084/173: Updated hydra example to prevent lazy loading of package, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 4c35ab7 055/173: Fixed syntax bug in MELPA description, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy d324b9f 046/173: Cleaned up code structure and isolated functions, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 404aa7e 042/173: Transfers now use TRAMP asynchrously, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy c04badf 048/173: Moved autoloading functions last, changed parameters for copy functions, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 3569e5e 058/173: More grammatical fixes for README.md, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 4005d0e 001/173: My initial commit, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 1c1e379 063/173: More improvement on README for force uploads, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 1f0bdf6 071/173: Create directories on remote When uploading files in a folder that, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy b1f9e5b 050/173: Now detects remote changes, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy bf86728 068/173: Added deploy command,
Stefan Monnier <=
- [elpa] externals/ssh-deploy dbd8608 076/173: Improved documentation, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 2eab0ee 091/173: Fixed bug for eshell in base directory, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy c02b0c9 094/173: Removed debug code from directory-diff function, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 68804ee 097/173: Updated use-package README example, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy d2c204f 101/173: Fixed syntax error in example configuration, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 4f77b6c 118/173: Silenced code notices and fixes syntax for (display-warning), Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy a3f9ec5 120/173: Now possible to define remote SQL port numbers, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 4c1a539 064/173: Added customizable exclusion patterns, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy f9a2785 086/173: Removed tramp-term functionality, supports native TRAMP strings, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy c64013a 099/173: Made directory variables permanent, Stefan Monnier, 2018/10/20