1 ;; Copyright (C) 2012-2013 Free Software Foundation, Inc.
3 ;; Author: Dmitry Gutov <dgutov@yandex.ru>
4 ;; URL: https://github.com/dgutov/diff-hl
6 ;; This file is part of GNU Emacs.
8 ;; GNU Emacs is free software: you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
13 ;; GNU Emacs is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23 ;; Toggle in the current buffer with `M-x diff-hl-amend-mode'.
24 ;; Toggle in all buffers with `M-x global-diff-hl-amend-mode'.
31 (define-minor-mode diff-hl-amend-mode
32 "Show changes against the second-last revision in `diff-hl-mode'.
33 Most useful with backends that support rewriting local commits,
34 and most importantly, 'amending' the most recent one.
35 Currently only supports Git, Mercurial and Bazaar."
37 (if diff-hl-amend-mode
40 (add-hook 'after-revert-hook 'diff-hl-amend-setup nil t))
41 (remove-hook 'after-revert-hook 'diff-hl-amend-setup t)
42 (setq-local diff-hl-reference-revision nil))
46 (defun diff-hl-amend-setup ()
47 (let ((backend (vc-backend buffer-file-name)))
49 (setq-local diff-hl-reference-revision
59 (define-globalized-minor-mode global-diff-hl-amend-mode diff-hl-amend-mode
60 turn-on-diff-hl-amend-mode)
62 (defun turn-on-diff-hl-amend-mode ()
63 "Turn on `diff-hl-amend-mode' in a buffer if appropriate."
64 (and buffer-file-name (diff-hl-amend-mode 1)))
66 (provide 'diff-hl-amend)
68 ;;; diff-hl-amend.el ends here