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
(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
(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 . "-")
;; 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
\r
;;; Code:\r
\r
+ (require 'fringe)\r
(require 'diff-mode)\r
(require 'vc)\r
(require 'vc-dir)\r
(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