Skip to content

Commit

Permalink
Add user-configurable variable for delta command-line args
Browse files Browse the repository at this point in the history
  • Loading branch information
dandavison committed Apr 23, 2020
1 parent f82cf03 commit 9d57a69
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion magit-delta.el
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,28 @@
(defvar magit-delta-dark-theme "Monokai Extended"
"The color theme to use when Emacs has a dark background.")

(defvar magit-delta-delta-args
`("--max-line-distance" "0.6"
"--24-bit-color" ,(if xterm-color--support-truecolor "always" "never")
"--color-only")
"Delta command line args as a list of strings.
--color-only is required in order to use delta with magit; it
will be added if not present.")

(defun magit-delta--make-delta-args ()
"Make final list of delta command-line arguments."
(let ((args magit-delta-delta-args))
(unless (-intersection '("--theme" "--light" "--dark") args)
(setq args (nconc
(list "--theme"
(if (eq (frame-parameter nil 'background-mode) 'light)
magit-delta-light-theme magit-delta-dark-theme))
args)))
(unless (member "--color-only" args)
(setq args (cons "--color-only" args)))
args))

(setq magit-diff-preprocess-git-output-always--orig-value nil
magit-diff-preprocess-git-output-function--orig-value nil
magit-delta--magit-diff-refine-hunk--orig-value nil)
Expand Down Expand Up @@ -70,7 +92,8 @@ https://github.com/dandavison/delta"

(defun magit-delta-call-delta-and-convert-ansi-escape-sequences ()
(apply #'call-process-region
(point-min) (point-max) magit-delta-delta-executable t t nil (magit-delta-delta-args))
(point-min) (point-max)
magit-delta-delta-executable t t nil (magit-delta--make-delta-args))
(let ((buffer-read-only nil))
(xterm-color-colorize-buffer 'use-overlays)))

Expand Down

0 comments on commit 9d57a69

Please sign in to comment.