summaryrefslogtreecommitdiff
path: root/lisp/vc-annotate-lens-mode.el
blob: 00f674eda703c55f5e435fcad1d125199c95ade4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

;;; Code:

(make-variable-buffer-local
 (defvar vc-annotate-lens-cursor-position 0
   "Holds the cursor position from the last run of post-command-hooks."))

(defun do-stuff-if-moved-post-command ()
  (interactive)
  (unless (equal (line-number-at-pos) vc-annotate-lens-cursor-position)
    (vc-region-history line-number-at-pos)
    (message "%s" vc-annotate-lens-cursor-position))
  (setq vc-annotate-lens-cursor-position (line-number-at-pos)))

(define-minor-mode vc-annotate-lens-mode
  "Show 'vc-annotate' information when you move to a line."
  :lighter " vc-annotate-lens"
  )

(add-hook 'vc-annotate-lens-mode-on-hook (lambda () (add-hook 'post-command-hook #'do-stuff-if-moved-post-command)))
(add-hook 'vc-annotate-lens-mode-off-hook (lambda () (remove-hook 'post-command-hook #'do-stuff-if-moved-post-command)))

(provide 'vc-annotate-lens-mode)
;;; vc-annotate-lens-mode.el ends here.