From: Dmitry Gutov Date: Sun, 8 Sep 2013 04:39:05 +0000 (+0300) Subject: * diff-hl-add-highlighting: Return the overlay X-Git-Url: https://code.delx.au/gnu-emacs-elpa/commitdiff_plain/64582ebadef24cdbb1e3b8d2369d7d31627b1b18 * 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 66991026d..a3b766fbe 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 87f15bf63..583fd148d 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)))