;; Author: Dmitry Gutov <dgutov@yandex.ru>\r
;; URL: https://github.com/dgutov/diff-hl\r
;; Keywords: vc, diff\r
-;; Version: 1.5.3\r
+;; Version: 1.6.0\r
;; Package-Requires: ((cl-lib "0.2"))\r
\r
;; This file is part of GNU Emacs.\r
(numberp text-scale-mode-amount))\r
(expt text-scale-mode-step text-scale-mode-amount)\r
1))\r
- (spacing (or (default-value 'line-spacing) 0))\r
- (h (round (+ (* (frame-char-height) scale)\r
- (if (floatp spacing)\r
- (* (frame-char-height) spacing)\r
- spacing))))\r
+ (spacing (or (and (display-graphic-p) (default-value 'line-spacing)) 0))\r
+ (h (+ (ceiling (* (frame-char-height) scale))\r
+ (if (floatp spacing)\r
+ (truncate (* (frame-char-height) spacing))\r
+ spacing)))\r
(w (frame-parameter nil 'left-fringe))\r
(middle (make-vector h (expt 2 (1- w))))\r
(ones (1- (expt 2 w)))\r
(aset insert-bmp (1+ middle-pos) delete-row)\r
(aset insert-bmp (1- w2) 0)\r
(define-fringe-bitmap 'diff-hl-bmp-insert insert-bmp w2 w2)\r
- (define-fringe-bitmap 'diff-hl-bmp-change (make-vector\r
- w2 (* 3 middle-bit)) w2 w2))))\r
+ )))\r
\r
(defun diff-hl-maybe-define-bitmaps ()\r
(when (window-system) ;; No fringes in the console.\r
(intern (format "diff-hl-bmp-%s" pos)))\r
\r
(defun diff-hl-fringe-bmp-from-type (type _pos)\r
- (if (eq type 'unknown)\r
- 'question-mark\r
- (intern (format "diff-hl-bmp-%s" type))))\r
+ (cl-case type\r
+ (unknown 'question-mark)\r
+ (change 'exclamation-mark)\r
+ (t (intern (format "diff-hl-bmp-%s" type)))))\r
\r
(defvar vc-svn-diff-switches)\r
\r
(diff-hl-maybe-define-bitmaps)\r
(add-hook 'after-save-hook 'diff-hl-update nil t)\r
(add-hook 'after-change-functions 'diff-hl-edit nil t)\r
- (if vc-mode\r
- (diff-hl-update)\r
- (add-hook 'find-file-hook 'diff-hl-update t t))\r
+ (add-hook (if vc-mode\r
+ ;; Defer until the end of this hook, so that its\r
+ ;; elements can modify the update behavior.\r
+ 'diff-hl-mode-on-hook\r
+ ;; If we're only opening the file now,\r
+ ;; `vc-find-file-hook' likely hasn't run yet, so\r
+ ;; let's wait until the state information is\r
+ ;; saved, in order not to fetch it twice.\r
+ 'find-file-hook)\r
+ 'diff-hl-update t t)\r
(add-hook 'vc-checkin-hook 'diff-hl-update nil t)\r
(add-hook 'after-revert-hook 'diff-hl-update nil t)\r
+ ;; Magit does call `auto-revert-handler', but it usually\r
+ ;; doesn't do much, because `buffer-stale--default-function'\r
+ ;; doesn't care about changed VC state.\r
+ ;; https://github.com/magit/magit/issues/603\r
(add-hook 'magit-revert-buffer-hook 'diff-hl-update nil t)\r
(add-hook 'text-scale-mode-hook 'diff-hl-define-bitmaps nil t))\r
(remove-hook 'after-save-hook 'diff-hl-update t)\r