[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ssh-deploy 13dcacb 034/133: More cosmetic changes to di
From: |
Stefan Monnier |
Subject: |
[elpa] externals/ssh-deploy 13dcacb 034/133: More cosmetic changes to diff mode |
Date: |
Sat, 27 Mar 2021 14:48:38 -0400 (EDT) |
branch: externals/ssh-deploy
commit 13dcacb32a09a1961b569949bce5fa2a7cd6a3de
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
More cosmetic changes to diff mode
---
ssh-deploy-diff-mode.el | 92 ++++++++++++++++++++-----------------------------
1 file changed, 37 insertions(+), 55 deletions(-)
diff --git a/ssh-deploy-diff-mode.el b/ssh-deploy-diff-mode.el
index 75673f5..d877f97 100644
--- a/ssh-deploy-diff-mode.el
+++ b/ssh-deploy-diff-mode.el
@@ -3,8 +3,8 @@
;; Author: Christian Johansson <github.com/cjohansson>
;; Maintainer: Christian Johansson <github.com/cjohansson>
;; Created: 1 Feb 2018
-;; Modified: 29 Oct 2018
-;; Version: 1.15
+;; Modified: 1 Nov 2018
+;; Version: 1.16
;; Keywords: tools, convenience
;; URL: https://github.com/cjohansson/emacs-ssh-deploy
@@ -178,12 +178,9 @@
(root-remote (nth 3 parts))
(path-local (file-truename (expand-file-name file-name root-local)))
(path-remote (expand-file-name file-name root-remote)))
- (if (fboundp 'ssh-deploy-upload)
- (cond ((or (= section ssh-deploy-diff-mode--section-only-in-a)
- (= section ssh-deploy-diff-mode--section-in-both))
- (ssh-deploy-upload path-local path-remote 1))
- (t "Copy A is not available in this section"))
- (display-warning 'ssh-deploy "Function ssh-deploy-upload is missing"
:warning))))
+ (cond ((memq section '(only-in-a in-both))
+ (ssh-deploy-upload path-local path-remote 1))
+ (t (message "Copy A is not available in this section")))))
(defun ssh-deploy-diff-mode--copy-b (parts)
"Perform an download of remote-path to local-path based on PARTS from
section B or section BOTH."
@@ -194,49 +191,41 @@
(root-remote (nth 3 parts))
(path-local (file-truename (expand-file-name file-name root-local)))
(path-remote (expand-file-name file-name root-remote)))
- (if (fboundp 'ssh-deploy-download)
- (cond ((or (= section ssh-deploy-diff-mode--section-only-in-b)
- (= section ssh-deploy-diff-mode--section-in-both))
- (ssh-deploy-download path-remote path-local))
- (t "Copy B is not available in this section"))
- (display-warning 'ssh-deploy "Function ssh-deploy-download is missing"
:warning))))
+ (cond ((memq section '(only-in-b in-both))
+ (ssh-deploy-download path-remote path-local))
+ (t (message "Copy B is not available in this section")))))
;; TODO Should we really pass path as buffer argument in this?
(defun ssh-deploy-diff-mode--delete (parts)
"Delete path in both, only in a or only in b based on PARTS from section A,
B or BOTH."
- (require 'ssh-deploy)
(let* ((section (nth 1 parts))
(file-name (nth 0 parts))
(root-local (nth 2 parts))
(root-remote (nth 3 parts))
(path-local (file-truename (expand-file-name file-name root-local)))
(path-remote (expand-file-name file-name root-remote)))
- (if (and (fboundp 'ssh-deploy-delete)
- (fboundp 'ssh-deploy-delete-both))
- (cond ((= section ssh-deploy-diff-mode--section-in-both)
- (let ((yes-no-prompt (read-string (format "Type 'yes' to
confirm that you want to delete the file '%s': " file-name))))
- (if (string= yes-no-prompt "yes")
- (ssh-deploy-delete-both path-local))))
- ((= section ssh-deploy-diff-mode--section-only-in-a)
(ssh-deploy-delete path-local))
- ((= section ssh-deploy-diff-mode--section-only-in-b)
(ssh-deploy-delete path-remote))
- ((= section ssh-deploy-diff-mode--section-in-both)
(ssh-deploy-delete-both path-local))
- (t (message "Delete is not available in this section")))
- (display-warning 'ssh-deploy "Function ssh-deploy-delete or
ssh-deploy-delete-both is missing" :warning))))
+ (pcase section
+ ('in-both
+ (let ((yes-no-prompt (read-string (format "Type 'yes' to confirm that
you want to delete the file '%s': " file-name))))
+ (if (string= yes-no-prompt "yes")
+ (ssh-deploy-delete-both path-local))))
+ ('only-in-a
+ (ssh-deploy-delete path-local))
+ ('only-in-b
+ (ssh-deploy-delete-both path-remote))
+ (_ (message "Delete is not available in this section")))))
(defun ssh-deploy-diff-mode--difference (parts)
"If file exists in both start a difference session based on PARTS."
- (require 'ssh-deploy)
(let ((section (nth 1 parts)))
- (if (= section ssh-deploy-diff-mode--section-in-both)
- (if (fboundp 'ssh-deploy-diff-files)
- (let* ((file-name (nth 0 parts))
- (root-local (file-truename (nth 2 parts)))
- (root-remote (nth 3 parts))
- (path-local (file-truename (expand-file-name file-name
root-local)))
- (path-remote (expand-file-name file-name root-remote)))
- (ssh-deploy-diff-files path-local path-remote)))
- (display-warning 'ssh-deploy "Function ssh-deploy-diff-files is missing"
:warning))
- (message "File must exists in both roots to perform a difference
action.")))
+ (if (eq section 'in-both)
+ (let* ((file-name (nth 0 parts))
+ (root-local (file-truename (nth 2 parts)))
+ (root-remote (nth 3 parts))
+ (path-local (file-truename (expand-file-name file-name
root-local)))
+ (path-remote (expand-file-name file-name root-remote)))
+ (ssh-deploy-diff-files path-local path-remote))
+ (message "File must exists in both roots to perform a difference
action."))))
(defun ssh-deploy-diff-mode--open (parts)
"Perform a open file action based on PARTS from section A or section B."
@@ -247,26 +236,19 @@
(root-remote (nth 3 parts))
(path-local (file-truename (expand-file-name file-name root-local)))
(path-remote (expand-file-name file-name root-remote)))
- (cond ((= section ssh-deploy-diff-mode--section-only-in-a)
- (progn
- (message "Opening file '%s'" path-local)
- (find-file path-local)))
- ((= section ssh-deploy-diff-mode--section-only-in-b)
- (progn
- (message "Opening file '%s'" path-remote)
- (find-file path-remote)))
- (t (message "Open is not available in this section")))))
+ (pcase section
+ ('only-in-a
+ (message "Opening file '%s'" path-local)
+ (find-file path-local))
+ ('only-in-b
+ (message "Opening file '%s'" path-remote)
+ (find-file path-remote))
+ (_ (message "Open is not available in this section")))))
-(defun ssh-deploy-diff-mode ()
+(define-derived-mode ssh-deploy-diff-mode special-mode "SSH-Deploy-Diff"
"Major mode for SSH Deploy interactive directory differences."
- (interactive)
- (kill-all-local-variables)
- (use-local-map ssh-deploy-diff-mode--map)
- (set (make-local-variable 'font-lock-defaults)
'(ssh-deploy-diff-mode--font-lock-keywords))
- (setq major-mode 'ssh-deploy-diff-mode)
- (setq mode-name "SSH-Deploy-Diff")
- (read-only-mode t)
- (run-hooks 'ssh-deploy-diff-mode-hook))
+ (set (make-local-variable 'font-lock-defaults)
+ '(ssh-deploy-diff-mode--font-lock-keywords)))
(provide 'ssh-deploy-diff-mode)
- [elpa] externals/ssh-deploy 2e3cf30 016/133: Fixed issue with directory differences, (continued)
- [elpa] externals/ssh-deploy 2e3cf30 016/133: Fixed issue with directory differences, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy d5386ab 018/133: Renamed internal argument with-threads to async-with-threads, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy cb4c6ff 020/133: Using (expand-file-name) instead of (concat), Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy e0bd19c 022/133: Removed obsolete arguments from directory-diff operations, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 102943f 028/133: Added pre-defined prefix key map, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy afbcc70 030/133: mode-line now shows whether current file is under deployment, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 0e7c608 031/133: Deployment menu only shows when current buffer is deployment, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 8dadac5 032/133: Made menu-bar feature optional, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy b409812 033/133: Started on implementing changes to diff-mode, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 13dcacb 034/133: More cosmetic changes to diff mode,
Stefan Monnier <=
- [elpa] externals/ssh-deploy 4268c8b 035/133: Fixed bug with constant definition, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 7be2881 038/133: Fixed proper symbols for actions, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 3c5fe09 037/133: More work on diff mode cosmetic changes, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 95a932a 047/133: Started on unit-tests, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 0b43ceb 048/133: Added unit tests for get-revision-path and is-not-empty-string, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 4ff27e9 049/133: Minor modifications after suggestions from flycheck-package, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 5871711 052/133: Renamed TRAMP to Tramp and added link to lisp code style, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy e834379 053/133: Updated version, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy 2388c00 056/133: Added -p suffix to predicate functions, Stefan Monnier, 2021/03/27
- [elpa] externals/ssh-deploy bc93b81 057/133: Updated version, Stefan Monnier, 2021/03/27