]> code.delx.au - gnu-emacs-elpa/commitdiff
Merge commit '3f49d2b3934e69d11410d08f1be8e0011237c11c' from diff-hl
authorDmitry Gutov <dgutov@yandex.ru>
Sun, 10 Aug 2014 16:32:38 +0000 (20:32 +0400)
committerDmitry Gutov <dgutov@yandex.ru>
Sun, 10 Aug 2014 16:32:38 +0000 (20:32 +0400)
1  2 
packages/diff-hl/README.md
packages/diff-hl/diff-hl-margin.el
packages/diff-hl/diff-hl.el

index b01e8bd206cd6c71b26400cf1732d39d3847a194,325f53ea570c349cbb6f346eafedf7f4106ef82c..325f53ea570c349cbb6f346eafedf7f4106ef82c
@@@ -57,14 -57,15 +57,15 @@@ Note
    you'd usually want to fix all errors and warnings before continuing,\r
    and then the conflicting indicators go away.\r
  \r
- * There's no fringe when Emacs is running in the console, but the navigation and\r
-   revert commands still work. Consider turning `diff-hl-margin-mode` on.\r
+ * There's no fringe when Emacs is running in the console, but the navigation\r
+   and revert commands still work. Consider turning `diff-hl-margin-mode` on,\r
+   to show the indicators in the margin instead.\r
  \r
  * Frame-local and buffer-local values of `line-spacing` are not supported.\r
  \r
