emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ELPA-diffs] ELPA branch, master, updated. fb2b5ab1c9b1a2425dfc75a63cf7b


From: Dmitry Gutov
Subject: [ELPA-diffs] ELPA branch, master, updated. fb2b5ab1c9b1a2425dfc75a63cf7b46619352cc1
Date: Sun, 10 Nov 2013 10:02:24 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "ELPA".

The branch, master has been updated
       via  fb2b5ab1c9b1a2425dfc75a63cf7b46619352cc1 (commit)
       via  0a29a07b6f6d135b65b9180b084750a99de6bbd6 (commit)
       via  80abec80ea5c060470a34e2d2ed593f1bb9dc5eb (commit)
       via  b2339aeece4bfa826aa82e7bf4a9ca26c2f0b2fb (commit)
       via  83dc1adf52ca091f1f7deff212b4e1c0b4a408a5 (commit)
       via  c7e813c0d002cf55a8d0b038b1f007621c42501c (commit)
       via  2a5c412650af7e698ba524da377acb4c7782384b (commit)
       via  897b8a7c5efa1a77f347b6d32d35f26f10a617d8 (commit)
       via  85b8500dc1223e637a085ff64e5fbdbb87a3fecb (commit)
       via  ae54feeba092a31ea010507ea114722ee5a174aa (commit)
       via  a34d20ab9b079e152f816f3cdcd93b6a1d000683 (commit)
       via  99684245590ae41898aca17ea5a79d9d2fc59afa (commit)
       via  cc09724f6c9972999fffd3df7cbba85f2f99db33 (commit)
       via  46a07e9320b2ca5f1a99b07c5f3c024ea4ee2148 (commit)
       via  0feda0686f359de86b936ccb1ca0a87b2fa7bf6b (commit)
       via  64582ebadef24cdbb1e3b8d2369d7d31627b1b18 (commit)
       via  0901cb7a2f5949192c2004933bf3d6463e9a7937 (commit)
       via  558c909c4d5bd0210af3ef74568645cba0a5d6a5 (commit)
       via  6acd02b1705b35b1050478c855630d3889d0e337 (commit)
       via  545941781e3a4cc853fbcc1e35d5d6ac0f316c41 (commit)
       via  c204f8f923bc87b106b5706dd3e82d89fd2d15a2 (commit)
       via  906b14fe069f196eeeaca1fe26537994ee308ac0 (commit)
       via  15d21070b0ca5e947d75815fb76ff8c9617a9a1e (commit)
       via  f486ccc8df2bdf8c4322d46c135a114a4f749873 (commit)
       via  75877484c38ee161fafa1ec526f7be998dd4d83d (commit)
       via  7bd2e96638843a28ee75e663856f417bdcaf1de2 (commit)
       via  720de3aac501027b38da3f165d25c65356740bad (commit)
       via  7b83bf62590dc56081f99dd075b5f1fb712fab79 (commit)
       via  cf9d8ecf1377a83d1233bc08c9e4a16afb7dda93 (commit)
       via  6857ec54fbda11ea4d9379bc644ca5ae3db61c64 (commit)
       via  20f500de6f9fc4a0414875b5ed052597c8622638 (commit)
       via  20857ea5f2f8d348f93feecacaa5e0f7846d26c8 (commit)
       via  75109bf275634698fcb619d009414ca7285a5104 (commit)
       via  b2fa067f2292c030d15218ec9a03f68ac9421115 (commit)
       via  5754bba72d8b2609dc04543b9a8e0d8c8627ab64 (commit)
       via  e79b30e306eb656f04f11a0be141bef8d55b6147 (commit)
       via  115e298c467fd8cf131432d133aaeedd7c79bbf5 (commit)
       via  0b3952ce9b92ed215fb1f919c08c185dbf00bc8f (commit)
       via  76a3e46411d531bef28c75efaa836da94878baa6 (commit)
       via  4c79a96bf197407d127a10aa244bb9c82d454ce5 (commit)
       via  9a5bac36b58a5cde93462723f6f2e035d2595383 (commit)
       via  6f3e9c4258855fad0ef3983d56dc517de72098f2 (commit)
       via  da9348b38618e5122c3c3fda3b711330c1cb9dd2 (commit)
       via  43ce511b3a2682d73f601d361f54f344d68635f2 (commit)
       via  d361bc218f8f0cbac0104431abcc7e4aa5558d00 (commit)
       via  e8401cfd787b6994eaad945e3d56e786f37e11c0 (commit)
       via  8db67625ce53d2f8f8de99182d05b5498fd847c1 (commit)
       via  691a845019b2a28265ed2ef898757a885af4836c (commit)
       via  f58bfee02c22756f42600557d455a3d4a2f1cb97 (commit)
       via  82bcd10c390e65c6df723a50f9b16afdcfd687cb (commit)
       via  6d3c0160395332216d40774317d162c9812582e3 (commit)
       via  3194f36d401dbc37bbf61b3cfdf97c669c56d412 (commit)
       via  f839577452be1452f8fb9771e037ee18c78df2d0 (commit)
       via  7563c2bd3e88cec70488288e2a6c556d6c2df21d (commit)
       via  0a6a4f5801744037b8824a5a109a6c5609e53520 (commit)
       via  a34e1c06a3453a808900dd0293865ecb1ba5d63d (commit)
       via  9702c9e2c3b80b25ece8b0d2fd56dd238ef720bc (commit)
       via  af0b8350779f1fd0f4d26f487034ae38b51dd06b (commit)
       via  8938553ad3235207ba91db334585878f68b3abee (commit)
       via  0c8786c08969c0572c4c1e8bfc0e58811d5d3f65 (commit)
       via  3b5f2171b472425ced2ce6ae3daee56a4444a708 (commit)
       via  ada43865f1986ee320793165315be511cfac1cea (commit)
       via  0891ade07b087e3402854e4f419bb09b5ca93e84 (commit)
       via  e6ff86f5dab4070dd00fa53a5faa655199a596af (commit)
       via  932c1533636797d2066f51aa786fafe2a68626dd (commit)
       via  ae6572a4c5eec82f4e11155c5815ead0dd0d848d (commit)
       via  9f415468aea2a9208a0da71bbb39a286b9e7f2a0 (commit)
       via  f43a48179bb6c0e9b92d949b420e5c18f6c9d16d (commit)
       via  a01d2917a07d91269c13901bb65fd7ef54766fd4 (commit)
       via  aeb05382b6d7a12f6263706207a1fe9bd868150f (commit)
       via  1a124bff876b1a356a1d97942e0c77e04cbd3d62 (commit)
       via  321a2787c94fc14c8f45c367b5c2e637bc9cec63 (commit)
       via  eb5f3a129e981f25bd56ce60e1e789545d2f91e6 (commit)
       via  52eab96485cac593b24cc7ab9b536945a7a69ec8 (commit)
       via  a723a9b2fedd3e81661871a3a94722af7a82bb07 (commit)
       via  1c7b014de8093aace41e6adf7a75f7b51a6d907a (commit)
       via  796a360f789da86d421534975231c68defbc36da (commit)
       via  bef2e8563e5aab7b3b84e832902479e5408eaa2e (commit)
       via  db63ddbe30ef6f05e5a917b3a03d75329e80f72e (commit)
       via  7c3bf2a1c4556503bbe7cb8e4c6df2777b55e75e (commit)
       via  bce3c487bd59cf2cf3715225a6aa0807936a0ef9 (commit)
       via  17a1147aabfb71281ef87bc1774fa41d224945c5 (commit)
       via  aebf27fb14895e9d5a9c5e069187f8b79765eac8 (commit)
       via  421c9bfc709eb03f7e7ecc889c9489dc363df02e (commit)
       via  0b769b12398e731717b490425f8d5024137d53d3 (commit)
       via  16c512c04c8e468731d145a180554723ca762705 (commit)
       via  f61eac1863b28762668816fdfbae662bf1bab7b2 (commit)
       via  f2f1e307fe9ebde07666b0d6429877c8e8347fdc (commit)
       via  89feaf319084d4d3f0003501698b39a80f47ce41 (commit)
       via  c94a0730e11577e90f87ea3e9d5b608d0214ae37 (commit)
       via  48f12b6eed43e0dcdf91ae901c641e88de72365f (commit)
       via  b59711456b0d7dbffa51e11e3b07f7c3b9ca2455 (commit)
       via  f40157161ce4bb3b1288fb22cee090917df0d749 (commit)
       via  6e525390d9715e4e0f76f0b3c44707ab6601851f (commit)
       via  bfd1a32195efbb505ebc224720603b1fa7de2a8f (commit)
       via  21530240c963d3e9caff5772a369d993bfb99da4 (commit)
       via  54d3006728ea83e230b6d4d75c431df9c65a7686 (commit)
       via  9577de5080a17f30dd46dfe35745fe6ff90e7689 (commit)
       via  0a1789e1d69a052fa7b245bcc4faf96750bc360c (commit)
       via  63462c296f90f2a5a4ca9d51a9aec71f9d6d60cc (commit)
       via  c1332998d0daba69e14cb1ba1aa8994e2f16f64b (commit)
       via  64051234816f3e55b661390be96ffde704ba1383 (commit)
       via  2e45254224325bcbda54e761e36ec7f8bd42113f (commit)
       via  6c7494ed8abc50041efaf9df1c4dc84a5d70d708 (commit)
       via  ea3b233ae5b360538377be28382c139b4e928ed0 (commit)
       via  13e19b3327e4415d0e92767673fe2ce57e20918f (commit)
       via  6889278472f3eaccb5f0bb6640e1fbb16f7eac84 (commit)
       via  664c36d25c84d66a319fefaabf4b8674d30c3f30 (commit)
       via  2d75ef18b1d38d39e6bba7afd4cc80dd6037cd9e (commit)
       via  c0622576146b06b7c804967d2935005c9101441b (commit)
       via  98178b797b91aa75a55db2451cd81b781bb6c3b7 (commit)
       via  cea71a7b76f985526cd624cc875ecdffb79a308b (commit)
       via  46d1b68f8df7f52ff715c21f25533aafd1bce1ca (commit)
       via  bbffb8f54d06cbf78a13706be09c45d5acadd45b (commit)
       via  0921681fa8e1deaf26e6f030db57360f5190fa46 (commit)
      from  34e3d94eb31cd286c429f12c2a318f7a79dcec4b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit fb2b5ab1c9b1a2425dfc75a63cf7b46619352cc1
Author: Dmitry Gutov <address@hidden>
Date:   Sun Nov 10 12:00:20 2013 +0200

    Add diff-hl to externals-list

diff --git a/externals-list b/externals-list
index b05f150..a5eccd8 100644
--- a/externals-list
+++ b/externals-list
@@ -22,6 +22,7 @@
  ;;FIXME:("cedet"      :external "??")
  ("coffee-mode"                :subtree 
"https://github.com/defunkt/coffee-mode";)
  ("company"            :subtree 
"https://github.com/company-mode/company-mode.git";)
+ ("diff-hl"            :subtree "https://github.com/dgutov/diff-hl.git";)
  ("dismal"             :external nil)
  ("eldoc-eval"         :subtree 
"https://github.com/thierryvolpiatto/eldoc-eval.git";)
  ("enwc"               :subtree 
"bzr::bzr://bzr.savannah.nongnu.org/enwc/trunk")

commit 0a29a07b6f6d135b65b9180b084750a99de6bbd6
Merge: 34e3d94 80abec8
Author: Dmitry Gutov <address@hidden>
Date:   Sun Nov 10 12:01:40 2013 +0200

    Add 'packages/diff-hl/' from commit 
'80abec80ea5c060470a34e2d2ed593f1bb9dc5eb'
    
    git-subtree-dir: packages/diff-hl
    git-subtree-mainline: 34e3d94eb31cd286c429f12c2a318f7a79dcec4b
    git-subtree-split: 80abec80ea5c060470a34e2d2ed593f1bb9dc5eb

diff --cc packages/diff-hl/.elpaignore
index 0000000,fc72b33..fc72b33
mode 000000,100644..100644
--- a/packages/diff-hl/.elpaignore
+++ b/packages/diff-hl/.elpaignore
diff --cc packages/diff-hl/README.md
index 0000000,b01e8bd..b01e8bd
mode 000000,100644..100644
--- a/packages/diff-hl/README.md
+++ b/packages/diff-hl/README.md
diff --cc packages/diff-hl/diff-hl-amend.el
index 0000000,defb3f4..defb3f4
mode 000000,100644..100644
--- a/packages/diff-hl/diff-hl-amend.el
+++ b/packages/diff-hl/diff-hl-amend.el
diff --cc packages/diff-hl/diff-hl-dired.el
index 0000000,a31a7a6..a31a7a6
mode 000000,100644..100644
--- a/packages/diff-hl/diff-hl-dired.el
+++ b/packages/diff-hl/diff-hl-dired.el
diff --cc packages/diff-hl/diff-hl-margin.el
index 0000000,f805aab..f805aab
mode 000000,100644..100644
--- a/packages/diff-hl/diff-hl-margin.el
+++ b/packages/diff-hl/diff-hl-margin.el
diff --cc packages/diff-hl/diff-hl.el
index 0000000,41df9b9..41df9b9
mode 000000,100644..100644
--- a/packages/diff-hl/diff-hl.el
+++ b/packages/diff-hl/diff-hl.el
diff --cc packages/diff-hl/screenshot-dired.png
index 0000000,97df41b..97df41b
mode 000000,100644..100644
--- a/packages/diff-hl/screenshot-dired.png
+++ b/packages/diff-hl/screenshot-dired.png
diff --cc packages/diff-hl/screenshot-margin.png
index 0000000,6698a29..6698a29
mode 000000,100644..100644
--- a/packages/diff-hl/screenshot-margin.png
+++ b/packages/diff-hl/screenshot-margin.png
diff --cc packages/diff-hl/screenshot.png
index 0000000,5f99db7..5f99db7
mode 000000,100644..100644
--- a/packages/diff-hl/screenshot.png
+++ b/packages/diff-hl/screenshot.png

commit 80abec80ea5c060470a34e2d2ed593f1bb9dc5eb
Author: Dmitry Gutov <address@hidden>
Date:   Sun Nov 10 11:50:56 2013 +0200

    Update the copyright blurbs

diff --git a/diff-hl-amend.el b/diff-hl-amend.el
index 713f838..defb3f4 100644
--- a/diff-hl-amend.el
+++ b/diff-hl-amend.el
@@ -1,14 +1,16 @@
+;; Copyright (C) 2012-2013  Free Software Foundation, Inc.
+
 ;; Author:   Dmitry Gutov <address@hidden>
 ;; URL:      https://github.com/dgutov/diff-hl
 
-;; This file is not part of GNU Emacs.
+;; This file is part of GNU Emacs.
 
-;; This file is free software: you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
 ;; the Free Software Foundation, either version 3 of the License, or
 ;; (at your option) any later version.
 
-;; This file is distributed in the hope that it will be useful,
+;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ;; GNU General Public License for more details.
diff --git a/diff-hl-dired.el b/diff-hl-dired.el
index 047d0e8..a31a7a6 100644
--- a/diff-hl-dired.el
+++ b/diff-hl-dired.el
@@ -1,13 +1,15 @@
 ;;; diff-hl-dired.el --- Highlight changed files in Dired -*- lexical-binding: 
t -*-
 
-;; This file is not part of GNU Emacs.
+;; Copyright (C) 2012-2013  Free Software Foundation, Inc.
 
-;; This file is free software: you can redistribute it and/or modify
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
 ;; the Free Software Foundation, either version 3 of the License, or
 ;; (at your option) any later version.
 
-;; This file is distributed in the hope that it will be useful,
+;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ;; GNU General Public License for more details.
diff --git a/diff-hl-margin.el b/diff-hl-margin.el
index 22674e6..f805aab 100644
--- a/diff-hl-margin.el
+++ b/diff-hl-margin.el
@@ -1,13 +1,15 @@
 ;;; diff-hl-margin.el --- Highlight buffer changes on margins -*- 
lexical-binding: t -*-
 
-;; This file is not part of GNU Emacs.
+;; Copyright (C) 2012-2013  Free Software Foundation, Inc.
 
-;; This file is free software: you can redistribute it and/or modify
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
 ;; the Free Software Foundation, either version 3 of the License, or
 ;; (at your option) any later version.
 
-;; This file is distributed in the hope that it will be useful,
+;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ;; GNU General Public License for more details.
diff --git a/diff-hl.el b/diff-hl.el
index ecebb04..41df9b9 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -1,19 +1,21 @@
 ;;; diff-hl.el --- Highlight uncommitted changes -*- lexical-binding: t -*-
 
+;; Copyright (C) 2012-2013  Free Software Foundation, Inc.
+
 ;; Author:   Dmitry Gutov <address@hidden>
 ;; URL:      https://github.com/dgutov/diff-hl
 ;; Keywords: vc, diff
 ;; Version:  1.5.1
 ;; Package-Requires: ((cl-lib "0.2"))
 
-;; This file is not part of GNU Emacs.
+;; This file is part of GNU Emacs.
 
-;; This file is free software: you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
 ;; the Free Software Foundation, either version 3 of the License, or
 ;; (at your option) any later version.
 
-;; This file is distributed in the hope that it will be useful,
+;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ;; GNU General Public License for more details.

commit b2339aeece4bfa826aa82e7bf4a9ca26c2f0b2fb
Author: Dmitry Gutov <address@hidden>
Date:   Sun Nov 10 11:47:13 2013 +0200

    Bump the version, add .elpaignore, drop Makefile

diff --git a/.elpaignore b/.elpaignore
new file mode 100644
index 0000000..fc72b33
--- /dev/null
+++ b/.elpaignore
@@ -0,0 +1,2 @@
+README.md
+screenshot*
diff --git a/Makefile b/Makefile
deleted file mode 100644
index d3550ef..0000000
--- a/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-elpa: *.el
-       @version=`grep -o "Version: .*" diff-hl.el | cut -c 11- | tr -d '\r'`; \
-       dir=diff-hl-$$version; \
-       mkdir -p "$$dir"; \
-       cp -r diff-hl*.el diff-hl-$$version; \
-       echo "(define-package \"diff-hl\" \"$$version\" \
-       \"Highlight uncommitted changes\")" \
-       > "$$dir"/diff-hl-pkg.el; \
-       tar cvf diff-hl-$$version.tar --mode 644 "$$dir"
-
-clean:
-       @rm -rf diff-hl-*/ diff-hl-*.tar *.elc
diff --git a/diff-hl.el b/diff-hl.el
index d1db17c..ecebb04 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -3,7 +3,7 @@
 ;; Author:   Dmitry Gutov <address@hidden>
 ;; URL:      https://github.com/dgutov/diff-hl
 ;; Keywords: vc, diff
-;; Version:  1.5.0
+;; Version:  1.5.1
 ;; Package-Requires: ((cl-lib "0.2"))
 
 ;; This file is not part of GNU Emacs.

commit 83dc1adf52ca091f1f7deff212b4e1c0b4a408a5
Author: Dmitry Gutov <address@hidden>
Date:   Sun Oct 6 23:42:22 2013 +0300

    Allow users to choose which margin to use
    
    Closes #13

diff --git a/diff-hl-margin.el b/diff-hl-margin.el
index 6745742..22674e6 100644
--- a/diff-hl-margin.el
+++ b/diff-hl-margin.el
@@ -37,18 +37,33 @@
 
 (defvar diff-hl-margin-old-highlight-function nil)
 
