Skip to content

Commit

Permalink
Merge branch 'master' into syohex/dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
dandavison committed May 4, 2020
2 parents ef0a5cb + a3081b0 commit 8745644
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions magit-delta.el
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
;; Author: Dan Davison <[email protected]>
;; URL: https://github.com/dandavison/magit-delta
;; Version: 0.1
;; Package-Requires: ((emacs "25.1") (magit "2.90.1") (xterm-color "1.9"))
;; Package-Requires: ((emacs "25.1") magit xterm-color)

;;; Commentary:

Expand All @@ -14,6 +14,10 @@
;; Use M-x magit-delta-mode to toggle between using Delta, and normal Magit
;; behavior.

;; This package depends on truecolor support in xterm-color
;; (xterm-color@d73867bc8785839e539b6d6dcc881a1e4d3f8def) and `magit-diff-wash-diffs-hook' in magit
;; (magit@8de6ecf5c5c840f8a964c3e5bd4d7a1aedf04e10).

;;; Code:
(require 'magit)
(require 'xterm-color)
Expand Down Expand Up @@ -113,9 +117,17 @@ The input buffer contents are expected to be raw git output."
(defun magit-delta-hide-plus-minus-markers ()
(save-excursion
(goto-char (point-min))
(while (re-search-forward "^\\(+\\|-\\)" nil t)
(let ((ov (make-overlay (match-beginning 0) (match-end 0))))
(overlay-put ov 'display " ")))))
;; Within hunks, hide - or + at the start of a line.
(let ((in-hunk nil))
(while (re-search-forward "^\\(diff\\|@@\\|+\\|-\\)" nil t)
(cond
((string-equal (match-string 0) "diff")
(setq in-hunk nil))
((string-equal (match-string 0) "@@")
(setq in-hunk t))
(in-hunk
(add-text-properties (match-beginning 0) (match-end 0)
'(display " "))))))))

(provide 'magit-delta)

Expand Down

0 comments on commit 8745644

Please sign in to comment.