branch: externals/ssh-deploy commit 828aca3ad1393cf529790fe5946a2dddb2383428 Author: Christian Johansson <christ...@cvj.se> Commit: Christian Johansson <christ...@cvj.se>
Local path and local root is now evaluated based on their truenames. --- README.md | 9 ++++----- ssh-deploy.el | 32 +++++++++++++++++++++++--------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index fe13e4e..2dcab9d 100644 --- a/README.md +++ b/README.md @@ -39,16 +39,15 @@ This application is made by Christian Johansson <christ...@cvj.se> 2016 and is l You can remove the `add-to-list` line if you installed via `MELPA` repository. * 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 using `tramp`, or if current buffer is a directory it will show differences with remote directory using `ztree-diff` using `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 differences with remote directory using `ztree-diff` via `tramp`. * 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. -* If you press `C-c C-z t` you will open a terminal with remote host. +* If you press `C-c C-z t` you will open a terminal with remote host via `tramp-term`. * If you press `C-c C-z b` you will browse current directory on remote host in `dired-mode`. -The above configuration uses the plugin `use-package` which I highly recommend. +The local path and local root is evaluated based on it's *truename* so if you use different symbolic local paths it shouldn't affect the deployment procedure. -## TODO -* Add notification for remote changes of files +The above configuration uses the plugin `use-package` which I highly recommend. ## Read more * <https://www.emacswiki.org/emacs/DirectoryVariables> diff --git a/ssh-deploy.el b/ssh-deploy.el index 64b06bc..783be76 100644 --- a/ssh-deploy.el +++ b/ssh-deploy.el @@ -89,8 +89,8 @@ (defun ssh-deploy-remote-terminal (remote-host) "Opens REMOTE-HOST in tramp terminal." (if (and (fboundp 'tramp-term) - (fboundp 'tramp-term--initialize) - (fboundp 'tramp-term--do-ssh-login)) + (fboundp 'tramp-term--initialize) + (fboundp 'tramp-term--do-ssh-login)) (progn (let ((hostname (replace-regexp-in-string ":.*$" "" remote-host))) (let ((host (split-string hostname "@"))) @@ -183,27 +183,39 @@ "Upload current path to remote host if it is configured for SSH deployment." (if (and (ssh-deploy-is-not-empty-string ssh-deploy-root-local) (ssh-deploy-is-not-empty-string ssh-deploy-root-remote)) (if (ssh-deploy-is-not-empty-string buffer-file-name) - (ssh-deploy ssh-deploy-root-local ssh-deploy-root-remote t 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)) (if (ssh-deploy-is-not-empty-string default-directory) - (ssh-deploy ssh-deploy-root-local ssh-deploy-root-remote t (expand-file-name 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)))))) ;;;### autoload (defun ssh-deploy-download-handler () "Download current path from remote host if it is configured for SSH deployment." (if (and (ssh-deploy-is-not-empty-string ssh-deploy-root-local) (ssh-deploy-is-not-empty-string ssh-deploy-root-remote)) (if (ssh-deploy-is-not-empty-string buffer-file-name) - (ssh-deploy ssh-deploy-root-local ssh-deploy-root-remote nil 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)) (if (ssh-deploy-is-not-empty-string default-directory) - (ssh-deploy ssh-deploy-root-local ssh-deploy-root-remote nil (expand-file-name 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)))))) ;;;### autoload (defun ssh-deploy-diff-handler () "Compare current path with remote host if it is configured for SSH deployment." (if (and (ssh-deploy-is-not-empty-string ssh-deploy-root-local) (ssh-deploy-is-not-empty-string ssh-deploy-root-remote)) (if (ssh-deploy-is-not-empty-string buffer-file-name) - (ssh-deploy-diff ssh-deploy-root-local ssh-deploy-root-remote 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)) (if (ssh-deploy-is-not-empty-string default-directory) - (ssh-deploy-diff ssh-deploy-root-local ssh-deploy-root-remote (expand-file-name 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)))))) ;;;### autoload (defun ssh-deploy-remote-terminal-handler () @@ -215,7 +227,9 @@ (defun ssh-deploy-browse-remote-handler () "Open current relative path on remote host in `dired-mode' if it is configured for SSH deployment." (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)) - (ssh-deploy-browse-remote ssh-deploy-root-local ssh-deploy-root-remote 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)))) (provide 'ssh-deploy) ;;; ssh-deploy.el ends here