[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/diff-hl 9d5a0d8 2/2: Rename functions for clarity
From: |
ELPA Syncer |
Subject: |
[elpa] externals/diff-hl 9d5a0d8 2/2: Rename functions for clarity |
Date: |
Mon, 5 Apr 2021 09:57:07 -0400 (EDT) |
branch: externals/diff-hl
commit 9d5a0d8bf6efc125e5d37301a34b93e5b8e2873e
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>
Rename functions for clarity
---
diff-hl-flydiff.el | 8 ++++----
diff-hl-show-hunk.el | 2 +-
diff-hl.el | 11 ++++++-----
test/diff-hl-test.el | 4 ++--
4 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/diff-hl-flydiff.el b/diff-hl-flydiff.el
index 4eefa49..1410b2c 100644
--- a/diff-hl-flydiff.el
+++ b/diff-hl-flydiff.el
@@ -40,9 +40,9 @@
(defvar diff-hl-flydiff-timer nil)
(make-variable-buffer-local 'diff-hl-flydiff-modified-tick)
-(defun diff-hl-flydiff-buffer-with-head (file &optional backend)
+(defun diff-hl-flydiff-changes-buffer (file &optional backend)
(setq diff-hl-flydiff-modified-tick (buffer-chars-modified-tick))
- (diff-hl-diff-buffer-with-head file " *diff-hl-diff*" backend))
+ (diff-hl-diff-buffer-with-reference file " *diff-hl-diff*" backend))
(defun diff-hl-flydiff-update ()
(unless (or
@@ -68,14 +68,14 @@ This is a global minor mode. It alters how `diff-hl-mode'
works."
(advice-add 'diff-hl-modified-p :before-until
#'diff-hl-flydiff/modified-p)
(advice-add 'diff-hl-changes-buffer :override
- #'diff-hl-flydiff-buffer-with-head)
+ #'diff-hl-flydiff-changes-buffer)
(setq diff-hl-flydiff-timer
(run-with-idle-timer diff-hl-flydiff-delay t
#'diff-hl-flydiff-update)))
(advice-remove 'diff-hl-overlay-modified #'ignore)
(advice-remove 'diff-hl-modified-p #'diff-hl-flydiff/modified-p)
- (advice-remove 'diff-hl-changes-buffer #'diff-hl-flydiff-buffer-with-head)
+ (advice-remove 'diff-hl-changes-buffer #'diff-hl-flydiff-changes-buffer)
(and diff-hl-flydiff-timer
(cancel-timer diff-hl-flydiff-timer))))
diff --git a/diff-hl-show-hunk.el b/diff-hl-show-hunk.el
index 2be7a06..f4945de 100644
--- a/diff-hl-show-hunk.el
+++ b/diff-hl-show-hunk.el
@@ -129,7 +129,7 @@ buffer."
(line (line-number-at-pos))
(dest-buffer "*diff-hl-show-hunk-diff-buffer*"))
(with-current-buffer buffer
- (diff-hl-diff-buffer-with-head (buffer-file-name buffer) dest-buffer)
+ (diff-hl-diff-buffer-with-reference (buffer-file-name buffer)
dest-buffer)
(switch-to-buffer dest-buffer)
(diff-hl-diff-skip-to line)
(setq vc-sentinel-movepoint (point)))
diff --git a/diff-hl.el b/diff-hl.el
index aa528bc..143122f 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -793,15 +793,15 @@ the user should be returned."
(declare-function diff-no-select "diff")
-;; TODO: Consider simplifying given FILE always = buffer-file-name.
-(defun diff-hl-diff-buffer-with-head (file &optional dest-buffer backend)
- "Compute the differences between FILE and its revision.
- The diffs are computed in the buffer DEST-BUFFER. This requires
+(defun diff-hl-diff-buffer-with-reference (file &optional dest-buffer backend)
+ "Compute the diff between the current buffer contents and reference.
+The diffs are computed in the buffer DEST-BUFFER. This requires
the `diff-program' to be in your `exec-path'."
(require 'diff)
(vc-ensure-vc-buffer)
(save-current-buffer
- (let* ((dest-buffer (or dest-buffer "*diff-hl-diff-bufer-with-head*"))
+ (let* ((dest-buffer (or dest-buffer
"*diff-hl-diff-buffer-with-reference*"))
+ (backend (or backend (vc-backend file)))
(temporary-file-directory
(if (file-directory-p "/dev/shm/")
"/dev/shm/"
@@ -825,6 +825,7 @@ the `diff-program' to be in your `exec-path'."
(delete-matching-lines "^Diff finished.*")))
(get-buffer-create dest-buffer))))
+;; TODO: Cache based on .git/index's mtime, maybe.
(defun diff-hl-git-index-object-name (file)
(with-temp-buffer
(vc-git-command (current-buffer) 0 file "ls-files" "-s")
diff --git a/test/diff-hl-test.el b/test/diff-hl-test.el
index 4b8563b..df9f84c 100644
--- a/test/diff-hl-test.el
+++ b/test/diff-hl-test.el
@@ -151,13 +151,13 @@
(let ((diff-hl-show-staged-changes t))
(should
(equal (diff-hl-changes-from-buffer
- (diff-hl-diff-buffer-with-head buffer-file-name nil 'Git))
+ (diff-hl-diff-buffer-with-reference buffer-file-name))
'((1 1 insert)
(12 1 insert)))))
(let ((diff-hl-show-staged-changes nil))
(should
(equal (diff-hl-changes-from-buffer
- (diff-hl-diff-buffer-with-head buffer-file-name nil 'Git))
+ (diff-hl-diff-buffer-with-reference buffer-file-name))
'((12 1 insert)))))))
(defun diff-hl-run-tests ()