-(defun diff-hl-flydiff/changes (&rest args)
- (let* ((file buffer-file-name)
- (backend (vc-backend file)))
- (when backend
- (let ((state (vc-state file backend)))
- (cond
- ((or
- (buffer-modified-p)
- (eq state 'edited)
- (and (eq state 'up-to-date)
- ;; VC state is stale in after-revert-hook.
- (or revert-buffer-in-progress-p
- ;; Diffing against an older revision.
- diff-hl-reference-revision)))
- (let (diff-auto-refine-mode res)
- (with-current-buffer (diff-hl-flydiff-buffer-with-head)
- (goto-char (point-min))
- (unless (eobp)
- (ignore-errors
- (diff-beginning-of-hunk t))
- (while (looking-at diff-hunk-header-re-unified)
- (let ((line (string-to-number (match-string 3)))
- (len (let ((m (match-string 4)))
- (if m (string-to-number m) 1)))
- (beg (point)))
- (diff-end-of-hunk)
- (let* ((inserts (diff-count-matches "^\\+" beg (point)))
- (deletes (diff-count-matches "^-" beg (point)))
- (type (cond ((zerop deletes) 'insert)
- ((zerop inserts) 'delete)
- (t 'change))))
- (when (eq type 'delete)
- (setq len 1)
- (cl-incf line))
- (push (list line len type) res))))))
- (setq diff-hl-flydiff-modified-tick (buffer-modified-tick))
- (nreverse res)))
- ((eq state 'added)
- `((1 ,(line-number-at-pos (point-max)) insert)))
- ((eq state 'removed)
- `((1 ,(line-number-at-pos (point-max)) delete))))))))
+(defun diff-hl-flydiff/modified-p (state)
+ (or
+ (buffer-modified-p)
+ (eq state 'edited)
+ (and (eq state 'up-to-date)
+ ;; VC state is stale in after-revert-hook.
+ (or revert-buffer-in-progress-p
+ ;; Diffing against an older revision.
+ diff-hl-reference-revision))))
+
+(defun diff-hl-flydiff/update-modified-tick (&rest args)
+ (setq diff-hl-flydiff-modified-tick (buffer-modified-tick)))