[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 8cec226 22/22: Merge commit '6ea154f73f8389abb03c804bb4a4d
From: |
Dmitry Gutov |
Subject: |
[elpa] master 8cec226 22/22: Merge commit '6ea154f73f8389abb03c804bb4a4d21c8893861b' from diff-hl |
Date: |
Fri, 02 Jan 2015 23:46:35 +0000 |
branch: master
commit 8cec2263db753122a414fdf9156ac523dfc38bcd
Merge: c9c9f55 6ea154f
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>
Merge commit '6ea154f73f8389abb03c804bb4a4d21c8893861b' from diff-hl
---
packages/diff-hl/diff-hl-dired.el | 114 ++++++++++++++++++++++++++++-------
packages/diff-hl/diff-hl-margin.el | 3 +-
packages/diff-hl/diff-hl.el | 48 ++++++++++-----
3 files changed, 124 insertions(+), 41 deletions(-)
diff --git a/packages/diff-hl/diff-hl-dired.el
b/packages/diff-hl/diff-hl-dired.el
index a94be03..09cf851 100644
--- a/packages/diff-hl/diff-hl-dired.el
+++ b/packages/diff-hl/diff-hl-dired.el
@@ -1,6 +1,6 @@
;;; diff-hl-dired.el --- Highlight changed files in Dired -*- lexical-binding:
t -*-
-;; Copyright (C) 2012-2013 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2014 Free Software Foundation, Inc.
;; This file is part of GNU Emacs.
@@ -22,13 +22,49 @@
;; To enable in all Dired buffers, add this to your init file:
;;
;; (add-hook 'dired-mode-hook 'diff-hl-dired-mode)
+;;
+;; or
+;;
+;; (add-hook 'dired-mode-hook 'diff-hl-dired-mode-unless-remote)
+;;
+;; to do it only in local Dired buffers.
;;; Code:
(require 'diff-hl)
+(require 'dired)
(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 dired-ignored))
+ "Face used to highlight unregistered files.")
+
+(defface diff-hl-dired-ignored
+ '((default :inherit dired-ignored))
+ "Face used to highlight unregistered files.")
+
+(defcustom diff-hl-dired-extra-indicators t
+ "Non-nil to indicate ignored files."
+ :group 'diff-hl
+ :type 'boolean)
+
;;;###autoload
(define-minor-mode diff-hl-dired-mode
"Toggle VC diff highlighting on the side of a Dired window."
@@ -57,30 +93,54 @@
(with-current-buffer diff-hl-dired-process-buffer
(setq default-directory (expand-file-name def-dir))
(erase-buffer)
- (vc-call-backend
- backend 'dir-status def-dir
- (lambda (entries &optional _more-to-come)
- (with-current-buffer buffer
- (dolist (entry entries)
- (cl-destructuring-bind (file state &rest) entry
- (let ((type (plist-get
- '(edited change added insert removed delete
- unregistered unknown)
- state)))
- (if (string-match "\\`\\([^/]+\\)/" file)
- (let* ((dir (match-string 1 file))
- (value (cdr (assoc dir dirs-alist))))
- (unless (eq value type)
- (if (null value)
- (push (cons dir type) dirs-alist)
- (setcdr (assoc dir dirs-alist) 'change))))
- (push (cons file type) files-alist)))))
- ;; Process's finished, time to use the results.
- (unless (get-buffer-process diff-hl-dired-process-buffer)
- (diff-hl-dired-highlight-items (append dirs-alist
- files-alist)))))
+ (diff-hl-dired-status-files
+ backend def-dir
+ (when diff-hl-dired-extra-indicators
+ (cl-loop for file in (directory-files def-dir)
+ unless (member file '("." ".." ".hg"))
+ collect file))
+ (lambda (entries &optional more-to-come)
+ (when (buffer-live-p buffer)
+ (with-current-buffer buffer
+ (dolist (entry entries)
+ (cl-destructuring-bind (file state &rest r) entry
+ ;; Work around http://debbugs.gnu.org/18605
+ (setq file (replace-regexp-in-string "\\` " "" file))
+ (let ((type (plist-get
+ '(edited change added insert removed delete
+ unregistered unknown ignored ignored)
+ state)))
+ (if (string-match "\\`\\([^/]+\\)/" file)
+ (let* ((dir (match-string 1 file))
+ (value (cdr (assoc dir dirs-alist))))
+ (unless (eq value type)
+ (cond
+ ((eq type 'up-to-date))
+ ((null value)
+ (push (cons dir type) dirs-alist))
+ ((not (eq type 'ignored))
+ (setcdr (assoc dir dirs-alist) 'change)))))
+ (push (cons file type) files-alist)))))
+ (unless more-to-come
+ (diff-hl-dired-highlight-items
+ (append dirs-alist files-alist))))))
)))))
+(defun diff-hl-dired-status-files (backend dir files uf)
+ (if (version< "25" emacs-version)
+ (vc-call-backend backend 'dir-status-files dir files uf)
+ (vc-call-backend backend 'dir-status-files dir files nil uf)))
+
+(when (version< emacs-version "24.4.51.5")
+ ;; Work around http://debbugs.gnu.org/19386
+ (defadvice vc-git-dir-status-goto-stage (around
+ diff-hl-dired-skip-up-to-date
+ (stage files update-function)
+ activate)
+ (when (eq stage 'ls-files-up-to-date)
+ (setq stage 'diff-index))
+ ad-do-it))
+
(defun diff-hl-dired-highlight-items (alist)
"Highlight ALIST containing (FILE . TYPE) elements."
(dolist (pair alist)
@@ -91,12 +151,20 @@
(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)
+(defun diff-hl-dired-mode-unless-remote ()
+ (unless (file-remote-p default-directory)
+ (diff-hl-dired-mode)))
+
(provide 'diff-hl-dired)
;;; diff-hl-dired.el ends here
diff --git a/packages/diff-hl/diff-hl-margin.el
b/packages/diff-hl/diff-hl-margin.el
index ef3db0a..26fa7ad 100644
--- a/packages/diff-hl/diff-hl-margin.el
+++ b/packages/diff-hl/diff-hl-margin.el
@@ -101,7 +101,8 @@ You probably shouldn't use this function directly."
(defvar diff-hl-margin-spec-cache
(cl-loop for (type . char) in '((insert . "+") (delete . "-")
- (change . "|") (unknown . "?"))
+ (change . "!") (unknown . "?")
+ (ignored . "i"))
nconc
(cl-loop for side in '(left right)
collect
diff --git a/packages/diff-hl/diff-hl.el b/packages/diff-hl/diff-hl.el
index c116a6e..22a877a 100644
--- a/packages/diff-hl/diff-hl.el
+++ b/packages/diff-hl/diff-hl.el
@@ -5,7 +5,7 @@
;; Author: Dmitry Gutov <address@hidden>
;; URL: https://github.com/dgutov/diff-hl
;; Keywords: vc, diff
-;; Version: 1.6.0
+;; Version: 1.7.0
;; Package-Requires: ((cl-lib "0.2"))
;; This file is part of GNU Emacs.
@@ -86,10 +86,6 @@
"Face used to highlight changed lines."
:group 'diff-hl)
-(defface diff-hl-unknown
- '((default :inherit diff-header))
- "Face used to highlight unregistered files.")
-
(defcustom diff-hl-command-prefix (kbd "C-x v")
"The prefix for all `diff-hl' commands."
:group 'diff-hl
@@ -114,6 +110,12 @@
(const diff-hl-fringe-bmp-from-type)
function))
+(defcustom diff-hl-fringe-face-function 'diff-hl-fringe-face-from-type
+ "Function to choose the fringe face for a given change type
+ and position within a hunk. Should accept two arguments."
+ :group 'diff-hl
+ :type 'function)
+
(defvar diff-hl-reference-revision nil
"Revision to diff against. nil means the most recent one.")
@@ -122,11 +124,11 @@
(numberp text-scale-mode-amount))
(expt text-scale-mode-step text-scale-mode-amount)
1))
- (spacing (or (default-value 'line-spacing) 0))
- (h (round (+ (* (frame-char-height) scale)
- (if (floatp spacing)
- (* (frame-char-height) spacing)
- spacing))))
+ (spacing (or (and (display-graphic-p) (default-value 'line-spacing))
0))
+ (h (+ (ceiling (* (frame-char-height) scale))
+ (if (floatp spacing)
+ (truncate (* (frame-char-height) spacing))
+ spacing)))
(w (frame-parameter nil 'left-fringe))
(middle (make-vector h (expt 2 (1- w))))
(ones (1- (expt 2 w)))
@@ -141,7 +143,11 @@
(define-fringe-bitmap 'diff-hl-bmp-middle middle h w 'center)
(define-fringe-bitmap 'diff-hl-bmp-bottom bottom h w 'bottom)
(define-fringe-bitmap 'diff-hl-bmp-single single h w 'top)
+ (define-fringe-bitmap 'diff-hl-bmp-i [3 3 0 3 3 3 3 3 3 3] nil 2 'center)
(let* ((w2 (* (/ w 2) 2))
+ ;; When fringes are disabled, it's easier to fix up the width,
+ ;; instead of doing nothing (#20).
+ (w2 (if (zerop w2) 2 w2))
(delete-row (- (expt 2 (1- w2)) 2))
(middle-pos (1- (/ w2 2)))
(middle-bit (expt 2 middle-pos))
@@ -152,8 +158,7 @@
(aset insert-bmp (1+ middle-pos) delete-row)
(aset insert-bmp (1- w2) 0)
(define-fringe-bitmap 'diff-hl-bmp-insert insert-bmp w2 w2)
- (define-fringe-bitmap 'diff-hl-bmp-change (make-vector
- w2 (* 3 middle-bit)) w2 w2))))
+ )))
(defun diff-hl-maybe-define-bitmaps ()
(when (window-system) ;; No fringes in the console.
@@ -167,19 +172,24 @@
(let* ((key (list type pos diff-hl-fringe-bmp-function))
(val (gethash key diff-hl-spec-cache)))
(unless val
- (let* ((face-sym (intern (format "diff-hl-%s" type)))
+ (let* ((face-sym (funcall diff-hl-fringe-face-function type pos))
(bmp-sym (funcall diff-hl-fringe-bmp-function type pos)))
(setq val (propertize " " 'display `((left-fringe ,bmp-sym
,face-sym))))
(puthash key val diff-hl-spec-cache)))
val))
+(defun diff-hl-fringe-face-from-type (type _pos)
+ (intern (format "diff-hl-%s" type)))
+
(defun diff-hl-fringe-bmp-from-pos (_type pos)
(intern (format "diff-hl-bmp-%s" pos)))
(defun diff-hl-fringe-bmp-from-type (type _pos)
- (if (eq type 'unknown)
- 'question-mark
- (intern (format "diff-hl-bmp-%s" type))))
+ (cl-case type
+ (unknown 'question-mark)
+ (change 'exclamation-mark)
+ (ignored 'diff-hl-bmp-i)
+ (t (intern (format "diff-hl-bmp-%s" type)))))
(defvar vc-svn-diff-switches)
@@ -213,7 +223,8 @@
(with-current-buffer buf-name
(goto-char (point-min))
(unless (eobp)
- (diff-beginning-of-hunk t)
+ (ignore-errors
+ (diff-beginning-of-hunk t))
(while (looking-at diff-hunk-header-re-unified)
(let ((line (string-to-number (match-string 3)))
(len (let ((m (match-string 4)))
@@ -440,7 +451,9 @@ in the source file, or the last line of the hunk above it."
;; Magit does call `auto-revert-handler', but it usually
;; doesn't do much, because `buffer-stale--default-function'
;; doesn't care about changed VC state.
+ ;; https://github.com/magit/magit/issues/603
(add-hook 'magit-revert-buffer-hook 'diff-hl-update nil t)
+ (add-hook 'auto-revert-mode-hook 'diff-hl-update nil t)
(add-hook 'text-scale-mode-hook 'diff-hl-define-bitmaps nil t))
(remove-hook 'after-save-hook 'diff-hl-update t)
(remove-hook 'after-change-functions 'diff-hl-edit t)
@@ -448,6 +461,7 @@ in the source file, or the last line of the hunk above it."
(remove-hook 'vc-checkin-hook 'diff-hl-update t)
(remove-hook 'after-revert-hook 'diff-hl-update t)
(remove-hook 'magit-revert-buffer-hook 'diff-hl-update t)
+ (remove-hook 'auto-revert-mode-hook 'diff-hl-update t)
(remove-hook 'text-scale-mode-hook 'diff-hl-define-bitmaps t)
(diff-hl-remove-overlays)))
- [elpa] master 9c5004e 13/22: diff-hl-dired-{unknown, ignored}: inherit from dired-ignored instead, (continued)
- [elpa] master 9c5004e 13/22: diff-hl-dired-{unknown, ignored}: inherit from dired-ignored instead, Dmitry Gutov, 2015/01/02
- [elpa] master 32951f0 01/22: Add link to an issue, Dmitry Gutov, 2015/01/02
- [elpa] master 788f1fd 14/22: diff-hl-dired-update-ignores: Specifically exclude .hg from iteration, Dmitry Gutov, 2015/01/02
- [elpa] master 469e332 15/22: Add user option `diff-hl-dired-extra-indicators', Dmitry Gutov, 2015/01/02
- [elpa] master bfe57a1 16/22: Use "i" for ignored files, Dmitry Gutov, 2015/01/02
- [elpa] master b4d6dc3 18/22: Introduce diff-hl-dired-mode-unless-remote, Dmitry Gutov, 2015/01/02
- [elpa] master c029ae8 17/22: diff-hl-dired: Always use dir-status-files, Dmitry Gutov, 2015/01/02
- [elpa] master c1351b0 19/22: Collect files only when diff-hl-dired-extra-indicators is non-nil, Dmitry Gutov, 2015/01/02
- [elpa] master cb467b4 20/22: diff-hl-dired-update: Support Emacs 25, Dmitry Gutov, 2015/01/02
- [elpa] master 6ea154f 21/22: Bump the version, Dmitry Gutov, 2015/01/02
- [elpa] master 8cec226 22/22: Merge commit '6ea154f73f8389abb03c804bb4a4d21c8893861b' from diff-hl,
Dmitry Gutov <=