+(defgroup diff-hl-margin nil
+  "Highlight buffer changes on margin"
+  :group 'diff-hl)
+
+(defcustom diff-hl-margin-side 'left
+  "Which margin to use for indicators."
+  :type '(choice (const left)
+                 (const right))
+  :set (lambda (var value)
+         (let ((on diff-hl-margin-mode))
+           (when on (diff-hl-margin-mode -1))
+           (set-default var value)
+           (when on (diff-hl-margin-mode 1)))))
+
 ;;;###autoload
 (define-minor-mode diff-hl-margin-mode
   "Toggle displaying `diff-hl-mode' highlights on the margin."
   :lighter "" :global t
-  (if diff-hl-margin-mode
-      (progn
-        (setq diff-hl-margin-old-highlight-function diff-hl-highlight-function
-              diff-hl-highlight-function 'diff-hl-highlight-on-margin)
-        (setq-default left-margin-width 1))
-    (setq diff-hl-highlight-function diff-hl-margin-old-highlight-function
-          diff-hl-margin-old-highlight-function nil)
-    (setq-default left-margin-width 0))
+  (let ((width-var (intern (format "%s-margin-width" diff-hl-margin-side))))
+    (if diff-hl-margin-mode
+        (progn
+          (setq diff-hl-margin-old-highlight-function 
diff-hl-highlight-function
+                diff-hl-highlight-function 'diff-hl-highlight-on-margin)
+          (set-default width-var 1))
+      (setq diff-hl-highlight-function diff-hl-margin-old-highlight-function
+            diff-hl-margin-old-highlight-function nil)
+      (set-default width-var 0)))
   (dolist (buffer (buffer-list))
     (with-current-buffer buffer
       (cond
@@ -61,15 +76,19 @@
 (defvar diff-hl-margin-spec-cache
   (loop for (type . char) in '((insert . "+") (delete . "-")
                                (change . "|") (unknown . "?"))
-        collect (cons type
-                      (propertize
-                       " " 'display
-                       `((margin left-margin)
-                         ,(propertize char 'face
-                                      (intern (format "diff-hl-%s" type))))))))
+        nconc
+        (loop for side in '(left right)
+              collect
+              (cons (cons type side)
+                    (propertize
+                     " " 'display
+                     `((margin ,(intern (format "%s-margin" side)))
+                       ,(propertize char 'face
+                                    (intern (format "diff-hl-%s" type)))))))))
 
 (defun diff-hl-highlight-on-margin (ovl type _shape)
-  (let ((spec (cdr (assoc type diff-hl-margin-spec-cache))))
+  (let ((spec (cdr (assoc (cons type diff-hl-margin-side)
+                          diff-hl-margin-spec-cache))))
     (overlay-put ovl 'before-string spec)))
 
 (provide 'diff-hl-margin)

commit c7e813c0d002cf55a8d0b038b1f007621c42501c
Author: Dmitry Gutov <address@hidden>
Date:   Fri Sep 27 03:13:26 2013 +0300

    Move blurb of text a bit up

diff --git a/README.md b/README.md
index ea3afb7..b01e8bd 100644
--- a/README.md
+++ b/README.md
@@ -24,11 +24,10 @@ Screenshots
 
 diff-hl-mode
 -----
+Top window: a buffer in this minor mode, bottom window: the corresponding diff.
 
 ![screenie](screenshot.png)
 
-Top window: a buffer in this minor mode, bottom window: the corresponding diff.
-
 diff-hl-dired-mode
 -----
 

commit 2a5c412650af7e698ba524da377acb4c7782384b
Author: Dmitry Gutov <address@hidden>
Date:   Fri Sep 27 03:12:16 2013 +0300

    Check in the Makefile
    
    Not that it does us much good 
(https://github.com/nicferrier/marmalade/issues/56)

diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..d3550ef
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,12 @@
+elpa: *.el
+       @version=`grep -o "Version: .*" diff-hl.el | cut -c 11- | tr -d '\r'`; \
+       dir=diff-hl-$$version; \
+       mkdir -p "$$dir"; \
+       cp -r diff-hl*.el diff-hl-$$version; \
+       echo "(define-package \"diff-hl\" \"$$version\" \
+       \"Highlight uncommitted changes\")" \
+       > "$$dir"/diff-hl-pkg.el; \
+       tar cvf diff-hl-$$version.tar --mode 644 "$$dir"
+
+clean:
+       @rm -rf diff-hl-*/ diff-hl-*.tar *.elc

commit 897b8a7c5efa1a77f347b6d32d35f26f10a617d8
Author: Dmitry Gutov <address@hidden>
Date:   Fri Sep 27 02:59:04 2013 +0300

    Bump the version

diff --git a/diff-hl.el b/diff-hl.el
index 17f8c20..d1db17c 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -3,7 +3,7 @@
 ;; Author:   Dmitry Gutov <address@hidden>
 ;; URL:      https://github.com/dgutov/diff-hl
 ;; Keywords: vc, diff
-;; Version:  1.4.6
+;; Version:  1.5.0
 ;; Package-Requires: ((cl-lib "0.2"))
 
 ;; This file is not part of GNU Emacs.

commit 85b8500dc1223e637a085ff64e5fbdbb87a3fecb
Author: Dmitry Gutov <address@hidden>
Date:   Fri Sep 27 02:55:54 2013 +0300

    Update the documentation, add new screenshots

diff --git a/README.md b/README.md
index de67c58..ea3afb7 100644
--- a/README.md
+++ b/README.md
@@ -1,20 +1,44 @@
 About
 =====
 
-`diff-hl-mode` highlights uncommitted changes on the left fringe of the window,
+`diff-hl-mode` highlights uncommitted changes on the left side of the window,
 allows you to jump between and revert them selectively.
 
-For the usage instructions and the list of commands, see the header comment.
+For the usage instructions and the list of commands, see the Commentary section
+inside the file.
 
 Tested with Git, Mercurial, Bazaar and SVN. May work with other VC backends, 
too.
 
-Screenshot
+The package also contains auxiliary modes:
+
+* `diff-hl-dired-mode` provides similar functionality in Dired.
+* `diff-hl-margin-mode` changes the highlighting function to
+  use the margin instead of the fringe.
+* `diff-hl-amend-mode` shifts the reference revision back by one.
+
+Check out the Commentary section in each respective file for the usage
+instructions.
+
+Screenshots
 =====
 
+diff-hl-mode
+-----
+
 ![screenie](screenshot.png)
 
 Top window: a buffer in this minor mode, bottom window: the corresponding diff.
 
+diff-hl-dired-mode
+-----
+
+![screenie](screenshot-dired.png)
+
+diff-hl-margin-mode
+-----
+
+![screenie](screenshot-margin.png)
+
 Requirements
 =====
 
@@ -28,8 +52,14 @@ Notes
   maybe we can do something similar to `highlight-markup-buffers` with a hidden
   buffer containing the unmodified copy.
 
+* We conflict with other modes when they put indicators on the fringe,
+  such as [Flycheck](https://github.com/flycheck/flycheck). This is
+  rarely a significant problem, since if you're using such a mode,
+  you'd usually want to fix all errors and warnings before continuing,
+  and then the conflicting indicators go away.
+
 * There's no fringe when Emacs is running in the console, but the navigation 
and
-  revert commands still work.
+  revert commands still work. Consider turning `diff-hl-margin-mode` on.
 
 * Frame-local and buffer-local values of `line-spacing` are not supported.
 
diff --git a/diff-hl-dired.el b/diff-hl-dired.el
index 066ff6f..047d0e8 100644
--- a/diff-hl-dired.el
+++ b/diff-hl-dired.el
@@ -27,7 +27,7 @@
 
 ;;;###autoload
 (define-minor-mode diff-hl-dired-mode
-  "Toggle VC diff fringe highlighting in a Dired buffer."
+  "Toggle VC diff highlighting on the side of a Dired window."
   :lighter ""
   (if diff-hl-dired-mode
       (progn
diff --git a/diff-hl.el b/diff-hl.el
index df2e34d..17f8c20 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -23,8 +23,9 @@
 
 ;;; Commentary:
 
-;; `diff-hl-mode' highlights uncommitted changes on the left fringe of the
-;; window, allows you to jump between the hunks and revert them selectively.
+;; `diff-hl-mode' highlights uncommitted changes on the left side of
+;; the window (using the fringe, by default), allows you to jump
+;; between the hunks and revert them selectively.
 
 ;; Provided commands:
 ;;
@@ -58,7 +59,7 @@
   (require 'face-remap))
 
 (defgroup diff-hl nil
-  "VC diff fringe highlighting"
+  "VC diff highlighting on the side of a window"
   :group 'vc)
 
 (defface diff-hl-insert
@@ -398,7 +399,7 @@ in the source file, or the last line of the hunk above it."
 
 ;;;###autoload
 (define-minor-mode diff-hl-mode
-  "Toggle VC diff fringe highlighting."
+  "Toggle VC diff highlighting."
   :lighter "" :keymap `(([remap vc-diff] . diff-hl-diff-goto-hunk)
                         (,(kbd "C-x v n") . diff-hl-revert-hunk)
                         (,(kbd "C-x v [") . diff-hl-previous-hunk)
diff --git a/screenshot-dired.png b/screenshot-dired.png
new file mode 100644
index 0000000..97df41b
Binary files /dev/null and b/screenshot-dired.png differ
diff --git a/screenshot-margin.png b/screenshot-margin.png
new file mode 100644
index 0000000..6698a29
Binary files /dev/null and b/screenshot-margin.png differ

commit ae54feeba092a31ea010507ea114722ee5a174aa
Author: Dmitry Gutov <address@hidden>
Date:   Wed Sep 25 05:15:50 2013 +0300

    diff-hl-margin-mode: Walk buffers outside of the if form

diff --git a/diff-hl-margin.el b/diff-hl-margin.el
index 57a0b70..6745742 100644
--- a/diff-hl-margin.el
+++ b/diff-hl-margin.el
@@ -45,24 +45,17 @@
       (progn
         (setq diff-hl-margin-old-highlight-function diff-hl-highlight-function
               diff-hl-highlight-function 'diff-hl-highlight-on-margin)
-        (setq-default left-margin-width 1)
-        (dolist (buffer (buffer-list))
-          (with-current-buffer buffer
-            (cond
-             (diff-hl-mode
-              (diff-hl-update))
-             (diff-hl-dired-mode
-              (diff-hl-dired-update))))))
+        (setq-default left-margin-width 1))
     (setq diff-hl-highlight-function diff-hl-margin-old-highlight-function
           diff-hl-margin-old-highlight-function nil)
-    (setq-default left-margin-width 0)
-    (dolist (buffer (buffer-list))
-      (with-current-buffer buffer
-        (cond
-         (diff-hl-mode
-          (diff-hl-update))
-         (diff-hl-dired-mode
-          (diff-hl-dired-update))))))
+    (setq-default left-margin-width 0))
+  (dolist (buffer (buffer-list))
+    (with-current-buffer buffer
+      (cond
+       (diff-hl-mode
+        (diff-hl-update))
+       (diff-hl-dired-mode
+        (diff-hl-dired-update)))))
   (walk-windows (lambda (win) (set-window-buffer win (window-buffer win)))))
 
 (defvar diff-hl-margin-spec-cache

commit a34d20ab9b079e152f816f3cdcd93b6a1d000683
Author: Dmitry Gutov <address@hidden>
Date:   Wed Sep 25 05:06:43 2013 +0300

    New global mode: diff-hl-margin

diff --git a/diff-hl-margin.el b/diff-hl-margin.el
new file mode 100644
index 0000000..57a0b70
--- /dev/null
+++ b/diff-hl-margin.el
@@ -0,0 +1,84 @@
+;;; diff-hl-margin.el --- Highlight buffer changes on margins -*- 
lexical-binding: t -*-
+
+;; This file is not part of GNU Emacs.
+
+;; This file is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This file is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This is a global mode, it modified `diff-hl-mode' to use the margin
+;; instead of the fringe. To toggle, type `M-x diff-hl-margin-mode'.
+;;
+;; Compared to the default behavior, this makes `diff-hl-mode'
+;; indicators show up even when Emacs is running in a terminal.
+;;
+;; On the flip side, the indicators look simpler, and they are
+;; incompatible with `linum-mode' or any other mode that uses the
+;; margin.
+;;
+;; You might want to enable it conditionally in your init file
+;; depending on whether Emacs is running in graphical mode:
+;;
+;; (unless (window-system) (diff-hl-margin-mode))
+
+(require 'diff-hl)
+(require 'diff-hl-dired)
+
+(defvar diff-hl-margin-old-highlight-function nil)
+
+;;;###autoload
+(define-minor-mode diff-hl-margin-mode
+  "Toggle displaying `diff-hl-mode' highlights on the margin."
+  :lighter "" :global t
+  (if diff-hl-margin-mode
+      (progn
+        (setq diff-hl-margin-old-highlight-function diff-hl-highlight-function
+              diff-hl-highlight-function 'diff-hl-highlight-on-margin)
+        (setq-default left-margin-width 1)
+        (dolist (buffer (buffer-list))
+          (with-current-buffer buffer
+            (cond
+             (diff-hl-mode
+              (diff-hl-update))
+             (diff-hl-dired-mode
+              (diff-hl-dired-update))))))
+    (setq diff-hl-highlight-function diff-hl-margin-old-highlight-function
+          diff-hl-margin-old-highlight-function nil)
+    (setq-default left-margin-width 0)
+    (dolist (buffer (buffer-list))
+      (with-current-buffer buffer
+        (cond
+         (diff-hl-mode
+          (diff-hl-update))
+         (diff-hl-dired-mode
+          (diff-hl-dired-update))))))
+  (walk-windows (lambda (win) (set-window-buffer win (window-buffer win)))))
+
+(defvar diff-hl-margin-spec-cache
+  (loop for (type . char) in '((insert . "+") (delete . "-")
+                               (change . "|") (unknown . "?"))
+        collect (cons type
+                      (propertize
+                       " " 'display
+                       `((margin left-margin)
+                         ,(propertize char 'face
+                                      (intern (format "diff-hl-%s" type))))))))
+
+(defun diff-hl-highlight-on-margin (ovl type _shape)
+  (let ((spec (cdr (assoc type diff-hl-margin-spec-cache))))
+    (overlay-put ovl 'before-string spec)))
+
+(provide 'diff-hl-margin)
+
+;;; diff-hl-margin.el ends here

commit 99684245590ae41898aca17ea5a79d9d2fc59afa
Author: Dmitry Gutov <address@hidden>
Date:   Tue Sep 24 04:35:51 2013 +0300

    Introduce diff-hl-highlight-function

diff --git a/diff-hl.el b/diff-hl.el
index f9d65fc..df2e34d 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -91,6 +91,12 @@
   :group 'diff-hl
   :type 'boolean)
 
+(defcustom diff-hl-highlight-function 'diff-hl-highlight-on-fringe
+  "Function to highlight the current line. Its arguments are
+  overlay, change type and position within a hunk."
+  :group 'diff-hl
+  :type 'function)
+
 (defcustom diff-hl-fringe-bmp-function 'diff-hl-fringe-bmp-from-pos
   "Function to choose the fringe bitmap for a given change type
   and position within a hunk.  Should accept two arguments."
@@ -252,9 +258,12 @@
 (defun diff-hl-add-highlighting (type shape)
   (let ((o (make-overlay (point) (point))))
     (overlay-put o 'diff-hl t)
-    (overlay-put o 'before-string (diff-hl-fringe-spec type shape))
+    (funcall diff-hl-highlight-function o type shape)
     o))
 
+(defun diff-hl-highlight-on-fringe (ovl type shape)
+  (overlay-put ovl 'before-string (diff-hl-fringe-spec type shape)))
+
 (defun diff-hl-remove-overlays ()
   (dolist (o (overlays-in (point-min) (point-max)))
     (when (overlay-get o 'diff-hl) (delete-overlay o))))

commit cc09724f6c9972999fffd3df7cbba85f2f99db33
Author: Dmitry Gutov <address@hidden>
Date:   Tue Sep 10 05:47:12 2013 +0300

    * diff-hl-mode: Extract diff-hl-maybe-define-bitmaps.
    * diff-hl-dired-mode: Use it.
    
    #6

diff --git a/diff-hl-dired.el b/diff-hl-dired.el
index a3b766f..066ff6f 100644
--- a/diff-hl-dired.el
+++ b/diff-hl-dired.el
@@ -31,6 +31,7 @@
   :lighter ""
   (if diff-hl-dired-mode
       (progn
+        (diff-hl-maybe-define-bitmaps)
         (set (make-local-variable 'diff-hl-dired-process-buffer) nil)
         (add-hook 'dired-after-readin-hook 'diff-hl-dired-update nil t))
     (remove-hook 'dired-after-readin-hook 'diff-hl-dired-update t)
diff --git a/diff-hl.el b/diff-hl.el
index 4bfde1a..f9d65fc 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -140,6 +140,12 @@
       (define-fringe-bitmap 'diff-hl-bmp-change (make-vector
                                                  w2 (* 3 middle-bit)) w2 w2))))
 
+(defun diff-hl-maybe-define-bitmaps ()
+  (when (window-system) ;; No fringes in the console.
+    (unless (fringe-bitmap-p 'diff-hl-bmp-empty)
+      (diff-hl-define-bitmaps)
+      (define-fringe-bitmap 'diff-hl-bmp-empty [0] 1 1 'center))))
+
 (defvar diff-hl-spec-cache (make-hash-table :test 'equal))
 
 (defun diff-hl-fringe-spec (type pos)
@@ -390,10 +396,7 @@ in the source file, or the last line of the hunk above it."
                         (,(kbd "C-x v ]") . diff-hl-next-hunk))
   (if diff-hl-mode
       (progn
-        (when (window-system) ;; No fringes in the console.
-          (unless (fringe-bitmap-p 'diff-hl-bmp-empty)
-            (diff-hl-define-bitmaps)
-            (define-fringe-bitmap 'diff-hl-bmp-empty [0] 1 1 'center)))
+        (diff-hl-maybe-define-bitmaps)
         (add-hook 'after-save-hook 'diff-hl-update nil t)
         (add-hook 'after-change-functions 'diff-hl-edit nil t)
         (if vc-mode

commit 46a07e9320b2ca5f1a99b07c5f3c024ea4ee2148
Author: Dmitry Gutov <address@hidden>
Date:   Mon Sep 9 00:13:30 2013 +0300

    Scale to non-default fringe sizes better

diff --git a/diff-hl.el b/diff-hl.el
index 95eb871..4bfde1a 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -131,14 +131,14 @@
            (middle-pos (1- (/ w2 2)))
            (middle-bit (expt 2 middle-pos))
            (insert-bmp (make-vector w2 (* 3 middle-bit))))
-      (define-fringe-bitmap 'diff-hl-bmp-delete (make-vector 2 delete-row))
+      (define-fringe-bitmap 'diff-hl-bmp-delete (make-vector 2 delete-row) w2 
w2)
       (aset insert-bmp 0 0)
       (aset insert-bmp middle-pos delete-row)
       (aset insert-bmp (1+ middle-pos) delete-row)
       (aset insert-bmp (1- w2) 0)
-      (define-fringe-bitmap 'diff-hl-bmp-insert insert-bmp)
+      (define-fringe-bitmap 'diff-hl-bmp-insert insert-bmp w2 w2)
       (define-fringe-bitmap 'diff-hl-bmp-change (make-vector
-                                                 w2 (* 3 middle-bit))))))
+                                                 w2 (* 3 middle-bit)) w2 w2))))
 
 (defvar diff-hl-spec-cache (make-hash-table :test 'equal))
 

commit 0feda0686f359de86b936ccb1ca0a87b2fa7bf6b
Author: Dmitry Gutov <address@hidden>
Date:   Sun Sep 8 08:11:34 2013 +0300

    diff-hl-define-bitmaps: Fix the latest additions

diff --git a/diff-hl.el b/diff-hl.el
index 583fd14..95eb871 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -126,16 +126,19 @@
     (define-fringe-bitmap 'diff-hl-bmp-middle middle h w 'center)
     (define-fringe-bitmap 'diff-hl-bmp-bottom bottom h w 'bottom)
     (define-fringe-bitmap 'diff-hl-bmp-single single h w 'top)
-    (let* ((w2 (- w 2))
-           (delete-row (1- (expr 2 w2)))
-           (middle-bit (expt 2 (1- (/ w2 2))))
-           (insert-bmp (make-vector 2 (* 3 middle-bit))))
+    (let* ((w2 (* (/ w 2) 2))
+           (delete-row (- (expt 2 (1- w2)) 2))
+           (middle-pos (1- (/ w2 2)))
+           (middle-bit (expt 2 middle-pos))
+           (insert-bmp (make-vector w2 (* 3 middle-bit))))
       (define-fringe-bitmap 'diff-hl-bmp-delete (make-vector 2 delete-row))
-      (aset insert-bmp middle-bit delete-row)
-      (aset insert-bmp (1+ middle-bit) delete-row)
+      (aset insert-bmp 0 0)
+      (aset insert-bmp middle-pos delete-row)
+      (aset insert-bmp (1+ middle-pos) delete-row)
+      (aset insert-bmp (1- w2) 0)
       (define-fringe-bitmap 'diff-hl-bmp-insert insert-bmp)
       (define-fringe-bitmap 'diff-hl-bmp-change (make-vector
-                                                 w (* 3 middle-bit))))))
+                                                 w2 (* 3 middle-bit))))))
 
 (defvar diff-hl-spec-cache (make-hash-table :test 'equal))
 

commit 64582ebadef24cdbb1e3b8d2369d7d31627b1b18
Author: Dmitry Gutov <address@hidden>
Date:   Sun Sep 8 07:39:05 2013 +0300

    * diff-hl-add-highlighting: Return the overlay
    * diff-hl-dired-highlight-items: Make sure the overlay will disappear
      if the file is deleted.

diff --git a/diff-hl-dired.el b/diff-hl-dired.el
index 6699102..a3b766f 100644
--- a/diff-hl-dired.el
+++ b/diff-hl-dired.el
@@ -87,9 +87,10 @@
         (goto-char (point-min))
         (when (and type (dired-goto-file-1
                          file (expand-file-name file) nil))
-          (forward-line 0)
-          (let ((diff-hl-fringe-bmp-function 'diff-hl-fringe-bmp-from-type))
-            (diff-hl-add-highlighting type 'single)))))))
+          (let* ((diff-hl-fringe-bmp-function 'diff-hl-fringe-bmp-from-type)
+                 (o (diff-hl-add-highlighting type 'single)))
+            (overlay-put o 'modification-hooks '(diff-hl-overlay-modified))
+            ))))))
 
 (defalias 'diff-hl-dired-clear 'diff-hl-remove-overlays)
 
diff --git a/diff-hl.el b/diff-hl.el
index 87f15bf..583fd14 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -243,7 +243,8 @@
 (defun diff-hl-add-highlighting (type shape)
   (let ((o (make-overlay (point) (point))))
     (overlay-put o 'diff-hl t)
-    (overlay-put o 'before-string (diff-hl-fringe-spec type shape))))
+    (overlay-put o 'before-string (diff-hl-fringe-spec type shape))
+    o))
 
 (defun diff-hl-remove-overlays ()
   (dolist (o (overlays-in (point-min) (point-max)))

commit 0901cb7a2f5949192c2004933bf3d6463e9a7937
Author: Dmitry Gutov <address@hidden>
Date:   Sun Sep 8 06:42:54 2013 +0300

    diff-hl-unknown: Inherit from diff-header
    
    Its background color lightness matches others better.

diff --git a/diff-hl.el b/diff-hl.el
index d75c3bc..87f15bf 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -83,7 +83,7 @@
   :group 'diff-hl)
 
 (defface diff-hl-unknown
-  '((default :inherit diff-nonexistent))
+  '((default :inherit diff-header))
   "Face used to highlight unregistered files.")
 
 (defcustom diff-hl-draw-borders t

commit 558c909c4d5bd0210af3ef74568645cba0a5d6a5
Author: Dmitry Gutov <address@hidden>
Date:   Sun Sep 8 06:36:30 2013 +0300

    diff-hl-dired-highlight-items: Use diff-hl-fringe-bmp-from-type

diff --git a/diff-hl-dired.el b/diff-hl-dired.el
index e27a308..6699102 100644
--- a/diff-hl-dired.el
+++ b/diff-hl-dired.el
@@ -88,7 +88,8 @@
         (when (and type (dired-goto-file-1
                          file (expand-file-name file) nil))
           (forward-line 0)
-          (diff-hl-add-highlighting type 'single))))))
+          (let ((diff-hl-fringe-bmp-function 'diff-hl-fringe-bmp-from-type))
+            (diff-hl-add-highlighting type 'single)))))))
 
 (defalias 'diff-hl-dired-clear 'diff-hl-remove-overlays)
 

commit 6acd02b1705b35b1050478c855630d3889d0e337
Author: Dmitry Gutov <address@hidden>
Date:   Sun Sep 8 06:33:41 2013 +0300

    diff-hl-fringe-bmp-function: New option
    
    * diff-hl-define-bitmaps: Add new bitmaps.
    * diff-hl-fringe-bmp-from-pos, diff-hl-fringe-bmp-from-type: New functions.
    * diff-hl-fringe-spec: Include fringe-bmp-function in the hash key.

diff --git a/diff-hl.el b/diff-hl.el
index ea7a1b5..d75c3bc 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -91,6 +91,14 @@
   :group 'diff-hl
   :type 'boolean)
 
+(defcustom diff-hl-fringe-bmp-function 'diff-hl-fringe-bmp-from-pos
+  "Function to choose the fringe bitmap for a given change type
+  and position within a hunk.  Should accept two arguments."
+  :group 'diff-hl
+  :type '(choice (const diff-hl-fringe-bmp-from-pos)
+                 (const diff-hl-fringe-bmp-from-type)
+                 function))
+
 (defvar diff-hl-reference-revision nil
   "Revision to diff against.  nil means the most recent one.")
 
@@ -117,20 +125,38 @@
     (define-fringe-bitmap 'diff-hl-bmp-top top h w 'top)
     (define-fringe-bitmap 'diff-hl-bmp-middle middle h w 'center)
     (define-fringe-bitmap 'diff-hl-bmp-bottom bottom h w 'bottom)
-    (define-fringe-bitmap 'diff-hl-bmp-single single h w 'top)))
+    (define-fringe-bitmap 'diff-hl-bmp-single single h w 'top)
+    (let* ((w2 (- w 2))
+           (delete-row (1- (expr 2 w2)))
+           (middle-bit (expt 2 (1- (/ w2 2))))
+           (insert-bmp (make-vector 2 (* 3 middle-bit))))
+      (define-fringe-bitmap 'diff-hl-bmp-delete (make-vector 2 delete-row))
+      (aset insert-bmp middle-bit delete-row)
+      (aset insert-bmp (1+ middle-bit) delete-row)
+      (define-fringe-bitmap 'diff-hl-bmp-insert insert-bmp)
+      (define-fringe-bitmap 'diff-hl-bmp-change (make-vector
+                                                 w (* 3 middle-bit))))))
 
 (defvar diff-hl-spec-cache (make-hash-table :test 'equal))
 
 (defun diff-hl-fringe-spec (type pos)
-  (let* ((key (cons type pos))
+  (let* ((key (list type pos diff-hl-fringe-bmp-function))
          (val (gethash key diff-hl-spec-cache)))
     (unless val
-      (let* ((face-sym (intern (concat "diff-hl-" (symbol-name type))))
-             (bmp-sym (intern (concat "diff-hl-bmp-" (symbol-name pos)))))
+      (let* ((face-sym (intern (format "diff-hl-%s" type)))
+             (bmp-sym (funcall diff-hl-fringe-bmp-function type pos)))
         (setq val (propertize " " 'display `((left-fringe ,bmp-sym 
,face-sym))))
         (puthash key val diff-hl-spec-cache)))
     val))
 
+(defun diff-hl-fringe-bmp-from-pos (type pos)
+  (intern (format "diff-hl-bmp-%s" pos)))
+
+(defun diff-hl-fringe-bmp-from-type (type pos)
+  (if (eq type 'unknown)
+      'question-mark
+    (intern (format "diff-hl-bmp-%s" type))))
+
 (defmacro diff-hl-with-diff-switches (body)
   `(let ((vc-git-diff-switches nil)
          (vc-hg-diff-switches nil)

commit 545941781e3a4cc853fbcc1e35d5d6ac0f316c41
Author: Dmitry Gutov <address@hidden>
Date:   Sun Sep 8 02:23:54 2013 +0300

    diff-hl-dired-update: Only process the results once

diff --git a/diff-hl-dired.el b/diff-hl-dired.el
index 94723c4..e27a308 100644
--- a/diff-hl-dired.el
+++ b/diff-hl-dired.el
@@ -71,11 +71,11 @@
                            (if (null value)
                                (push (cons dir type) dirs-alist)
                              (setcdr (assoc dir dirs-alist) 'change))))
-                     (push (cons file type) files-alist))
-                   ;; Process's finished, time to use the results.
-                   (unless (get-buffer-process diff-hl-dired-process-buffer)
-                     (diff-hl-dired-highlight-items (append dirs-alist
-                                                            files-alist))))))))
+                     (push (cons file type) files-alist)))))
+             ;; Process's finished, time to use the results.
+             (unless (get-buffer-process diff-hl-dired-process-buffer)
+               (diff-hl-dired-highlight-items (append dirs-alist
+                                                      files-alist)))))
          )))))
 
 (defun diff-hl-dired-highlight-items (alist)

commit c204f8f923bc87b106b5706dd3e82d89fd2d15a2
Author: Dmitry Gutov <address@hidden>
Date:   Fri Sep 6 12:03:16 2013 +0300

    diff-hl-amend-mode: Don't defer via find-file-hook
    
    Simpler model at the cost of +1 external process call (#11).

diff --git a/diff-hl-amend.el b/diff-hl-amend.el
index 3f65cb7..713f838 100644
--- a/diff-hl-amend.el
+++ b/diff-hl-amend.el
@@ -34,11 +34,8 @@ Currently only supports Git, Mercurial and Bazaar."
   :lighter " Amend"
   (if diff-hl-amend-mode
       (progn
-        (if vc-mode
-            (diff-hl-amend-setup)
-          (add-hook 'find-file-hook 'diff-hl-amend-setup nil t))
+        (diff-hl-amend-setup)
         (add-hook 'after-revert-hook 'diff-hl-amend-setup nil t))
-    (remove-hook 'find-file-hook 'diff-hl-amend-setup t)
     (remove-hook 'after-revert-hook 'diff-hl-amend-setup t)
     (setq-local diff-hl-reference-revision nil))
   (when diff-hl-mode

commit 906b14fe069f196eeeaca1fe26537994ee308ac0
Author: Dmitry Gutov <address@hidden>
Date:   Fri Sep 6 00:46:34 2013 +0300

    diff-hl-dired-highlight-items: Use the `single' type
    
    * Because having changes in several disjoint files is the most usual
      situation, and they look better this way.
    
    * It doesn't look too good with several adjacent changed files. Maybe
      do some smart grouping preprocessing later.

diff --git a/diff-hl-dired.el b/diff-hl-dired.el
index bca7536..94723c4 100644
--- a/diff-hl-dired.el
+++ b/diff-hl-dired.el
@@ -88,7 +88,7 @@
         (when (and type (dired-goto-file-1
                          file (expand-file-name file) nil))
           (forward-line 0)
-          (diff-hl-add-highlighting type 'middle))))))
+          (diff-hl-add-highlighting type 'single))))))
 
 (defalias 'diff-hl-dired-clear 'diff-hl-remove-overlays)
 

commit 15d21070b0ca5e947d75815fb76ff8c9617a9a1e
Author: Dmitry Gutov <address@hidden>
Date:   Thu Sep 5 11:53:39 2013 +0300

    Autoload diff-hl-dired-mode

diff --git a/diff-hl-dired.el b/diff-hl-dired.el
index 20a08a5..bca7536 100644
--- a/diff-hl-dired.el
+++ b/diff-hl-dired.el
@@ -25,6 +25,7 @@
 
 (require 'diff-hl)
 
+;;;###autoload
 (define-minor-mode diff-hl-dired-mode
   "Toggle VC diff fringe highlighting in a Dired buffer."
   :lighter ""

commit f486ccc8df2bdf8c4322d46c135a114a4f749873
Author: Dmitry Gutov <address@hidden>
Date:   Thu Sep 5 04:46:53 2013 +0300

    Highlight unregistered files in diff-hl-dired

diff --git a/diff-hl-dired.el b/diff-hl-dired.el
index ccdd8aa..20a08a5 100644
--- a/diff-hl-dired.el
+++ b/diff-hl-dired.el
@@ -60,7 +60,8 @@
              (dolist (entry entries)
                (cl-destructuring-bind (file state &rest) entry
                  (let ((type (plist-get
-                              '(edited change added insert removed delete)
+                              '(edited change added insert removed delete
+                                unregistered unknown)
                               state)))
                    (if (string-match "\\`\\([^/]+\\)/" file)
                        (let* ((dir (match-string 1 file))
diff --git a/diff-hl.el b/diff-hl.el
index 310bb56..ea7a1b5 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -82,6 +82,10 @@
   "Face used to highlight changed lines."
   :group 'diff-hl)
 
+(defface diff-hl-unknown
+  '((default :inherit diff-nonexistent))
+  "Face used to highlight unregistered files.")
+
 (defcustom diff-hl-draw-borders t
   "Non-nil to draw borders around fringe indicators."
   :group 'diff-hl

commit 75877484c38ee161fafa1ec526f7be998dd4d83d
Author: Dmitry Gutov <address@hidden>
Date:   Thu Sep 5 03:47:37 2013 +0300

    * Use one diff-hl-dired-process-buffer per dired buffer.
    * Use `vc-responsible-backend', remove `diff-hl-dired-files'.
    * Highlight subdirectories depending on files they contain.
    
    Closes #6

diff --git a/diff-hl-dired.el b/diff-hl-dired.el
index dac2491..ccdd8aa 100644
--- a/diff-hl-dired.el
+++ b/diff-hl-dired.el
@@ -17,9 +17,6 @@
 
 ;;; Commentary:
 
-;; FIXME: Raises "Stack overflow in equal" error in Emacs 24.3.50.2
-;; (at least) when changing directory.
-;;
 ;; To enable in all Dired buffers, add this to your init file:
 ;;
 ;; (add-hook 'dired-mode-hook 'diff-hl-dired-mode)
@@ -33,48 +30,66 @@
   :lighter ""
   (if diff-hl-dired-mode
       (progn
-        (add-hook 'dired-after-readin-hook 'diff-hl-dired-update nil t)
-        (diff-hl-dired-update))
+        (set (make-local-variable 'diff-hl-dired-process-buffer) nil)
+        (add-hook 'dired-after-readin-hook 'diff-hl-dired-update nil t))
     (remove-hook 'dired-after-readin-hook 'diff-hl-dired-update t)
     (diff-hl-dired-clear)))
 
 (defvar diff-hl-dired-process-buffer nil)
 
 (defun diff-hl-dired-update ()
-  (let ((backend (cl-loop for file in (diff-hl-dired-files)
-                          for backend = (vc-backend file)
-                          thereis backend))
+  "Highlight the Dired buffer."
+  (let ((backend (ignore-errors (vc-responsible-backend default-directory)))
         (def-dir default-directory)
-        (buffer (current-buffer)))
-    (diff-hl-dired-clear)
-    (unless (buffer-live-p diff-hl-dired-process-buffer)
-      (setq diff-hl-dired-process-buffer
-            (generate-new-buffer " *diff-hl-dired* tmp status")))
-    (with-current-buffer diff-hl-dired-process-buffer
-      (setq default-directory (expand-file-name def-dir))
-      (erase-buffer)
-      (vc-call-backend
-       backend 'dir-status def-dir
-       (lambda (entries &optional more-to-come)
-         (with-current-buffer buffer
-           (dolist (entry entries)
-             (cl-destructuring-bind (file state &rest) entry
-               (let ((type (plist-get
-                            '(edited change added insert removed delete)
-                            state)))
-                 (save-excursion
-                   (goto-char (point-min))
-                   (when (and type (dired-goto-file-1 file
-                                                      (expand-file-name file)
-                                                      (point-max)))
-                     (diff-hl-add-highlighting type 'middle))))))))))))
+        (buffer (current-buffer))
+        dirs-alist files-alist)
+    (when backend
+      (diff-hl-dired-clear)
+      (if (buffer-live-p diff-hl-dired-process-buffer)
+          (let ((proc (get-buffer-process diff-hl-dired-process-buffer)))
+            (when proc (kill-process proc)))
+        (setq diff-hl-dired-process-buffer
+              (generate-new-buffer " *diff-hl-dired* tmp status")))
+      (with-current-buffer diff-hl-dired-process-buffer
+        (setq default-directory (expand-file-name def-dir))
+        (erase-buffer)
+        (vc-call-backend
+         backend 'dir-status def-dir
+         (lambda (entries &optional more-to-come)
+           (with-current-buffer buffer
+             (dolist (entry entries)
+               (cl-destructuring-bind (file state &rest) entry
+                 (let ((type (plist-get
+                              '(edited change added insert removed delete)
+                              state)))
+                   (if (string-match "\\`\\([^/]+\\)/" file)
+                       (let* ((dir (match-string 1 file))
+                              (value (cdr (assoc dir dirs-alist))))
+                         (unless (eq value type)
+                           (if (null value)
+                               (push (cons dir type) dirs-alist)
+                             (setcdr (assoc dir dirs-alist) 'change))))
+                     (push (cons file type) files-alist))
+                   ;; Process's finished, time to use the results.
+                   (unless (get-buffer-process diff-hl-dired-process-buffer)
+                     (diff-hl-dired-highlight-items (append dirs-alist
+                                                            files-alist))))))))
+         )))))
 
-(defalias 'diff-hl-dired-clear 'diff-hl-remove-overlays)
+(defun diff-hl-dired-highlight-items (alist)
+  "Highlight ALIST containing (FILE . TYPE) elements."
+  (dolist (pair alist)
+    (let ((file (car pair))
+          (type (cdr pair)))
+      (save-excursion
+        (goto-char (point-min))
+        (when (and type (dired-goto-file-1
+                         file (expand-file-name file) nil))
+          (forward-line 0)
+          (diff-hl-add-highlighting type 'middle))))))
 
-(defun diff-hl-dired-files ()
-  (cl-loop for file in (directory-files default-directory)
-           when (and (file-exists-p file)
-                     (not (file-directory-p file)))
-           collect (expand-file-name file)))
+(defalias 'diff-hl-dired-clear 'diff-hl-remove-overlays)
 
 (provide 'diff-hl-dired)
+
+;;; diff-hl-dired.el ends here

commit 7bd2e96638843a28ee75e663856f417bdcaf1de2
Author: Dmitry Gutov <address@hidden>
Date:   Wed Sep 4 16:29:26 2013 +0300

    diff-hl-amend-mode: Reword the docstring

diff --git a/diff-hl-amend.el b/diff-hl-amend.el
index 5accf3b..3f65cb7 100644
--- a/diff-hl-amend.el
+++ b/diff-hl-amend.el
@@ -28,8 +28,8 @@
 ;;;###autoload
 (define-minor-mode diff-hl-amend-mode
   "Show changes against the second-last revision in `diff-hl-mode'.
-Most useful with VCSes that support rewriting local commits, and
-'amending' the most recent one in particular.
+Most useful with backends that support rewriting local commits,
+and most importantly, 'amending' the most recent one.
 Currently only supports Git, Mercurial and Bazaar."
   :lighter " Amend"
   (if diff-hl-amend-mode

commit 720de3aac501027b38da3f165d25c65356740bad
Author: Dmitry Gutov <address@hidden>
Date:   Wed Sep 4 16:02:04 2013 +0300

    Autoload diff-hl-mode

diff --git a/diff-hl.el b/diff-hl.el
index 92b91af..310bb56 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -347,6 +347,7 @@ in the source file, or the last line of the hunk above it."
   (interactive)
   (diff-hl-next-hunk t))
 
+;;;###autoload
 (define-minor-mode diff-hl-mode
   "Toggle VC diff fringe highlighting."
   :lighter "" :keymap `(([remap vc-diff] . diff-hl-diff-goto-hunk)

commit 7b83bf62590dc56081f99dd075b5f1fb712fab79
Author: Dmitry Gutov <address@hidden>
Date:   Wed Sep 4 16:00:44 2013 +0300

    Initial implementation of diff-hl-dired-mode
    
    #6

diff --git a/diff-hl-dired.el b/diff-hl-dired.el
new file mode 100644
index 0000000..dac2491
--- /dev/null
+++ b/diff-hl-dired.el
@@ -0,0 +1,80 @@
+;;; diff-hl-dired.el --- Highlight changed files in Dired -*- lexical-binding: 
t -*-
+
+;; This file is not part of GNU Emacs.
+
+;; This file is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This file is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; FIXME: Raises "Stack overflow in equal" error in Emacs 24.3.50.2
+;; (at least) when changing directory.
+;;
+;; To enable in all Dired buffers, add this to your init file:
+;;
+;; (add-hook 'dired-mode-hook 'diff-hl-dired-mode)
+
+;;; Code:
+
+(require 'diff-hl)
+
+(define-minor-mode diff-hl-dired-mode
+  "Toggle VC diff fringe highlighting in a Dired buffer."
+  :lighter ""
+  (if diff-hl-dired-mode
+      (progn
+        (add-hook 'dired-after-readin-hook 'diff-hl-dired-update nil t)
+        (diff-hl-dired-update))
+    (remove-hook 'dired-after-readin-hook 'diff-hl-dired-update t)
+    (diff-hl-dired-clear)))
+
+(defvar diff-hl-dired-process-buffer nil)
+
+(defun diff-hl-dired-update ()
+  (let ((backend (cl-loop for file in (diff-hl-dired-files)
+                          for backend = (vc-backend file)
+                          thereis backend))
+        (def-dir default-directory)
+        (buffer (current-buffer)))
+    (diff-hl-dired-clear)
+    (unless (buffer-live-p diff-hl-dired-process-buffer)
+      (setq diff-hl-dired-process-buffer
+            (generate-new-buffer " *diff-hl-dired* tmp status")))
+    (with-current-buffer diff-hl-dired-process-buffer
+      (setq default-directory (expand-file-name def-dir))
+      (erase-buffer)
+      (vc-call-backend
+       backend 'dir-status def-dir
+       (lambda (entries &optional more-to-come)
+         (with-current-buffer buffer
+           (dolist (entry entries)
+             (cl-destructuring-bind (file state &rest) entry
+               (let ((type (plist-get
+                            '(edited change added insert removed delete)
+                            state)))
+                 (save-excursion
+                   (goto-char (point-min))
+                   (when (and type (dired-goto-file-1 file
+                                                      (expand-file-name file)
+                                                      (point-max)))
+                     (diff-hl-add-highlighting type 'middle))))))))))))
+
+(defalias 'diff-hl-dired-clear 'diff-hl-remove-overlays)
+
+(defun diff-hl-dired-files ()
+  (cl-loop for file in (directory-files default-directory)
+           when (and (file-exists-p file)
+                     (not (file-directory-p file)))
+           collect (expand-file-name file)))
+
+(provide 'diff-hl-dired)
diff --git a/diff-hl.el b/diff-hl.el
index 506ae31..92b91af 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -191,17 +191,14 @@
           (setq current-line line)
           (let ((hunk-beg (point)))
             (while (cl-plusp len)
-              (let ((o (make-overlay (point) (point))))
-                (overlay-put o 'diff-hl t)
-                (overlay-put o 'before-string
-                             (diff-hl-fringe-spec
-                              type
-                              (cond
-                               ((not diff-hl-draw-borders) 'empty)
-                               ((and (= len 1) (= line current-line)) 'single)
-                               ((= len 1) 'bottom)
-                               ((= line current-line) 'top)
-                               (t 'middle)))))
+              (diff-hl-add-highlighting
+               type
+               (cond
+                ((not diff-hl-draw-borders) 'empty)
+                ((and (= len 1) (= line current-line)) 'single)
+                ((= len 1) 'bottom)
+                ((= line current-line) 'top)
+                (t 'middle)))
               (forward-line 1)
               (cl-incf current-line)
               (cl-decf len))
@@ -213,6 +210,11 @@
               (overlay-put h 'insert-in-front-hooks hook)
               (overlay-put h 'insert-behind-hooks hook))))))))
 
+(defun diff-hl-add-highlighting (type shape)
+  (let ((o (make-overlay (point) (point))))
+    (overlay-put o 'diff-hl t)
+    (overlay-put o 'before-string (diff-hl-fringe-spec type shape))))
+
 (defun diff-hl-remove-overlays ()
   (dolist (o (overlays-in (point-min) (point-max)))
     (when (overlay-get o 'diff-hl) (delete-overlay o))))

commit cf9d8ecf1377a83d1233bc08c9e4a16afb7dda93
Author: Dmitry Gutov <address@hidden>
Date:   Wed Sep 4 04:06:14 2013 +0300

    diff-hl-amend: Add explicit (require)

diff --git a/diff-hl-amend.el b/diff-hl-amend.el
index ba93298..5accf3b 100644
--- a/diff-hl-amend.el
+++ b/diff-hl-amend.el
@@ -23,6 +23,8 @@
 
 ;;; Code:
 
+(require 'diff-hl)
+
 ;;;###autoload
 (define-minor-mode diff-hl-amend-mode
   "Show changes against the second-last revision in `diff-hl-mode'.

commit 6857ec54fbda11ea4d9379bc644ca5ae3db61c64
Author: Dmitry Gutov <address@hidden>
Date:   Tue Sep 3 19:34:54 2013 +0300

    diff-hl-amend-set{,up}

diff --git a/diff-hl-amend.el b/diff-hl-amend.el
index 9967341..ba93298 100644
--- a/diff-hl-amend.el
+++ b/diff-hl-amend.el
@@ -33,7 +33,7 @@ Currently only supports Git, Mercurial and Bazaar."
   (if diff-hl-amend-mode
       (progn
         (if vc-mode
-            (diff-hl-amend-set)
+            (diff-hl-amend-setup)
           (add-hook 'find-file-hook 'diff-hl-amend-setup nil t))
         (add-hook 'after-revert-hook 'diff-hl-amend-setup nil t))
     (remove-hook 'find-file-hook 'diff-hl-amend-setup t)

commit 20f500de6f9fc4a0414875b5ed052597c8622638
Author: Dmitry Gutov <address@hidden>
Date:   Tue Sep 3 19:31:18 2013 +0300

    Add the footer

diff --git a/diff-hl-amend.el b/diff-hl-amend.el
index f3a151b..9967341 100644
--- a/diff-hl-amend.el
+++ b/diff-hl-amend.el
@@ -61,3 +61,7 @@ Currently only supports Git, Mercurial and Bazaar."
 (defun turn-on-diff-hl-amend-mode ()
   "Turn on `diff-hl-amend-mode' in a buffer if appropriate."
   (and buffer-file-name (diff-hl-amend-mode 1)))
+
+(provide 'diff-hl-amend)
+
+;;; diff-hl-amend.el ends here

commit 20857ea5f2f8d348f93feecacaa5e0f7846d26c8
Author: Dmitry Gutov <address@hidden>
Date:   Tue Sep 3 19:14:20 2013 +0300

    Add diff-hl-amend-mode
    
    Closes #11

diff --git a/diff-hl-amend.el b/diff-hl-amend.el
new file mode 100644
index 0000000..f3a151b
--- /dev/null
+++ b/diff-hl-amend.el
@@ -0,0 +1,63 @@
+;; Author:   Dmitry Gutov <address@hidden>
+;; URL:      https://github.com/dgutov/diff-hl
+
+;; This file is not part of GNU Emacs.
+
+;; This file is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This file is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Toggle in the current buffer with `M-x diff-hl-amend-mode'.
+;; Toggle in all buffers with `M-x global-diff-hl-amend-mode'.
+
+;;; Code:
+
+;;;###autoload
+(define-minor-mode diff-hl-amend-mode
+  "Show changes against the second-last revision in `diff-hl-mode'.
+Most useful with VCSes that support rewriting local commits, and
+'amending' the most recent one in particular.
+Currently only supports Git, Mercurial and Bazaar."
+  :lighter " Amend"
+  (if diff-hl-amend-mode
+      (progn
+        (if vc-mode
+            (diff-hl-amend-set)
+          (add-hook 'find-file-hook 'diff-hl-amend-setup nil t))
+        (add-hook 'after-revert-hook 'diff-hl-amend-setup nil t))
+    (remove-hook 'find-file-hook 'diff-hl-amend-setup t)
+    (remove-hook 'after-revert-hook 'diff-hl-amend-setup t)
+    (setq-local diff-hl-reference-revision nil))
+  (when diff-hl-mode
+    (diff-hl-update)))
+
+(defun diff-hl-amend-setup ()
+  (let ((backend (vc-backend buffer-file-name)))
+    (when backend
+      (setq-local diff-hl-reference-revision
+                  (cl-case backend
+                    (Git
+                     "HEAD^")
+                    (Hg
+                     "-2")
+                    (Bzr
+                     "revno:-2"))))))
+
+;;;###autoload
+(define-globalized-minor-mode global-diff-hl-amend-mode diff-hl-amend-mode
+  turn-on-diff-hl-amend-mode)
+
+(defun turn-on-diff-hl-amend-mode ()
+  "Turn on `diff-hl-amend-mode' in a buffer if appropriate."
+  (and buffer-file-name (diff-hl-amend-mode 1)))
diff --git a/diff-hl.el b/diff-hl.el
index 2872e37..506ae31 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -87,6 +87,9 @@
   :group 'diff-hl
   :type 'boolean)
 
+(defvar diff-hl-reference-revision nil
+  "Revision to diff against.  nil means the most recent one.")
+
 (defun diff-hl-define-bitmaps ()
   (let* ((scale (if (and (boundp 'text-scale-mode-amount)
                          (numberp text-scale-mode-amount))
@@ -141,11 +144,16 @@
          ((or (eq state 'edited)
               (and (eq state 'up-to-date)
                    ;; VC state is stale in after-revert-hook.
-                   revert-buffer-in-progress-p))
+                   (or revert-buffer-in-progress-p
+                       ;; Diffing against an older revision.
+                       diff-hl-reference-revision)))
           (let* ((buf-name " *diff-hl* ")
+                 diff-auto-refine-mode
                  res)
             (diff-hl-with-diff-switches
-             (vc-call-backend backend 'diff (list file) nil nil buf-name))
+             (vc-call-backend backend 'diff (list file)
+                              diff-hl-reference-revision nil
+                              buf-name))
             (with-current-buffer buf-name
               (goto-char (point-min))
               (unless (eobp)
@@ -239,7 +247,7 @@
   (vc-buffer-sync)
   (let* ((line (line-number-at-pos))
          (buffer (current-buffer)))
-    (vc-diff-internal t (vc-deduce-fileset) nil nil t)
+    (vc-diff-internal t (vc-deduce-fileset) diff-hl-reference-revision nil t)
     (vc-exec-after `(if (< (line-number-at-pos (point-max)) 3)
                         (with-current-buffer ,buffer (diff-hl-remove-overlays))
                       (diff-hl-diff-skip-to ,line)
@@ -279,7 +287,8 @@ in the source file, or the last line of the hunk above it."
         (fileset (vc-deduce-fileset)))
     (unwind-protect
         (progn
-          (vc-diff-internal nil fileset nil nil nil diff-buffer)
+          (vc-diff-internal nil fileset diff-hl-reference-revision nil
+                            nil diff-buffer)
           (vc-exec-after
            `(let (beg-line end-line)
               (when (eobp)

commit 75109bf275634698fcb619d009414ca7285a5104
Author: Dmitry Gutov <address@hidden>
Date:   Fri Apr 19 23:47:10 2013 +0400

    Fix #10
    
    And replace `cl-plus' check with `numberp': negative values of
    text-scale-mode-amount are fine.

diff --git a/README.md b/README.md
index b933b17..de67c58 100644
--- a/README.md
+++ b/README.md
@@ -31,6 +31,8 @@ Notes
 * There's no fringe when Emacs is running in the console, but the navigation 
and
   revert commands still work.
 
+* Frame-local and buffer-local values of `line-spacing` are not supported.
+
 * [git-gutter](https://github.com/syohex/emacs-git-gutter) provides interactive
   commands to show/hide/toggle margin indicators for the same information, and
   allows you to customize how the indicators look.
diff --git a/diff-hl.el b/diff-hl.el
index af5f1bd..2872e37 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -3,7 +3,7 @@
 ;; Author:   Dmitry Gutov <address@hidden>
 ;; URL:      https://github.com/dgutov/diff-hl
 ;; Keywords: vc, diff
-;; Version:  1.4.5
+;; Version:  1.4.6
 ;; Package-Requires: ((cl-lib "0.2"))
 
 ;; This file is not part of GNU Emacs.
@@ -89,10 +89,14 @@
 
 (defun diff-hl-define-bitmaps ()
   (let* ((scale (if (and (boundp 'text-scale-mode-amount)
-                         (cl-plusp text-scale-mode-amount))
+                         (numberp text-scale-mode-amount))
                     (expt text-scale-mode-step text-scale-mode-amount)
                   1))
-         (h (round (* (frame-char-height) scale)))
+         (spacing (or (default-value 'line-spacing) 0))
+         (h (round (+ (* (frame-char-height) scale)
+                      (if (floatp spacing)
+                          (* (frame-char-height) spacing)
+                        spacing))))
          (w (frame-parameter nil 'left-fringe))
          (middle (make-vector h (expt 2 (1- w))))
          (ones (1- (expt 2 w)))

commit b2fa067f2292c030d15218ec9a03f68ac9421115
Author: Dmitry Gutov <address@hidden>
Date:   Thu Apr 4 02:07:17 2013 +0400

    Fix #8
    
    This largely reverts 82bcd10, discarding the ~15% performance gain in
    favor of better compatibility.

diff --git a/diff-hl.el b/diff-hl.el
index abfe988..af5f1bd 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -3,7 +3,7 @@
 ;; Author:   Dmitry Gutov <address@hidden>
 ;; URL:      https://github.com/dgutov/diff-hl
 ;; Keywords: vc, diff
-;; Version:  1.4.4
+;; Version:  1.4.5
 ;; Package-Requires: ((cl-lib "0.2"))
 
 ;; This file is not part of GNU Emacs.
@@ -176,17 +176,27 @@
       (dolist (c changes)
         (cl-destructuring-bind (line len type) c
           (forward-line (- line current-line))
+          (setq current-line line)
           (let ((hunk-beg (point)))
-            (forward-line len)
-            (setq current-line (+ line len))
-            (let ((h (make-overlay hunk-beg (1- (point))))
+            (while (cl-plusp len)
+              (let ((o (make-overlay (point) (point))))
+                (overlay-put o 'diff-hl t)
+                (overlay-put o 'before-string
+                             (diff-hl-fringe-spec
+                              type
+                              (cond
+                               ((not diff-hl-draw-borders) 'empty)
+                               ((and (= len 1) (= line current-line)) 'single)
+                               ((= len 1) 'bottom)
+                               ((= line current-line) 'top)
+                               (t 'middle)))))
+              (forward-line 1)
+              (cl-incf current-line)
+              (cl-decf len))
+            (let ((h (make-overlay hunk-beg (point)))
                   (hook '(diff-hl-overlay-modified)))
               (overlay-put h 'diff-hl t)
-              (if (= len 1)
-                  (overlay-put h 'before-string (diff-hl-fringe-spec type 
'single))
-                (overlay-put h 'before-string (diff-hl-fringe-spec type 'top))
-                (overlay-put h 'line-prefix (diff-hl-fringe-spec type 'middle))
-                (overlay-put h 'after-string (diff-hl-fringe-spec type 
'bottom)))
+              (overlay-put h 'diff-hl-hunk t)
               (overlay-put h 'modification-hooks hook)
               (overlay-put h 'insert-in-front-hooks hook)
               (overlay-put h 'insert-behind-hooks hook))))))))
@@ -196,9 +206,12 @@
     (when (overlay-get o 'diff-hl) (delete-overlay o))))
 
 (defun diff-hl-overlay-modified (ov after-p _beg _end &optional _length)
-  "Delete the overlay."
+  "Delete the hunk overlay and all our line overlays inside it."
   (unless after-p
     (when (overlay-buffer ov)
+      (save-restriction
+        (narrow-to-region (overlay-start ov) (overlay-end ov))
+        (diff-hl-remove-overlays))
       (delete-overlay ov))))
 
 (defvar diff-hl-timer nil)
@@ -295,7 +308,7 @@ in the source file, or the last line of the hunk above it."
 
 (defun diff-hl-hunk-overlay-at (pos)
   (cl-loop for o in (overlays-in pos (1+ pos))
-           when (overlay-get o 'diff-hl)
+           when (overlay-get o 'diff-hl-hunk)
            return o))
 
 (defun diff-hl-next-hunk (&optional backward)

commit 5754bba72d8b2609dc04543b9a8e0d8c8627ab64
Author: Dmitry Gutov <address@hidden>
Date:   Sat Mar 16 09:25:21 2013 +0400

    Close #5

diff --git a/README.md b/README.md
index 8a39110..b933b17 100644
--- a/README.md
+++ b/README.md
@@ -34,3 +34,19 @@ Notes
 * [git-gutter](https://github.com/syohex/emacs-git-gutter) provides interactive
   commands to show/hide/toggle margin indicators for the same information, and
   allows you to customize how the indicators look.
+
+Integration
+=====
+
+If you're using some package other than `vc` to commit changes, it might
+not run `vc-checkin-hook` after commits. In that case, you'll need to
+either add `diff-hl-update` to the hook it does run, or advise some
+function that's called in the buffer after its state has changed.
+
+psvn
+-----
+
+```lisp
+(defadvice svn-status-update-modeline (after svn-update-diff-hl activate)
+  (diff-hl-update))
+```

commit e79b30e306eb656f04f11a0be141bef8d55b6147
Author: Dmitry Gutov <address@hidden>
Date:   Thu Mar 7 04:08:25 2013 +0400

    * diff-hl-next-hunk: don't get distracted by unrelated overlays

diff --git a/diff-hl.el b/diff-hl.el
index 518a5d8..abfe988 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -3,7 +3,7 @@
 ;; Author:   Dmitry Gutov <address@hidden>
 ;; URL:      https://github.com/dgutov/diff-hl
 ;; Keywords: vc, diff
-;; Version:  1.4.3
+;; Version:  1.4.4
 ;; Package-Requires: ((cl-lib "0.2"))
 
 ;; This file is not part of GNU Emacs.
@@ -308,9 +308,7 @@ in the source file, or the last line of the hunk above it."
                                   (previous-overlay-change (point))
                                 (next-overlay-change (point))))
                    (let ((o (diff-hl-hunk-overlay-at (point))))
-                     (when (and o (if backward
-                                      (>= (overlay-end o) (point))
-                                    (<= (overlay-start o) (point))))
+                     (when (and o (= (overlay-start o) (point)))
                        (throw 'found (overlay-start o)))))))))
     (if pos
         (goto-char pos)

commit 115e298c467fd8cf131432d133aaeedd7c79bbf5
Author: Dmitry Gutov <address@hidden>
Date:   Thu Mar 7 01:46:07 2013 +0400

    Me fixey

diff --git a/README.md b/README.md
index 4387e45..8a39110 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@ Screenshot
 
 ![screenie](screenshot.png)
 
-Top window: buffer in this minor mode, bottom window: corresponding diff.
+Top window: a buffer in this minor mode, bottom window: the corresponding diff.
 
 Requirements
 =====

commit 0b3952ce9b92ed215fb1f919c08c185dbf00bc8f
Author: Dmitry Gutov <address@hidden>
Date:   Wed Mar 6 20:49:39 2013 +0400

    Better readme

diff --git a/README.md b/README.md
index 09dd7c0..4387e45 100644
--- a/README.md
+++ b/README.md
@@ -6,12 +6,19 @@ allows you to jump between and revert them selectively.
 
 For the usage instructions and the list of commands, see the header comment.
 
-Tested with Git, Mercurial, and Bazaar. May work with other VC backends, too.
+Tested with Git, Mercurial, Bazaar and SVN. May work with other VC backends, 
too.
 
 Screenshot
 =====
 
-[![screenie](http://i.imgur.com/bC8dBs.png)](http://i.imgur.com/bC8dB.png)
+![screenie](screenshot.png)
+
+Top window: buffer in this minor mode, bottom window: corresponding diff.
+
+Requirements
+=====
+
+Emacs 24+. On OS X, Emacs 24.3 or higher is recommended.
 
 Notes
 =====
@@ -21,6 +28,9 @@ Notes
   maybe we can do something similar to `highlight-markup-buffers` with a hidden
   buffer containing the unmodified copy.
 
-* [git-gutter](https://github.com/syohex/emacs-git-gutter) provides the 
commands
-  to show/hide/toggle margin indicators for the same information, and allows 
you
-  to customize how the indicators look.
+* There's no fringe when Emacs is running in the console, but the navigation 
and
+  revert commands still work.
+
+* [git-gutter](https://github.com/syohex/emacs-git-gutter) provides interactive
+  commands to show/hide/toggle margin indicators for the same information, and
+  allows you to customize how the indicators look.
diff --git a/screenshot.png b/screenshot.png
new file mode 100644
index 0000000..5f99db7
Binary files /dev/null and b/screenshot.png differ

commit 76a3e46411d531bef28c75efaa836da94878baa6
Merge: 9a5bac3 4c79a96
Author: Dmitry Gutov <address@hidden>
Date:   Wed Mar 6 00:25:30 2013 -0800

    Merge pull request #4 from pashky/master
    
    vc-svn backend needs some love too!


commit 4c79a96bf197407d127a10aa244bb9c82d454ce5
Author: pashky <address@hidden>
Date:   Wed Mar 6 03:18:14 2013 +0400

    SVN needs nil diff switches too to revert to -U0 context

diff --git a/diff-hl.el b/diff-hl.el
index ec0c156..518a5d8 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -123,6 +123,7 @@
 (defmacro diff-hl-with-diff-switches (body)
   `(let ((vc-git-diff-switches nil)
          (vc-hg-diff-switches nil)
+         (vc-svn-diff-switches nil)
          (vc-diff-switches '("-U0"))
          (vc-disable-async-diff t))
      ,body))

commit 9a5bac36b58a5cde93462723f6f2e035d2595383
Author: Dmitry Gutov <address@hidden>
Date:   Sat Feb 9 01:37:09 2013 +0400

    Bump the version

diff --git a/diff-hl.el b/diff-hl.el
index 609c6e8..ec0c156 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -3,7 +3,7 @@
 ;; Author:   Dmitry Gutov <address@hidden>
 ;; URL:      https://github.com/dgutov/diff-hl
 ;; Keywords: vc, diff
-;; Version:  1.4.2
+;; Version:  1.4.3
 ;; Package-Requires: ((cl-lib "0.2"))
 
 ;; This file is not part of GNU Emacs.

commit 6f3e9c4258855fad0ef3983d56dc517de72098f2
Merge: 43ce511 da9348b
Author: Dmitry Gutov <address@hidden>
Date:   Fri Feb 8 13:17:46 2013 -0800

    Merge pull request #3 from joseph-churchill/master
    
    Work in terminal and when minor mode function is called directly


commit da9348b38618e5122c3c3fda3b711330c1cb9dd2
Author: Joseph Churchill <address@hidden>
Date:   Fri Feb 8 11:20:37 2013 -0800

    Move fringe bitmap initialization into minor mode def function.
    
    Also, in turn-on-diff-hl-mode, the all initialization code was inside
    (when (window-sytem) ...)
    preventing the mode from being enabled at all in a terminal (and not just
    the fringe bitmaps from being enabled).

diff --git a/diff-hl.el b/diff-hl.el
index e4e69a4..609c6e8 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -328,6 +328,10 @@ in the source file, or the last line of the hunk above it."
                         (,(kbd "C-x v ]") . diff-hl-next-hunk))
   (if diff-hl-mode
       (progn
+        (when (window-system) ;; No fringes in the console.
+          (unless (fringe-bitmap-p 'diff-hl-bmp-empty)
+            (diff-hl-define-bitmaps)
+            (define-fringe-bitmap 'diff-hl-bmp-empty [0] 1 1 'center)))
         (add-hook 'after-save-hook 'diff-hl-update nil t)
         (add-hook 'after-change-functions 'diff-hl-edit nil t)
         (if vc-mode
@@ -377,15 +381,11 @@ in the source file, or the last line of the hunk above 
it."
 ;;;###autoload
 (defun turn-on-diff-hl-mode ()
   "Turn on `diff-hl-mode' or `diff-hl-dir-mode' in a buffer if appropriate."
-  (when (window-system) ;; No fringes in the console.
-    (unless (fringe-bitmap-p 'diff-hl-bmp-empty)
-      (diff-hl-define-bitmaps)
-      (define-fringe-bitmap 'diff-hl-bmp-empty [0] 1 1 'center))
-    (cond
-     (buffer-file-name
-      (diff-hl-mode 1))
-     ((eq major-mode 'vc-dir-mode)
-      (diff-hl-dir-mode 1)))))
+  (cond
+   (buffer-file-name
+    (diff-hl-mode 1))
+   ((eq major-mode 'vc-dir-mode)
+    (diff-hl-dir-mode 1))))
 
 ;;;###autoload
 (define-globalized-minor-mode global-diff-hl-mode diff-hl-mode

commit 43ce511b3a2682d73f601d361f54f344d68635f2
Author: Dmitry Gutov <address@hidden>
Date:   Mon Feb 4 04:32:36 2013 +0400

    Fix jumping to one-line hunks on empty lines, too

diff --git a/diff-hl.el b/diff-hl.el
index 17984c5..e4e69a4 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -3,7 +3,7 @@
 ;; Author:   Dmitry Gutov <address@hidden>
 ;; URL:      https://github.com/dgutov/diff-hl
 ;; Keywords: vc, diff
-;; Version:  1.4.1
+;; Version:  1.4.2
 ;; Package-Requires: ((cl-lib "0.2"))
 
 ;; This file is not part of GNU Emacs.
@@ -293,7 +293,7 @@ in the source file, or the last line of the hunk above it."
       (quit-windows-on diff-buffer))))
 
 (defun diff-hl-hunk-overlay-at (pos)
-  (cl-loop for o in (overlays-at pos)
+  (cl-loop for o in (overlays-in pos (1+ pos))
            when (overlay-get o 'diff-hl)
            return o))
 

commit d361bc218f8f0cbac0104431abcc7e4aa5558d00
Author: Dmitry Gutov <address@hidden>
Date:   Mon Feb 4 04:29:19 2013 +0400

    Fix jumping to one-line hunks

diff --git a/diff-hl.el b/diff-hl.el
index 5b1ecda..17984c5 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -308,8 +308,8 @@ in the source file, or the last line of the hunk above it."
                                 (next-overlay-change (point))))
                    (let ((o (diff-hl-hunk-overlay-at (point))))
                      (when (and o (if backward
-                                      (<= (overlay-end o) (1+ (point)))
-                                    (>= (overlay-start o) (point))))
+                                      (>= (overlay-end o) (point))
+                                    (<= (overlay-start o) (point))))
                        (throw 'found (overlay-start o)))))))))
     (if pos
         (goto-char pos)

commit e8401cfd787b6994eaad945e3d56e786f37e11c0
Author: Dmitry Gutov <address@hidden>
Date:   Mon Feb 4 02:27:46 2013 +0400

    Remove the stab at highlight-changes-mode

diff --git a/README.md b/README.md
index 78ab74b..09dd7c0 100644
--- a/README.md
+++ b/README.md
@@ -22,9 +22,5 @@ Notes
   buffer containing the unmodified copy.
 
 * [git-gutter](https://github.com/syohex/emacs-git-gutter) provides the 
commands
-  to show/hide/toggle indicators for the same information, and allows you to
-  customize how the indicators look.
-
-* Out of other modes providing similar functionality, `highlight-changes-mode` 
is the
-  closest I could find. Angry Fruit Salad aside, it may be fine for writing
-  prose, but I think it's pretty much useless for version-controlled files.
+  to show/hide/toggle margin indicators for the same information, and allows 
you
+  to customize how the indicators look.

commit 8db67625ce53d2f8f8de99182d05b5498fd847c1
Author: Dmitry Gutov <address@hidden>
Date:   Mon Feb 4 02:16:44 2013 +0400

    Ignore up-to-date vc state when the buffer is being reverted

diff --git a/diff-hl.el b/diff-hl.el
index 93bf299..5b1ecda 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -131,36 +131,40 @@
   (let* ((file buffer-file-name)
          (backend (vc-backend file)))
     (when backend
-      (cl-case (vc-state file backend)
-        (edited
-         (let* ((buf-name " *diff-hl* ")
-                res)
-           (diff-hl-with-diff-switches
-            (vc-call-backend backend 'diff (list file) nil nil buf-name))
-           (with-current-buffer buf-name
-             (goto-char (point-min))
-             (unless (eobp)
-               (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))))))
-           (nreverse res)))
-        (added
-         `((1 ,(line-number-at-pos (point-max)) insert)))
-        (removed
-         `((1 ,(line-number-at-pos (point-max)) delete)))))))
+      (let ((state (vc-state file backend)))
+        (cond
+         ((or (eq state 'edited)
+              (and (eq state 'up-to-date)
+                   ;; VC state is stale in after-revert-hook.
+                   revert-buffer-in-progress-p))
+          (let* ((buf-name " *diff-hl* ")
+                 res)
+            (diff-hl-with-diff-switches
+             (vc-call-backend backend 'diff (list file) nil nil buf-name))
+            (with-current-buffer buf-name
+              (goto-char (point-min))
+              (unless (eobp)
+                (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))))))
+            (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-update ()
   (let ((changes (diff-hl-changes))

commit 691a845019b2a28265ed2ef898757a885af4836c
Author: Dmitry Gutov <address@hidden>
Date:   Sun Feb 3 20:50:09 2013 +0400

    Defer (window-system) check until a buffer is opened
    
    Fixes #2

diff --git a/diff-hl.el b/diff-hl.el
index 8ca1679..93bf299 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -3,7 +3,7 @@
 ;; Author:   Dmitry Gutov <address@hidden>
 ;; URL:      https://github.com/dgutov/diff-hl
 ;; Keywords: vc, diff
-;; Version:  1.4.0
+;; Version:  1.4.1
 ;; Package-Requires: ((cl-lib "0.2"))
 
 ;; This file is not part of GNU Emacs.
@@ -108,10 +108,6 @@
     (define-fringe-bitmap 'diff-hl-bmp-bottom bottom h w 'bottom)
     (define-fringe-bitmap 'diff-hl-bmp-single single h w 'top)))
 
-(when (window-system)
-  (define-fringe-bitmap 'diff-hl-bmp-empty [0] 1 1 'center)
-  (diff-hl-define-bitmaps))
-
 (defvar diff-hl-spec-cache (make-hash-table :test 'equal))
 
 (defun diff-hl-fringe-spec (type pos)
@@ -378,6 +374,9 @@ in the source file, or the last line of the hunk above it."
 (defun turn-on-diff-hl-mode ()
   "Turn on `diff-hl-mode' or `diff-hl-dir-mode' in a buffer if appropriate."
   (when (window-system) ;; No fringes in the console.
+    (unless (fringe-bitmap-p 'diff-hl-bmp-empty)
+      (diff-hl-define-bitmaps)
+      (define-fringe-bitmap 'diff-hl-bmp-empty [0] 1 1 'center))
     (cond
      (buffer-file-name
       (diff-hl-mode 1))

commit f58bfee02c22756f42600557d455a3d4a2f1cb97
Author: Dmitry Gutov <address@hidden>
Date:   Sun Jan 27 21:44:32 2013 +0400

    Highlight 'added and 'removed states, too

diff --git a/diff-hl.el b/diff-hl.el
index 732ef20..8ca1679 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -3,7 +3,7 @@
 ;; Author:   Dmitry Gutov <address@hidden>
 ;; URL:      https://github.com/dgutov/diff-hl
 ;; Keywords: vc, diff
-;; Version:  1.3.6
+;; Version:  1.4.0
 ;; Package-Requires: ((cl-lib "0.2"))
 
 ;; This file is not part of GNU Emacs.
@@ -132,30 +132,39 @@
      ,body))
 
 (defun diff-hl-changes ()
-  (let* ((buf-name " *diff-hl* ")
-         (file buffer-file-name)
-         (backend (vc-backend file))
-         res)
-    (when (and backend (eq (vc-state file backend) 'edited))
-      (diff-hl-with-diff-switches
-       (vc-call-backend backend 'diff (list file) nil nil buf-name))
-      (with-current-buffer buf-name
-        (goto-char (point-min))
-        (unless (eobp)
-          (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))))
-                (push (list line len type) res)))))))
-    (nreverse res)))
+  (let* ((file buffer-file-name)
+         (backend (vc-backend file)))
+    (when backend
+      (cl-case (vc-state file backend)
+        (edited
+         (let* ((buf-name " *diff-hl* ")
+                res)
+           (diff-hl-with-diff-switches
+            (vc-call-backend backend 'diff (list file) nil nil buf-name))
+           (with-current-buffer buf-name
+             (goto-char (point-min))
+             (unless (eobp)
+               (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))))))
+           (nreverse res)))
+        (added
+         `((1 ,(line-number-at-pos (point-max)) insert)))
+        (removed
+         `((1 ,(line-number-at-pos (point-max)) delete)))))))
 
 (defun diff-hl-update ()
   (let ((changes (diff-hl-changes))
@@ -165,9 +174,6 @@
       (goto-char (point-min))
       (dolist (c changes)
         (cl-destructuring-bind (line len type) c
-          (when (eq type 'delete)
-            (setq len 1)
-            (cl-incf line))
           (forward-line (- line current-line))
           (let ((hunk-beg (point)))
             (forward-line len)

commit 82bcd10c390e65c6df723a50f9b16afdcfd687cb
Author: Dmitry Gutov <address@hidden>
Date:   Sun Jan 27 20:58:48 2013 +0400

    Use the line-prefix property
    
    Intead of lots of tiny overlays

diff --git a/diff-hl.el b/diff-hl.el
index 63d4293..732ef20 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -169,41 +169,29 @@
             (setq len 1)
             (cl-incf line))
           (forward-line (- line current-line))
-          (setq current-line line)
           (let ((hunk-beg (point)))
-            (while (cl-plusp len)
-              (let ((o (make-overlay (point) (line-end-position))))
-                (overlay-put o 'diff-hl t)
-                (overlay-put o 'before-string
-                             (diff-hl-fringe-spec
-                              type
-                              (cond
-                               ((not diff-hl-draw-borders) 'empty)
-                               ((and (= len 1) (= line current-line)) 'single)
-                               ((= len 1) 'bottom)
-                               ((= line current-line) 'top)
-                               (t 'middle)))))
-              (forward-line 1)
-              (cl-incf current-line)
-              (cl-decf len))
-            (let ((h (make-overlay hunk-beg (point)))
+            (forward-line len)
+            (setq current-line (+ line len))
+            (let ((h (make-overlay hunk-beg (1- (point))))
                   (hook '(diff-hl-overlay-modified)))
               (overlay-put h 'diff-hl t)
-              (overlay-put h 'diff-hl-hunk t)
+              (if (= len 1)
+                  (overlay-put h 'before-string (diff-hl-fringe-spec type 
'single))
+                (overlay-put h 'before-string (diff-hl-fringe-spec type 'top))
+                (overlay-put h 'line-prefix (diff-hl-fringe-spec type 'middle))
+                (overlay-put h 'after-string (diff-hl-fringe-spec type 
'bottom)))
               (overlay-put h 'modification-hooks hook)
-              (overlay-put h 'insert-in-front-hooks hook))))))))
+              (overlay-put h 'insert-in-front-hooks hook)
+              (overlay-put h 'insert-behind-hooks hook))))))))
 
 (defun diff-hl-remove-overlays ()
   (dolist (o (overlays-in (point-min) (point-max)))
     (when (overlay-get o 'diff-hl) (delete-overlay o))))
 
 (defun diff-hl-overlay-modified (ov after-p _beg _end &optional _length)
-  "Delete the overlay and all our overlays inside it."
+  "Delete the overlay."
   (unless after-p
     (when (overlay-buffer ov)
-      (save-restriction
-        (narrow-to-region (overlay-start ov) (overlay-end ov))
-        (diff-hl-remove-overlays))
       (delete-overlay ov))))
 
 (defvar diff-hl-timer nil)
@@ -300,7 +288,7 @@ in the source file, or the last line of the hunk above it."
 
 (defun diff-hl-hunk-overlay-at (pos)
   (cl-loop for o in (overlays-at pos)
-           when (overlay-get o 'diff-hl-hunk)
+           when (overlay-get o 'diff-hl)
            return o))
 
 (defun diff-hl-next-hunk (&optional backward)

commit 6d3c0160395332216d40774317d162c9812582e3
Author: Dmitry Gutov <address@hidden>
Date:   Sun Jan 27 14:12:08 2013 +0400

    Mention git-gutter

diff --git a/README.md b/README.md
index 7d3448e..78ab74b 100644
--- a/README.md
+++ b/README.md
@@ -21,6 +21,10 @@ Notes
   maybe we can do something similar to `highlight-markup-buffers` with a hidden
   buffer containing the unmodified copy.
 
-* Out of modes providing similar functionality, `highlight-changes-mode` is the
+* [git-gutter](https://github.com/syohex/emacs-git-gutter) provides the 
commands
+  to show/hide/toggle indicators for the same information, and allows you to
+  customize how the indicators look.
+
+* Out of other modes providing similar functionality, `highlight-changes-mode` 
is the
   closest I could find. Angry Fruit Salad aside, it may be fine for writing
   prose, but I think it's pretty much useless for version-controlled files.

commit 3194f36d401dbc37bbf61b3cfdf97c669c56d412
Author: Dmitry Gutov <address@hidden>
Date:   Sun Jan 27 13:58:24 2013 +0400

    Depends -> Requires

diff --git a/diff-hl.el b/diff-hl.el
index 916182c..63d4293 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -4,7 +4,7 @@
 ;; URL:      https://github.com/dgutov/diff-hl
 ;; Keywords: vc, diff
 ;; Version:  1.3.6
-;; Package-Depends: ((cl-lib "0.2"))
+;; Package-Requires: ((cl-lib "0.2"))
 
 ;; This file is not part of GNU Emacs.
 

commit f839577452be1452f8fb9771e037ee18c78df2d0
Author: Dmitry Gutov <address@hidden>
Date:   Sun Jan 27 13:42:16 2013 +0400

    Don't rely on diff-mode faces changes provided by starter-kit

diff --git a/diff-hl.el b/diff-hl.el
index e1db6dd..916182c 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -62,18 +62,19 @@
   :group 'vc)
 
 (defface diff-hl-insert
-  '((t :inherit diff-added))
+  '((default :inherit diff-added)
+    (((class color)) :foreground "green4"))
   "Face used to highlight inserted lines."
   :group 'diff-hl)
 
 (defface diff-hl-delete
-  '((t :inherit diff-removed))
+  '((default :inherit diff-removed)
+    (((class color)) :foreground "red3"))
   "Face used to highlight deleted lines."
   :group 'diff-hl)
 
 (defface diff-hl-change
-  '((default
-     :foreground "blue")
+  '((default :foreground "blue3")
     (((class color) (min-colors 88) (background light))
      :background "#ddddff")
     (((class color) (min-colors 88) (background dark))

commit 7563c2bd3e88cec70488288e2a6c556d6c2df21d
Author: Dmitry Gutov <address@hidden>
Date:   Sun Jan 27 13:05:27 2013 +0400

    Silence the "reference to free variable" warning

diff --git a/diff-hl.el b/diff-hl.el
index 4973b20..e1db6dd 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -389,6 +389,10 @@ in the source file, or the last line of the hunk above it."
      ((eq major-mode 'vc-dir-mode)
       (diff-hl-dir-mode 1)))))
 
+;;;###autoload
+(define-globalized-minor-mode global-diff-hl-mode diff-hl-mode
+  turn-on-diff-hl-mode :after-hook (diff-hl-global-mode-change))
+
 (defun diff-hl-global-mode-change ()
   (unless global-diff-hl-mode
     (dolist (buf (buffer-list))
@@ -396,10 +400,6 @@ in the source file, or the last line of the hunk above it."
         (when diff-hl-dir-mode
           (diff-hl-dir-mode -1))))))
 
-;;;###autoload
-(define-globalized-minor-mode global-diff-hl-mode diff-hl-mode
-  turn-on-diff-hl-mode :after-hook (diff-hl-global-mode-change))
-
 (provide 'diff-hl)
 
 ;;; diff-hl.el ends here

commit 0a6a4f5801744037b8824a5a109a6c5609e53520
Author: Dmitry Gutov <address@hidden>
Date:   Sun Jan 27 13:04:30 2013 +0400

    Prefix all cl functions, add cl-lib dependency
    
    The latter should make it work in Emacs 24.{1,2}, as long as this is 
installed
    from a package repository.

diff --git a/diff-hl.el b/diff-hl.el
index 8ea8623..4973b20 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -3,7 +3,8 @@
 ;; Author:   Dmitry Gutov <address@hidden>
 ;; URL:      https://github.com/dgutov/diff-hl
 ;; Keywords: vc, diff
-;; Version:  1.3.5
+;; Version:  1.3.6
+;; Package-Depends: ((cl-lib "0.2"))
 
 ;; This file is not part of GNU Emacs.
 
@@ -51,7 +52,7 @@
 (require 'vc)
 (require 'vc-dir)
 (eval-when-compile
-  (require 'cl)
+  (require 'cl-lib)
   (require 'vc-git)
   (require 'vc-hg)
   (require 'face-remap))
@@ -87,7 +88,7 @@
 
 (defun diff-hl-define-bitmaps ()
   (let* ((scale (if (and (boundp 'text-scale-mode-amount)
-                         (plusp text-scale-mode-amount))
+                         (cl-plusp text-scale-mode-amount))
                     (expt text-scale-mode-step text-scale-mode-amount)
                   1))
          (h (round (* (frame-char-height) scale)))
@@ -162,14 +163,14 @@
     (save-excursion
       (goto-char (point-min))
       (dolist (c changes)
-        (destructuring-bind (line len type) c
+        (cl-destructuring-bind (line len type) c
           (when (eq type 'delete)
             (setq len 1)
-            (incf line))
+            (cl-incf line))
           (forward-line (- line current-line))
           (setq current-line line)
           (let ((hunk-beg (point)))
-            (while (plusp len)
+            (while (cl-plusp len)
               (let ((o (make-overlay (point) (line-end-position))))
                 (overlay-put o 'diff-hl t)
                 (overlay-put o 'before-string
@@ -182,8 +183,8 @@
                                ((= line current-line) 'top)
                                (t 'middle)))))
               (forward-line 1)
-              (incf current-line)
-              (decf len))
+              (cl-incf current-line)
+              (cl-decf len))
             (let ((h (make-overlay hunk-beg (point)))
                   (hook '(diff-hl-overlay-modified)))
               (overlay-put h 'diff-hl t)
@@ -247,10 +248,10 @@ in the source file, or the last line of the hunk above 
it."
               ;; Retreat to the previous hunk.
               (forward-line -1)
             (let ((to-go (1+ (- line hunk-line))))
-              (while (plusp to-go)
+              (while (cl-plusp to-go)
                 (forward-line 1)
                 (unless (looking-at "^-")
-                  (decf to-go))))))))))
+                  (cl-decf to-go))))))))))
 
 (defun diff-hl-revert-hunk ()
   "Revert the diff hunk with changes at or above the point."
@@ -287,7 +288,7 @@ in the source file, or the last line of the hunk above it."
                     (recenter (/ (+ wbh (- beg-line end-line) 2) 2))
                   (recenter 1)))
               (unless (yes-or-no-p (format "Revert current hunk in %s?"
-                                           ,(caadr fileset)))
+                                           ,(cl-caadr fileset)))
                 (error "Revert canceled"))
               (let ((diff-advance-after-apply-hunk nil))
                 (diff-apply-hunk t))
@@ -297,9 +298,9 @@ in the source file, or the last line of the hunk above it."
       (quit-windows-on diff-buffer))))
 
 (defun diff-hl-hunk-overlay-at (pos)
-  (loop for o in (overlays-at pos)
-        when (overlay-get o 'diff-hl-hunk)
-        return o))
+  (cl-loop for o in (overlays-at pos)
+           when (overlay-get o 'diff-hl-hunk)
+           return o))
 
 (defun diff-hl-next-hunk (&optional backward)
   "Go to the beginning of the next hunk in the current buffer."

commit a34e1c06a3453a808900dd0293865ecb1ba5d63d
Author: Dmitry Gutov <address@hidden>
Date:   Sun Jan 27 00:47:56 2013 +0400

    Mention hunks in the commentary

diff --git a/diff-hl.el b/diff-hl.el
index 8319736..8ea8623 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -23,7 +23,7 @@
 ;;; Commentary:
 
 ;; `diff-hl-mode' highlights uncommitted changes on the left fringe of the
-;; window, allows you to jump between them and revert them selectively.
+;; window, allows you to jump between the hunks and revert them selectively.
 
 ;; Provided commands:
 ;;

commit 9702c9e2c3b80b25ece8b0d2fd56dd238ef720bc
Author: Dmitry Gutov <address@hidden>
Date:   Sun Jan 27 00:45:42 2013 +0400

    Make a clearer summary

diff --git a/diff-hl.el b/diff-hl.el
index e9552d3..8319736 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -1,4 +1,4 @@
-;;; diff-hl.el --- VC diff fringe highlighting -*- lexical-binding: t -*-
+;;; diff-hl.el --- Highlight uncommitted changes -*- lexical-binding: t -*-
 
 ;; Author:   Dmitry Gutov <address@hidden>
 ;; URL:      https://github.com/dgutov/diff-hl
@@ -23,7 +23,7 @@
 ;;; Commentary:
 
 ;; `diff-hl-mode' highlights uncommitted changes on the left fringe of the
-;; window, allows you to jump between and revert them selectively.
+;; window, allows you to jump between them and revert them selectively.
 
 ;; Provided commands:
 ;;

commit af0b8350779f1fd0f4d26f487034ae38b51dd06b
Author: Dmitry Gutov <address@hidden>
Date:   Sun Jan 27 00:43:33 2013 +0400

    Fix an error that happened during vc-revert

diff --git a/diff-hl.el b/diff-hl.el
index 82dcd56..e9552d3 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -3,7 +3,7 @@
 ;; Author:   Dmitry Gutov <address@hidden>
 ;; URL:      https://github.com/dgutov/diff-hl
 ;; Keywords: vc, diff
-;; Version:  1.3.4
+;; Version:  1.3.5
 
 ;; This file is not part of GNU Emacs.
 
@@ -198,10 +198,11 @@
 (defun diff-hl-overlay-modified (ov after-p _beg _end &optional _length)
   "Delete the overlay and all our overlays inside it."
   (unless after-p
-    (save-restriction
-      (narrow-to-region (overlay-start ov) (overlay-end ov))
-      (diff-hl-remove-overlays))
-    (delete-overlay ov)))
+    (when (overlay-buffer ov)
+      (save-restriction
+        (narrow-to-region (overlay-start ov) (overlay-end ov))
+        (diff-hl-remove-overlays))
+      (delete-overlay ov))))
 
 (defvar diff-hl-timer nil)
 

commit 8938553ad3235207ba91db334585878f68b3abee
Author: Dmitry Gutov <address@hidden>
Date:   Tue Dec 18 19:43:05 2012 +0400

    Remove the hard dependency on smartrep

diff --git a/diff-hl.el b/diff-hl.el
index fa2ef31..82dcd56 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -3,8 +3,7 @@
 ;; Author:   Dmitry Gutov <address@hidden>
 ;; URL:      https://github.com/dgutov/diff-hl
 ;; Keywords: vc, diff
-;; Version:  1.3.3
-;; Package-Requires: ((smartrep "0.0.3"))
+;; Version:  1.3.4
 
 ;; This file is not part of GNU Emacs.
 

commit 0c8786c08969c0572c4c1e8bfc0e58811d5d3f65
Author: Dmitry Gutov <address@hidden>
Date:   Tue Dec 18 19:42:53 2012 +0400

    Handle the almost-empty diff buffer, as in the async case

diff --git a/diff-hl.el b/diff-hl.el
index 02bd01e..fa2ef31 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -226,7 +226,7 @@
   (let* ((line (line-number-at-pos))
          (buffer (current-buffer)))
     (vc-diff-internal t (vc-deduce-fileset) nil nil t)
-    (vc-exec-after `(if (eobp)
+    (vc-exec-after `(if (< (line-number-at-pos (point-max)) 3)
                         (with-current-buffer ,buffer (diff-hl-remove-overlays))
                       (diff-hl-diff-skip-to ,line)
                       (setq vc-sentinel-movepoint (point))))))

commit 3b5f2171b472425ced2ce6ae3daee56a4444a708
Author: Dmitry Gutov <address@hidden>
Date:   Tue Dec 18 19:21:38 2012 +0400

    Only display the changes when vc-state is 'edited
    
    Highlighting the whole file for 'added and 'removed would also be nice, but 
it's
    kind of a hassle to do right, with sticky overlays.

diff --git a/diff-hl.el b/diff-hl.el
index 0dd0f47..02bd01e 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -135,7 +135,7 @@
          (file buffer-file-name)
          (backend (vc-backend file))
          res)
-    (when (and backend (not (eq (vc-state file backend) 'up-to-date)))
+    (when (and backend (eq (vc-state file backend) 'edited))
       (diff-hl-with-diff-switches
        (vc-call-backend backend 'diff (list file) nil nil buf-name))
       (with-current-buffer buf-name

commit ada43865f1986ee320793165315be511cfac1cea
Author: Dmitry Gutov <address@hidden>
Date:   Tue Oct 2 03:42:36 2012 +0400

    diff-hl-diff-goto-hunk: Fix when the process call is async
    
    Like with Bazaar.

diff --git a/diff-hl.el b/diff-hl.el
index 46a54c3..0dd0f47 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -3,7 +3,7 @@
 ;; Author:   Dmitry Gutov <address@hidden>
 ;; URL:      https://github.com/dgutov/diff-hl
 ;; Keywords: vc, diff
-;; Version:  1.3.2
+;; Version:  1.3.3
 ;; Package-Requires: ((smartrep "0.0.3"))
 
 ;; This file is not part of GNU Emacs.
@@ -228,7 +228,8 @@
     (vc-diff-internal t (vc-deduce-fileset) nil nil t)
     (vc-exec-after `(if (eobp)
                         (with-current-buffer ,buffer (diff-hl-remove-overlays))
-                      (diff-hl-diff-skip-to ,line)))))
+                      (diff-hl-diff-skip-to ,line)
+                      (setq vc-sentinel-movepoint (point))))))
 
 (defun diff-hl-diff-skip-to (line)
   "In `diff-mode', skip to the hunk and line corresponding to LINE

commit 0891ade07b087e3402854e4f419bb09b5ca93e84
Author: Dmitry Gutov <address@hidden>
Date:   Sun Sep 30 19:29:23 2012 +0400

    Clarify relationship with vc-dir-mode

diff --git a/diff-hl.el b/diff-hl.el
index 9b13958..46a54c3 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -3,7 +3,7 @@
 ;; Author:   Dmitry Gutov <address@hidden>
 ;; URL:      https://github.com/dgutov/diff-hl
 ;; Keywords: vc, diff
-;; Version:  1.3.1
+;; Version:  1.3.2
 ;; Package-Requires: ((smartrep "0.0.3"))
 
 ;; This file is not part of GNU Emacs.
@@ -41,7 +41,7 @@
 ;;
 ;; (global-diff-hl-mode)
 ;;
-;; Only in `prog-mode' and `vc-dir-mode' buffers:
+;; Only in `prog-mode' buffers, with `vc-dir' integration:
 ;;
 ;; (add-hook 'prog-mode-hook 'turn-on-diff-hl-mode)
 ;; (add-hook 'vc-dir-mode-hook 'turn-on-diff-hl-mode)

commit e6ff86f5dab4070dd00fa53a5faa655199a596af
Author: Dmitry Gutov <address@hidden>
Date:   Sun Sep 30 06:30:01 2012 +0400

    Backtick

diff --git a/diff-hl.el b/diff-hl.el
index 6f0c675..9b13958 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -33,7 +33,7 @@
 ;; `diff-hl-previous-hunk'   C-x v [
 ;; `diff-hl-next-hunk'       C-x v ]
 ;;
-;; The mode takes advantage of `smartrep` if it is installed.
+;; The mode takes advantage of `smartrep' if it is installed.
 
 ;; Add either of the following to your init file.
 ;;

commit 932c1533636797d2066f51aa786fafe2a68626dd
Author: Dmitry Gutov <address@hidden>
Date:   Sun Sep 30 06:24:40 2012 +0400

    Some more touches

diff --git a/README.md b/README.md
index 9c330ce..7d3448e 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,8 @@
 About
 =====
 
-`diff-hl-mode` highlights uncommitted changes on the left fringe of the buffer
-window, allows you to jump between them, and revert them selectively.
+`diff-hl-mode` highlights uncommitted changes on the left fringe of the window,
+allows you to jump between and revert them selectively.
 
 For the usage instructions and the list of commands, see the header comment.
 
@@ -11,7 +11,7 @@ Tested with Git, Mercurial, and Bazaar. May work with other 
VC backends, too.
 Screenshot
 =====
 
-[![Foo](http://i.imgur.com/bC8dBs.png)](http://i.imgur.com/bC8dB.png)
+[![screenie](http://i.imgur.com/bC8dBs.png)](http://i.imgur.com/bC8dB.png)
 
 Notes
 =====
@@ -23,4 +23,4 @@ Notes
 
 * Out of modes providing similar functionality, `highlight-changes-mode` is the
   closest I could find. Angry Fruit Salad aside, it may be fine for writing
-  prose, but think it's pretty much useless for version-controlled files.
+  prose, but I think it's pretty much useless for version-controlled files.
diff --git a/diff-hl.el b/diff-hl.el
index dbbf0f6..6f0c675 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -24,9 +24,7 @@
 ;;; Commentary:
 
 ;; `diff-hl-mode' highlights uncommitted changes on the left fringe of the
-;; buffer window, allows you to jump between them, and revert them selectively.
-;;
-;; For the full description, see README.md or the home page.
+;; window, allows you to jump between and revert them selectively.
 
 ;; Provided commands:
 ;;

commit ae6572a4c5eec82f4e11155c5815ead0dd0d848d
Author: Dmitry Gutov <address@hidden>
Date:   Sun Sep 30 05:44:49 2012 +0400

    Improve documentation (Refs #1)

diff --git a/README.md b/README.md
index 0a5c852..9c330ce 100644
--- a/README.md
+++ b/README.md
@@ -1,36 +1,26 @@
 About
 =====
 
-`diff-hl-mode` provides IDE-like highlighting of `vc-diff` results on the left
-fringe of the current buffer.
+`diff-hl-mode` highlights uncommitted changes on the left fringe of the buffer
+window, allows you to jump between them, and revert them selectively.
 
-Since it uses the corresponding VC diff command, it's only accurate when the
-buffer is in saved state.
-
-Additionally, it defines and binds
-
-* `diff-hl-diff-goto-hunk` (`C-x v =`)
-* `diff-hl-revert-hunk` (`C-x v n`)
-* `diff-hl-previous-hunk` (`C-x v [`)
-* `diff-hl-next-hunk` (`C-x v ]`)
-
-The mode takes advantage of `smartrep` if it is installed.
+For the usage instructions and the list of commands, see the header comment.
 
 Tested with Git, Mercurial, and Bazaar. May work with other VC backends, too.
 
-Usage
+Screenshot
 =====
 
-Ensure `diff-hl.el` is in a directory on your load-path, and add the following
-to your `~/.emacs` or `~/.emacs.d/init.el`
+[![Foo](http://i.imgur.com/bC8dBs.png)](http://i.imgur.com/bC8dB.png)
 
-    (require 'diff-hl)
-
-and, to use it in all buffers
-
-    (global-diff-hl-mode)
+Notes
+=====
 
-or, for example, to use it in all `prog-mode` and `vc-dir-mode` buffers
+* Since it uses the corresponding VC diff command, it's only accurate when the
+  buffer is in saved state. Highlighting changes "on the fly" might be better,
+  maybe we can do something similar to `highlight-markup-buffers` with a hidden
+  buffer containing the unmodified copy.
 
-    (add-hook 'prog-mode-hook 'turn-on-diff-hl-mode)
-    (add-hook 'vc-dir-mode-hook 'turn-on-diff-hl-mode)
+* Out of modes providing similar functionality, `highlight-changes-mode` is the
+  closest I could find. Angry Fruit Salad aside, it may be fine for writing
+  prose, but think it's pretty much useless for version-controlled files.
diff --git a/diff-hl.el b/diff-hl.el
index 03ceac2..dbbf0f6 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -23,10 +23,30 @@
 
 ;;; Commentary:
 
-;; `diff-hl-mode' provides IDE-like highlighting of `vc-diff' results
-;; on the left fringe of the current buffer.
+;; `diff-hl-mode' highlights uncommitted changes on the left fringe of the
+;; buffer window, allows you to jump between them, and revert them selectively.
 ;;
-;; For full description, see README.md or the home page.
+;; For the full description, see README.md or the home page.
+
+;; Provided commands:
+;;
+;; `diff-hl-diff-goto-hunk'  C-x v =
+;; `diff-hl-revert-hunk'     C-x v n
+;; `diff-hl-previous-hunk'   C-x v [
+;; `diff-hl-next-hunk'       C-x v ]
+;;
+;; The mode takes advantage of `smartrep` if it is installed.
+
+;; Add either of the following to your init file.
+;;
+;; To use it in all buffers:
+;;
+;; (global-diff-hl-mode)
+;;
+;; Only in `prog-mode' and `vc-dir-mode' buffers:
+;;
+;; (add-hook 'prog-mode-hook 'turn-on-diff-hl-mode)
+;; (add-hook 'vc-dir-mode-hook 'turn-on-diff-hl-mode)
 
 ;;; Code:
 
@@ -179,7 +199,7 @@
     (when (overlay-get o 'diff-hl) (delete-overlay o))))
 
 (defun diff-hl-overlay-modified (ov after-p _beg _end &optional _length)
-  ;; Delete the overlay and all our overlays inside it.
+  "Delete the overlay and all our overlays inside it."
   (unless after-p
     (save-restriction
       (narrow-to-region (overlay-start ov) (overlay-end ov))
@@ -189,7 +209,7 @@
 (defvar diff-hl-timer nil)
 
 (defun diff-hl-edit (_beg _end _len)
-  ;; DTRT when we've `undo'-ed the buffer into unmodified state.
+  "DTRT when we've `undo'-ne the buffer into unmodified state."
   (when undo-in-progress
     (when diff-hl-timer
       (cancel-timer diff-hl-timer))
@@ -202,7 +222,7 @@
       (diff-hl-update))))
 
 (defun diff-hl-diff-goto-hunk ()
-  "Run VC diff command and go to the line corresponding to current."
+  "Run VC diff command and go to the line corresponding to the current."
   (interactive)
   (vc-buffer-sync)
   (let* ((line (line-number-at-pos))
@@ -306,7 +326,7 @@ in the source file, or the last line of the hunk above it."
   (diff-hl-next-hunk t))
 
 (define-minor-mode diff-hl-mode
-  "Toggle display of VC diff indicators in the left fringe."
+  "Toggle VC diff fringe highlighting."
   :lighter "" :keymap `(([remap vc-diff] . diff-hl-diff-goto-hunk)
                         (,(kbd "C-x v n") . diff-hl-revert-hunk)
                         (,(kbd "C-x v [") . diff-hl-previous-hunk)

commit 9f415468aea2a9208a0da71bbb39a286b9e7f2a0
Author: Dmitry Gutov <address@hidden>
Date:   Thu Sep 27 03:12:33 2012 +0400

    diff-hl-previous-hunk: Fix an edge case
    
    Continued from a01d2917a07d91269c13901bb65fd7ef54766fd4.
    
    I may have to start writing tests soon.

diff --git a/diff-hl.el b/diff-hl.el
index 84725a0..03ceac2 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -3,7 +3,7 @@
 ;; Author:   Dmitry Gutov <address@hidden>
 ;; URL:      https://github.com/dgutov/diff-hl
 ;; Keywords: vc, diff
-;; Version:  1.3
+;; Version:  1.3.1
 ;; Package-Requires: ((smartrep "0.0.3"))
 
 ;; This file is not part of GNU Emacs.
@@ -287,7 +287,6 @@ in the source file, or the last line of the hunk above it."
   (interactive)
   (let ((pos (save-excursion
                (catch 'found
-                 (when (and backward (bolp) (not (eobp))) (forward-char))
                  (while (not (if backward (bobp) (eobp)))
                    (goto-char (if backward
                                   (previous-overlay-change (point))

commit f43a48179bb6c0e9b92d949b420e5c18f6c9d16d
Author: Dmitry Gutov <address@hidden>
Date:   Wed Sep 26 03:32:40 2012 +0400

    diff-hl-revert-hunk: Recenter the window on the hunk, if possible
    
    Mention smartrep in the README, bump version.

diff --git a/README.md b/README.md
index 740dbf6..0a5c852 100644
--- a/README.md
+++ b/README.md
@@ -14,6 +14,8 @@ Additionally, it defines and binds
 * `diff-hl-previous-hunk` (`C-x v [`)
 * `diff-hl-next-hunk` (`C-x v ]`)
 
+The mode takes advantage of `smartrep` if it is installed.
+
 Tested with Git, Mercurial, and Bazaar. May work with other VC backends, too.
 
 Usage
diff --git a/diff-hl.el b/diff-hl.el
index fcda8fe..84725a0 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -3,7 +3,7 @@
 ;; Author:   Dmitry Gutov <address@hidden>
 ;; URL:      https://github.com/dgutov/diff-hl
 ;; Keywords: vc, diff
-;; Version:  1.2
+;; Version:  1.3
 ;; Package-Requires: ((smartrep "0.0.3"))
 
 ;; This file is not part of GNU Emacs.
@@ -248,19 +248,25 @@ in the source file, or the last line of the hunk above 
it."
         (progn
           (vc-diff-internal nil fileset nil nil nil diff-buffer)
           (vc-exec-after
-           `(progn
+           `(let (beg-line end-line)
               (when (eobp)
                 (with-current-buffer ,buffer (diff-hl-remove-overlays))
                 (error "Buffer is up-to-date"))
               (diff-hl-diff-skip-to ,line)
               (save-excursion
                 (while (looking-at "[-+]") (forward-line 1))
+                (setq end-line (line-number-at-pos (point)))
                 (unless (eobp) (diff-split-hunk)))
               (unless (looking-at "[-+]") (forward-line -1))
               (while (looking-at "[-+]") (forward-line -1))
+              (setq beg-line (line-number-at-pos (point)))
               (unless (looking-at "@")
                 (forward-line 1)
                 (diff-split-hunk))
+              (let ((wbh (window-body-height)))
+                (if (>= wbh (- end-line beg-line))
+                    (recenter (/ (+ wbh (- beg-line end-line) 2) 2))
+                  (recenter 1)))
               (unless (yes-or-no-p (format "Revert current hunk in %s?"
                                            ,(caadr fileset)))
                 (error "Revert canceled"))

commit a01d2917a07d91269c13901bb65fd7ef54766fd4
Author: Dmitry Gutov <address@hidden>
Date:   Tue Sep 25 04:03:28 2012 +0400

    diff-hl-previous-hunk: Fix an edge case

diff --git a/diff-hl.el b/diff-hl.el
index d237da4..fcda8fe 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -284,7 +284,7 @@ in the source file, or the last line of the hunk above it."
                  (when (and backward (bolp) (not (eobp))) (forward-char))
                  (while (not (if backward (bobp) (eobp)))
                    (goto-char (if backward
-                                  (1- (previous-overlay-change (point)))
+                                  (previous-overlay-change (point))
                                 (next-overlay-change (point))))
                    (let ((o (diff-hl-hunk-overlay-at (point))))
                      (when (and o (if backward

commit aeb05382b6d7a12f6263706207a1fe9bd868150f
Author: Dmitry Gutov <address@hidden>
Date:   Tue Sep 25 02:06:43 2012 +0400

    Use map-keymap

diff --git a/diff-hl.el b/diff-hl.el
index 11667c3..d237da4 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -326,10 +326,16 @@ in the source file, or the last line of the hunk above 
it."
 
 (when (require 'smartrep nil t)
   (let (smart-keys)
-    (dolist (c '("n" "[" "]"))
-      (let* ((cmd (lookup-key diff-hl-mode-map (kbd (concat "C-x v " c)))))
-        (push (cons c cmd) smart-keys)))
-    (smartrep-define-key diff-hl-mode-map "C-x v" smart-keys)))
+    (cl-labels ((scan (map)
+                      (map-keymap
+                       (lambda (event binding)
+                         (if (consp binding)
+                             (scan binding)
+                           (when (characterp event)
+                             (push (cons (string event) binding) smart-keys))))
+                       map)))
+      (scan diff-hl-mode-map)
+      (smartrep-define-key diff-hl-mode-map "C-x v" smart-keys))))
 
 (defun diff-hl-dir-update ()
   (dolist (pair (if (vc-dir-marked-files)

commit 1a124bff876b1a356a1d97942e0c77e04cbd3d62
Author: Dmitry Gutov <address@hidden>
Date:   Mon Sep 24 03:20:03 2012 +0400

    Silence byte-compilation

diff --git a/diff-hl.el b/diff-hl.el
index bb488dc..11667c3 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -32,6 +32,7 @@
 
 (require 'diff-mode)
 (require 'vc)
+(require 'vc-dir)
 (eval-when-compile
   (require 'cl)
   (require 'vc-git)

commit 321a2787c94fc14c8f45c367b5c2e637bc9cec63
Author: Dmitry Gutov <address@hidden>
Date:   Mon Sep 24 03:07:20 2012 +0400

    Don't need `read-kbd-macro` for single characters

diff --git a/diff-hl.el b/diff-hl.el
index e4ddedd..bb488dc 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -327,7 +327,7 @@ in the source file, or the last line of the hunk above it."
   (let (smart-keys)
     (dolist (c '("n" "[" "]"))
       (let* ((cmd (lookup-key diff-hl-mode-map (kbd (concat "C-x v " c)))))
-        (push (cons (read-kbd-macro c) cmd) smart-keys)))
+        (push (cons c cmd) smart-keys)))
     (smartrep-define-key diff-hl-mode-map "C-x v" smart-keys)))
 
 (defun diff-hl-dir-update ()

commit eb5f3a129e981f25bd56ce60e1e789545d2f91e6
Author: Dmitry Gutov <address@hidden>
Date:   Mon Sep 24 02:57:38 2012 +0400

    Use smartrep when available

diff --git a/diff-hl.el b/diff-hl.el
index cc6699c..e4ddedd 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -4,6 +4,7 @@
 ;; URL:      https://github.com/dgutov/diff-hl
 ;; Keywords: vc, diff
 ;; Version:  1.2
+;; Package-Requires: ((smartrep "0.0.3"))
 
 ;; This file is not part of GNU Emacs.
 
@@ -322,6 +323,13 @@ in the source file, or the last line of the hunk above it."
     (remove-hook 'text-scale-mode-hook 'diff-hl-define-bitmaps t)
     (diff-hl-remove-overlays)))
 
+(when (require 'smartrep nil t)
+  (let (smart-keys)
+    (dolist (c '("n" "[" "]"))
+      (let* ((cmd (lookup-key diff-hl-mode-map (kbd (concat "C-x v " c)))))
+        (push (cons (read-kbd-macro c) cmd) smart-keys)))
+    (smartrep-define-key diff-hl-mode-map "C-x v" smart-keys)))
+
 (defun diff-hl-dir-update ()
   (dolist (pair (if (vc-dir-marked-files)
                     (vc-dir-marked-only-files-and-states)

commit 52eab96485cac593b24cc7ab9b536945a7a69ec8
Author: Dmitry Gutov <address@hidden>
Date:   Mon Sep 24 01:27:31 2012 +0400

    diff-hl-revert-hunk: Fix for pure removal hunks
    
    diff-hl-previous-hunk: Fix for when point is on the bol right after a hunk

diff --git a/diff-hl.el b/diff-hl.el
index fe0cbef..cc6699c 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -237,23 +237,31 @@ in the source file, or the last line of the hunk above 
it."
   (vc-buffer-sync)
   (let ((diff-buffer (generate-new-buffer-name "*diff-hl*"))
         (buffer (current-buffer))
-        (line (line-number-at-pos))
+        (line (save-excursion
+                (unless (diff-hl-hunk-overlay-at (point))
+                  (diff-hl-previous-hunk))
+                (line-number-at-pos)))
         (fileset (vc-deduce-fileset)))
     (unwind-protect
         (progn
-          (diff-hl-with-diff-switches
-           (vc-diff-internal nil fileset nil nil nil diff-buffer))
+          (vc-diff-internal nil fileset nil nil nil diff-buffer)
           (vc-exec-after
            `(progn
               (when (eobp)
                 (with-current-buffer ,buffer (diff-hl-remove-overlays))
                 (error "Buffer is up-to-date"))
               (diff-hl-diff-skip-to ,line)
-              (save-restriction
-                (diff-restrict-view)
-                (unless (yes-or-no-p (format "Revert current hunk in %s?"
-                                             ,(caadr fileset)))
-                  (error "Revert canceled")))
+              (save-excursion
+                (while (looking-at "[-+]") (forward-line 1))
+                (unless (eobp) (diff-split-hunk)))
+              (unless (looking-at "[-+]") (forward-line -1))
+              (while (looking-at "[-+]") (forward-line -1))
+              (unless (looking-at "@")
+                (forward-line 1)
+                (diff-split-hunk))
+              (unless (yes-or-no-p (format "Revert current hunk in %s?"
+                                           ,(caadr fileset)))
+                (error "Revert canceled"))
               (let ((diff-advance-after-apply-hunk nil))
                 (diff-apply-hunk t))
               (with-current-buffer ,buffer
@@ -261,21 +269,26 @@ in the source file, or the last line of the hunk above 
it."
               (message "Hunk reverted"))))
       (quit-windows-on diff-buffer))))
 
+(defun diff-hl-hunk-overlay-at (pos)
+  (loop for o in (overlays-at pos)
+        when (overlay-get o 'diff-hl-hunk)
+        return o))
+
 (defun diff-hl-next-hunk (&optional backward)
   "Go to the beginning of the next hunk in the current buffer."
   (interactive)
   (let ((pos (save-excursion
                (catch 'found
+                 (when (and backward (bolp) (not (eobp))) (forward-char))
                  (while (not (if backward (bobp) (eobp)))
                    (goto-char (if backward
                                   (1- (previous-overlay-change (point)))
                                 (next-overlay-change (point))))
-                   (loop for o in (overlays-at (point))
-                         when (overlay-get o 'diff-hl-hunk)
-                         unless (if backward
-                                    (> (overlay-end o) (1+ (point)))
-                                  (< (overlay-start o) (point)))
-                         do (throw 'found (overlay-start o))))))))
+                   (let ((o (diff-hl-hunk-overlay-at (point))))
+                     (when (and o (if backward
+                                      (<= (overlay-end o) (1+ (point)))
+                                    (>= (overlay-start o) (point))))
+                       (throw 'found (overlay-start o)))))))))
     (if pos
         (goto-char pos)
       (error "No further hunks found"))))

commit a723a9b2fedd3e81661871a3a94722af7a82bb07
Author: Dmitry Gutov <address@hidden>
Date:   Sun Sep 23 23:45:22 2012 +0400

    Add hunk navigation commands

diff --git a/README.md b/README.md
index 8aea738..740dbf6 100644
--- a/README.md
+++ b/README.md
@@ -7,16 +7,20 @@ fringe of the current buffer.
 Since it uses the corresponding VC diff command, it's only accurate when the
 buffer is in saved state.
 
-Additionally, it defines and binds `diff-hl-diff-goto-hunk` and
-`diff-hl-revert-hunk`, to `C-x v =` and `C-x v n` respectively.
+Additionally, it defines and binds
+
+* `diff-hl-diff-goto-hunk` (`C-x v =`)
+* `diff-hl-revert-hunk` (`C-x v n`)
+* `diff-hl-previous-hunk` (`C-x v [`)
+* `diff-hl-next-hunk` (`C-x v ]`)
 
 Tested with Git, Mercurial, and Bazaar. May work with other VC backends, too.
 
 Usage
 =====
 
-Ensure diff-hl.el is in a directory on your load-path, and add the following to
-your `~/.emacs` or `~/.emacs.d/init.el`
+Ensure `diff-hl.el` is in a directory on your load-path, and add the following
+to your `~/.emacs` or `~/.emacs.d/init.el`
 
     (require 'diff-hl)
 
diff --git a/diff-hl.el b/diff-hl.el
index b1730f9..fe0cbef 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -3,7 +3,7 @@
 ;; Author:   Dmitry Gutov <address@hidden>
 ;; URL:      https://github.com/dgutov/diff-hl
 ;; Keywords: vc, diff
-;; Version:  1.1
+;; Version:  1.2
 
 ;; This file is not part of GNU Emacs.
 
@@ -168,6 +168,7 @@
             (let ((h (make-overlay hunk-beg (point)))
                   (hook '(diff-hl-overlay-modified)))
               (overlay-put h 'diff-hl t)
+              (overlay-put h 'diff-hl-hunk t)
               (overlay-put h 'modification-hooks hook)
               (overlay-put h 'insert-in-front-hooks hook))))))))
 
@@ -260,10 +261,36 @@ in the source file, or the last line of the hunk above 
it."
               (message "Hunk reverted"))))
       (quit-windows-on diff-buffer))))
 
+(defun diff-hl-next-hunk (&optional backward)
+  "Go to the beginning of the next hunk in the current buffer."
+  (interactive)
+  (let ((pos (save-excursion
+               (catch 'found
+                 (while (not (if backward (bobp) (eobp)))
+                   (goto-char (if backward
+                                  (1- (previous-overlay-change (point)))
+                                (next-overlay-change (point))))
+                   (loop for o in (overlays-at (point))
+                         when (overlay-get o 'diff-hl-hunk)
+                         unless (if backward
+                                    (> (overlay-end o) (1+ (point)))
+                                  (< (overlay-start o) (point)))
+                         do (throw 'found (overlay-start o))))))))
+    (if pos
+        (goto-char pos)
+      (error "No further hunks found"))))
+
+(defun diff-hl-previous-hunk ()
+  "Go to the beginning of the previous hunk in the current buffer."
+  (interactive)
+  (diff-hl-next-hunk t))
+
 (define-minor-mode diff-hl-mode
   "Toggle display of VC diff indicators in the left fringe."
   :lighter "" :keymap `(([remap vc-diff] . diff-hl-diff-goto-hunk)
-                        (,(kbd "C-x v n") . diff-hl-revert-hunk))
+                        (,(kbd "C-x v n") . diff-hl-revert-hunk)
+                        (,(kbd "C-x v [") . diff-hl-previous-hunk)
+                        (,(kbd "C-x v ]") . diff-hl-next-hunk))
   (if diff-hl-mode
       (progn
         (add-hook 'after-save-hook 'diff-hl-update nil t)

commit 1c7b014de8093aace41e6adf7a75f7b51a6d907a
Author: Dmitry Gutov <address@hidden>
Date:   Sun Sep 23 03:49:47 2012 +0400

    Use after-revert-hook

diff --git a/diff-hl.el b/diff-hl.el
index b733efe..b1730f9 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -272,11 +272,13 @@ in the source file, or the last line of the hunk above 
it."
             (diff-hl-update)
           (add-hook 'find-file-hook 'diff-hl-update t t))
         (add-hook 'vc-checkin-hook 'diff-hl-update nil t)
+        (add-hook 'after-revert-hook 'diff-hl-update nil t)
         (add-hook 'text-scale-mode-hook 'diff-hl-define-bitmaps nil t))
     (remove-hook 'after-save-hook 'diff-hl-update t)
     (remove-hook 'after-change-functions 'diff-hl-edit t)
     (remove-hook 'find-file-hook 'diff-hl-update t)
     (remove-hook 'vc-checkin-hook 'diff-hl-update t)
+    (remove-hook 'after-revert-hook 'diff-hl-update t)
     (remove-hook 'text-scale-mode-hook 'diff-hl-define-bitmaps t)
     (diff-hl-remove-overlays)))
 

commit 796a360f789da86d421534975231c68defbc36da
Author: Dmitry Gutov <address@hidden>
Date:   Tue Jul 17 07:33:23 2012 +0400

    Remove workaround for bug#11929
    
    The initialization is already deferred anyway.

diff --git a/diff-hl.el b/diff-hl.el
index 6ac0d24..b733efe 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -112,7 +112,7 @@
 
 (defun diff-hl-changes ()
   (let* ((buf-name " *diff-hl* ")
-         (file (buffer-file-name))
+         (file buffer-file-name)
          (backend (vc-backend file))
          res)
     (when (and backend (not (eq (vc-state file backend) 'up-to-date)))
@@ -302,9 +302,7 @@ in the source file, or the last line of the hunk above it."
   "Turn on `diff-hl-mode' or `diff-hl-dir-mode' in a buffer if appropriate."
   (when (window-system) ;; No fringes in the console.
     (cond
-     ;; FIXME: Why is this called twice for each buffer?
-     ;; Isn't fundamental-mode supposed to not run any hooks?
-     ((and buffer-file-name (not (eq major-mode (default-value 'major-mode))))
+     (buffer-file-name
       (diff-hl-mode 1))
      ((eq major-mode 'vc-dir-mode)
       (diff-hl-dir-mode 1)))))

commit bef2e8563e5aab7b3b84e832902479e5408eaa2e
Author: Dmitry Gutov <address@hidden>
Date:   Tue Jul 17 07:24:23 2012 +0400

    Update docstring

diff --git a/diff-hl.el b/diff-hl.el
index 0f7956b..6ac0d24 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -291,7 +291,7 @@ in the source file, or the last line of the hunk above it."
             (diff-hl-remove-overlays)))))))
 
 (define-minor-mode diff-hl-dir-mode
-  "Toggle `diff-hl-mode' link in `vc-dir-mode' buffer."
+  "Toggle `diff-hl-mode' integration in a `vc-dir-mode' buffer."
   :lighter ""
   (if diff-hl-dir-mode
       (add-hook 'vc-checkin-hook 'diff-hl-dir-update t t)

commit db63ddbe30ef6f05e5a917b3a03d75329e80f72e
Author: Dmitry Gutov <address@hidden>
Date:   Wed Jul 11 06:14:34 2012 +0400

    Work correctly when no files in vc-dir buffer are marked

diff --git a/diff-hl.el b/diff-hl.el
index 4e30059..0f7956b 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -281,7 +281,9 @@ in the source file, or the last line of the hunk above it."
     (diff-hl-remove-overlays)))
 
 (defun diff-hl-dir-update ()
-  (dolist (pair (vc-dir-marked-only-files-and-states))
+  (dolist (pair (if (vc-dir-marked-files)
+                    (vc-dir-marked-only-files-and-states)
+                  (vc-dir-child-files-and-states)))
     (when (eq 'up-to-date (cdr pair))
       (let ((buffer (find-buffer-visiting (car pair))))
         (when buffer

commit 7c3bf2a1c4556503bbe7cb8e4c6df2777b55e75e
Author: Dmitry Gutov <address@hidden>
Date:   Wed Jul 11 06:08:50 2012 +0400

    Clean up diff-hl-dir-mode buffers when turned off

diff --git a/diff-hl.el b/diff-hl.el
index 058631d..4e30059 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -3,7 +3,7 @@
 ;; Author:   Dmitry Gutov <address@hidden>
 ;; URL:      https://github.com/dgutov/diff-hl
 ;; Keywords: vc, diff
-;; Version:  1.0.1
+;; Version:  1.1
 
 ;; This file is not part of GNU Emacs.
 
@@ -260,7 +260,6 @@ in the source file, or the last line of the hunk above it."
               (message "Hunk reverted"))))
       (quit-windows-on diff-buffer))))
 
-;;;###autoload
 (define-minor-mode diff-hl-mode
   "Toggle display of VC diff indicators in the left fringe."
   :lighter "" :keymap `(([remap vc-diff] . diff-hl-diff-goto-hunk)
@@ -289,7 +288,6 @@ in the source file, or the last line of the hunk above it."
           (with-current-buffer buffer
             (diff-hl-remove-overlays)))))))
 
-;;;###autoload
 (define-minor-mode diff-hl-dir-mode
   "Toggle `diff-hl-mode' link in `vc-dir-mode' buffer."
   :lighter ""
@@ -297,7 +295,9 @@ in the source file, or the last line of the hunk above it."
       (add-hook 'vc-checkin-hook 'diff-hl-dir-update t t)
     (remove-hook 'vc-checkin-hook 'diff-hl-dir-update t)))
 
+;;;###autoload
 (defun turn-on-diff-hl-mode ()
+  "Turn on `diff-hl-mode' or `diff-hl-dir-mode' in a buffer if appropriate."
   (when (window-system) ;; No fringes in the console.
     (cond
      ;; FIXME: Why is this called twice for each buffer?
@@ -307,9 +307,16 @@ in the source file, or the last line of the hunk above it."
      ((eq major-mode 'vc-dir-mode)
       (diff-hl-dir-mode 1)))))
 
+(defun diff-hl-global-mode-change ()
+  (unless global-diff-hl-mode
+    (dolist (buf (buffer-list))
+      (with-current-buffer buf
+        (when diff-hl-dir-mode
+          (diff-hl-dir-mode -1))))))
+
 ;;;###autoload
 (define-globalized-minor-mode global-diff-hl-mode diff-hl-mode
-  turn-on-diff-hl-mode)
+  turn-on-diff-hl-mode :after-hook (diff-hl-global-mode-change))
 
 (provide 'diff-hl)
 

commit bce3c487bd59cf2cf3715225a6aa0807936a0ef9
Author: Dmitry Gutov <address@hidden>
Date:   Wed Jul 11 01:09:12 2012 +0400

    Hook into checkin from vc-dir mode

diff --git a/README.md b/README.md
index d71c25a..8aea738 100644
--- a/README.md
+++ b/README.md
@@ -24,6 +24,7 @@ and, to use it in all buffers
 
     (global-diff-hl-mode)
 
-or, for example, to use it in all `prog-mode` buffers
+or, for example, to use it in all `prog-mode` and `vc-dir-mode` buffers
 
     (add-hook 'prog-mode-hook 'turn-on-diff-hl-mode)
+    (add-hook 'vc-dir-mode-hook 'turn-on-diff-hl-mode)
diff --git a/diff-hl.el b/diff-hl.el
index d5fd958..058631d 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -281,12 +281,31 @@ in the source file, or the last line of the hunk above 
it."
     (remove-hook 'text-scale-mode-hook 'diff-hl-define-bitmaps t)
     (diff-hl-remove-overlays)))
 
+(defun diff-hl-dir-update ()
+  (dolist (pair (vc-dir-marked-only-files-and-states))
+    (when (eq 'up-to-date (cdr pair))
+      (let ((buffer (find-buffer-visiting (car pair))))
+        (when buffer
+          (with-current-buffer buffer
+            (diff-hl-remove-overlays)))))))
+
+;;;###autoload
+(define-minor-mode diff-hl-dir-mode
+  "Toggle `diff-hl-mode' link in `vc-dir-mode' buffer."
+  :lighter ""
+  (if diff-hl-dir-mode
+      (add-hook 'vc-checkin-hook 'diff-hl-dir-update t t)
+    (remove-hook 'vc-checkin-hook 'diff-hl-dir-update t)))
+
 (defun turn-on-diff-hl-mode ()
-  ;; FIXME: Why is this called twice for each buffer?
-  ;; Isn't fundamental-mode supposed to not run any hooks?
-  (and buffer-file-name (not (eq major-mode (default-value 'major-mode)))
-       (window-system) ;; No fringes in the console.
-       (diff-hl-mode 1)))
+  (when (window-system) ;; No fringes in the console.
+    (cond
+     ;; FIXME: Why is this called twice for each buffer?
+     ;; Isn't fundamental-mode supposed to not run any hooks?
+     ((and buffer-file-name (not (eq major-mode (default-value 'major-mode))))
+      (diff-hl-mode 1))
+     ((eq major-mode 'vc-dir-mode)
+      (diff-hl-dir-mode 1)))))
 
 ;;;###autoload
 (define-globalized-minor-mode global-diff-hl-mode diff-hl-mode

commit 17a1147aabfb71281ef87bc1774fa41d224945c5
Author: Dmitry Gutov <address@hidden>
Date:   Sun Jul 8 03:33:49 2012 +0400

    ~

diff --git a/diff-hl.el b/diff-hl.el
index 534f468..d5fd958 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -115,8 +115,7 @@
          (file (buffer-file-name))
          (backend (vc-backend file))
          res)
-    (when (and backend (not (eq (vc-state (buffer-file-name) backend)
-                                'up-to-date)))
+    (when (and backend (not (eq (vc-state file backend) 'up-to-date)))
       (diff-hl-with-diff-switches
        (vc-call-backend backend 'diff (list file) nil nil buf-name))
       (with-current-buffer buf-name

commit aebf27fb14895e9d5a9c5e069187f8b79765eac8
Author: Dmitry Gutov <address@hidden>
Date:   Thu Jul 5 02:57:44 2012 +0400

    Short-circuit when file is up-to-date

diff --git a/diff-hl.el b/diff-hl.el
index 76973ab..534f468 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -3,7 +3,7 @@
 ;; Author:   Dmitry Gutov <address@hidden>
 ;; URL:      https://github.com/dgutov/diff-hl
 ;; Keywords: vc, diff
-;; Version:  1.0
+;; Version:  1.0.1
 
 ;; This file is not part of GNU Emacs.
 
@@ -115,7 +115,8 @@
          (file (buffer-file-name))
          (backend (vc-backend file))
          res)
-    (when backend
+    (when (and backend (not (eq (vc-state (buffer-file-name) backend)
+                                'up-to-date)))
       (diff-hl-with-diff-switches
        (vc-call-backend backend 'diff (list file) nil nil buf-name))
       (with-current-buffer buf-name

commit 421c9bfc709eb03f7e7ecc889c9489dc363df02e
Author: Dmitry Gutov <address@hidden>
Date:   Mon Jul 2 04:20:27 2012 +0400

    Reorder description lines

diff --git a/README.md b/README.md
index 9a0909a..d71c25a 100644
--- a/README.md
+++ b/README.md
@@ -4,12 +4,12 @@ About
 `diff-hl-mode` provides IDE-like highlighting of `vc-diff` results on the left
 fringe of the current buffer.
 
-Additionally, it defines and binds `diff-hl-diff-goto-hunk` and
-`diff-hl-revert-hunk`, to `C-x v =` and `C-x v n` respectively.
-
 Since it uses the corresponding VC diff command, it's only accurate when the
 buffer is in saved state.
 
+Additionally, it defines and binds `diff-hl-diff-goto-hunk` and
+`diff-hl-revert-hunk`, to `C-x v =` and `C-x v n` respectively.
+
 Tested with Git, Mercurial, and Bazaar. May work with other VC backends, too.
 
 Usage

commit 0b769b12398e731717b490425f8d5024137d53d3
Author: Dmitry Gutov <address@hidden>
Date:   Mon Jul 2 01:27:25 2012 +0400

    Update comments, assign version

diff --git a/README.md b/README.md
index 6e82c3a..9a0909a 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,13 @@
 About
 =====
 
-`diff-hl-mode` provides IDE-like highlighting on the fringe to the left of the
-changed buffer lines, compared to current HEAD.
+`diff-hl-mode` provides IDE-like highlighting of `vc-diff` results on the left
+fringe of the current buffer.
 
-Since it uses the corresponding VC diff command, it's only accurate when a
+Additionally, it defines and binds `diff-hl-diff-goto-hunk` and
+`diff-hl-revert-hunk`, to `C-x v =` and `C-x v n` respectively.
+
+Since it uses the corresponding VC diff command, it's only accurate when the
 buffer is in saved state.
 
 Tested with Git, Mercurial, and Bazaar. May work with other VC backends, too.
diff --git a/diff-hl.el b/diff-hl.el
index 85429d9..76973ab 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -1,7 +1,9 @@
 ;;; diff-hl.el --- VC diff fringe highlighting -*- lexical-binding: t -*-
 
 ;; Author:   Dmitry Gutov <address@hidden>
+;; URL:      https://github.com/dgutov/diff-hl
 ;; Keywords: vc, diff
+;; Version:  1.0
 
 ;; This file is not part of GNU Emacs.
 
@@ -18,6 +20,15 @@
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
+;;; Commentary:
+
+;; `diff-hl-mode' provides IDE-like highlighting of `vc-diff' results
+;; on the left fringe of the current buffer.
+;;
+;; For full description, see README.md or the home page.
+
+;;; Code:
+
 (require 'diff-mode)
 (require 'vc)
 (eval-when-compile
@@ -188,7 +199,7 @@
       (diff-hl-update))))
 
 (defun diff-hl-diff-goto-hunk ()
-  "Open diff buffer and skip to the line corresponding to current."
+  "Run VC diff command and go to the line corresponding to current."
   (interactive)
   (vc-buffer-sync)
   (let* ((line (line-number-at-pos))
@@ -220,6 +231,7 @@ in the source file, or the last line of the hunk above it."
                   (decf to-go))))))))))
 
 (defun diff-hl-revert-hunk ()
+  "Revert the diff hunk with changes at or above the point."
   (interactive)
   (vc-buffer-sync)
   (let ((diff-buffer (generate-new-buffer-name "*diff-hl*"))
@@ -281,3 +293,5 @@ in the source file, or the last line of the hunk above it."
   turn-on-diff-hl-mode)
 
 (provide 'diff-hl)
+
+;;; diff-hl.el ends here

commit 16c512c04c8e468731d145a180554723ca762705
Author: Dmitry Gutov <address@hidden>
Date:   Mon Jul 2 00:31:37 2012 +0400

    Don't overload vc-diff-revert, bind to "C-x v n" instead

diff --git a/diff-hl.el b/diff-hl.el
index 6d270f4..85429d9 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -55,12 +55,6 @@
   :group 'diff-hl
   :type 'boolean)
 
-(defcustom diff-hl-revert-current-hunk t
-  "Non-nil to only revert current hunk by default.
-`diff-hl-revert' will do the opposite when called with prefix argument."
-  :group 'diff-hl
-  :type 'boolean)
-
 (defun diff-hl-define-bitmaps ()
   (let* ((scale (if (and (boundp 'text-scale-mode-amount)
                          (plusp text-scale-mode-amount))
@@ -225,41 +219,40 @@ in the source file, or the last line of the hunk above 
it."
                 (unless (looking-at "^-")
                   (decf to-go))))))))))
 
-(defun diff-hl-revert (arg)
-  (interactive "P")
-  (if (not (diff-xor arg diff-hl-revert-current-hunk))
-      (vc-revert)
-    (vc-buffer-sync)
-    (let ((diff-buffer (generate-new-buffer-name "*diff-hl*"))
-          (buffer (current-buffer))
-          (line (line-number-at-pos))
-          (fileset (vc-deduce-fileset)))
-      (unwind-protect
-          (progn
-            (diff-hl-with-diff-switches
-             (vc-diff-internal nil fileset nil nil nil diff-buffer))
-            (vc-exec-after
-             `(progn
-                (when (eobp)
-                  (with-current-buffer ,buffer (diff-hl-remove-overlays))
-                  (error "Buffer is up-to-date"))
-                (diff-hl-diff-skip-to ,line)
-                (save-restriction
-                  (diff-restrict-view)
-                  (unless (yes-or-no-p (format "Revert current hunk in %s?"
-                                               ,(caadr fileset)))
-                    (error "Revert canceled")))
-                (let ((diff-advance-after-apply-hunk nil))
-                  (diff-apply-hunk t)))))
-        (quit-windows-on diff-buffer)
-        (save-buffer)
-        (message "Hunk reverted")))))
+(defun diff-hl-revert-hunk ()
+  (interactive)
+  (vc-buffer-sync)
+  (let ((diff-buffer (generate-new-buffer-name "*diff-hl*"))
+        (buffer (current-buffer))
+        (line (line-number-at-pos))
+        (fileset (vc-deduce-fileset)))
+    (unwind-protect
+        (progn
+          (diff-hl-with-diff-switches
+           (vc-diff-internal nil fileset nil nil nil diff-buffer))
+          (vc-exec-after
+           `(progn
+              (when (eobp)
+                (with-current-buffer ,buffer (diff-hl-remove-overlays))
+                (error "Buffer is up-to-date"))
+              (diff-hl-diff-skip-to ,line)
+              (save-restriction
+                (diff-restrict-view)
+                (unless (yes-or-no-p (format "Revert current hunk in %s?"
+                                             ,(caadr fileset)))
+                  (error "Revert canceled")))
+              (let ((diff-advance-after-apply-hunk nil))
+                (diff-apply-hunk t))
+              (with-current-buffer ,buffer
+                (save-buffer))
+              (message "Hunk reverted"))))
+      (quit-windows-on diff-buffer))))
 
 ;;;###autoload
 (define-minor-mode diff-hl-mode
   "Toggle display of VC diff indicators in the left fringe."
-  :lighter "" :keymap '(([remap vc-diff] . diff-hl-diff-goto-hunk)
-                        ([remap vc-revert] . diff-hl-revert))
+  :lighter "" :keymap `(([remap vc-diff] . diff-hl-diff-goto-hunk)
+                        (,(kbd "C-x v n") . diff-hl-revert-hunk))
   (if diff-hl-mode
       (progn
         (add-hook 'after-save-hook 'diff-hl-update nil t)

commit f61eac1863b28762668816fdfbae662bf1bab7b2
Author: Dmitry Gutov <address@hidden>
Date:   Sun Jul 1 23:24:19 2012 +0400

    Tweak the notion of current hunk

diff --git a/diff-hl.el b/diff-hl.el
index 01d4ddb..6d270f4 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -205,6 +205,8 @@
                       (diff-hl-diff-skip-to ,line)))))
 
 (defun diff-hl-diff-skip-to (line)
+  "In `diff-mode', skip to the hunk and line corresponding to LINE
+in the source file, or the last line of the hunk above it."
   (diff-hunk-next)
   (let (found)
     (while (and (looking-at diff-hunk-header-re-unified) (not found))
@@ -214,11 +216,14 @@
         (if (> line (+ hunk-line len))
             (diff-hunk-next)
           (setq found t)
-          (let ((to-go (1+ (- line hunk-line))))
-            (while (plusp to-go)
-              (forward-line 1)
-              (unless (looking-at "^-")
-                (decf to-go)))))))))
+          (if (< line hunk-line)
+              ;; Retreat to the previous hunk.
+              (forward-line -1)
+            (let ((to-go (1+ (- line hunk-line))))
+              (while (plusp to-go)
+                (forward-line 1)
+                (unless (looking-at "^-")
+                  (decf to-go))))))))))
 
 (defun diff-hl-revert (arg)
   (interactive "P")

commit f2f1e307fe9ebde07666b0d6429877c8e8347fdc
Author: Dmitry Gutov <address@hidden>
Date:   Sun Jul 1 22:55:48 2012 +0400

    Use 0 lines of context when diffing for revert

diff --git a/diff-hl.el b/diff-hl.el
index 66118ca..01d4ddb 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -98,17 +98,21 @@
         (puthash key val diff-hl-spec-cache)))
     val))
 
-(defun diff-hl-changes ()
-  (let* ((buf-name " *vc-diff-hl* ")
-         (vc-git-diff-switches nil)
+(defmacro diff-hl-with-diff-switches (body)
+  `(let ((vc-git-diff-switches nil)
          (vc-hg-diff-switches nil)
          (vc-diff-switches '("-U0"))
-         (vc-disable-async-diff t)
+         (vc-disable-async-diff t))
+     ,body))
+
+(defun diff-hl-changes ()
+  (let* ((buf-name " *diff-hl* ")
          (file (buffer-file-name))
          (backend (vc-backend file))
          res)
     (when backend
-      (vc-call-backend backend 'diff (list file) nil nil buf-name)
+      (diff-hl-with-diff-switches
+       (vc-call-backend backend 'diff (list file) nil nil buf-name))
       (with-current-buffer buf-name
         (goto-char (point-min))
         (unless (eobp)
@@ -227,7 +231,8 @@
           (fileset (vc-deduce-fileset)))
       (unwind-protect
           (progn
-            (vc-diff-internal nil fileset nil nil nil diff-buffer)
+            (diff-hl-with-diff-switches
+             (vc-diff-internal nil fileset nil nil nil diff-buffer))
             (vc-exec-after
              `(progn
                 (when (eobp)

commit 89feaf319084d4d3f0003501698b39a80f47ce41
Author: Dmitry Gutov <address@hidden>
Date:   Sun Jul 1 22:43:18 2012 +0400

    Remove overlays when diff shows no changes

diff --git a/diff-hl.el b/diff-hl.el
index fd6a3a4..66118ca 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -193,26 +193,28 @@
   "Open diff buffer and skip to the line corresponding to current."
   (interactive)
   (vc-buffer-sync)
-  (let* ((line (line-number-at-pos)))
+  (let* ((line (line-number-at-pos))
+         (buffer (current-buffer)))
     (vc-diff-internal t (vc-deduce-fileset) nil nil t)
-    (vc-exec-after `(diff-hl-diff-skip-to ,line))))
+    (vc-exec-after `(if (eobp)
+                        (with-current-buffer ,buffer (diff-hl-remove-overlays))
+                      (diff-hl-diff-skip-to ,line)))))
 
 (defun diff-hl-diff-skip-to (line)
-  (unless (eobp)
-    (diff-hunk-next)
-    (let (found)
-      (while (and (looking-at diff-hunk-header-re-unified) (not found))
-        (let ((hunk-line (string-to-number (match-string 3)))
-              (len (let ((m (match-string 4)))
-                     (if m (string-to-number m) 1))))
-          (if (> line (+ hunk-line len))
-              (diff-hunk-next)
-            (setq found t)
-            (let ((to-go (1+ (- line hunk-line))))
-              (while (plusp to-go)
-                (forward-line 1)
-                (unless (looking-at "^-")
-                  (decf to-go))))))))))
+  (diff-hunk-next)
+  (let (found)
+    (while (and (looking-at diff-hunk-header-re-unified) (not found))
+      (let ((hunk-line (string-to-number (match-string 3)))
+            (len (let ((m (match-string 4)))
+                   (if m (string-to-number m) 1))))
+        (if (> line (+ hunk-line len))
+            (diff-hunk-next)
+          (setq found t)
+          (let ((to-go (1+ (- line hunk-line))))
+            (while (plusp to-go)
+              (forward-line 1)
+              (unless (looking-at "^-")
+                (decf to-go)))))))))
 
 (defun diff-hl-revert (arg)
   (interactive "P")

commit c94a0730e11577e90f87ea3e9d5b608d0214ae37
Author: Dmitry Gutov <address@hidden>
Date:   Sun Jul 1 21:07:29 2012 +0400

    Introduce diff-hl-revert-current-hunk

diff --git a/diff-hl.el b/diff-hl.el
index 58a6715..fd6a3a4 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -55,6 +55,12 @@
   :group 'diff-hl
   :type 'boolean)
 
+(defcustom diff-hl-revert-current-hunk t
+  "Non-nil to only revert current hunk by default.
+`diff-hl-revert' will do the opposite when called with prefix argument."
+  :group 'diff-hl
+  :type 'boolean)
+
 (defun diff-hl-define-bitmaps ()
   (let* ((scale (if (and (boundp 'text-scale-mode-amount)
                          (plusp text-scale-mode-amount))
@@ -210,16 +216,13 @@
 
 (defun diff-hl-revert (arg)
   (interactive "P")
-  (if (not arg)
+  (if (not (diff-xor arg diff-hl-revert-current-hunk))
       (vc-revert)
     (vc-buffer-sync)
     (let ((diff-buffer (generate-new-buffer-name "*diff-hl*"))
           (buffer (current-buffer))
           (line (line-number-at-pos))
           (fileset (vc-deduce-fileset)))
-      (unless (loop for o in (overlays-at (point))
-                    thereis (overlay-get o 'diff-hl))
-        (error "No hunk at point"))
       (unwind-protect
           (progn
             (vc-diff-internal nil fileset nil nil nil diff-buffer)
@@ -227,7 +230,7 @@
              `(progn
                 (when (eobp)
                   (with-current-buffer ,buffer (diff-hl-remove-overlays))
-                  (error "Buffer seems up-to-date"))
+                  (error "Buffer is up-to-date"))
                 (diff-hl-diff-skip-to ,line)
                 (save-restriction
                   (diff-restrict-view)
@@ -237,7 +240,8 @@
                 (let ((diff-advance-after-apply-hunk nil))
                   (diff-apply-hunk t)))))
         (quit-windows-on diff-buffer)
-        (save-buffer)))))
+        (save-buffer)
+        (message "Hunk reverted")))))
 
 ;;;###autoload
 (define-minor-mode diff-hl-mode

commit 48f12b6eed43e0dcdf91ae901c641e88de72365f
Author: Dmitry Gutov <address@hidden>
Date:   Sun Jul 1 20:17:55 2012 +0400

    Allow to revert current hunk only

diff --git a/diff-hl.el b/diff-hl.el
index f1eabda..58a6715 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -208,10 +208,42 @@
                 (unless (looking-at "^-")
                   (decf to-go))))))))))
 
+(defun diff-hl-revert (arg)
+  (interactive "P")
+  (if (not arg)
+      (vc-revert)
+    (vc-buffer-sync)
+    (let ((diff-buffer (generate-new-buffer-name "*diff-hl*"))
+          (buffer (current-buffer))
+          (line (line-number-at-pos))
+          (fileset (vc-deduce-fileset)))
+      (unless (loop for o in (overlays-at (point))
+                    thereis (overlay-get o 'diff-hl))
+        (error "No hunk at point"))
+      (unwind-protect
+          (progn
+            (vc-diff-internal nil fileset nil nil nil diff-buffer)
+            (vc-exec-after
+             `(progn
+                (when (eobp)
+                  (with-current-buffer ,buffer (diff-hl-remove-overlays))
+                  (error "Buffer seems up-to-date"))
+                (diff-hl-diff-skip-to ,line)
+                (save-restriction
+                  (diff-restrict-view)
+                  (unless (yes-or-no-p (format "Revert current hunk in %s?"
+                                               ,(caadr fileset)))
+                    (error "Revert canceled")))
+                (let ((diff-advance-after-apply-hunk nil))
+                  (diff-apply-hunk t)))))
+        (quit-windows-on diff-buffer)
+        (save-buffer)))))
+
 ;;;###autoload
 (define-minor-mode diff-hl-mode
   "Toggle display of VC diff indicators in the left fringe."
-  :lighter "" :keymap '(([remap vc-diff] . diff-hl-diff-goto-hunk))
+  :lighter "" :keymap '(([remap vc-diff] . diff-hl-diff-goto-hunk)
+                        ([remap vc-revert] . diff-hl-revert))
   (if diff-hl-mode
       (progn
         (add-hook 'after-save-hook 'diff-hl-update nil t)

commit b59711456b0d7dbffa51e11e3b07f7c3b9ca2455
Author: Dmitry Gutov <address@hidden>
Date:   Sun Jul 1 19:43:23 2012 +0400

    Fix edge case with deletion at the end of a hunk

diff --git a/diff-hl.el b/diff-hl.el
index 665e953..f1eabda 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -162,7 +162,7 @@
 
 (defun diff-hl-overlay-modified (ov after-p _beg _end &optional _length)
   ;; Delete the overlay and all our overlays inside it.
-  (when after-p
+  (unless after-p
     (save-restriction
       (narrow-to-region (overlay-start ov) (overlay-end ov))
       (diff-hl-remove-overlays))

commit f40157161ce4bb3b1288fb22cee090917df0d749
Author: Dmitry Gutov <address@hidden>
Date:   Sun Jul 1 08:15:03 2012 +0400

    Invalidate all hunk's overlays together

diff --git a/diff-hl.el b/diff-hl.el
index 5c49627..665e953 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -134,30 +134,39 @@
             (incf line))
           (forward-line (- line current-line))
           (setq current-line line)
-          (while (plusp len)
-            (let ((o (make-overlay (point) (line-end-position))))
-              (overlay-put o 'diff-hl t)
-              (overlay-put o 'before-string
-                           (diff-hl-fringe-spec
-                            type
-                            (cond ((not diff-hl-draw-borders) 'empty)
-                                  ((and (= len 1) (= line current-line)) 
'single)
-                                  ((= len 1) 'bottom)
-                                  ((= line current-line) 'top)
-                                  (t 'middle))))
-              (overlay-put o 'modification-hooks '(diff-hl-overlay-modified))
-              (overlay-put o 'insert-in-front-hooks 
'(diff-hl-overlay-modified)))
-            (forward-line 1)
-            (incf current-line)
-            (decf len)))))))
+          (let ((hunk-beg (point)))
+            (while (plusp len)
+              (let ((o (make-overlay (point) (line-end-position))))
+                (overlay-put o 'diff-hl t)
+                (overlay-put o 'before-string
+                             (diff-hl-fringe-spec
+                              type
+                              (cond
+                               ((not diff-hl-draw-borders) 'empty)
+                               ((and (= len 1) (= line current-line)) 'single)
+                               ((= len 1) 'bottom)
+                               ((= line current-line) 'top)
+                               (t 'middle)))))
+              (forward-line 1)
+              (incf current-line)
+              (decf len))
+            (let ((h (make-overlay hunk-beg (point)))
+                  (hook '(diff-hl-overlay-modified)))
+              (overlay-put h 'diff-hl t)
+              (overlay-put h 'modification-hooks hook)
+              (overlay-put h 'insert-in-front-hooks hook))))))))
 
 (defun diff-hl-remove-overlays ()
   (dolist (o (overlays-in (point-min) (point-max)))
     (when (overlay-get o 'diff-hl) (delete-overlay o))))
 
 (defun diff-hl-overlay-modified (ov after-p _beg _end &optional _length)
-  ;; Do the simplest possible thing, for now.
-  (when after-p (delete-overlay ov)))
+  ;; Delete the overlay and all our overlays inside it.
+  (when after-p
+    (save-restriction
+      (narrow-to-region (overlay-start ov) (overlay-end ov))
+      (diff-hl-remove-overlays))
+    (delete-overlay ov)))
 
 (defvar diff-hl-timer nil)
 

commit 6e525390d9715e4e0f76f0b3c44707ab6601851f
Author: Dmitry Gutov <address@hidden>
Date:   Sun Jul 1 07:43:42 2012 +0400

    Use `diff-hunk-prev/next' to benefit from `diff-auto-refine-mode'

diff --git a/diff-hl.el b/diff-hl.el
index d7171d8..5c49627 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -184,14 +184,14 @@
 
 (defun diff-hl-diff-skip-to (line)
   (unless (eobp)
-    (diff-beginning-of-hunk t)
+    (diff-hunk-next)
     (let (found)
       (while (and (looking-at diff-hunk-header-re-unified) (not found))
         (let ((hunk-line (string-to-number (match-string 3)))
               (len (let ((m (match-string 4)))
                      (if m (string-to-number m) 1))))
           (if (> line (+ hunk-line len))
-              (diff-end-of-hunk)
+              (diff-hunk-next)
             (setq found t)
             (let ((to-go (1+ (- line hunk-line))))
               (while (plusp to-go)

commit bfd1a32195efbb505ebc224720603b1fa7de2a8f
Author: Dmitry Gutov <address@hidden>
Date:   Sat Jun 30 04:58:47 2012 +0400

    Fix compilation warning

diff --git a/diff-hl.el b/diff-hl.el
index 9c0f465..d7171d8 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -23,7 +23,8 @@
 (eval-when-compile
   (require 'cl)
   (require 'vc-git)
-  (require 'vc-hg))
+  (require 'vc-hg)
+  (require 'face-remap))
 
 (defgroup diff-hl nil
   "VC diff fringe highlighting"

commit 21530240c963d3e9caff5772a369d993bfb99da4
Author: Dmitry Gutov <address@hidden>
Date:   Sat Jun 30 04:52:38 2012 +0400

    Abort when diff buffer is empty

diff --git a/diff-hl.el b/diff-hl.el
index 384f91e..9c0f465 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -182,20 +182,21 @@
     (vc-exec-after `(diff-hl-diff-skip-to ,line))))
 
 (defun diff-hl-diff-skip-to (line)
-  (diff-beginning-of-hunk t)
-  (let (found)
-    (while (and (looking-at diff-hunk-header-re-unified) (not found))
-      (let ((hunk-line (string-to-number (match-string 3)))
-            (len (let ((m (match-string 4)))
-                   (if m (string-to-number m) 1))))
-        (if (> line (+ hunk-line len))
-            (diff-end-of-hunk)
-          (setq found t)
-          (let ((to-go (1+ (- line hunk-line))))
-            (while (plusp to-go)
-              (forward-line 1)
-              (unless (looking-at "^-")
-                (decf to-go)))))))))
+  (unless (eobp)
+    (diff-beginning-of-hunk t)
+    (let (found)
+      (while (and (looking-at diff-hunk-header-re-unified) (not found))
+        (let ((hunk-line (string-to-number (match-string 3)))
+              (len (let ((m (match-string 4)))
+                     (if m (string-to-number m) 1))))
+          (if (> line (+ hunk-line len))
+              (diff-end-of-hunk)
+            (setq found t)
+            (let ((to-go (1+ (- line hunk-line))))
+              (while (plusp to-go)
+                (forward-line 1)
+                (unless (looking-at "^-")
+                  (decf to-go))))))))))
 
 ;;;###autoload
 (define-minor-mode diff-hl-mode

commit 54d3006728ea83e230b6d4d75c431df9c65a7686
Author: Dmitry Gutov <address@hidden>
Date:   Sat Jun 30 04:48:31 2012 +0400

    Go to current hunk after vc-diff

diff --git a/diff-hl.el b/diff-hl.el
index 5dfd73a..384f91e 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -173,10 +173,34 @@
     (unless (buffer-modified-p)
       (diff-hl-update))))
 
+(defun diff-hl-diff-goto-hunk ()
+  "Open diff buffer and skip to the line corresponding to current."
+  (interactive)
+  (vc-buffer-sync)
+  (let* ((line (line-number-at-pos)))
+    (vc-diff-internal t (vc-deduce-fileset) nil nil t)
+    (vc-exec-after `(diff-hl-diff-skip-to ,line))))
+
+(defun diff-hl-diff-skip-to (line)
+  (diff-beginning-of-hunk t)
+  (let (found)
+    (while (and (looking-at diff-hunk-header-re-unified) (not found))
+      (let ((hunk-line (string-to-number (match-string 3)))
+            (len (let ((m (match-string 4)))
+                   (if m (string-to-number m) 1))))
+        (if (> line (+ hunk-line len))
+            (diff-end-of-hunk)
+          (setq found t)
+          (let ((to-go (1+ (- line hunk-line))))
+            (while (plusp to-go)
+              (forward-line 1)
+              (unless (looking-at "^-")
+                (decf to-go)))))))))
+
 ;;;###autoload
 (define-minor-mode diff-hl-mode
   "Toggle display of VC diff indicators in the left fringe."
-  :lighter ""
+  :lighter "" :keymap '(([remap vc-diff] . diff-hl-diff-goto-hunk))
   (if diff-hl-mode
       (progn
         (add-hook 'after-save-hook 'diff-hl-update nil t)

commit 9577de5080a17f30dd46dfe35745fe6ff90e7689
Author: Dmitry Gutov <address@hidden>
Date:   Fri Jun 29 19:11:47 2012 +0400

    Support text-scale-mode

diff --git a/diff-hl.el b/diff-hl.el
index 87faff4..5dfd73a 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -54,9 +54,12 @@
   :group 'diff-hl
   :type 'boolean)
 
-(when (window-system)
-  (define-fringe-bitmap 'diff-hl-bmp-empty [0] 1 1 'center)
-  (let* ((h (frame-char-height))
+(defun diff-hl-define-bitmaps ()
+  (let* ((scale (if (and (boundp 'text-scale-mode-amount)
+                         (plusp text-scale-mode-amount))
+                    (expt text-scale-mode-step text-scale-mode-amount)
+                  1))
+         (h (round (* (frame-char-height) scale)))
          (w (frame-parameter nil 'left-fringe))
          (middle (make-vector h (expt 2 (1- w))))
          (ones (1- (expt 2 w)))
@@ -67,10 +70,14 @@
     (aset bottom (1- h) ones)
     (aset single 0 ones)
     (aset single (1- h) ones)
-    (define-fringe-bitmap 'diff-hl-bmp-top top h 8 'top)
-    (define-fringe-bitmap 'diff-hl-bmp-middle middle h 8 'center)
-    (define-fringe-bitmap 'diff-hl-bmp-bottom bottom h 8 'bottom)
-    (define-fringe-bitmap 'diff-hl-bmp-single single h 8 'center)))
+    (define-fringe-bitmap 'diff-hl-bmp-top top h w 'top)
+    (define-fringe-bitmap 'diff-hl-bmp-middle middle h w 'center)
+    (define-fringe-bitmap 'diff-hl-bmp-bottom bottom h w 'bottom)
+    (define-fringe-bitmap 'diff-hl-bmp-single single h w 'top)))
+
+(when (window-system)
+  (define-fringe-bitmap 'diff-hl-bmp-empty [0] 1 1 'center)
+  (diff-hl-define-bitmaps))
 
 (defvar diff-hl-spec-cache (make-hash-table :test 'equal))
 
@@ -177,11 +184,13 @@
         (if vc-mode
             (diff-hl-update)
           (add-hook 'find-file-hook 'diff-hl-update t t))
-        (add-hook 'vc-checkin-hook 'diff-hl-update nil t))
+        (add-hook 'vc-checkin-hook 'diff-hl-update nil t)
+        (add-hook 'text-scale-mode-hook 'diff-hl-define-bitmaps nil t))
     (remove-hook 'after-save-hook 'diff-hl-update t)
     (remove-hook 'after-change-functions 'diff-hl-edit t)
     (remove-hook 'find-file-hook 'diff-hl-update t)
     (remove-hook 'vc-checkin-hook 'diff-hl-update t)
+    (remove-hook 'text-scale-mode-hook 'diff-hl-define-bitmaps t)
     (diff-hl-remove-overlays)))
 
 (defun turn-on-diff-hl-mode ()

commit 0a1789e1d69a052fa7b245bcc4faf96750bc360c
Author: Dmitry Gutov <address@hidden>
Date:   Fri Jun 29 18:30:15 2012 +0400

    Fix diff-hl-change border color

diff --git a/diff-hl.el b/diff-hl.el
index 302a2a6..87faff4 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -40,12 +40,12 @@
   :group 'diff-hl)
 
 (defface diff-hl-change
-  '((((class color) (min-colors 88) (background light))
+  '((default
+     :foreground "blue")
+    (((class color) (min-colors 88) (background light))
      :background "#ddddff")
     (((class color) (min-colors 88) (background dark))
-     :background "#333355")
-    (((class color))
-     :foreground "blue"))
+     :background "#333355"))
   "Face used to highlight changed lines."
   :group 'diff-hl)
 

commit 63462c296f90f2a5a4ca9d51a9aec71f9d6d60cc
Author: Dmitry Gutov <address@hidden>
Date:   Fri Jun 29 18:14:25 2012 +0400

    Use vc-checkin-hook

diff --git a/diff-hl.el b/diff-hl.el
index 2df0772..302a2a6 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -176,10 +176,12 @@
         (add-hook 'after-change-functions 'diff-hl-edit nil t)
         (if vc-mode
             (diff-hl-update)
-          (add-hook 'find-file-hook 'diff-hl-update t t)))
+          (add-hook 'find-file-hook 'diff-hl-update t t))
+        (add-hook 'vc-checkin-hook 'diff-hl-update nil t))
     (remove-hook 'after-save-hook 'diff-hl-update t)
     (remove-hook 'after-change-functions 'diff-hl-edit t)
     (remove-hook 'find-file-hook 'diff-hl-update t)
+    (remove-hook 'vc-checkin-hook 'diff-hl-update t)
     (diff-hl-remove-overlays)))
 
 (defun turn-on-diff-hl-mode ()

commit c1332998d0daba69e14cb1ba1aa8994e2f16f64b
Author: Dmitry Gutov <address@hidden>
Date:   Fri Jun 29 18:04:38 2012 +0400

    Draw borders around fringe indicators

diff --git a/diff-hl.el b/diff-hl.el
index 10006c7..2df0772 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -25,6 +25,10 @@
   (require 'vc-git)
   (require 'vc-hg))
 
+(defgroup diff-hl nil
+  "VC diff fringe highlighting"
+  :group 'vc)
+
 (defface diff-hl-insert
   '((t :inherit diff-added))
   "Face used to highlight inserted lines."
@@ -39,11 +43,46 @@
   '((((class color) (min-colors 88) (background light))
      :background "#ddddff")
     (((class color) (min-colors 88) (background dark))
-     :background "#333355"))
+     :background "#333355")
+    (((class color))
+     :foreground "blue"))
   "Face used to highlight changed lines."
   :group 'diff-hl)
 
-(define-fringe-bitmap 'diff-hl-empty [0] 1 1 'center)
+(defcustom diff-hl-draw-borders t
+  "Non-nil to draw borders around fringe indicators."
+  :group 'diff-hl
+  :type 'boolean)
+
+(when (window-system)
+  (define-fringe-bitmap 'diff-hl-bmp-empty [0] 1 1 'center)
+  (let* ((h (frame-char-height))
+         (w (frame-parameter nil 'left-fringe))
+         (middle (make-vector h (expt 2 (1- w))))
+         (ones (1- (expt 2 w)))
+         (top (copy-sequence middle))
+         (bottom (copy-sequence middle))
+         (single (copy-sequence middle)))
+    (aset top 0 ones)
+    (aset bottom (1- h) ones)
+    (aset single 0 ones)
+    (aset single (1- h) ones)
+    (define-fringe-bitmap 'diff-hl-bmp-top top h 8 'top)
+    (define-fringe-bitmap 'diff-hl-bmp-middle middle h 8 'center)
+    (define-fringe-bitmap 'diff-hl-bmp-bottom bottom h 8 'bottom)
+    (define-fringe-bitmap 'diff-hl-bmp-single single h 8 'center)))
+
+(defvar diff-hl-spec-cache (make-hash-table :test 'equal))
+
+(defun diff-hl-fringe-spec (type pos)
+  (let* ((key (cons type pos))
+         (val (gethash key diff-hl-spec-cache)))
+    (unless val
+      (let* ((face-sym (intern (concat "diff-hl-" (symbol-name type))))
+             (bmp-sym (intern (concat "diff-hl-bmp-" (symbol-name pos)))))
+        (setq val (propertize " " 'display `((left-fringe ,bmp-sym 
,face-sym))))
+        (puthash key val diff-hl-spec-cache)))
+    val))
 
 (defun diff-hl-changes ()
   (let* ((buf-name " *vc-diff-hl* ")
@@ -74,15 +113,6 @@
                 (push (list line len type) res)))))))
     (nreverse res)))
 
-(eval-and-compile
-  (dolist (type '(insert delete change))
-    (let* ((type-str (symbol-name type))
-           (spec-sym (intern (concat "diff-hl-" type-str "-spec")))
-           (face-sym (intern (concat "diff-hl-" type-str))))
-      (eval `(defconst ,spec-sym
-               ,(propertize " " 'display
-                            `((left-fringe diff-hl-empty ,face-sym))))))))
-
 (defun diff-hl-update ()
   (let ((changes (diff-hl-changes))
         (current-line 1))
@@ -100,10 +130,13 @@
             (let ((o (make-overlay (point) (line-end-position))))
               (overlay-put o 'diff-hl t)
               (overlay-put o 'before-string
-                           (case type
-                             ('insert diff-hl-insert-spec)
-                             ('delete diff-hl-delete-spec)
-                             ('change diff-hl-change-spec)))
+                           (diff-hl-fringe-spec
+                            type
+                            (cond ((not diff-hl-draw-borders) 'empty)
+                                  ((and (= len 1) (= line current-line)) 
'single)
+                                  ((= len 1) 'bottom)
+                                  ((= line current-line) 'top)
+                                  (t 'middle))))
               (overlay-put o 'modification-hooks '(diff-hl-overlay-modified))
               (overlay-put o 'insert-in-front-hooks 
'(diff-hl-overlay-modified)))
             (forward-line 1)
@@ -152,8 +185,9 @@
 (defun turn-on-diff-hl-mode ()
   ;; FIXME: Why is this called twice for each buffer?
   ;; Isn't fundamental-mode supposed to not run any hooks?
-  (when (and buffer-file-name (not (eq major-mode (default-value 
'major-mode))))
-    (diff-hl-mode 1)))
+  (and buffer-file-name (not (eq major-mode (default-value 'major-mode)))
+       (window-system) ;; No fringes in the console.
+       (diff-hl-mode 1)))
 
 ;;;###autoload
 (define-globalized-minor-mode global-diff-hl-mode diff-hl-mode

commit 64051234816f3e55b661390be96ffde704ba1383
Author: Dmitry Gutov <address@hidden>
Date:   Wed Jun 27 02:35:13 2012 +0400

    Fix indentation

diff --git a/diff-hl.el b/diff-hl.el
index 498b306..10006c7 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -65,7 +65,7 @@
                   (len (let ((m (match-string 4)))
                          (if m (string-to-number m) 1)))
                   (beg (point)))
-               (diff-end-of-hunk)
+              (diff-end-of-hunk)
               (let* ((inserts (diff-count-matches "^\\+" beg (point)))
                      (deletes (diff-count-matches "^-" beg (point)))
                      (type (cond ((zerop deletes) 'insert)

commit 2e45254224325bcbda54e761e36ec7f8bd42113f
Author: Dmitry Gutov <address@hidden>
Date:   Tue Jun 26 15:15:18 2012 +0400

    Remove overlays when the mode is disabled

diff --git a/diff-hl.el b/diff-hl.el
index 4347223..498b306 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -86,10 +86,9 @@
 (defun diff-hl-update ()
   (let ((changes (diff-hl-changes))
         (current-line 1))
+    (diff-hl-remove-overlays)
     (save-excursion
       (goto-char (point-min))
-      (mapc (lambda (o) (when (overlay-get o 'diff-hl) (delete-overlay o)))
-            (overlays-in (point-min) (point-max)))
       (dolist (c changes)
         (destructuring-bind (line len type) c
           (when (eq type 'delete)
@@ -111,6 +110,10 @@
             (incf current-line)
             (decf len)))))))
 
+(defun diff-hl-remove-overlays ()
+  (dolist (o (overlays-in (point-min) (point-max)))
+    (when (overlay-get o 'diff-hl) (delete-overlay o))))
+
 (defun diff-hl-overlay-modified (ov after-p _beg _end &optional _length)
   ;; Do the simplest possible thing, for now.
   (when after-p (delete-overlay ov)))
@@ -143,7 +146,8 @@
           (add-hook 'find-file-hook 'diff-hl-update t t)))
     (remove-hook 'after-save-hook 'diff-hl-update t)
     (remove-hook 'after-change-functions 'diff-hl-edit t)
-    (remove-hook 'find-file-hook 'diff-hl-update t)))
+    (remove-hook 'find-file-hook 'diff-hl-update t)
+    (diff-hl-remove-overlays)))
 
 (defun turn-on-diff-hl-mode ()
   ;; FIXME: Why is this called twice for each buffer?

commit 6c7494ed8abc50041efaf9df1c4dc84a5d70d708
Author: Dmitry Gutov <address@hidden>
Date:   Tue Jun 26 15:09:38 2012 +0400

    Defer initialization until vc-mode is on
    
    Saves ~0.03s on "git ls-files" here

diff --git a/diff-hl.el b/diff-hl.el
index 67f05e2..4347223 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -133,13 +133,17 @@
 ;;;###autoload
 (define-minor-mode diff-hl-mode
   "Toggle display of VC diff indicators in the left fringe."
-  :after-hook (diff-hl-update)
+  :lighter ""
   (if diff-hl-mode
       (progn
         (add-hook 'after-save-hook 'diff-hl-update nil t)
-        (add-hook 'after-change-functions 'diff-hl-edit nil t))
+        (add-hook 'after-change-functions 'diff-hl-edit nil t)
+        (if vc-mode
+            (diff-hl-update)
+          (add-hook 'find-file-hook 'diff-hl-update t t)))
     (remove-hook 'after-save-hook 'diff-hl-update t)
-    (remove-hook 'after-change-functions 'diff-hl-edit t)))
+    (remove-hook 'after-change-functions 'diff-hl-edit t)
+    (remove-hook 'find-file-hook 'diff-hl-update t)))
 
 (defun turn-on-diff-hl-mode ()
   ;; FIXME: Why is this called twice for each buffer?

commit ea3b233ae5b360538377be28382c139b4e928ed0
Author: Dmitry Gutov <address@hidden>
Date:   Tue Jun 26 03:04:46 2012 +0400

    Work around the mode being enabled twice

diff --git a/diff-hl.el b/diff-hl.el
index dc55116..67f05e2 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -142,7 +142,9 @@
     (remove-hook 'after-change-functions 'diff-hl-edit t)))
 
 (defun turn-on-diff-hl-mode ()
-  (when (buffer-file-name)
+  ;; FIXME: Why is this called twice for each buffer?
+  ;; Isn't fundamental-mode supposed to not run any hooks?
+  (when (and buffer-file-name (not (eq major-mode (default-value 
'major-mode))))
     (diff-hl-mode 1)))
 
 ;;;###autoload

commit 13e19b3327e4415d0e92767673fe2ce57e20918f
Author: Dmitry Gutov <address@hidden>
Date:   Mon Jun 25 19:57:39 2012 +0400

    lexical-binding: t

diff --git a/diff-hl.el b/diff-hl.el
index 63eeb51..dc55116 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -1,4 +1,4 @@
-;;; diff-hl.el --- VC diff highlighting in the buffer window
+;;; diff-hl.el --- VC diff fringe highlighting -*- lexical-binding: t -*-
 
 ;; Author:   Dmitry Gutov <address@hidden>
 ;; Keywords: vc, diff
@@ -20,7 +20,10 @@
 
 (require 'diff-mode)
 (require 'vc)
-(eval-when-compile (require 'cl))
+(eval-when-compile
+  (require 'cl)
+  (require 'vc-git)
+  (require 'vc-hg))
 
 (defface diff-hl-insert
   '((t :inherit diff-added))
@@ -108,13 +111,13 @@
             (incf current-line)
             (decf len)))))))
 
-(defun diff-hl-overlay-modified (ov after-p beg end &optional length)
+(defun diff-hl-overlay-modified (ov after-p _beg _end &optional _length)
   ;; Do the simplest possible thing, for now.
   (when after-p (delete-overlay ov)))
 
 (defvar diff-hl-timer nil)
 
-(defun diff-hl-edit (beg end len)
+(defun diff-hl-edit (_beg _end _len)
   ;; DTRT when we've `undo'-ed the buffer into unmodified state.
   (when undo-in-progress
     (when diff-hl-timer

commit 6889278472f3eaccb5f0bb6640e1fbb16f7eac84
Author: Dmitry Gutov <address@hidden>
Date:   Mon Jun 25 19:37:12 2012 +0400

    Rename background buffer

diff --git a/diff-hl.el b/diff-hl.el
index 8e890ab..63eeb51 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -43,7 +43,7 @@
 (define-fringe-bitmap 'diff-hl-empty [0] 1 1 'center)
 
 (defun diff-hl-changes ()
-  (let* ((buf-name " *vc-bg-diff* ")
+  (let* ((buf-name " *vc-diff-hl* ")
          (vc-git-diff-switches nil)
          (vc-hg-diff-switches nil)
          (vc-diff-switches '("-U0"))

commit 664c36d25c84d66a319fefaabf4b8674d30c3f30
Author: Dmitry Gutov <address@hidden>
Date:   Mon Jun 25 19:35:55 2012 +0400

    Silence some compilation warnings

diff --git a/diff-hl.el b/diff-hl.el
index 7a9231c..8e890ab 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -20,6 +20,7 @@
 
 (require 'diff-mode)
 (require 'vc)
+(eval-when-compile (require 'cl))
 
 (defface diff-hl-insert
   '((t :inherit diff-added))
@@ -70,13 +71,14 @@
                 (push (list line len type) res)))))))
     (nreverse res)))
 
-(dolist (type '(insert delete change))
-  (let* ((type-str (symbol-name type))
-         (spec-sym (intern (concat "diff-hl-" type-str "-spec")))
-         (face-sym (intern (concat "diff-hl-" type-str))))
-    (eval `(defconst ,spec-sym
-             ,(propertize " " 'display
-                          `((left-fringe diff-hl-empty ,face-sym)))))))
+(eval-and-compile
+  (dolist (type '(insert delete change))
+    (let* ((type-str (symbol-name type))
+           (spec-sym (intern (concat "diff-hl-" type-str "-spec")))
+           (face-sym (intern (concat "diff-hl-" type-str))))
+      (eval `(defconst ,spec-sym
+               ,(propertize " " 'display
+                            `((left-fringe diff-hl-empty ,face-sym))))))))
 
 (defun diff-hl-update ()
   (let ((changes (diff-hl-changes))

commit 2d75ef18b1d38d39e6bba7afd4cc80dd6037cd9e
Author: Dmitry Gutov <address@hidden>
Date:   Mon Jun 25 18:42:52 2012 +0400

    README, comments, license

diff --git a/README.md b/README.md
new file mode 100644
index 0000000..6e82c3a
--- /dev/null
+++ b/README.md
@@ -0,0 +1,26 @@
+About
+=====
+
+`diff-hl-mode` provides IDE-like highlighting on the fringe to the left of the
+changed buffer lines, compared to current HEAD.
+
+Since it uses the corresponding VC diff command, it's only accurate when a
+buffer is in saved state.
+
+Tested with Git, Mercurial, and Bazaar. May work with other VC backends, too.
+
+Usage
+=====
+
+Ensure diff-hl.el is in a directory on your load-path, and add the following to
+your `~/.emacs` or `~/.emacs.d/init.el`
+
+    (require 'diff-hl)
+
+and, to use it in all buffers
+
+    (global-diff-hl-mode)
+
+or, for example, to use it in all `prog-mode` buffers
+
+    (add-hook 'prog-mode-hook 'turn-on-diff-hl-mode)
diff --git a/diff-hl.el b/diff-hl.el
index a0be038..7a9231c 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -1,3 +1,23 @@
+;;; diff-hl.el --- VC diff highlighting in the buffer window
+
+;; Author:   Dmitry Gutov <address@hidden>
+;; Keywords: vc, diff
+
+;; This file is not part of GNU Emacs.
+
+;; This file is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This file is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
 (require 'diff-mode)
 (require 'vc)
 
@@ -87,7 +107,7 @@
             (decf len)))))))
 
 (defun diff-hl-overlay-modified (ov after-p beg end &optional length)
-  ;; Do the simplest possible thing for now.
+  ;; Do the simplest possible thing, for now.
   (when after-p (delete-overlay ov)))
 
 (defvar diff-hl-timer nil)
@@ -107,7 +127,7 @@
 
 ;;;###autoload
 (define-minor-mode diff-hl-mode
-  "Toggle display of vc diff indicators in the left margin."
+  "Toggle display of VC diff indicators in the left fringe."
   :after-hook (diff-hl-update)
   (if diff-hl-mode
       (progn

commit c0622576146b06b7c804967d2935005c9101441b
Author: Dmitry Gutov <address@hidden>
Date:   Mon Jun 25 18:03:20 2012 +0400

    The macro was broken, use `eval'

diff --git a/diff-hl.el b/diff-hl.el
index 5760884..a0be038 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -50,14 +50,13 @@
                 (push (list line len type) res)))))))
     (nreverse res)))
 
-(defmacro diff-hl-defspec (symbol)
+(dolist (type '(insert delete change))
   (let* ((type-str (symbol-name type))
          (spec-sym (intern (concat "diff-hl-" type-str "-spec")))
          (face-sym (intern (concat "diff-hl-" type-str))))
-    `(defconst ,spec-sym
-       ,(propertize " " 'display `((left-fringe diff-hl-empty ,face-sym))))))
-
-(mapc (lambda (type) (diff-hl-defspec type)) '(insert delete change))
+    (eval `(defconst ,spec-sym
+             ,(propertize " " 'display
+                          `((left-fringe diff-hl-empty ,face-sym)))))))
 
 (defun diff-hl-update ()
   (let ((changes (diff-hl-changes))

commit 98178b797b91aa75a55db2451cd81b781bb6c3b7
Author: Dmitry Gutov <address@hidden>
Date:   Mon Jun 25 16:15:53 2012 +0400

    DTRT after undo

diff --git a/diff-hl.el b/diff-hl.el
index 187abcc..5760884 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -88,15 +88,34 @@
             (decf len)))))))
 
 (defun diff-hl-overlay-modified (ov after-p beg end &optional length)
+  ;; Do the simplest possible thing for now.
   (when after-p (delete-overlay ov)))
 
+(defvar diff-hl-timer nil)
+
+(defun diff-hl-edit (beg end len)
+  ;; DTRT when we've `undo'-ed the buffer into unmodified state.
+  (when undo-in-progress
+    (when diff-hl-timer
+      (cancel-timer diff-hl-timer))
+    (setq diff-hl-timer
+          (run-with-idle-timer 0.01 nil #'diff-hl-after-undo 
(current-buffer)))))
+
+(defun diff-hl-after-undo (buffer)
+  (with-current-buffer buffer
+    (unless (buffer-modified-p)
+      (diff-hl-update))))
+
 ;;;###autoload
 (define-minor-mode diff-hl-mode
   "Toggle display of vc diff indicators in the left margin."
   :after-hook (diff-hl-update)
   (if diff-hl-mode
-      (add-hook 'after-save-hook 'diff-hl-update nil t)
-    (remove-hook 'after-save-hook 'diff-hl-update t)))
+      (progn
+        (add-hook 'after-save-hook 'diff-hl-update nil t)
+        (add-hook 'after-change-functions 'diff-hl-edit nil t))
+    (remove-hook 'after-save-hook 'diff-hl-update t)
+    (remove-hook 'after-change-functions 'diff-hl-edit t)))
 
 (defun turn-on-diff-hl-mode ()
   (when (buffer-file-name)

commit cea71a7b76f985526cd624cc875ecdffb79a308b
Author: Dmitry Gutov <address@hidden>
Date:   Mon Jun 25 15:11:44 2012 +0400

    Disable async diff (for bzr)

diff --git a/diff-hl.el b/diff-hl.el
index 12c546d..187abcc 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -26,6 +26,7 @@
          (vc-git-diff-switches nil)
          (vc-hg-diff-switches nil)
          (vc-diff-switches '("-U0"))
+         (vc-disable-async-diff t)
          (file (buffer-file-name))
          (backend (vc-backend file))
          res)

commit 46d1b68f8df7f52ff715c21f25533aafd1bce1ca
Author: Dmitry Gutov <address@hidden>
Date:   Mon Jun 25 15:01:39 2012 +0400

    Define globalized minor mode

diff --git a/diff-hl.el b/diff-hl.el
index fc5375b..12c546d 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -97,4 +97,12 @@
       (add-hook 'after-save-hook 'diff-hl-update nil t)
     (remove-hook 'after-save-hook 'diff-hl-update t)))
 
+(defun turn-on-diff-hl-mode ()
+  (when (buffer-file-name)
+    (diff-hl-mode 1)))
+
+;;;###autoload
+(define-globalized-minor-mode global-diff-hl-mode diff-hl-mode
+  turn-on-diff-hl-mode)
+
 (provide 'diff-hl)

commit bbffb8f54d06cbf78a13706be09c45d5acadd45b
Author: Dmitry Gutov <address@hidden>
Date:   Mon Jun 25 02:19:46 2012 +0400

    Minor mode; show on fringe; change colors

diff --git a/diff-hl.el b/diff-hl.el
index f9b36a8..fc5375b 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -2,30 +2,31 @@
 (require 'vc)
 
 (defface diff-hl-insert
-  '((default :inherit diff-added)
-    (((class color) (min-colors 88)) :background "#33dd33"))
+  '((t :inherit diff-added))
   "Face used to highlight inserted lines."
   :group 'diff-hl)
 
 (defface diff-hl-delete
-  '((default :inherit diff-removed)
-    (((class color) (min-colors 88)) :background "#dd3333"))
+  '((t :inherit diff-removed))
   "Face used to highlight deleted lines."
   :group 'diff-hl)
 
 (defface diff-hl-change
-  '((default :inherit diff-changed)
-    (((class color) (min-colors 88)) :background "#3333dd"))
+  '((((class color) (min-colors 88) (background light))
+     :background "#ddddff")
+    (((class color) (min-colors 88) (background dark))
+     :background "#333355"))
   "Face used to highlight changed lines."
   :group 'diff-hl)
 
+(define-fringe-bitmap 'diff-hl-empty [0] 1 1 'center)
+
 (defun diff-hl-changes ()
   (let* ((buf-name " *vc-bg-diff* ")
          (vc-git-diff-switches nil)
          (vc-hg-diff-switches nil)
          (vc-diff-switches '("-U0"))
          (file (buffer-file-name))
-         (vc-handled-backends (default-value 'vc-handled-backends))
          (backend (vc-backend file))
          res)
     (when backend
@@ -52,9 +53,8 @@
   (let* ((type-str (symbol-name type))
          (spec-sym (intern (concat "diff-hl-" type-str "-spec")))
          (face-sym (intern (concat "diff-hl-" type-str))))
-    `(defconst ,spec-sym ,(propertize " " 'display
-                                      `((margin left-margin)
-                                        ,(propertize " " 'face face-sym))))))
+    `(defconst ,spec-sym
+       ,(propertize " " 'display `((left-fringe diff-hl-empty ,face-sym))))))
 
 (mapc (lambda (type) (diff-hl-defspec type)) '(insert delete change))
 
@@ -62,14 +62,14 @@
   (let ((changes (diff-hl-changes))
         (current-line 1))
     (save-excursion
-      (set-window-margins nil 1 (cdr (window-margins)))
       (goto-char (point-min))
       (mapc (lambda (o) (when (overlay-get o 'diff-hl) (delete-overlay o)))
             (overlays-in (point-min) (point-max)))
       (dolist (c changes)
         (destructuring-bind (line len type) c
           (when (eq type 'delete)
-            (setq len 1))
+            (setq len 1)
+            (incf line))
           (forward-line (- line current-line))
           (setq current-line line)
           (while (plusp len)
@@ -79,9 +79,22 @@
                            (case type
                              ('insert diff-hl-insert-spec)
                              ('delete diff-hl-delete-spec)
-                             ('change diff-hl-change-spec))))
+                             ('change diff-hl-change-spec)))
+              (overlay-put o 'modification-hooks '(diff-hl-overlay-modified))
+              (overlay-put o 'insert-in-front-hooks 
'(diff-hl-overlay-modified)))
             (forward-line 1)
             (incf current-line)
             (decf len)))))))
 
+(defun diff-hl-overlay-modified (ov after-p beg end &optional length)
+  (when after-p (delete-overlay ov)))
+
+;;;###autoload
+(define-minor-mode diff-hl-mode
+  "Toggle display of vc diff indicators in the left margin."
+  :after-hook (diff-hl-update)
+  (if diff-hl-mode
+      (add-hook 'after-save-hook 'diff-hl-update nil t)
+    (remove-hook 'after-save-hook 'diff-hl-update t)))
+
 (provide 'diff-hl)

commit 0921681fa8e1deaf26e6f030db57360f5190fa46
Author: Dmitry Gutov <address@hidden>
Date:   Mon Jun 25 00:27:51 2012 +0400

    First commit

diff --git a/diff-hl.el b/diff-hl.el
new file mode 100644
index 0000000..f9b36a8
--- /dev/null
+++ b/diff-hl.el
@@ -0,0 +1,87 @@
+(require 'diff-mode)
+(require 'vc)
+
+(defface diff-hl-insert
+  '((default :inherit diff-added)
+    (((class color) (min-colors 88)) :background "#33dd33"))
+  "Face used to highlight inserted lines."
+  :group 'diff-hl)
+
+(defface diff-hl-delete
+  '((default :inherit diff-removed)
+    (((class color) (min-colors 88)) :background "#dd3333"))
+  "Face used to highlight deleted lines."
+  :group 'diff-hl)
+
+(defface diff-hl-change
+  '((default :inherit diff-changed)
+    (((class color) (min-colors 88)) :background "#3333dd"))
+  "Face used to highlight changed lines."
+  :group 'diff-hl)
+
+(defun diff-hl-changes ()
+  (let* ((buf-name " *vc-bg-diff* ")
+         (vc-git-diff-switches nil)
+         (vc-hg-diff-switches nil)
+         (vc-diff-switches '("-U0"))
+         (file (buffer-file-name))
+         (vc-handled-backends (default-value 'vc-handled-backends))
+         (backend (vc-backend file))
+         res)
+    (when backend
+      (vc-call-backend backend 'diff (list file) nil nil buf-name)
+      (with-current-buffer buf-name
+        (goto-char (point-min))
+        (unless (eobp)
+          (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))))
+                (push (list line len type) res)))))))
+    (nreverse res)))
+
+(defmacro diff-hl-defspec (symbol)
+  (let* ((type-str (symbol-name type))
+         (spec-sym (intern (concat "diff-hl-" type-str "-spec")))
+         (face-sym (intern (concat "diff-hl-" type-str))))
+    `(defconst ,spec-sym ,(propertize " " 'display
+                                      `((margin left-margin)
+                                        ,(propertize " " 'face face-sym))))))
+
+(mapc (lambda (type) (diff-hl-defspec type)) '(insert delete change))
+
+(defun diff-hl-update ()
+  (let ((changes (diff-hl-changes))
+        (current-line 1))
+    (save-excursion
+      (set-window-margins nil 1 (cdr (window-margins)))
+      (goto-char (point-min))
+      (mapc (lambda (o) (when (overlay-get o 'diff-hl) (delete-overlay o)))
+            (overlays-in (point-min) (point-max)))
+      (dolist (c changes)
+        (destructuring-bind (line len type) c
+          (when (eq type 'delete)
+            (setq len 1))
+          (forward-line (- line current-line))
+          (setq current-line line)
+          (while (plusp len)
+            (let ((o (make-overlay (point) (line-end-position))))
+              (overlay-put o 'diff-hl t)
+              (overlay-put o 'before-string
+                           (case type
+                             ('insert diff-hl-insert-spec)
+                             ('delete diff-hl-delete-spec)
+                             ('change diff-hl-change-spec))))
+            (forward-line 1)
+            (incf current-line)
+            (decf len)))))))
+
+(provide 'diff-hl)

-----------------------------------------------------------------------

Summary of changes:
 externals-list                         |    1 +
 packages/diff-hl/.elpaignore           |    2 +
 packages/diff-hl/README.md             |   83 ++++++
 packages/diff-hl/diff-hl-amend.el      |   68 +++++
 packages/diff-hl/diff-hl-dired.el      |  102 +++++++
 packages/diff-hl/diff-hl-margin.el     |   98 +++++++
 packages/diff-hl/diff-hl.el            |  480 ++++++++++++++++++++++++++++++++
 packages/diff-hl/screenshot-dired.png  |  Bin 0 -> 57595 bytes
 packages/diff-hl/screenshot-margin.png |  Bin 0 -> 96375 bytes
 packages/diff-hl/screenshot.png        |  Bin 0 -> 58512 bytes
 10 files changed, 834 insertions(+), 0 deletions(-)
 create mode 100644 packages/diff-hl/.elpaignore
 create mode 100644 packages/diff-hl/README.md
 create mode 100644 packages/diff-hl/diff-hl-amend.el
 create mode 100644 packages/diff-hl/diff-hl-dired.el
 create mode 100644 packages/diff-hl/diff-hl-margin.el
 create mode 100644 packages/diff-hl/diff-hl.el
 create mode 100644 packages/diff-hl/screenshot-dired.png
 create mode 100644 packages/diff-hl/screenshot-margin.png
 create mode 100644 packages/diff-hl/screenshot.png


hooks/post-receive
-- 
ELPA



reply via email to

[Prev in Thread] Current Thread [Next in Thread]