[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ssh-deploy 947a3c7 024/133: Improved usability with pre
From: |
Stefan Monnier |
Subject: |
[elpa] externals/ssh-deploy 947a3c7 024/133: Improved usability with pre-defined hooks |
Date: |
Sat, 27 Mar 2021 14:48:36 -0400 (EDT) |
branch: externals/ssh-deploy
commit 947a3c7f51d2fd8aa27c9433252c372c269deecf
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Improved usability with pre-defined hooks
---
README.md | 11 +++++++----
ssh-deploy.el | 57 ++++++++++++++++++++++++++++++++++-----------------------
2 files changed, 41 insertions(+), 27 deletions(-)
diff --git a/README.md b/README.md
index c7f04f3..69853a4 100644
--- a/README.md
+++ b/README.md
@@ -153,9 +153,11 @@ By combining a `~/.authinfo.gpg` setup and a `public-key`
setup you should be ab
;; ssh-deploy - prefix = C-c C-z, f = forced upload, u = upload, d = download,
x = diff, t = terminal, b = browse, h = shell
(add-to-list 'load-path "~/.emacs.d/ssh-deploy/")
(require 'ssh-deploy)
+
(ssh-deploy-line-mode) ;; If you want mode-line feature
-(add-hook 'after-save-hook (lambda() (if (and (boundp
'ssh-deploy-on-explicit-save) (> ssh-deploy-on-explicit-save 0))
(ssh-deploy-upload-handler)) ))
-(add-hook 'find-file-hook (lambda() (if (and (boundp
'ssh-deploy-automatically-detect-remote-changes) (>
ssh-deploy-automatically-detect-remote-changes 0))
(ssh-deploy-remote-changes-handler)) ))
+(ssh-deploy-add-after-save-hook) ;; If you want automatic upload support
+(ssh-deploy-add-find-file-hook) ;; If you want detecting remote changes support
+
(global-set-key (kbd "C-c C-z f") 'ssh-deploy-upload-handler-forced)
(global-set-key (kbd "C-c C-z u") 'ssh-deploy-upload-handler)
(global-set-key (kbd "C-c C-z D") 'ssh-deploy-delete-handler)
@@ -180,10 +182,11 @@ By combining a `~/.authinfo.gpg` setup and a `public-key`
setup you should be ab
:ensure t
:demand
:bind (("C-c C-z" . hydra-ssh-deploy/body))
- :hook ((after-save . (lambda() (if (and (boundp
'ssh-deploy-on-explicit-save) (> ssh-deploy-on-explicit-save 0))
(ssh-deploy-upload-handler)) ))
- (find-file . (lambda() (if (and (boundp
'ssh-deploy-automatically-detect-remote-changes) (>
ssh-deploy-automatically-detect-remote-changes 0))
(ssh-deploy-remote-changes-handler)) )))
+ :hook ((after-save . ssh-deploy-after-save)
+ (find-file . ssh-deploy-find-file))
:config
(ssh-deploy-line-mode) ;; If you want mode-line feature
+
(defhydra hydra-ssh-deploy (:color red :hint nil)
"
_u_: Upload _f_: Force Upload
diff --git a/ssh-deploy.el b/ssh-deploy.el
index c386268..2f6aa14 100644
--- a/ssh-deploy.el
+++ b/ssh-deploy.el
@@ -53,10 +53,10 @@
;; (setq ange-ftp-netrc-filename "~/.authinfo.gpg")
;;
;; - To setup a upload hook on save do this:
-;; (add-hook 'after-save-hook (lambda() (if (and (boundp
'ssh-deploy-on-explicit-save) (> ssh-deploy-on-explicit-save 0))
(ssh-deploy-upload-handler)) ))
+;; Add to init-script: (ssh-deploy-add-after-save-hook)
;;
;; - To setup automatic storing of base revisions and detection of remote
changes do this:
-;; (add-hook 'find-file-hook (lambda() (if (and (boundp
'ssh-deploy-automatically-detect-remote-changes) (>
ssh-deploy-automatically-detect-remote-changes 0))
(ssh-deploy-remote-changes-handler)) ))
+;; Add to init-script: (ssh-deploy-add-find-file-hook)
;;
;; - To enable mode line to this:
;; (ssh-deploy-line-mode)
@@ -84,10 +84,11 @@
;; :ensure t
;; :demand
;; :bind (("C-c C-z" . hydra-ssh-deploy/body))
-;; :hook ((after-save . (lambda() (if (and (boundp
'ssh-deploy-on-explicit-save) (> ssh-deploy-on-explicit-save 0)
(ssh-deploy-upload-handler)) )))
-;; (find-file . (lambda() (if (and (boundp
'ssh-deploy-automatically-detect-remote-changes) (>
ssh-deploy-automatically-detect-remote-changes 0))
(ssh-deploy-remote-changes-handler)) )))
+;; :hook ((after-save . ssh-deploy-after-save)
+;; (find-file . ssh-deploy-find-file))
;; :config
;; (ssh-deploy-line-mode) ;; If you want mode-line feature
+;;
;; (defhydra hydra-ssh-deploy (:color red :hint nil)
;; "
;; _u_: Upload _f_: Force Upload
@@ -221,11 +222,11 @@
(put 'ssh-deploy-async-with-threads 'permanent-local t)
(put 'ssh-deploy-async-with-threads 'safe-local-variable 'integerp)
-(defcustom ssh-deploy-async-with-threads nil
- "Boolean variable if asynchronous method should use threads if available,
nil by default."
+(defcustom ssh-deploy-async-with-threads 0
+ "Boolean variable if asynchronous method should use threads if available, 0
by default."
:type 'boolean)
(put 'ssh-deploy-async-with-threads 'permanent-local t)
-(put 'ssh-deploy-async-with-threads 'safe-local-variable 'booleanp)
+(put 'ssh-deploy-async-with-threads 'safe-local-variable 'integerp)
(defcustom ssh-deploy-revision-folder "~/.ssh-deploy-revisions/"
"String variable with file name to revisions with trailing slash."
@@ -351,26 +352,20 @@
(let ((buffer (find-buffer-visiting filename)))
(when buffer
(with-current-buffer buffer
- (unless (listp ssh-deploy--mode-line-status)
- (setq ssh-deploy--mode-line-status '()))
(push status ssh-deploy--mode-line-status)
;; (message "SSH Deploy - Updated status to: %s"
ssh-deploy--mode-line-status)
(ssh-deploy--mode-line-status-refresh))))
(progn
- (unless (listp ssh-deploy--mode-line-status)
- (setq ssh-deploy--mode-line-status '()))
(push status ssh-deploy--mode-line-status)
;; (message "SSH Deploy - Updated status to: %s"
ssh-deploy--mode-line-status)
(ssh-deploy--mode-line-status-refresh))))
(defun ssh-deploy--mode-line-status-refresh ()
"Refresh the status text based on the status variable."
- (unless (listp ssh-deploy--mode-line-status)
- ;; (message "Resetting status: %s" ssh-deploy--mode-line-status)
- (setq ssh-deploy--mode-line-status '()))
(let ((status (pop ssh-deploy--mode-line-status)))
;; (message "SSH Deploy - Refreshing status based on: %s" status)
- (ssh-deploy--mode-line-status-update status)))
+ (when status
+ (ssh-deploy--mode-line-status-update status))))
(defun ssh-deploy--mode-line-status-update (&optional status)
"Update the local status text variable to a text representation based on
STATUS."
@@ -919,14 +914,13 @@
(if file-or-directory
(delete-file path t)
(delete-directory path t t))
- (list path 0 path)))
- (list path 1 path)))
+ (list path 0)))
+ (list path 1)))
(lambda(response)
- (when (nth 2 response)
- (ssh-deploy--mode-line-set-status-and-update
ssh-deploy--status-idle (nth 2 response))
- (let ((local-buffer (find-buffer-visiting (nth 2 response))))
- (when local-buffer
- (kill-buffer local-buffer))))
+ (ssh-deploy--mode-line-set-status-and-update
ssh-deploy--status-idle (nth 0 response))
+ (let ((local-buffer (find-buffer-visiting (nth 0 response))))
+ (when local-buffer
+ (kill-buffer local-buffer)))
(cond ((= 0 (nth 1 response)) (message "Completed deletion of
'%s'. (asynchronously)" (nth 0 response)))
(t (display-warning 'ssh-deploy (format "Did not find '%s'
for deletion. (asynchronously)" (nth 0 response)) :warning))))
async-with-threads))
@@ -1239,7 +1233,7 @@
(root-local (file-truename ssh-deploy-root-local))
(yes-no-prompt (read-string (format "Type 'yes' to confirm
that you want to delete the file '%s': " path-local))))
(if (string= yes-no-prompt "yes")
- (ssh-deploy-delete-both path-local root-local
ssh-deploy-root-remote ssh-deploy-async ssh-deploy-debug
ssh-deploy-async-with-threads)))
+ (ssh-deploy-delete-both path-local root-local
ssh-deploy-root-remote ssh-deploy-async ssh-deploy-debug
ssh-deploy-exclude-list ssh-deploy-async-with-threads)))
(if (and (ssh-deploy--is-not-empty-string default-directory)
(file-exists-p default-directory))
(let* ((path-local (file-truename default-directory))
@@ -1404,6 +1398,23 @@
(ssh-deploy--mode-line-status-refresh)
+;;; Hooks
+
+
+(defun ssh-deploy-after-save () "Logic for automatic uploads."
+ (when (and (boundp 'ssh-deploy-on-explicit-save)
ssh-deploy-on-explicit-save (> ssh-deploy-on-explicit-save 0))
(ssh-deploy-upload-handler)))
+
+(defun ssh-deploy-add-after-save-hook () "Add the `after-save-hook'."
+ (when (fboundp 'ssh-deploy-after-save)
+ (add-hook 'after-save-hook 'ssh-deploy-after-save)))
+
+(defun ssh-deploy-find-file () "Logic for detecting remote change."
+ (when (and (boundp 'ssh-deploy-automatically-detect-remote-changes)
ssh-deploy-automatically-detect-remote-changes (>
ssh-deploy-automatically-detect-remote-changes 0))
(ssh-deploy-remote-changes-handler)))
+
+(defun ssh-deploy-add-find-file-hook () "Add the `find-file-hook'."
+ (when (fboundp 'ssh-deploy-find-file) (add-hook 'find-file-hook
'ssh-deploy-find-file)))
+
+
(provide 'ssh-deploy)
;;; ssh-deploy.el ends here
- [elpa] externals/ssh-deploy cb792e8 002/133: Added ELPA to description and changed http references to https, (continued)
- [elpa] externals/ssh-deploy cb792e8 002/133: Added ELPA to description and changed http references to https, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 71796c3 006/133: Optimization for menu-code completed, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 6fbc09f 010/133: Various changes relating to changing optional boolean argument to, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy b93b944 009/133: Updated README for optional threading and mode-line, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy d934ef8 017/133: More work on optional booleans to integers, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy edee8df 019/133: Improved documentation, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 4073f79 014/133: Updated documentation to suggest ~/.authinfo.gpg usage, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 2048399 021/133: Passing async-with-threads to directory diff, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 54ec0d2 023/133: Updated mode-line logic for deletions, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy fbc6e85 025/133: Created predefined hydra, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 947a3c7 024/133: Improved usability with pre-defined hooks,
Stefan Monnier <=
- [elpa] externals/ssh-deploy 20ce7f2 026/133: Created a pred-fined prefix map and hydra map, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy a12e59f 027/133: Updated comments, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy c1f8837 029/133: Updated documentation with pre-defined hydra and pre-fix map, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy d548011 036/133: Fixed bug with constant definition, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy d853e2f 040/133: Fixed issue with passing local variables to diff-mode, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 98c00bb 042/133: Fixed bug with synchronous forced uploads, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 103588b 050/133: Running custom script asynchronously loads ssh-deploy library, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 2b3a531 012/133: Updated date, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy d7a42fe 015/133: Replaced (concat) with (expand-file-name), Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 80cd448 011/133: Merge branch 'master' of https://github.com/cjohansson/emacs-ssh-deploy, Stefan Monnier, 2021/03/27