2017-06-08 11:47:56 +02:00
|
|
|
;;; tools/upload/config.el -*- lexical-binding: t; -*-
|
2017-02-19 18:54:32 -05:00
|
|
|
|
2018-09-19 23:48:05 -04:00
|
|
|
;; Uses `ssh-deploy' to map a local folder to a remote one. Set
|
|
|
|
;; `ssh-deploy-root-remote' and `ssh-deploy-root-local' in a .dir-locals.el file
|
|
|
|
;; to establish this mapping.
|
2017-02-19 18:54:32 -05:00
|
|
|
;;
|
2017-04-16 16:09:01 -04:00
|
|
|
;; Example:
|
2018-09-19 23:48:05 -04:00
|
|
|
;; ((nil . ((ssh-deploy-root-local . "/local/path/to/project")
|
|
|
|
;; (ssh-deploy-root-remote . "/ssh:user@server:/remote/project/")
|
|
|
|
;; (ssh-deploy-on-explicity-save . t))))
|
2017-04-16 16:09:01 -04:00
|
|
|
;;
|
|
|
|
;; Note: `ssh-deploy-root-local' is optional, and will resort to
|
|
|
|
;; `doom-project-root' if unspecified.
|
2017-02-19 18:54:32 -05:00
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! ssh-deploy
|
2017-02-19 18:54:32 -05:00
|
|
|
:commands (ssh-deploy-upload-handler
|
|
|
|
ssh-deploy-upload-handler-forced
|
|
|
|
ssh-deploy-diff-handler
|
2018-02-21 16:46:15 -05:00
|
|
|
ssh-deploy-browse-remote-handler
|
2017-02-19 18:54:32 -05:00
|
|
|
ssh-deploy-remote-changes-handler)
|
|
|
|
:init
|
2018-12-05 22:07:33 -05:00
|
|
|
(setq ssh-deploy-revision-folder (concat doom-cache-dir "ssh-revisions/")
|
|
|
|
ssh-deploy-on-explicit-save t
|
|
|
|
ssh-deploy-automatically-detect-remote-changes nil)
|
|
|
|
|
2018-09-19 23:51:56 -04:00
|
|
|
;; Make these safe as file-local variables
|
2018-09-19 23:58:01 -04:00
|
|
|
(dolist (sym '((ssh-deploy-root-local . stringp)
|
|
|
|
(ssh-deploy-root-remote . stringp)
|
|
|
|
(ssh-deploy-script . functionp)
|
|
|
|
(ssh-deploy-on-explicitly-save . booleanp)
|
|
|
|
(ssh-deploy-async . booleanp)
|
|
|
|
(ssh-deploy-exclude-list . listp)))
|
|
|
|
(put (car sym) 'safe-local-variable (cdr sym)))
|
2018-09-19 23:51:56 -04:00
|
|
|
|
2017-02-19 18:54:32 -05:00
|
|
|
;; Maybe auto-upload on save
|
2019-09-13 21:59:03 -04:00
|
|
|
(add-hook! 'after-save-hook
|
|
|
|
(defun +upload-init-after-save-h ()
|
|
|
|
(when (and (bound-and-true-p ssh-deploy-root-remote)
|
|
|
|
ssh-deploy-on-explicit-save)
|
|
|
|
(ssh-deploy-upload-handler))))
|
2017-02-19 18:54:32 -05:00
|
|
|
|
2017-04-16 16:09:01 -04:00
|
|
|
;; Enable ssh-deploy if variables are set, and check for changes on open file
|
|
|
|
;; (if possible)
|
2019-09-13 21:59:03 -04:00
|
|
|
(add-hook! 'find-file-hook
|
|
|
|
(defun +upload-init-find-file-h ()
|
|
|
|
(when (bound-and-true-p ssh-deploy-root-remote)
|
|
|
|
(require 'ssh-deploy)
|
|
|
|
(unless ssh-deploy-root-local
|
|
|
|
(setq ssh-deploy-root-local (doom-project-root)))
|
|
|
|
(when ssh-deploy-automatically-detect-remote-changes
|
|
|
|
(ssh-deploy-remote-changes-handler))))))
|