\r
(global-diff-hl-mode)\r
\r
-or, for example, to use it in all `prog-mode` buffers\r
+or, for example, to use it in all `prog-mode` and `vc-dir-mode` buffers\r
\r
(add-hook 'prog-mode-hook 'turn-on-diff-hl-mode)\r
+ (add-hook 'vc-dir-mode-hook 'turn-on-diff-hl-mode)\r
(remove-hook 'text-scale-mode-hook 'diff-hl-define-bitmaps t)\r
(diff-hl-remove-overlays)))\r
\r
+(defun diff-hl-dir-update ()\r
+ (dolist (pair (vc-dir-marked-only-files-and-states))\r
+ (when (eq 'up-to-date (cdr pair))\r
+ (let ((buffer (find-buffer-visiting (car pair))))\r
+ (when buffer\r
+ (with-current-buffer buffer\r
+ (diff-hl-remove-overlays)))))))\r
+\r
+;;;###autoload\r
+(define-minor-mode diff-hl-dir-mode\r
+ "Toggle `diff-hl-mode' link in `vc-dir-mode' buffer."\r
+ :lighter ""\r
+ (if diff-hl-dir-mode\r
+ (add-hook 'vc-checkin-hook 'diff-hl-dir-update t t)\r
+ (remove-hook 'vc-checkin-hook 'diff-hl-dir-update t)))\r
+\r
(defun turn-on-diff-hl-mode ()\r
- ;; FIXME: Why is this called twice for each buffer?\r
- ;; Isn't fundamental-mode supposed to not run any hooks?\r
- (and buffer-file-name (not (eq major-mode (default-value 'major-mode)))\r
- (window-system) ;; No fringes in the console.\r
- (diff-hl-mode 1)))\r
+ (when (window-system) ;; No fringes in the console.\r
+ (cond\r
+ ;; FIXME: Why is this called twice for each buffer?\r
+ ;; Isn't fundamental-mode supposed to not run any hooks?\r
+ ((and buffer-file-name (not (eq major-mode (default-value 'major-mode))))\r
+ (diff-hl-mode 1))\r
+ ((eq major-mode 'vc-dir-mode)\r
+ (diff-hl-dir-mode 1)))))\r
\r
;;;###autoload\r
(define-globalized-minor-mode global-diff-hl-mode diff-hl-mode\r