[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/diff-hl e264d13a3d 1/2: New option: diff-hl-async-inhib
From: |
ELPA Syncer |
Subject: |
[elpa] externals/diff-hl e264d13a3d 1/2: New option: diff-hl-async-inhibit-functions |
Date: |
Mon, 15 Jul 2024 03:57:58 -0400 (EDT) |
branch: externals/diff-hl
commit e264d13a3d55b2ab08e18119d3f69a55dd4f6a11
Author: Dmitry Gutov <dmitry@gutov.dev>
Commit: Dmitry Gutov <dmitry@gutov.dev>
New option: diff-hl-async-inhibit-functions
Fixes #213
---
diff-hl.el | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/diff-hl.el b/diff-hl.el
index 9ef52af49b..84012ed2a3 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -202,6 +202,17 @@ control (VC) backend. It's disabled in remote buffers,
though, since it
didn't work reliably in such during testing."
:type 'boolean)
+;; Threads are not reliable with remote files, yet.
+(defcustom diff-hl-async-inhibit-functions (list #'diff-hl-with-editor-p
+ #'file-remote-p)
+ "Functions to call to check whether asychronous method should be disabled.
+
+When `diff-hl-update-async' is non-nil, these functions are called in turn
+and passed the value `default-directory'.
+
+If any returns non-nil, `diff-hl-update' will run synchronously anyway."
+ :type '(repeat :tag "Predicate" function))
+
(defvar diff-hl-reference-revision nil
"Revision to diff against. nil means the most recent one.")
@@ -394,12 +405,16 @@ didn't work reliably in such during testing."
(defun diff-hl-update ()
"Updates the diff-hl overlay."
(if (and diff-hl-update-async
- ;; Disable threading on the remote file as it is unreliable.
- (not (file-remote-p default-directory)))
+ (not
+ (run-hook-with-args-until-success 'diff-hl-async-inhibit-functions
+ default-directory)))
;; TODO: debounce if a thread is already running.
(make-thread 'diff-hl--update-safe "diff-hl--update-safe")
(diff-hl--update)))
+(defun diff-hl-with-editor-p (_dir)
+ (bound-and-true-p with-editor-mode))
+
(defun diff-hl--update-safe ()
"Updates the diff-hl overlay. It handles and logs when an error is signaled."
(condition-case err