-
Notifications
You must be signed in to change notification settings - Fork 1
/
my-diff.el
75 lines (66 loc) · 2.37 KB
/
my-diff.el
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
;;; my-diff --- Centralised configuration of diff/patch handling
;;
;; Copyright (C) 2014 Alex Bennée
;;
;; Author: Alex Bennée <[email protected]>
;;
;; This file is not part of GNU Emacs.
;;
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;;
;;; Commentary:
;;
;; This is an attempt to reduce the mess that is my patch handling
;; stuff. This includes my first derrived mode "my-diff-mode" which was
;; useful (and may still be) for dealing with lots of patchs by hand.
;;
;;; Code:
(require 'use-package)
;; ediff
;;
;; Still needs some loving care to setup properly
(use-package ediff
:commands (ediff-buffers ediff-files)
:config
(progn
(setq diff-switches "-ub"
ediff-custom-diff-options "-U3"
ediff-split-window-function 'split-window-horizontally
ediff-window-setup-function 'ediff-setup-windows-plain)
(add-hook 'ediff-before-setup-hook
(lambda ()
(setq ediff-saved-window-configuration
(current-window-configuration))))
(let ((restore-window-configuration
(lambda ()
(set-window-configuration ediff-saved-window-configuration))))
(add-hook 'ediff-quit-hook restore-window-configuration 'append)
(add-hook 'ediff-suspend-hook restore-window-configuration 'append))))
;; override fancy completions when applying hunks as they make editing
;; the path harder than in needs to be.
(when (macrop 'define-advice)
(define-advice diff-apply-hunk
(:around (orig-fun &rest args) use-plain-completion)
(let ((completing-read-function 'magit-completing-read))
(apply orig-fun args))))
;; I'm just going to assume I have my-diff-mode
;; We want to find files like
;;
;; 0001-Remove-old-pre-SIGNAL_MANAGER-code.patch
;; mypatch.patch
;; adiff.diff
;; .dotest/0001
;;
;; But not files like
;; ~/.mozilla/firefox/adxbrp73.default/itsalltext/www.bennee.com.3022372z35.txt
(use-package my-diff-mode
:commands my-diff-mode
:mode (("\.diff$" . my-diff-mode)
("\.patch$" . my-diff-mode)
("\.rej$" . my-diff-mode)
("\\.dotest/[0123456789][0123456789][0123456789][0123456789]". my-diff-mode)))
(provide 'my-diff)
;;; my-diff.el ends here