]> code.delx.au - gnu-emacs-elpa/blobdiff - diff-hl-dired.el
Add and use fringe faces specific to diff-hl-dired
[gnu-emacs-elpa] / diff-hl-dired.el
index 047d0e89c465266094c37c87d4696d55431652df..928bb9c4f24ba5952b6d2f4c694634459c5b7ba9 100644 (file)
@@ -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.
 
 (require 'diff-hl)
 
+(defvar diff-hl-dired-process-buffer nil)
+
+(defgroup diff-hl-dired nil
+  "VC diff highlighting on the side of a Dired window."
+  :group 'diff-hl)
+
+(defface diff-hl-dired-insert
+  '((default :inherit diff-hl-insert))
+  "Face used to highlight added files.")
+
+(defface diff-hl-dired-delete
+  '((default :inherit diff-hl-delete))
+  "Face used to highlight directories with deleted files.")
+
+(defface diff-hl-dired-change
+  '((default :inherit diff-hl-change))
+  "Face used to highlight changed files.")
+
+(defface diff-hl-dired-unknown
+  '((default :inherit diff-header))
+  "Face used to highlight unregistered files.")
+
 ;;;###autoload
 (define-minor-mode diff-hl-dired-mode
   "Toggle VC diff highlighting on the side of a Dired window."
@@ -37,8 +61,6 @@
     (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 ()
   "Highlight the Dired buffer."
   (let ((backend (ignore-errors (vc-responsible-backend default-directory)))
@@ -57,7 +79,7 @@
         (erase-buffer)
         (vc-call-backend
          backend 'dir-status def-dir
-         (lambda (entries &optional more-to-come)
+         (lambda (entries &optional _more-to-come)
            (with-current-buffer buffer
              (dolist (entry entries)
                (cl-destructuring-bind (file state &rest) entry
         (when (and type (dired-goto-file-1
                          file (expand-file-name file) nil))
           (let* ((diff-hl-fringe-bmp-function 'diff-hl-fringe-bmp-from-type)
+                 (diff-hl-fringe-face-function 'diff-hl-dired-face-from-type)
                  (o (diff-hl-add-highlighting type 'single)))
             (overlay-put o 'modification-hooks '(diff-hl-overlay-modified))
             ))))))
 
+(defun diff-hl-dired-face-from-type (type _pos)
+  (intern (format "diff-hl-dired-%s" type)))
+
 (defalias 'diff-hl-dired-clear 'diff-hl-remove-overlays)
 
 (provide 'diff-hl-dired)