[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/diff-hl 63613acff1 2/4: Merge pull request #179 from Er
From: |
ELPA Syncer |
Subject: |
[elpa] externals/diff-hl 63613acff1 2/4: Merge pull request #179 from Ergus/master |
Date: |
Sun, 23 Jan 2022 22:57:36 -0500 (EST) |
branch: externals/diff-hl
commit 63613acff1202e5a71c583616e4a3a5b3c36c32a
Merge: e628ba35b8 bcf6fc646a
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: GitHub <noreply@github.com>
Merge pull request #179 from Ergus/master
Add new option diff-hl-disable-on-remote
---
README.md | 9 +++++++++
diff-hl.el | 23 +++++++++++++++++------
2 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/README.md b/README.md
index d1b3979e01..880b1cb672 100644
--- a/README.md
+++ b/README.md
@@ -127,3 +127,12 @@ When using Magit 2.4 or newer, add this to your init
script:
(add-hook 'magit-pre-refresh-hook 'diff-hl-magit-pre-refresh)
(add-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh)
```
+
+Tramp
+-----
+
+`diff-hl` should just work with Tramp. But sometimes a performance
+penalty may be experienced in slow or high latency connections. If
+you experiment such issue then an option may be to set
+`diff-hl-disable-on-remote` to `t` this will inhibit some `diff-hl`
+actions and hooks for the remote buffers.
diff --git a/diff-hl.el b/diff-hl.el
index 91b2b4c202..8bffdbc820 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -106,6 +106,11 @@
:group 'diff-hl
:type 'boolean)
+(defcustom diff-hl-disable-on-remote nil
+ "Non-nil will disable `diff-hl' on remote buffers."
+ :group 'diff-hl
+ :type 'boolean)
+
(defcustom diff-hl-ask-before-revert-hunk t
"Non-nil to ask for confirmation before revert a hunk."
:group 'diff-hl
@@ -851,10 +856,14 @@ The value of this variable is a mode line template as in
(defvar diff-hl--magit-unstaged-files nil)
(defun diff-hl-magit-pre-refresh ()
- (setq diff-hl--magit-unstaged-files (magit-unstaged-files t)))
+ (unless (and diff-hl-disable-on-remote
+ (file-remote-p default-directory))
+ (setq diff-hl--magit-unstaged-files (magit-unstaged-files t))))
(defun diff-hl-magit-post-refresh ()
- (let* ((topdir (magit-toplevel))
+ (unless (and diff-hl-disable-on-remote
+ (file-remote-p default-directory))
+ (let* ((topdir (magit-toplevel))
(modified-files
(mapcar (lambda (file) (expand-file-name file topdir))
(delete-consecutive-dups
@@ -884,7 +893,7 @@ The value of this variable is a mode line template as in
(diff-hl-update))
((not (memq (vc-state file backend) unmodified-states))
(vc-state-refresh file backend)
- (diff-hl-update))))))))))
+ (diff-hl-update)))))))))))
(defun diff-hl-dir-update ()
(dolist (pair (if (vc-dir-marked-files)
@@ -1016,10 +1025,12 @@ CONTEXT-LINES is the size of the unified diff context,
defaults to 0."
(defun turn-on-diff-hl-mode ()
"Turn on `diff-hl-mode' or `diff-hl-dir-mode' in a buffer if appropriate."
(cond
- (buffer-file-name
- (diff-hl-mode 1))
+ ((or (not buffer-file-name)
+ (and diff-hl-disable-on-remote
+ (file-remote-p buffer-file-name))))
((eq major-mode 'vc-dir-mode)
- (diff-hl-dir-mode 1))))
+ (diff-hl-dir-mode 1))
+ (t (diff-hl-mode 1))))
;;;###autoload
(defun diff-hl--global-turn-on ()