[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ssh-deploy 454af97 070/173: Added delete function for f
From: |
Stefan Monnier |
Subject: |
[elpa] externals/ssh-deploy 454af97 070/173: Added delete function for files and directories |
Date: |
Sat, 20 Oct 2018 10:36:32 -0400 (EDT) |
branch: externals/ssh-deploy
commit 454af9753768a94b9b494a7a56e2ee391a0eae5a
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
Added delete function for files and directories
---
README.md | 4 +++-
ssh-deploy.el | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++--------
2 files changed, 67 insertions(+), 10 deletions(-)
diff --git a/README.md b/README.md
index 0f8801d..f9a6b43 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.
@@ -50,6 +50,7 @@ Set your user and group as owner and file permissions to
`700`. Emacs should now
(add-hook 'find-file-hook (lambda() (if
ssh-deploy-automatically-detect-remote-changes
(ssh-deploy-remote-changes-handler)) ))
(global-set-key (kbd "C-c C-z f") (lambda()
(interactive)(ssh-deploy-upload-handler-forced) ))
(global-set-key (kbd "C-c C-z u") (lambda()
(interactive)(ssh-deploy-upload-handler) ))
+ (global-set-key (kbd "C-c C-z D") (lambda()
(interactive)(ssh-deploy-delete-handler) ))
(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) ))
@@ -67,6 +68,7 @@ You can remove the `add-to-list` line if you installed via
`MELPA` repository.
* 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.
+* If you press `C-c C-z D` you will delete the current file or directory after
a confirmation on local and 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`.
* If you press `C-c C-z r` you will rename current file or directory.
diff --git a/ssh-deploy.el b/ssh-deploy.el
index 838a657..8b7fdbf 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: 6 May 2017
-;; Version: 1.53
+;; Modified: 15 May 2017
+;; Version: 1.54
;; Keywords: tools, convenience
;; URL: https://github.com/cjohansson/emacs-ssh-deploy
@@ -30,7 +30,8 @@
;;; Commentary:
;; `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.
+;; deleting, 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'
@@ -52,6 +53,7 @@
;; - To set key-bindings do something like this:
;; (global-set-key (kbd "C-c C-z f") (lambda()
(interactive)(ssh-deploy-upload-handler-forced) ))
;; (global-set-key (kbd "C-c C-z u") (lambda()
(interactive)(ssh-deploy-upload-handler) ))
+;; (global-set-key (kbd "C-c C-z D") (lambda()
(interactive)(ssh-deploy-delete-handler) ))
;; (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) ))
@@ -174,6 +176,39 @@
(and (not (null string))
(not (zerop (length string)))))
+(defun ssh-deploy--delete (local-path local-root remote-root async debug)
+ "Delete LOCAL-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 local-path local-root)
+ (ssh-deploy--file-is-included local-path))
+ (progn
+ (let ((file-or-directory (file-regular-p local-path)))
+ (let ((remote-path (concat remote-root
(ssh-deploy--get-relative-path local-root local-path))))
+ (if (file-regular-p local-path)
+ (progn
+ (delete-file local-path t)
+ (message "Deleted file '%s'" local-path))
+ (progn
+ (delete-directory local-path t t)
+ (message "Deleted directory '%s'" local-path)))
+ (kill-this-buffer)
+ (if (and async (fboundp 'async-start))
+ (progn
+ (async-start
+ `(lambda()
+ (if (file-regular-p ,remote-path)
+ (delete-file ,remote-path t)
+ (delete-directory ,remote-path t t))
+ (list ,remote-path))
+ (lambda(files)
+ (message "Asynchronously deleted '%s'." (nth 0 files)))))
+ (progn
+ (if (file-regular-p remote-path)
+ (delete-file remote-path t)
+ (delete-directory remote-path t t))
+ (message "Synchronously deleted '%s'." remote-path))))))
+ (if debug
+ (message "Path '%s' is not in the root '%s' or is excluded from it."
local-path local-root))))
+
(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)
@@ -526,6 +561,26 @@
(ssh-deploy-diff local-root ssh-deploy-root-remote local-path
ssh-deploy-debug))))))
;;;### autoload
+(defun ssh-deploy-delete-handler ()
+ "Delete 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* ((local-path (file-truename buffer-file-name))
+ (local-root (file-truename ssh-deploy-root-local))
+ (yes-no-prompt (read-string (format "Type 'yes' to confirm
that you want to delete the file '%s': " local-path))))
+ (if (string= yes-no-prompt "yes")
+ (ssh-deploy--delete 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* ((local-path (file-truename default-directory))
+ (local-root (file-truename ssh-deploy-root-local))
+ (yes-no-prompt (read-string (format "Type 'yes' to confirm
that you want to delete the directory '%s': " local-path))))
+ (if (string= yes-no-prompt "yes")
+ (ssh-deploy--delete local-path local-root
ssh-deploy-root-remote ssh-deploy-async 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)
@@ -536,18 +591,18 @@
(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))
+ (new-local-path (file-truename new-local-path-tmp)))
+ (if (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))))))
+ (new-local-path (file-truename new-local-path-tmp)))
+ (if (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 ()
- [elpa] externals/ssh-deploy 5e0403c 085/173: Instructions for FTP in macOS 10.13, (continued)
- [elpa] externals/ssh-deploy 5e0403c 085/173: Instructions for FTP in macOS 10.13, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 0d8b5de 095/173: Only open directory diff buffer if there was any differences, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 407402d 100/173: Improved documentation about interaction-free password-based authentication, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy d0b45f4 106/173: Fixed typos in readme, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 6f54fd5 110/173: Fixed bug where upload file into folder that does not exist on remote, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 9d6d8a4 136/173: Improved comments, trying to trigger MELPA refresh, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy a724653 077/173: Added support for launching remote eshell, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 2226edb 088/173: Merge branch 'master' of https://github.com/cjohansson/emacs-ssh-deploy, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 72a5033 081/173: Moved safe variables declaration to plugin, made handler functions, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy d5315bf 080/173: Fix syntax notices and now restores eshell buffer name, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 454af97 070/173: Added delete function for files and directories,
Stefan Monnier <=
- [elpa] externals/ssh-deploy 5cd1f80 092/173: Improved code for detecting remote changes, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy e56b316 113/173: Fixed syntax error in (cond) expression, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 5442a7e 104/173: Removed dependency package, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 99727db 125/173: Updated completed deletion messages for more salience, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy c193330 107/173: Optimized (progn) structures, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 8d99eb6 130/173: Updated version, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy cf4f5e7 133/173: Added delete shortcut to menu-bar as well, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 36b81ff 111/173: Fixed bug where async upload to new remote directory was not working, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy c58f524 141/173: Using (with-current-buffer) instead of (switch-to-buffer), Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 42d4d7a 150/173: Merge branch 'master' of https://github.com/cjohansson/emacs-ssh-deploy, Stefan Monnier, 2018/10/20