|
|
|
|
@@ -5,7 +5,7 @@
|
|
|
|
|
;; Author: Dmitry Gutov <dgutov@yandex.ru>
|
|
|
|
|
;; URL: https://github.com/dgutov/diff-hl
|
|
|
|
|
;; Keywords: vc, diff
|
|
|
|
|
;; Version: 1.8.8
|
|
|
|
|
;; Version: 1.9.0
|
|
|
|
|
;; Package-Requires: ((cl-lib "0.2") (emacs "25.1"))
|
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
@@ -106,6 +106,11 @@
|
|
|
|
|
:group 'diff-hl
|
|
|
|
|
:type 'boolean)
|
|
|
|
|
|
|
|
|
|
(defcustom diff-hl-disable-on-remote nil
|
|
|
|
|
"Non-nil will disable `diff-hl' in 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
|
|
|
|
|
@@ -274,6 +279,7 @@ the current version of the file)."
|
|
|
|
|
(t (intern (format "diff-hl-bmp-%s" type)))))
|
|
|
|
|
|
|
|
|
|
(defvar vc-svn-diff-switches)
|
|
|
|
|
(defvar vc-fossil-diff-switches)
|
|
|
|
|
|
|
|
|
|
(defmacro diff-hl-with-diff-switches (body)
|
|
|
|
|
`(let ((vc-git-diff-switches
|
|
|
|
|
@@ -288,6 +294,7 @@ the current version of the file)."
|
|
|
|
|
vc-git-diff-switches))))
|
|
|
|
|
(vc-hg-diff-switches nil)
|
|
|
|
|
(vc-svn-diff-switches nil)
|
|
|
|
|
(vc-fossil-diff-switches '("-c" "0"))
|
|
|
|
|
(vc-diff-switches '("-U0"))
|
|
|
|
|
,@(when (boundp 'vc-disable-async-diff)
|
|
|
|
|
'((vc-disable-async-diff t))))
|
|
|
|
|
@@ -751,10 +758,10 @@ Only supported with Git."
|
|
|
|
|
(diff-hl-update)))))
|
|
|
|
|
|
|
|
|
|
(defun diff-hl-unstage-file ()
|
|
|
|
|
(interactive)
|
|
|
|
|
"Unstage all changes in the current file.
|
|
|
|
|
|
|
|
|
|
Only supported with Git."
|
|
|
|
|
(interactive)
|
|
|
|
|
(unless buffer-file-name
|
|
|
|
|
(user-error "No current file"))
|
|
|
|
|
(diff-hl--ensure-staging-supported)
|
|
|
|
|
@@ -802,7 +809,8 @@ The value of this variable is a mode line template as in
|
|
|
|
|
;; saved, in order not to fetch it twice.
|
|
|
|
|
'find-file-hook)
|
|
|
|
|
'diff-hl-update-once t t)
|
|
|
|
|
(add-hook 'vc-checkin-hook 'diff-hl-update nil t)
|
|
|
|
|
;; Never removed because it acts globally.
|
|
|
|
|
(add-hook 'vc-checkin-hook 'diff-hl-after-checkin)
|
|
|
|
|
(add-hook 'after-revert-hook 'diff-hl-after-revert nil t)
|
|
|
|
|
;; Magit does call `auto-revert-handler', but it usually
|
|
|
|
|
;; doesn't do much, because `buffer-stale--default-function'
|
|
|
|
|
@@ -816,13 +824,25 @@ The value of this variable is a mode line template as in
|
|
|
|
|
(remove-hook 'after-save-hook 'diff-hl-update t)
|
|
|
|
|
(remove-hook 'after-change-functions 'diff-hl-edit t)
|
|
|
|
|
(remove-hook 'find-file-hook 'diff-hl-update t)
|
|
|
|
|
(remove-hook 'vc-checkin-hook 'diff-hl-update t)
|
|
|
|
|
(remove-hook 'after-revert-hook 'diff-hl-update t)
|
|
|
|
|
(remove-hook 'magit-revert-buffer-hook 'diff-hl-update t)
|
|
|
|
|
(remove-hook 'magit-not-reverted-hook 'diff-hl-update t)
|
|
|
|
|
(remove-hook 'text-scale-mode-hook 'diff-hl-maybe-redefine-bitmaps t)
|
|
|
|
|
(diff-hl-remove-overlays)))
|
|
|
|
|
|
|
|
|
|
(defun diff-hl-after-checkin ()
|
|
|
|
|
(let ((fileset (vc-deduce-fileset t)))
|
|
|
|
|
(dolist (file (nth 1 fileset))
|
|
|
|
|
(let ((buf (find-buffer-visiting file)))
|
|
|
|
|
(when buf
|
|
|
|
|
(with-current-buffer buf
|
|
|
|
|
(when diff-hl-mode
|
|
|
|
|
(diff-hl-update))))))))
|
|
|
|
|
|
|
|
|
|
(defvar diff-hl-repeat-exceptions '(diff-hl-show-hunk
|
|
|
|
|
diff-hl-show-hunk-previous
|
|
|
|
|
diff-hl-show-hunk-next))
|
|
|
|
|
|
|
|
|
|
(when (require 'smartrep nil t)
|
|
|
|
|
(let (smart-keys)
|
|
|
|
|
(cl-labels ((scan (map)
|
|
|
|
|
@@ -830,7 +850,8 @@ The value of this variable is a mode line template as in
|
|
|
|
|
(lambda (event binding)
|
|
|
|
|
(if (consp binding)
|
|
|
|
|
(scan binding)
|
|
|
|
|
(when (characterp event)
|
|
|
|
|
(when (and (characterp event)
|
|
|
|
|
(not (memq binding diff-hl-repeat-exceptions)))
|
|
|
|
|
(push (cons (string event) binding) smart-keys))))
|
|
|
|
|
map)))
|
|
|
|
|
(scan diff-hl-command-map)
|
|
|
|
|
@@ -842,7 +863,8 @@ The value of this variable is a mode line template as in
|
|
|
|
|
;; chances of it being put into GNU ELPA are slim too.
|
|
|
|
|
(map-keymap
|
|
|
|
|
(lambda (_key cmd)
|
|
|
|
|
(put cmd 'repeat-map 'diff-hl-command-map))
|
|
|
|
|
(unless (memq cmd diff-hl-repeat-exceptions)
|
|
|
|
|
(put cmd 'repeat-map 'diff-hl-command-map)))
|
|
|
|
|
diff-hl-command-map)
|
|
|
|
|
|
|
|
|
|
(declare-function magit-toplevel "magit-git")
|
|
|
|
|
@@ -851,10 +873,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 +910,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)
|
|
|
|
|
@@ -1017,7 +1043,9 @@ CONTEXT-LINES is the size of the unified diff context, defaults to 0."
|
|
|
|
|
"Turn on `diff-hl-mode' or `diff-hl-dir-mode' in a buffer if appropriate."
|
|
|
|
|
(cond
|
|
|
|
|
(buffer-file-name
|
|
|
|
|
(diff-hl-mode 1))
|
|
|
|
|
(unless (and diff-hl-disable-on-remote
|
|
|
|
|
(file-remote-p buffer-file-name))
|
|
|
|
|
(diff-hl-mode 1)))
|
|
|
|
|
((eq major-mode 'vc-dir-mode)
|
|
|
|
|
(diff-hl-dir-mode 1))))
|
|
|
|
|
|
|
|
|
|
|