]> code.delx.au - gnu-emacs-elpa/commitdiff
Add and use fringe faces specific to diff-hl-dired
authorDmitry Gutov <dgutov@yandex.ru>
Sun, 28 Sep 2014 21:17:06 +0000 (01:17 +0400)
committerDmitry Gutov <dgutov@yandex.ru>
Sun, 28 Sep 2014 21:17:06 +0000 (01:17 +0400)
#25

diff-hl-dired.el
diff-hl.el

index a94be03066d0a9fe4b069a69b5cb638c6ca3c91a..928bb9c4f24ba5952b6d2f4c694634459c5b7ba9 100644 (file)
 
 (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."
         (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)
index d208ccbdd95678e6e977189ac2348713d9cab53a..258e48ace198882e4da11cb850dfb85632b92924 100644 (file)
   "Face used to highlight changed lines."\r
   :group 'diff-hl)\r
 \r
-(defface diff-hl-unknown\r
-  '((default :inherit diff-header))\r
-  "Face used to highlight unregistered files.")\r
-\r
 (defcustom diff-hl-command-prefix (kbd "C-x v")\r
   "The prefix for all `diff-hl' commands."\r
   :group 'diff-hl\r
                  (const diff-hl-fringe-bmp-from-type)\r
                  function))\r
 \r
+(defcustom diff-hl-fringe-face-function 'diff-hl-fringe-face-from-type\r
+  "Function to choose the fringe face for a given change type\r
+  and position within a hunk.  Should accept two arguments."\r
+  :group 'diff-hl\r
+  :type 'function)\r
+\r
 (defvar diff-hl-reference-revision nil\r
   "Revision to diff against.  nil means the most recent one.")\r
 \r
   (let* ((key (list type pos diff-hl-fringe-bmp-function))\r
          (val (gethash key diff-hl-spec-cache)))\r
     (unless val\r
-      (let* ((face-sym (intern (format "diff-hl-%s" type)))\r
+      (let* ((face-sym (funcall diff-hl-fringe-face-function type pos))\r
              (bmp-sym (funcall diff-hl-fringe-bmp-function type pos)))\r
         (setq val (propertize " " 'display `((left-fringe ,bmp-sym ,face-sym))))\r
         (puthash key val diff-hl-spec-cache)))\r
     val))\r
 \r
+(defun diff-hl-fringe-face-from-type (type _pos)\r
+  (intern (format "diff-hl-%s" type)))\r
+\r
 (defun diff-hl-fringe-bmp-from-pos (_type pos)\r
   (intern (format "diff-hl-bmp-%s" pos)))\r
 \r