summaryrefslogtreecommitdiff
path: root/modules/diff-config.el
blob: aaef8dbf8b46e28a4200dda9cfd9e45a1da4ed2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
;;; ediff-config.el --- diff Configuration  -*- lexical-binding: t; -*-

;;; Commentary:
;; highly useful setup for configuring ediff
;; https://oremacs.com/2015/01/17/setting-up-ediff/

;;; Code:

;; -------------------------------- Csetq Macro --------------------------------
;; a macro that allows a setq for custom variables. uses the variable's set
;; property without writing customizations to emacs init.

(defmacro csetq (variable value)
  `(funcall (or (get ',variable 'custom-set)
				'set-default)
            ',variable ,value))

;; ------------------------------- Ediff Settings ------------------------------
;; ediff configuration. note the dired-ediff-files function in dirvish.

;; lose the control panel
(csetq ediff-window-setup-function 'ediff-setup-windows-plain)

;; only split horizontally
(csetq ediff-split-window-function 'split-window-horizontally)

;; ignore whitespace in diffs
(csetq ediff-diff-options "-w")

;; only highlight the current diff:
(setq-default ediff-highlight-all-diffs 'nil)

;; use j and k for next and previous diffs
(defun cj/ediff-hook ()
  (ediff-setup-keymap)
  (define-key ediff-mode-map "j" 'ediff-next-difference)
  (define-key ediff-mode-map "k" 'ediff-previous-difference))
(add-hook 'ediff-mode-hook 'cj/ediff-hook)

;; restore the window setup after quitting
(winner-mode)
(add-hook 'ediff-after-quit-hook-internal 'winner-undo)

;; ----------------------------------- Ztree -----------------------------------
;; diff two directories

(use-package ztree
  :defer .5
  :bind
  ("C-c D" . ztree-diff))

(provide 'diff-config)
;;; diff-config.el ends here.