- * [git-gutter](https://github.com/syohex/emacs-git-gutter) provides interactive\r
-   commands to show/hide/toggle margin indicators for the same information, and\r
-   allows you to customize how the indicators look.\r
+ * [emacs-git-gutter](https://github.com/syohex/emacs-git-gutter) shows\r
+   indicators in the margin by default, allows you to customize how the\r
+   indicators look more easily, and has a "stage hunk" command.\r
  \r
  Integration\r
  =====\r
@@@ -81,3 -82,9 +82,9 @@@ psv
  (defadvice svn-status-update-modeline (after svn-update-diff-hl activate)\r
    (diff-hl-update))\r
  ```\r
\r
+ Magit\r
+ -----\r
\r
+ If you have a recent enough version installed, it defines\r
+ `magit-revert-buffer-hook`, which we use.\r
index dac0b853d64ed25187e0b60f5450dcd4ad4c36b3,ef3db0a53022d4cdae62ac12bfca8d2115cbca19..ef3db0a53022d4cdae62ac12bfca8d2115cbca19
  (define-minor-mode diff-hl-margin-mode
    "Toggle displaying `diff-hl-mode' highlights on the margin."
    :lighter "" :global t
-   (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
+   (if diff-hl-margin-mode
+       (progn
+         (add-hook 'diff-hl-mode-on-hook 'diff-hl-margin-minor-mode)
+         (add-hook 'diff-hl-mode-off-hook 'diff-hl-margin-minor-mode-off)
+         (add-hook 'diff-hl-dired-mode-on-hook 'diff-hl-margin-minor-mode)
+         (add-hook 'diff-hl-dired-mode-off-hook 'diff-hl-margin-minor-mode-off))
+     (remove-hook 'diff-hl-mode-on-hook 'diff-hl-margin-minor-mode)
+     (remove-hook 'diff-hl-mode-off-hook 'diff-hl-margin-minor-mode-off)
+     (remove-hook 'diff-hl-dired-mode-on-hook 'diff-hl-margin-minor-mode)
+     (remove-hook 'diff-hl-dired-mode-off-hook 'diff-hl-margin-minor-mode-off))
+   (dolist (buf (buffer-list))
+     (with-current-buffer buf
        (cond
         (diff-hl-mode
+         (diff-hl-margin-minor-mode (if diff-hl-margin-mode 1 -1))
          (diff-hl-update))
         (diff-hl-dired-mode
-         (diff-hl-dired-update)))))
-   (walk-windows (lambda (win) (set-window-buffer win (window-buffer win)))))
+         (diff-hl-margin-minor-mode (if diff-hl-margin-mode 1 -1))
+         (diff-hl-dired-update))))))
+ (define-minor-mode diff-hl-margin-minor-mode
+   "Toggle displaying `diff-hl-mode' highlights on the margin locally.
+ You probably shouldn't use this function directly."
+   :lighter ""
+   (let ((width-var (intern (format "%s-margin-width" diff-hl-margin-side))))
+     (if diff-hl-margin-minor-mode
+         (progn
+           (set (make-local-variable 'diff-hl-margin-old-highlight-function)
+                diff-hl-highlight-function)
+           (set (make-local-variable 'diff-hl-highlight-function)
+                'diff-hl-highlight-on-margin)
+           (set width-var 1))
+       (setq diff-hl-highlight-function diff-hl-margin-old-highlight-function
+             diff-hl-margin-old-highlight-function nil)
+       (set width-var 0)))
+   (dolist (win (get-buffer-window-list))
+     (set-window-buffer win (current-buffer))))
+ (defun diff-hl-margin-minor-mode-off ()
+   (diff-hl-margin-minor-mode -1))
  
  (defvar diff-hl-margin-spec-cache
    (cl-loop for (type . char) in '((insert . "+") (delete . "-")
index 4b25fc7f26030d48e4f8d5612d0c43497f222422,a2a8d38df5a93107ffd5548bba850cff0e09353f..a2a8d38df5a93107ffd5548bba850cff0e09353f
@@@ -5,7 -5,7 +5,7 @@@
  ;; Author:   Dmitry Gutov <dgutov@yandex.ru>\r
  ;; URL:      https://github.com/dgutov/diff-hl\r
  ;; Keywords: vc, diff\r
- ;; Version:  1.5.3\r
+ ;; Version:  1.6.0\r
  ;; Package-Requires: ((cl-lib "0.2"))\r
  \r
  ;; This file is part of GNU Emacs.\r
@@@ -51,6 -51,7 +51,7 @@@
  \r
  ;;; Code:\r
  \r
+ (require 'fringe)\r
  (require 'diff-mode)\r
  (require 'vc)\r
  (require 'vc-dir)\r
@@@ -424,17 -425,20 +425,20 @@@ in the source file, or the last line o
          (diff-hl-maybe-define-bitmaps)\r
          (add-hook 'after-save-hook 'diff-hl-update nil t)\r
          (add-hook 'after-change-functions 'diff-hl-edit nil t)\r
-         (if vc-mode\r
-             (diff-hl-update)\r
-           (add-hook 'find-file-hook 'diff-hl-update t t))\r
+         (add-hook (if vc-mode\r
+                       'diff-hl-mode-on-hook\r
+                     'find-file-hook)\r
+                   'diff-hl-update t t)\r
          (add-hook 'vc-checkin-hook 'diff-hl-update nil t)\r
          (add-hook 'after-revert-hook 'diff-hl-update nil t)\r
+         (add-hook 'magit-revert-buffer-hook 'diff-hl-update nil t)\r
          (add-hook 'text-scale-mode-hook 'diff-hl-define-bitmaps nil t))\r
      (remove-hook 'after-save-hook 'diff-hl-update t)\r
      (remove-hook 'after-change-functions 'diff-hl-edit t)\r
      (remove-hook 'find-file-hook 'diff-hl-update t)\r
      (remove-hook 'vc-checkin-hook 'diff-hl-update t)\r
      (remove-hook 'after-revert-hook 'diff-hl-update t)\r
+     (remove-hook 'magit-revert-buffer-hook 'diff-hl-update t)\r
      (remove-hook 'text-scale-mode-hook 'diff-hl-define-bitmaps t)\r
      (diff-hl-remove-overlays)))\r
  \r