update
[emacs.git] / .emacs.d / elisp / local / diff-mode-.el
1 ;;; diff-mode-.el --- Extensions to `diff-mode.el'.
2 ;;
3 ;; Filename: diff-mode-.el
4 ;; Description: Extensions to `diff-mode.el'.
5 ;; Author: Drew Adams
6 ;; Maintainer: Drew Adams (concat "drew.adams" "@" "oracle" ".com")
7 ;; Copyright (C) 2004-2016, Drew Adams, all rights reserved.
8 ;; Created: Mon Nov 08 16:36:09 2004
9 ;; Version: 0
10 ;; Package-Requires: ()
11 ;; Last-Updated: Thu Dec 31 12:54:01 2015 (-0800)
12 ;; By: dradams
13 ;; Update #: 712
14 ;; URL: http://www.emacswiki.org/diff-mode-.el
15 ;; Doc URL: http://www.emacswiki.org/DiffEnhancements
16 ;; Keywords: data, matching, tools, unix, local, font, face
17 ;; Compatibility: GNU Emacs: 21.x, 22.x, 23.x, 24.x, 25.x
18 ;;
19 ;; Features that might be required by this library:
20 ;;
21 ;; None
22 ;;
23 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
24 ;;
25 ;;; Commentary:
26 ;;
27 ;; Extensions to `diff-mode.el'.
28 ;;
29 ;; "*Diff*" buffer is highlighted differently.
30 ;;
31 ;; NOTE: The faces defined here look best on a medium-dark
32 ;; background, because some are light and some are dark.
33 ;; Try, for example, setting the background to "LightSteelBlue"
34 ;; in your `~/.emacs' file: You can do this is via
35 ;; `special-display-buffer-names':
36 ;;
37 ;; (setq special-display-buffer-names
38 ;; (cons '("*Diff*" (background-color . "LightSteelBlue"))
39 ;; special-display-buffer-names))
40 ;;
41 ;; You can alternatively change the background value of
42 ;; `special-display-frame-alist' and set
43 ;; `special-display-regexps' to something matching "*info*":
44 ;;
45 ;; (setq special-display-frame-alist
46 ;; (cons '(background-color . "LightSteelBlue")
47 ;; special-display-frame-alist))
48 ;; (setq special-display-regexps '("[ ]?[*][^*]+[*]"))
49 ;;
50 ;;
51 ;; New faces defined here:
52 ;;
53 ;; `diff-file1-hunk-header', `diff-file2-hunk-header'.
54 ;;
55 ;; New user options defined here:
56 ;;
57 ;; `diff-file1-hunk-header-face', `diff-file2-hunk-header-face'.
58 ;;
59 ;;
60 ;; ***** NOTE: The following faces defined in `diff-mode.el' have
61 ;; been REDEFINED HERE:
62 ;;
63 ;; `diff-added', `diff-changed', `diff-context',
64 ;; `diff-file-header', `diff-header', `diff-hunk-header',
65 ;; `diff-index', `diff-indicator-added', `diff-indicator-changed',
66 ;; `diff-indicator-removed', `diff-nonexistent', `diff-removed'.
67 ;;
68 ;;
69 ;; ***** NOTE: The following variable defined in `diff-mode.el' has
70 ;; been REDEFINED HERE:
71 ;;
72 ;; `diff-font-lock-keywords'.
73 ;;
74 ;;
75 ;; This library should be loaded *before* library `diff-mode.el'.
76 ;; Put this in your initialization file, `~/.emacs':
77 ;; (require 'diff-mode-)
78 ;;
79 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
80 ;;
81 ;;; Change Log:
82 ;;
83 ;; 2011/02/11 dadams
84 ;; Better defaults for faces on dark background.
85 ;; 2011/01/04 dadams
86 ;; Added autoload cookies for defface.
87 ;; 2008/01/01 dadams
88 ;; Added :group for deffaces.
89 ;; 2006/01/04 dadams
90 ;; Updated to use new Emacs 22 face names for indicator faces.
91 ;; Thanks to Juri Linkov for the letting me know about the new faces.
92 ;; Updated diff-font-lock-keywords to be = Emacs 22, except for file name.
93 ;; 2006/01/01 dadams
94 ;; Renamed faces, without "-face".
95 ;;
96 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
97 ;;
98 ;; This program is free software; you can redistribute it and/or modify
99 ;; it under the terms of the GNU General Public License as published by
100 ;; the Free Software Foundation; either version 2, or (at your option)
101 ;; any later version.
102
103 ;; This program is distributed in the hope that it will be useful,
104 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
105 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
106 ;; GNU General Public License for more details.
107
108 ;; You should have received a copy of the GNU General Public License
109 ;; along with this program; see the file COPYING. If not, write to
110 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
111 ;; Floor, Boston, MA 02110-1301, USA.
112 ;;
113 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
114 ;;
115 ;;; Code:
116
117 ;;;;;;;;;;;;;;;;;;;;;;;;
118
119
120 ;;; Define some additional faces.
121 ;;;###autoload
122 (defface diff-file1-hunk-header
123 '((((background dark))
124 (:foreground "Yellow" :background "#3E3E00003E3E")) ; ~ dark magenta
125 (t (:foreground "Blue" :background "DarkSeaGreen1")))
126 "Face used to highlight a diff hunk for the first `diff' argument."
127 :group 'diff-mode)
128 (defvar diff-file1-hunk-header-face 'diff-file1-hunk-header)
129
130 ;;;###autoload
131 (defface diff-file2-hunk-header
132 '((((background dark))
133 (:foreground "Cyan" :background "#111117175555")) ; ~ dark blue
134 (t (:foreground "Red" :background "PaleGoldenrod")))
135 "Face used to highlight a diff hunk for the second `diff' argument."
136 :group 'diff-mode)
137 (defvar diff-file2-hunk-header-face 'diff-file2-hunk-header)
138
139 ;;; These faces are standard in Emacs 22, but they are new for Emacs 21.
140 ;;;###autoload
141 (defface diff-indicator-changed
142 '((((background dark))
143 (:foreground "#111117175555" :background "Yellow")) ; ~ dark blue
144 (t (:foreground "PaleGoldenrod" :background "MediumBlue")))
145 "*Face used to highlight the line-start indicator of a modified line."
146 :group 'diff-mode)
147 (defvar diff-indicator-changed-face 'diff-indicator-changed)
148
149 ;;;###autoload
150 (defface diff-indicator-added
151 '((((background dark))
152 (:foreground "#111117175555" :background "#FFFF9B9BFFFF")) ; ~ dk blue, pink
153 (t (:foreground "PaleGoldenrod" :background "DarkGreen")))
154 "*Face used to highlight the line-start indicator of an inserted line."
155 :group 'diff-mode)
156 (defvar diff-indicator-added-face 'diff-indicator-added)
157
158 ;;;###autoload
159 (defface diff-indicator-removed
160 '((((background dark))
161 (:foreground "#111117175555" :background "#7474FFFF7474")) ; ~ dk blue,green
162 (t (:foreground "PaleGoldenrod" :background "DarkMagenta")))
163 "*Face used to highlight the line-start indicator of a removed line."
164 :group 'diff-mode)
165 (defvar diff-indicator-removed-face 'diff-indicator-removed)
166
167 ;;; Change existing `diff-mode' faces too.
168 (custom-set-faces
169 '(diff-added ((((background dark)) (:foreground "#FFFF9B9BFFFF")) ; ~ pink
170 (t (:foreground "DarkGreen"))) 'now)
171 '(diff-changed ((((background dark)) (:foreground "Yellow"))
172 (t (:foreground "MediumBlue"))) 'now)
173 '(diff-context ((((background dark)) (:foreground "White"))
174 (t (:foreground "Black"))) 'now)
175 '(diff-file-header ((((background dark)) (:foreground "Cyan" :background "Black"))
176 (t (:foreground "Red" :background "White"))) 'now)
177 ;; '(diff-function ((t (:foreground "Orange"))) 'now)
178 '(diff-header ((((background dark)) (:foreground "Cyan"))
179 (t (:foreground "Red"))) 'now)
180 '(diff-hunk-header
181 ((((background dark))
182 (:foreground "Black" :background "#05057F7F8D8D")) ; ~ dark cyan
183 (t (:foreground "White" :background "Salmon"))) 'now)
184 '(diff-index ((((background dark)) (:foreground "Magenta"))
185 (t (:foreground "Green"))) 'now)
186 '(diff-nonexistent ((((background dark)) (:foreground "#FFFFFFFF7474")) ; ~ yellow
187 (t (:foreground "DarkBlue"))) 'now)
188 '(diff-removed ((((background dark)) (:foreground "#7474FFFF7474"))
189 (t (:foreground "DarkMagenta"))) 'now)
190 )
191
192 ;;; The only real difference here now from the standard Emacs 22 version is the
193 ;;; use of diff-file1* and diff-file2*.
194 (defvar diff-font-lock-keywords
195 `(
196 ("^\\(@@ -[0-9,]+ \\+[0-9,]+ @@\\)\\(.*\\)$" ;unified
197 (1 diff-hunk-header-face) (2 diff-function-face))
198 ("^\\(\\*\\{15\\}\\)\\(.*\\)$" ;context
199 (1 diff-hunk-header-face) (2 diff-function-face))
200 ("^\\*\\*\\* .+ \\*\\*\\*\\*". diff-file1-hunk-header-face) ;context
201 ("^--- .+ ----$" . diff-file2-hunk-header-face) ;context
202 ("^[0-9,]+[acd][0-9,]+$" . diff-hunk-header-face) ; normal
203 ("^---$" . diff-hunk-header-face) ;normal
204 ("^\\(---\\|\\+\\+\\+\\|\\*\\*\\*\\) \\(\\S-+\\)\\(.*[^*-]\\)?\n"
205 (0 diff-header-face) (2 diff-file-header-face prepend))
206 ("^\\([-<]\\)\\(.*\n\\)" (1 diff-indicator-removed-face) (2 diff-removed-face))
207 ("^\\([+>]\\)\\(.*\n\\)" (1 diff-indicator-added-face) (2 diff-added-face))
208 ("^\\(!\\)\\(.*\n\\)" (1 diff-indicator-changed-face) (2 diff-changed-face))
209 ("^Index: \\(.+\\).*\n" (0 diff-header-face) (1 diff-index-face prepend))
210 ("^Only in .*\n" . diff-nonexistent-face)
211 ("^\\(#\\)\\(.*\\)"
212 (1 (if (facep 'font-lock-comment-delimiter-face)
213 'font-lock-comment-face))
214 (2 font-lock-comment-face))
215 ("^[^-=+*!<>#].*\n" (0 diff-context-face))))
216
217 ;;;;;;;;;;;;;;;;;;;;;;;
218
219 (provide 'diff-mode-)
220
221 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
222 ;;; diff-mode-.el ends here