11042
|
1 ;;; ediff-init.el --- Macros, variables and defsubsts used by Ediff
|
11234
|
2 ;;; Copyright (C) 1994, 1995 Free Software Foundation, Inc.
|
11042
|
3
|
|
4 ;; Author: Michael Kifer <kifer@cs.sunysb.edu>
|
|
5
|
|
6 ;; This file is part of GNU Emacs.
|
|
7
|
|
8 ;; GNU Emacs is free software; you can redistribute it and/or modify
|
|
9 ;; it under the terms of the GNU General Public License as published by
|
|
10 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
11 ;; any later version.
|
|
12
|
|
13 ;; GNU Emacs is distributed in the hope that it will be useful,
|
|
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16 ;; GNU General Public License for more details.
|
|
17
|
|
18 ;; You should have received a copy of the GNU General Public License
|
|
19 ;; along with GNU Emacs; see the file COPYING. If not, write to
|
|
20 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
21
|
|
22
|
|
23 (defconst ediff-xemacs-p (string-match "\\(Lucid\\|Xemacs\\)" emacs-version)
|
|
24 "Whether it is XEmacs.")
|
|
25 (defconst ediff-emacs-p (not ediff-xemacs-p)
|
|
26 "Whether it is Emacs.")
|
|
27
|
|
28 ;;; Macros
|
|
29 (defmacro ediff-odd-p (arg)
|
|
30 (` (eq (logand (, arg) 1) 1)))
|
|
31
|
|
32 (defmacro ediff-buffer-live-p (buf)
|
|
33 (` (and (, buf) (get-buffer (, buf)) (buffer-name (get-buffer (, buf))))))
|
|
34
|
|
35 (defmacro ediff-get-buffer (arg)
|
|
36 (` (cond ((eq (, arg) 'A) ediff-buffer-A)
|
|
37 ((eq (, arg) 'B) ediff-buffer-B)
|
|
38 ((eq (, arg) 'C) ediff-buffer-C)
|
|
39 )
|
|
40 ))
|
|
41
|
|
42 (defmacro ediff-get-value-according-to-buffer-type (buf-type list)
|
|
43 (` (cond ((eq (, buf-type) 'A) (nth 0 (, list)))
|
|
44 ((eq (, buf-type) 'B) (nth 1 (, list)))
|
|
45 ((eq (, buf-type) 'C) (nth 2 (, list))))))
|
|
46
|
|
47 (defmacro ediff-char-to-buftype (arg)
|
|
48 (` (cond ((memq (, arg) '(?a ?A)) 'A)
|
|
49 ((memq (, arg) '(?b ?B)) 'B)
|
|
50 ((memq (, arg) '(?c ?C)) 'C)
|
|
51 )
|
|
52 ))
|
|
53
|
|
54 (defmacro ediff-get-difference (n buf-type)
|
|
55 (` (aref
|
|
56 (symbol-value
|
|
57 (intern (format "ediff-difference-vector-%S" (, buf-type)))) (, n))))
|
|
58
|
|
59 ;; tell if it has been previously determined that the region has
|
|
60 ;; no diffs other than the white space and newlines
|
|
61 ;; The argument, N, is the diff region number used by Ediff to index the
|
|
62 ;; diff vector. It is 1 less than the number seen by the user.
|
|
63 ;;
|
|
64 ;; A difference vector has the form:
|
|
65 ;; [diff diff diff ...]
|
|
66 ;; where each diff has the form:
|
|
67 ;; [overlay fine-diff-vector no-fine-diffs-flag]
|
|
68 ;; fine-diff-vector is a vector [fine-diff fine-diff fine-diff ...]
|
|
69 (defmacro ediff-no-fine-diffs-p (n)
|
|
70 (` (aref (ediff-get-difference (, n) 'A) 2)))
|
|
71
|
|
72 (defmacro ediff-get-diff-overlay-from-diff-record (diff-rec)
|
|
73 (` (aref (, diff-rec) 0)))
|
|
74
|
|
75 (defmacro ediff-get-diff-overlay (n buf-type)
|
|
76 (` (ediff-get-diff-overlay-from-diff-record
|
|
77 (ediff-get-difference (, n) (, buf-type)))))
|
|
78
|
|
79 (defmacro ediff-get-fine-diff-vector-from-diff-record (diff-rec)
|
|
80 (` (aref (, diff-rec) 1)))
|
|
81
|
|
82 (defmacro ediff-set-fine-diff-vector (n buf-type fine-vec)
|
|
83 (` (aset (ediff-get-difference (, n) (, buf-type)) 1 (, fine-vec))))
|
|
84
|
|
85 (defmacro ediff-get-state-of-diff (n buf-type)
|
|
86 (` (if (ediff-buffer-live-p ediff-buffer-C)
|
|
87 (aref (ediff-get-difference (, n) (, buf-type)) 3))))
|
|
88 (defmacro ediff-set-state-of-diff (n buf-type val)
|
|
89 (` (aset (ediff-get-difference (, n) (, buf-type)) 3 (, val))))
|
|
90 (defmacro ediff-get-state-of-merge (n)
|
|
91 (` (if (ediff-buffer-live-p ediff-buffer-C)
|
|
92 (aref (ediff-get-difference (, n) 'C) 4))))
|
|
93 (defmacro ediff-set-state-of-merge (n val)
|
|
94 (` (aset (ediff-get-difference (, n) 'C) 4 (, val))))
|
|
95
|
|
96 ;; if flag is t, puts a mark on diff region saying that
|
|
97 ;; the differences are in white space only. If flag is nil,
|
|
98 ;; the region is marked as essential (i.e., differences are
|
|
99 ;; not just in the white space and newlines.)
|
|
100 (defmacro ediff-mark-diff-as-space-only (n flag)
|
|
101 (` (aset (ediff-get-difference (, n) 'A) 2 (, flag))))
|
|
102
|
|
103 (defmacro ediff-get-fine-diff-vector (n buf-type)
|
|
104 (` (ediff-get-fine-diff-vector-from-diff-record
|
|
105 (ediff-get-difference (, n) (, buf-type)))))
|
|
106
|
|
107
|
|
108 ;; Defines SYMBOL as an advertised local variable.
|
|
109 ;; Performs a defvar, then executes `make-variable-buffer-local' on
|
|
110 ;; the variable. Also sets the `permanent-local' property,
|
|
111 ;; so that `kill-all-local-variables' (called by major-mode setting
|
|
112 ;; commands) won't destroy Ediff control variables.
|
|
113 ;;
|
|
114 ;; Plagiarised from `emerge-defvar-local' for XEmacs.
|
|
115 (defmacro ediff-defvar-local (var value doc)
|
|
116 (` (progn
|
|
117 (defvar (, var) (, value) (, doc))
|
|
118 (make-variable-buffer-local '(, var))
|
|
119 (put '(, var) 'permanent-local t))))
|
|
120
|
|
121 ;; Macro to switch to BUFFER, evaluate FORMS, returns to original buffer.
|
|
122 ;; Differs from `save-excursion' in that it doesn't save the point and mark.
|
|
123 ;; This is essentially `emerge-eval-in-buffer' with the test for live buffers."
|
|
124 (defmacro ediff-eval-in-buffer (buffer &rest forms)
|
|
125 (` (let ((StartBuffer (current-buffer)))
|
|
126 (if (ediff-buffer-live-p (, buffer))
|
|
127 (unwind-protect
|
|
128 (progn
|
|
129 (set-buffer (, buffer))
|
|
130 (,@ forms))
|
|
131 (set-buffer StartBuffer))
|
|
132 (or (eq this-command 'ediff-quit)
|
|
133 (error
|
|
134 "You've killed an essential Ediff buffer---Please quit Ediff"))
|
|
135 ))))
|
|
136
|
|
137
|
|
138 (defmacro ediff-multiframe-setup-p ()
|
|
139 (` (and window-system ediff-multiframe)))
|
|
140
|
|
141 (defmacro ediff-narrow-control-frame-p ()
|
|
142 (` (and (ediff-multiframe-setup-p)
|
|
143 (equal ediff-help-message ediff-brief-message-string))))
|
|
144
|
|
145 (defmacro ediff-3way-comparison-job ()
|
|
146 (` (memq
|
|
147 ediff-job-name
|
|
148 '(ediff-files3 ediff-buffers3))))
|
|
149 (ediff-defvar-local ediff-3way-comparison-job nil "")
|
|
150
|
|
151 (defmacro ediff-merge-job ()
|
|
152 (` (memq
|
|
153 ediff-job-name
|
|
154 '(ediff-merge-files
|
|
155 ediff-merge-buffers
|
|
156 ediff-merge-files-with-ancestor
|
|
157 ediff-merge-buffers-with-ancestor
|
|
158 ediff-merge-revisions
|
|
159 ediff-merge-revisions-with-ancestor))))
|
|
160 (ediff-defvar-local ediff-merge-job nil "")
|
|
161
|
|
162 (defmacro ediff-merge-with-ancestor-job ()
|
|
163 (` (memq
|
|
164 ediff-job-name
|
|
165 '(ediff-merge-files-with-ancestor
|
|
166 ediff-merge-buffers-with-ancestor
|
|
167 ediff-merge-revisions-with-ancestor))))
|
|
168 (ediff-defvar-local ediff-merge-with-ancestor-job nil "")
|
|
169
|
|
170 (defmacro ediff-3way-job ()
|
|
171 (` (or ediff-3way-comparison-job ediff-merge-job)))
|
|
172 (ediff-defvar-local ediff-3way-job nil "")
|
|
173
|
|
174 ;; A diff3 job is like a 3way job, but ediff-merge doesn't require the use
|
|
175 ;; of diff3.
|
|
176 (defmacro ediff-diff3-job ()
|
|
177 (` (or ediff-3way-comparison-job
|
|
178 ediff-merge-with-ancestor-job)))
|
|
179 (ediff-defvar-local ediff-diff3-job nil "")
|
|
180
|
|
181 (defmacro ediff-word-mode-job ()
|
|
182 (` (memq
|
|
183 ediff-job-name
|
|
184 '(ediff-windows ediff-small-regions ediff-large-regions))))
|
|
185 (ediff-defvar-local ediff-word-mode-job nil "")
|
|
186
|
|
187
|
|
188 ;; Hook variables
|
|
189
|
|
190 (defvar ediff-before-setup-windows-hooks nil
|
|
191 "*Hooks to run before Ediff sets its own window config.
|
|
192 This can be used to save the previous window config, which can be restored
|
|
193 on ediff-quit or ediff-suspend.")
|
|
194 (defvar ediff-after-setup-windows-hooks nil
|
|
195 "*Hooks to run after Ediff sets its own window config.
|
|
196 This can be used to set up control window or icon in a desired place.")
|
|
197 (defvar ediff-before-setup-control-frame-hooks nil
|
|
198 "*Hooks run before setting up the frame to display Ediff Control Panel.
|
|
199 Can be used to change control frame parameters to position it where it
|
|
200 is desirable.")
|
|
201 (defvar ediff-after-setup-control-frame-hooks nil
|
|
202 "*Hooks run after setting up the frame to display Ediff Control Panel.
|
|
203 Can be used to move the frame where it is desired.")
|
|
204 (defvar ediff-startup-hooks nil
|
|
205 "*Hooks to run in the control buffer after Ediff has been set up.")
|
|
206 (defvar ediff-select-hooks nil
|
|
207 "*Hooks to run after a difference has been selected.")
|
|
208 (defvar ediff-unselect-hooks nil
|
|
209 "*Hooks to run after a difference has been unselected.")
|
|
210 (defvar ediff-prepare-buffer-hooks nil
|
|
211 "*Hooks called after buffers A, B, and C are set up.")
|
|
212 (defvar ediff-load-hooks nil
|
|
213 "*Hook run after Ediff is loaded. Can be used to change defaults.")
|
|
214
|
|
215 (defvar ediff-mode-hooks nil
|
|
216 "*Hook run just after ediff-mode is set up in the control buffer.
|
|
217 This is done before any windows or frames are created. One can use it to
|
|
218 set local variables that determine how the display looks like.")
|
|
219 (defvar ediff-keymap-setup-hooks nil
|
|
220 "*Hook run just after the default bindings in Ediff keymap are set up.")
|
|
221
|
|
222 (defvar ediff-display-help-hooks nil
|
|
223 "*Hooks run after preparing the help message.")
|
|
224
|
|
225 (defvar ediff-suspend-hooks (list 'ediff-default-suspend-hook)
|
|
226 "*Hooks to run in the Ediff control buffer when Ediff is suspended.")
|
|
227 (defvar ediff-quit-hooks (list 'ediff-cleanup-mess)
|
|
228 "*Hooks to run in the Ediff control buffer after finishing Ediff.")
|
|
229
|
|
230 ;; There will be deleted in due time
|
|
231 (make-variable-buffer-local 'local-write-file-hooks)
|
|
232 (make-variable-buffer-local 'before-change-function)
|
|
233
|
|
234
|
|
235 ;; Help messages
|
|
236
|
|
237 (defconst ediff-long-help-message-head
|
|
238 " Moving around | Toggling features | Manipulations
|
|
239 =====================|===========================|============================="
|
|
240 "The head of the full help message.")
|
|
241 (defconst ediff-long-help-message-tail
|
|
242 "=====================|===========================|=============================
|
|
243 i -status info | ? -help off | G -send bug report
|
|
244 -------------------------------------------------------------------------------
|
|
245 X,Y (x,y) on the left are meta-symbols for the keys A,B,C (a,b,c).
|
|
246 X,Y on the right are meta-symbols for buffers A,B,C.
|
|
247 A,B,C on the right denote the working buffers A,B,C, respectively."
|
|
248 "The tail of the full-help message.")
|
|
249
|
|
250 (defconst ediff-long-help-message-compare3
|
|
251 "
|
|
252 p,DEL -previous diff | | -vert/horiz split | xy -copy buf X's region to Y
|
|
253 n,SPC -next diff | h -hiliting | rx -restore buf X's old diff
|
|
254 j -jump to diff | @ -auto-refinement | * -refine current region
|
|
255 gx -goto X's point| | ! -update diff regions
|
|
256 C-l -recenter | ## -ignore whitespace |
|
|
257 v/V -scroll up/dn | #f/#h -focus/hide regions | wx -save buf X
|
|
258 </> -scroll lt/rt | X -read-only in buf X | wd -save diff output
|
|
259 z/q -suspend/quit | m -wide display | ~ -rotate buffers
|
|
260 "
|
|
261 "Normally, not a user option. See `ediff-help-message' for details.")
|
|
262
|
|
263 (defconst ediff-long-help-message-compare2
|
|
264 "
|
|
265 p,DEL -previous diff | | -vert/horiz split |a/b -copy A/B's region to B/A
|
|
266 n,SPC -next diff | h -hiliting | rx -restore buf X's old diff
|
|
267 j -jump to diff | @ -auto-refinement | * -refine current region
|
|
268 gx -goto X's point| | ! -update diff regions
|
|
269 C-l -recenter | ## -ignore whitespace |
|
|
270 v/V -scroll up/dn | #f/#h -focus/hide regions | wx -save buf X
|
|
271 </> -scroll lt/rt | X -read-only in buf X | wd -save diff output
|
|
272 z/q -suspend/quit | m -wide display | ~ -swap buffers
|
|
273 "
|
|
274 "Normally, not a user option. See `ediff-help-message' for details.")
|
|
275
|
|
276 (defconst ediff-long-help-message-word-mode
|
|
277 "
|
|
278 p,DEL -previous diff | | -vert/horiz split | xy -copy buf X's region to Y
|
|
279 n,SPC -next diff | h -hiliting | rx -restore buf X's old diff
|
|
280 j -jump to diff | |
|
|
281 gx -goto X's point| % -narrow/widen buffs | ! -recompute diffs
|
|
282 C-l -recenter | |
|
|
283 v/V -scroll up/dn | #f/#h -focus/hide regions | wx -save buf X
|
|
284 </> -scroll lt/rt | X -read-only in buf X | wd -save diff output
|
|
285 z/q -suspend/quit | m -wide display | ~ -swap buffers
|
|
286 "
|
|
287 "Normally, not a user option. See `ediff-help-message' for details.")
|
|
288
|
|
289 (defconst ediff-long-help-message-merge
|
|
290 "
|
|
291 p,DEL -previous diff | | -vert/horiz split | x -copy buf X's region to C
|
|
292 n,SPC -next diff | h -hiliting | r -restore buf C's old diff
|
|
293 j -jump to diff | @ -auto-refinement | * -refine current region
|
|
294 gx -goto X's point| ## -ignore whitespace | ! -update diff regions
|
|
295 C-l -recenter | #f/#h -focus/hide regions | + -combine diff regions
|
|
296 v/V -scroll up/dn | X -read-only in buf X | wx -save buf X
|
|
297 </> -scroll lt/rt | m -wide display | wd -save diff output
|
|
298 z/q -suspend/quit | s -shrink window C | ~ -swap buffers
|
|
299 | $ -show clashes only | & -merge w/new default
|
|
300 "
|
|
301 "Normally, not a user option. See `ediff-help-message' for details.")
|
|
302
|
|
303 ;; The actual long help message.
|
|
304 (ediff-defvar-local ediff-long-help-message ""
|
|
305 "Normally, not a user option. See `ediff-help-message' for details.")
|
|
306
|
|
307 (defconst ediff-brief-message-string
|
|
308 " ? - help "
|
|
309 "Contents of the brief help message.")
|
|
310 ;; The actual brief help message
|
|
311 (ediff-defvar-local ediff-brief-help-message ""
|
|
312 "Normally, not a user option. See `ediff-help-message' for details.")
|
|
313
|
|
314 (ediff-defvar-local ediff-brief-help-message-custom nil
|
|
315 "The brief help message that the user can customize.
|
|
316 If the user sets this to a parameter-less function, Ediff will use it to
|
|
317 produce the brief help message. This function must return a string.")
|
|
318 (ediff-defvar-local ediff-long-help-message-custom nil
|
|
319 "The long help message that the user can customize.
|
|
320 See `ediff-brief-help-message-custom' for more.")
|
|
321
|
|
322 (defvar ediff-prefer-long-help-message nil
|
|
323 "*If t, Ediff starts with a long help message. Short help msg otherwise.")
|
|
324
|
|
325 ;; The actual help message.
|
|
326 (ediff-defvar-local ediff-help-message ""
|
|
327 "The actual help message.
|
|
328 Normally, the user shouldn't touch this. However, if you want Ediff to
|
|
329 start up with different help messages for different jobs, you can change
|
|
330 the value of this variable and the variables `ediff-help-message-*' in
|
|
331 `ediff-startup-hooks'.")
|
|
332
|
|
333 ;; Selective browsing
|
|
334
|
|
335 (ediff-defvar-local ediff-skip-diff-region-function 'ediff-show-all-diffs
|
|
336 "Function that determines the next/previous diff region to show.
|
|
337 Should return t for regions to be ignored and nil otherwise.
|
|
338 This function gets a region number as an argument. The region number
|
|
339 is the one used internally by Ediff. It is 1 less than the number seen
|
|
340 by the user.")
|
|
341
|
|
342 ;; Regexp that determines buf A regions to focus on when skipping to diff
|
|
343 (ediff-defvar-local ediff-regexp-focus-A "" "")
|
|
344 ;; Regexp that determines buf B regions to focus on when skipping to diff
|
|
345 (ediff-defvar-local ediff-regexp-focus-B "" "")
|
|
346 ;; Regexp that determines buf C regions to focus on when skipping to diff
|
|
347 (ediff-defvar-local ediff-regexp-focus-C "" "")
|
|
348 ;; connective that determines whether to focus regions that match both or
|
|
349 ;; one of the regexps
|
|
350 (ediff-defvar-local ediff-focus-regexp-connective 'and "")
|
|
351
|
|
352 ;; Regexp that determines buf A regions to ignore when skipping to diff
|
|
353 (ediff-defvar-local ediff-regexp-hide-A "" "")
|
|
354 ;; Regexp that determines buf B regions to ignore when skipping to diff
|
|
355 (ediff-defvar-local ediff-regexp-hide-B "" "")
|
|
356 ;; Regexp that determines buf C regions to ignore when skipping to diff
|
|
357 (ediff-defvar-local ediff-regexp-hide-C "" "")
|
|
358 ;; connective that determines whether to hide regions that match both or
|
|
359 ;; one of the regexps
|
|
360 (ediff-defvar-local ediff-hide-regexp-connective 'and "")
|
|
361
|
|
362
|
|
363 (defvar ediff-ange-ftp-ftp-name (if ediff-xemacs-p
|
|
364 'ange-ftp-ftp-path
|
|
365 'ange-ftp-ftp-name)
|
|
366 "Function ange-ftp uses to find out if file is remote.")
|
|
367
|
|
368
|
|
369 ;; Copying difference regions between buffers.
|
|
370 (ediff-defvar-local ediff-killed-diffs-alist nil
|
|
371 "A list of killed diffs.
|
|
372 A diff is saved here if it is replaced by a diff
|
|
373 from another buffer. This alist has the form:
|
|
374 \((num (buff-object . diff) (buff-object . diff) (buff-object . diff)) ...),
|
|
375 where some buffer-objects may be missing.")
|
|
376
|
|
377
|
|
378 ;; Highlighting
|
|
379 (defvar ediff-before-flag-bol "->>\n"
|
|
380 "*Flag placed above the highlighted block of differences.
|
|
381 Must end with newline.")
|
|
382 (defvar ediff-after-flag-eol "<<-\n"
|
|
383 "*Flag placed below the highlighted block of differences.
|
|
384 Must end with newline.")
|
|
385
|
|
386 (defvar ediff-before-flag-mol "->>"
|
|
387 "*Like ediff-before-flag, used when a difference starts in mid-line.")
|
|
388 (defvar ediff-after-flag-mol "<<-"
|
|
389 "*Like ediff-after-flag, used when a difference starts in mid-line.")
|
|
390
|
|
391 (ediff-defvar-local ediff-before-flag-A nil
|
|
392 "This is the actual ASCII before-flag in effect in buffer A.
|
|
393 It is either `ediff-before-flag-mol' or `ediff-before-flag-bol' depending
|
|
394 on whether the selected difference region starts in the middle of a line
|
|
395 or at the beginning of a line.")
|
|
396 (ediff-defvar-local ediff-after-flag-A nil
|
|
397 "This is the actual ASCII after-flag in effect in buffer A.
|
|
398 It is either `ediff-before-flag-mol' or `ediff-before-flag-bol' depending
|
|
399 on whether the selected difference region starts in the middle of a line
|
|
400 or at the beginning of a line.")
|
|
401
|
|
402 (ediff-defvar-local ediff-before-flag-B nil
|
|
403 "This is the actual ASCII before-flag in effect in buffer B.
|
|
404 It is either `ediff-before-flag-mol' or `ediff-before-flag-bol' depending
|
|
405 on whether the selected difference region starts in the middle of a line
|
|
406 or at the beginning of a line.")
|
|
407 (ediff-defvar-local ediff-after-flag-B nil
|
|
408 "This is the actual ASCII after-flag in effect in buffer B.
|
|
409 It is either `ediff-before-flag-mol' or `ediff-before-flag-bol' depending
|
|
410 on whether the selected difference region starts in the middle of a line
|
|
411 or at the beginning of a line.")
|
|
412
|
|
413 (ediff-defvar-local ediff-before-flag-C nil
|
|
414 "This is the actual ASCII before-flag in effect in buffer C.
|
|
415 It is either `ediff-before-flag-mol' or `ediff-before-flag-bol' depending
|
|
416 on whether the selected difference region starts in the middle of a line
|
|
417 or at the beginning of a line.")
|
|
418 (ediff-defvar-local ediff-after-flag-C nil
|
|
419 "This is the actual ASCII after-flag in effect in buffer C.
|
|
420 It is either `ediff-before-flag-mol' or `ediff-before-flag-bol' depending
|
|
421 on whether the selected difference region starts in the middle of a line
|
|
422 or at the beginning of a line.")
|
|
423
|
|
424
|
|
425 (ediff-defvar-local ediff-use-faces t
|
|
426 "If t, differences are highlighted using faces on a window system.
|
|
427 If nil, they are highlighted using ASCII flags, ediff-before-flag
|
|
428 and ediff-after-flag. On a non-window system, differences are always
|
|
429 highlighted using ASCII flags.
|
|
430 This variable can be set either in .emacs or toggled interactively.
|
|
431 Use `setq-default' if setting it in .emacs")
|
|
432
|
|
433
|
|
434 ;; this indicates that diff regions are word-size, so fine diffs are
|
|
435 ;; permanently nixed; used in ediff-windows and ediff-small-regions
|
|
436 (ediff-defvar-local ediff-word-mode nil "")
|
|
437 ;; Name of the job (ediff-files, ediff-windows, etc.
|
|
438 (ediff-defvar-local ediff-job-name nil "")
|
|
439
|
|
440 ;; Narrowing and ediff-region/windows support
|
|
441 ;; This is a list (overlay-A overlay-B overlay-C)
|
|
442 ;; If set, Ediff compares only those parts of buffers A/B/C that lie within
|
|
443 ;; the bounds of these overlays.
|
|
444 (ediff-defvar-local ediff-narrow-bounds nil "")
|
|
445
|
|
446 ;; List (overlay-A overlay-B overlay-C), where each overlay spans the
|
|
447 ;; entire corresponding buffer.
|
|
448 (ediff-defvar-local ediff-wide-bounds nil "")
|
|
449
|
|
450 ;; Current visibility boundaries in buffers A, B, and C.
|
|
451 ;; This is also a list of overlays. When the user toggles narrow/widen,
|
|
452 ;; this list changes from ediff-wide-bounds to ediff-narrow-bounds.
|
|
453 ;; and back.
|
|
454 (ediff-defvar-local ediff-visible-bounds nil "")
|
|
455
|
|
456 (ediff-defvar-local ediff-start-narrowed t
|
|
457 "Non-nil means start narrowed, if doing ediff-windows, ediff-small-regions,
|
|
458 or ediff-large-regions.")
|
|
459 (ediff-defvar-local ediff-quit-widened t
|
|
460 "*Non-nil means: when finished, Ediff widens buffers A/B.
|
|
461 Actually, Ediff restores the scope of visibility that existed at startup.")
|
|
462
|
|
463 (ediff-defvar-local ediff-highlight-all-diffs t
|
|
464 "If nil, only the selected differences are highlighted.
|
|
465 This variable can be set either in .emacs or toggled interactively, using
|
|
466 ediff-toggle-hilit. Use `setq-default' to set it.")
|
|
467
|
|
468 ;; A var local to each control panel buffer. Indicates highlighting style
|
|
469 ;; in effect for this buffer: `face', `ascii', nil -- temporarily
|
|
470 ;; unhighlighted, `off' -- turned off \(on a dumb terminal only\).
|
|
471 (ediff-defvar-local ediff-highlighting-style nil "")
|
|
472
|
|
473
|
|
474 ;; Variables that control each Ediff session. They are local to the
|
|
475 ;; control buffer.
|
|
476
|
|
477 ;; Mode variables
|
|
478 ;; The buffer in which the A variant is stored.
|
|
479 (ediff-defvar-local ediff-buffer-A nil "")
|
|
480 ;; The buffer in which the B variant is stored.
|
|
481 (ediff-defvar-local ediff-buffer-B nil "")
|
|
482 ;; The buffer in which the C variant is stored.
|
|
483 (ediff-defvar-local ediff-buffer-C nil "")
|
|
484 ;; Ancestor buffer
|
|
485 (ediff-defvar-local ediff-ancestor-buffer nil "")
|
|
486 ;; The control buffer of ediff.
|
|
487 (ediff-defvar-local ediff-control-buffer nil "")
|
|
488
|
|
489
|
|
490 ;; The suffix of the control buffer name.
|
|
491 (ediff-defvar-local ediff-control-buffer-suffix nil "")
|
|
492 ;; Same as ediff-control-buffer-suffix, but without <,>.
|
|
493 ;; It's a number rather than string.
|
|
494 (ediff-defvar-local ediff-control-buffer-number nil "")
|
|
495
|
|
496
|
|
497 ;; There three are to be deleted in due time
|
|
498 ;; Working values of ediff-saved-variables for buffer A.
|
|
499 (ediff-defvar-local ediff-buffer-A-values nil "")
|
|
500 ;; working values of ediff-saved-variables for buffer B.
|
|
501 (ediff-defvar-local ediff-buffer-B-values nil "")
|
|
502 ;; working values of ediff-saved-variables for buffer C.
|
|
503 (ediff-defvar-local ediff-buffer-C-values nil "")
|
|
504
|
|
505 ;; The original values of ediff-protected-variables for buffer A
|
|
506 (ediff-defvar-local ediff-buffer-A-values-orig nil "")
|
|
507 ;; The original values of ediff-protected-variables for buffer B
|
|
508 (ediff-defvar-local ediff-buffer-B-values-orig nil "")
|
|
509 ;; The original values of ediff-protected-variables for buffer C
|
|
510 (ediff-defvar-local ediff-buffer-C-values-orig nil "")
|
|
511 ;; Buffer-local variables to be saved then restored during Ediff sessions
|
|
512 (defconst ediff-protected-variables '(buffer-read-only
|
|
513 mode-line-format))
|
|
514
|
|
515 ;; These three vars are to be deleted when emacs gets before/after strings
|
|
516 ;; Remember ediff-saved-variables for ediff-buffer-A as they were at setup.
|
|
517 (ediff-defvar-local ediff-buffer-A-values-setup nil "")
|
|
518 ;; Remembers ediff-saved-variables for ediff-buffer-B as they were at setup.
|
|
519 (ediff-defvar-local ediff-buffer-B-values-setup nil "")
|
|
520 ;; Remembers ediff-saved-variables for ediff-buffer-C as they were at setup.
|
|
521 (ediff-defvar-local ediff-buffer-C-values-setup nil "")
|
|
522
|
|
523 ;; Vector of differences between the variants. Each difference is
|
|
524 ;; represented by a vector of two overlays plus a vector of fine diffs,
|
|
525 ;; plus a no-fine-diffs flag. The first overlay spans the
|
|
526 ;; difference region in the A buffer and the second overlays the diff in
|
|
527 ;; the B buffer. If a difference section is empty, the corresponding
|
|
528 ;; overlay's endpoints coincide.
|
|
529 ;;
|
|
530 ;; The precise form of a difference vector for one buffer is:
|
|
531 ;; [diff diff diff ...]
|
|
532 ;; where each diff has the form:
|
|
533 ;; [diff-overlay fine-diff-vector no-fine-diffs-flag state-of-difference
|
|
534 ;; state-of-merge]
|
|
535 ;; fine-diff-vector is a vector [fine-diff-overlay fine-diff-overlay ...]
|
|
536 ;; no-fine-diffs-flag says if there are fine differences.
|
|
537 ;; state-of-difference is A, B, C, or nil, indicating which buffer is
|
|
538 ;; different from the other two (used only in 3-way jobs.
|
|
539 ;; state-of-merge is default-A, default-B, prefer-A, or prefer-B. It
|
|
540 ;; indicates the way a diff region was created in buffer C.
|
|
541 (ediff-defvar-local ediff-difference-vector-A nil "")
|
|
542 (ediff-defvar-local ediff-difference-vector-B nil "")
|
|
543 (ediff-defvar-local ediff-difference-vector-C nil "")
|
|
544
|
|
545 ;; The difference that is currently selected.
|
|
546 (ediff-defvar-local ediff-current-difference -1 "")
|
|
547 ;; Number of differences found.
|
|
548 (ediff-defvar-local ediff-number-of-differences nil "")
|
|
549
|
|
550 ;; Buffer containing the output of diff, which is used by Ediff to step
|
|
551 ;; through files.
|
|
552 (ediff-defvar-local ediff-diff-buffer nil "")
|
|
553 ;; Like ediff-diff-buffer, but contains context diff. It is not used by
|
|
554 ;; Ediff, but it is saved in a file, if user requests so.
|
|
555 (ediff-defvar-local ediff-custom-diff-buffer nil "")
|
|
556 ;; Buffer used for diff-style fine differences between regions.
|
|
557 (ediff-defvar-local ediff-fine-diff-buffer nil "")
|
|
558 ;; Temporary buffer used for computing fine differences.
|
|
559 (defconst ediff-tmp-buffer " *ediff-tmp*" "")
|
|
560 ;; Buffer used for messages
|
|
561 (defconst ediff-msg-buffer " *ediff-message*" "")
|
|
562 ;; Buffer containing the output of diff when diff returns errors.
|
|
563 (ediff-defvar-local ediff-error-buffer nil "")
|
|
564 ;; Buffer to display debug info
|
|
565 (ediff-defvar-local ediff-debug-buffer "*ediff-debug*" "")
|
|
566
|
|
567 ;; to be deleted in due time
|
|
568 ;; List of ediff control panels associated with each buffer A/B.
|
|
569 (ediff-defvar-local ediff-this-buffer-control-sessions nil "")
|
|
570
|
|
571 ;; to be deleted in due time
|
|
572 ;; List of difference overlays disturbed by working with the current diff.
|
|
573 (defvar ediff-disturbed-overlays nil "")
|
|
574
|
|
575 ;; Priority of non-selected overlays.
|
|
576 (defvar ediff-shadow-overlay-priority 100 "")
|
|
577
|
|
578
|
|
579 (if ediff-xemacs-p
|
|
580 (progn
|
|
581 (fset 'ediff-read-event (symbol-function 'next-command-event))
|
|
582 (fset 'ediff-overlayp (symbol-function 'extentp))
|
|
583 (fset 'ediff-make-overlay (symbol-function 'make-extent))
|
|
584 (fset 'ediff-delete-overlay (symbol-function 'delete-extent))
|
|
585 (fset 'ediff-overlay-buffer (symbol-function 'extent-buffer))
|
|
586 (fset 'ediff-overlay-p (symbol-function 'extentp))
|
|
587 (fset 'ediff-overlay-get (symbol-function 'extent-property)))
|
|
588 (fset 'ediff-read-event (symbol-function 'read-event))
|
|
589 (fset 'ediff-overlayp (symbol-function 'overlayp))
|
|
590 (fset 'ediff-make-overlay (symbol-function 'make-overlay))
|
|
591 (fset 'ediff-delete-overlay (symbol-function 'delete-overlay))
|
|
592 (fset 'ediff-overlay-buffer (symbol-function 'overlay-buffer))
|
|
593 (fset 'ediff-overlay-p (symbol-function 'overlayp))
|
|
594 (fset 'ediff-overlay-get (symbol-function 'overlay-get)))
|
|
595
|
|
596 ;; A fix for NeXT Step
|
|
597 ;; Should probably be eliminated in later versions.
|
|
598 (if (and window-system (eq window-system 'ns))
|
|
599 (progn
|
|
600 (fset 'x-display-color-p (symbol-function 'ns-display-color-p))
|
|
601 (fset 'x-color-defined-p (symbol-function 'ns-color-defined-p))
|
|
602 (fset 'x-display-pixel-height (symbol-function 'ns-display-pixel-height))
|
|
603 (fset 'x-display-pixel-width (symbol-function 'ns-display-pixel-width))
|
|
604 ))
|
|
605
|
|
606 (if ediff-xemacs-p
|
|
607 (progn
|
|
608 (fset 'ediff-make-frame (symbol-function 'make-screen))
|
|
609 ;;(fset 'ediff-make-frame-invisible
|
|
610 ;; (symbol-function 'make-screen-invisible))
|
|
611 (fset 'ediff-raise-frame (symbol-function 'raise-screen))
|
|
612 (fset 'ediff-iconify-frame (symbol-function 'iconify-screen))
|
|
613 (fset 'ediff-delete-frame (symbol-function 'delete-screen))
|
|
614 (fset 'ediff-frame-visible-p (symbol-function 'screen-visible-p))
|
|
615 (fset 'ediff-select-frame (symbol-function 'select-screen))
|
|
616 (fset 'ediff-selected-frame (symbol-function 'selected-screen))
|
|
617 ;;(fset 'ediff-frame-selected-window
|
|
618 ;; (symbol-function 'screen-selected-window))
|
|
619 (fset 'ediff-frame-parameters (symbol-function 'screen-parameters))
|
|
620 ;;(fset 'ediff-frame-pixel-width (symbol-function 'screen-pixel-width))
|
|
621 (fset 'ediff-frame-width (symbol-function 'screen-width))
|
|
622 (fset 'ediff-modify-frame-parameters
|
|
623 (symbol-function 'modify-screen-parameters))
|
|
624 (fset 'ediff-frame-live-p (symbol-function 'screen-live-p))
|
|
625 (fset 'ediff-window-frame (symbol-function 'window-screen))
|
|
626 (if window-system
|
|
627 (progn
|
|
628 (fset 'ediff-display-color-p (symbol-function 'x-color-display-p))
|
|
629 (fset 'ediff-valid-color-p (symbol-function 'x-valid-color-name-p))
|
|
630 (fset 'ediff-get-face (symbol-function 'get-face)))))
|
|
631 (if window-system
|
|
632 (progn
|
|
633 (fset 'ediff-make-frame (symbol-function 'make-frame))
|
|
634 ;;(fset 'ediff-make-frame-invisible
|
|
635 ;; (symbol-function 'make-frame-invisible))
|
|
636 (fset 'ediff-raise-frame (symbol-function 'raise-frame))
|
|
637 (fset 'ediff-iconify-frame (symbol-function 'iconify-frame))
|
|
638 (fset 'ediff-delete-frame (symbol-function 'delete-frame))
|
|
639 (fset 'ediff-frame-visible-p (symbol-function 'frame-visible-p))
|
|
640 (fset 'ediff-window-frame (symbol-function 'window-frame))
|
|
641 (fset 'ediff-select-frame (symbol-function 'select-frame))
|
|
642 (fset 'ediff-selected-frame (symbol-function 'selected-frame))
|
|
643 ;;(fset 'ediff-frame-selected-window
|
|
644 ;; (symbol-function 'frame-selected-window))
|
|
645 (fset 'ediff-frame-parameters (symbol-function 'frame-parameters))
|
|
646 ;;(fset 'ediff-frame-pixel-width (symbol-function 'frame-pixel-width))
|
|
647 (fset 'ediff-frame-width (symbol-function 'frame-width))
|
|
648 (fset 'ediff-modify-frame-parameters
|
|
649 (symbol-function 'modify-frame-parameters))
|
|
650 (fset 'ediff-frame-live-p (symbol-function 'frame-live-p))
|
|
651 ))
|
|
652
|
|
653 (if window-system
|
|
654 (progn
|
|
655 (fset 'ediff-display-color-p (symbol-function 'x-display-color-p))
|
|
656 ;; Temporary fix for OS/2 users
|
|
657 ;; pm-win.el in PM-Emacs should be fixed.
|
|
658 (if (eq window-system 'pm)
|
|
659 (fset 'ediff-valid-color-p
|
|
660 (function (lambda (color) (assoc color pm-color-alist))))
|
|
661 (fset 'ediff-valid-color-p (symbol-function 'x-color-defined-p)))
|
|
662
|
|
663 (fset 'ediff-get-face (symbol-function 'internal-get-face))))
|
|
664 )
|
|
665
|
|
666 ;; not a window system
|
|
667 (if (not window-system)
|
|
668 (progn
|
|
669 (fset 'ediff-window-frame (function (lambda (wind) (if wind 1 nil)) ))
|
|
670 (fset 'ediff-selected-frame 'selected-window)
|
|
671 (fset 'ediff-frame-width 'window-width)
|
|
672 (fset 'ediff-make-current-diff-overlay (function (lambda (type) nil)))))
|
|
673
|
|
674 (if (not window-system)
|
|
675 ()
|
|
676 (defun ediff-set-face (ground face color)
|
|
677 "Sets face foreground/background."
|
|
678 (if (ediff-valid-color-p color)
|
|
679 (if (eq ground 'foreground)
|
|
680 (set-face-foreground face color)
|
|
681 (set-face-background face color))
|
|
682 (cond ((memq face
|
|
683 '(ediff-current-diff-face-A
|
|
684 ediff-current-diff-face-B
|
|
685 ediff-current-diff-face-C))
|
|
686 (copy-face 'highlight face))
|
|
687 ((memq face
|
|
688 '(ediff-fine-diff-face-A
|
|
689 ediff-fine-diff-face-B
|
|
690 ediff-fine-diff-face-C
|
|
691 ;; ediff-combined-diff-face
|
|
692 ))
|
|
693 (copy-face 'secondary-selection face)
|
|
694 (set-face-underline-p face t))
|
|
695 ((memq face
|
|
696 '(ediff-even-diff-face-A ediff-odd-diff-face-A
|
|
697 ediff-even-diff-face-B ediff-odd-diff-face-B
|
|
698 ediff-even-diff-face-C ediff-odd-diff-face-C))
|
|
699 (copy-face 'secondary-selection face)))))
|
|
700
|
|
701 (defvar ediff-current-diff-face-A
|
|
702 (progn
|
|
703 (make-face 'ediff-current-diff-face-A)
|
|
704 (or (face-differs-from-default-p 'ediff-current-diff-face-A)
|
|
705 (cond ((ediff-display-color-p)
|
|
706 (ediff-set-face
|
|
707 'foreground 'ediff-current-diff-face-A "firebrick")
|
|
708 (ediff-set-face
|
|
709 'background 'ediff-current-diff-face-A "pale green"))
|
|
710 (t
|
|
711 (if ediff-xemacs-p
|
|
712 (copy-face 'modeline 'ediff-current-diff-face-A)
|
|
713 (copy-face 'highlight 'ediff-current-diff-face-A))
|
|
714 )))
|
|
715 'ediff-current-diff-face-A)
|
|
716 "Face for highlighting the selected difference in buffer A.")
|
|
717
|
|
718 (defvar ediff-current-diff-face-B
|
|
719 (progn
|
|
720 (make-face 'ediff-current-diff-face-B)
|
|
721 (or (face-differs-from-default-p 'ediff-current-diff-face-B)
|
|
722 (cond ((ediff-display-color-p)
|
|
723 (ediff-set-face
|
|
724 'foreground 'ediff-current-diff-face-B "DarkOrchid")
|
|
725 (ediff-set-face
|
|
726 'background 'ediff-current-diff-face-B "Yellow"))
|
|
727 (t
|
|
728 (if ediff-xemacs-p
|
|
729 (copy-face 'modeline 'ediff-current-diff-face-B)
|
|
730 (copy-face 'highlight 'ediff-current-diff-face-B))
|
|
731 )))
|
|
732 'ediff-current-diff-face-B)
|
|
733 "Face for highlighting the selected difference in buffer B.")
|
|
734
|
|
735
|
|
736 (defvar ediff-current-diff-face-C
|
|
737 (progn
|
|
738 (make-face 'ediff-current-diff-face-C)
|
|
739 (or (face-differs-from-default-p 'ediff-current-diff-face-C)
|
|
740 (cond ((ediff-display-color-p)
|
|
741 (ediff-set-face
|
|
742 'foreground 'ediff-current-diff-face-C "Navy")
|
|
743 (ediff-set-face
|
|
744 'background 'ediff-current-diff-face-C "Pink"))
|
|
745 (t
|
|
746 (if ediff-xemacs-p
|
|
747 (copy-face 'modeline 'ediff-current-diff-face-C)
|
|
748 (copy-face 'highlight 'ediff-current-diff-face-C))
|
|
749 )))
|
|
750 'ediff-current-diff-face-C)
|
|
751 "Face for highlighting the selected difference in buffer C.")
|
|
752
|
|
753 (defvar ediff-fine-diff-face-A
|
|
754 (progn
|
|
755 (make-face 'ediff-fine-diff-face-A)
|
|
756 (or (face-differs-from-default-p 'ediff-fine-diff-face-A)
|
|
757 (cond ((ediff-display-color-p)
|
|
758 (ediff-set-face 'foreground 'ediff-fine-diff-face-A
|
|
759 "Navy")
|
|
760 (ediff-set-face 'background 'ediff-fine-diff-face-A
|
|
761 "sky blue"))
|
|
762 (t (set-face-underline-p 'ediff-fine-diff-face-A t))))
|
|
763 'ediff-fine-diff-face-A)
|
|
764 "Face for highlighting the refinement of the selected diff in buffer A.")
|
|
765
|
|
766 (defvar ediff-fine-diff-face-B
|
|
767 (progn
|
|
768 (make-face 'ediff-fine-diff-face-B)
|
|
769 (or (face-differs-from-default-p 'ediff-fine-diff-face-B)
|
|
770 (cond ((ediff-display-color-p)
|
|
771 (ediff-set-face 'foreground 'ediff-fine-diff-face-B "Black")
|
|
772 (ediff-set-face 'background 'ediff-fine-diff-face-B "cyan"))
|
|
773 (t (set-face-underline-p 'ediff-fine-diff-face-B t))))
|
|
774 'ediff-fine-diff-face-B)
|
|
775 "Face for highlighting the refinement of the selected diff in buffer B.")
|
|
776
|
|
777 (defvar ediff-fine-diff-face-C
|
|
778 (progn
|
|
779 (make-face 'ediff-fine-diff-face-C)
|
|
780 (or (face-differs-from-default-p 'ediff-fine-diff-face-C)
|
|
781 (cond ((ediff-display-color-p)
|
|
782 (ediff-set-face 'foreground 'ediff-fine-diff-face-C "black")
|
|
783 (ediff-set-face
|
|
784 'background 'ediff-fine-diff-face-C "Turquoise"))
|
|
785 (t (set-face-underline-p 'ediff-fine-diff-face-C t))))
|
|
786 'ediff-fine-diff-face-C)
|
|
787 "Face for highlighting the refinement of the selected diff in buffer C.")
|
|
788
|
|
789 ;; (defvar ediff-combined-diff-face
|
|
790 ;; (progn
|
|
791 ;; (make-face 'ediff-combined-diff-face)
|
|
792 ;; (or (face-differs-from-default-p 'ediff-combined-diff-face)
|
|
793 ;; (cond ((ediff-display-color-p)
|
|
794 ;; (ediff-set-face 'foreground 'ediff-combined-diff-face "black")
|
|
795 ;; (ediff-set-face
|
|
796 ;; 'background 'ediff-combined-diff-face "Plum"))
|
|
797 ;; (t (set-face-underline-p 'ediff-combined-diff-face t))))
|
|
798 ;; 'ediff-combined-diff-face)
|
|
799 ;; "Face for highlighting combined selected diff regions in buffer C.")
|
|
800
|
|
801 (defvar ediff-even-diff-face-A
|
|
802 (progn
|
|
803 (make-face 'ediff-even-diff-face-A)
|
|
804 (or (face-differs-from-default-p 'ediff-even-diff-face-A)
|
|
805 (cond ((ediff-display-color-p)
|
|
806 (ediff-set-face
|
|
807 'foreground 'ediff-even-diff-face-A "black")
|
|
808 (ediff-set-face
|
|
809 'background 'ediff-even-diff-face-A "light grey"))
|
|
810 (t
|
|
811 (copy-face 'italic 'ediff-even-diff-face-A))))
|
|
812 'ediff-even-diff-face-A)
|
|
813 "Face used to highlight even-numbered differences in buffer A.")
|
|
814
|
|
815 (defvar ediff-even-diff-face-B
|
|
816 (progn
|
|
817 (make-face 'ediff-even-diff-face-B)
|
|
818 (or (face-differs-from-default-p 'ediff-even-diff-face-B)
|
|
819 (cond ((ediff-display-color-p)
|
|
820 (ediff-set-face
|
|
821 'foreground 'ediff-even-diff-face-B "White")
|
|
822 (ediff-set-face
|
|
823 'background 'ediff-even-diff-face-B "Gray"))
|
|
824 (t
|
|
825 (copy-face 'italic 'ediff-even-diff-face-B))))
|
|
826 'ediff-even-diff-face-B)
|
|
827 "Face used to highlight even-numbered differences in buffer B.")
|
|
828
|
|
829 (defvar ediff-even-diff-face-C
|
|
830 (progn
|
|
831 (make-face 'ediff-even-diff-face-C)
|
|
832 (copy-face 'ediff-even-diff-face-A 'ediff-even-diff-face-C)
|
|
833 'ediff-even-diff-face-C)
|
|
834 "Face used to highlight even-numbered differences in buffer C.")
|
|
835
|
|
836 (defvar ediff-odd-diff-face-A
|
|
837 (progn
|
|
838 (make-face 'ediff-odd-diff-face-A)
|
|
839 (or (face-differs-from-default-p 'ediff-odd-diff-face-A)
|
|
840 (cond ((ediff-display-color-p)
|
|
841 (ediff-set-face
|
|
842 'foreground 'ediff-odd-diff-face-A "White")
|
|
843 (ediff-set-face
|
|
844 'background 'ediff-odd-diff-face-A "Gray"))
|
|
845 (t
|
|
846 (copy-face 'italic 'ediff-odd-diff-face-A))))
|
|
847 'ediff-odd-diff-face-A)
|
|
848 "Face used to highlight odd-numbered differences in buffer A.")
|
|
849
|
|
850 (defvar ediff-odd-diff-face-B
|
|
851 (progn
|
|
852 (make-face 'ediff-odd-diff-face-B)
|
|
853 (or (face-differs-from-default-p 'ediff-odd-diff-face-B)
|
|
854 (cond ((ediff-display-color-p)
|
|
855 (ediff-set-face
|
|
856 'foreground 'ediff-odd-diff-face-B "Black")
|
|
857 (ediff-set-face
|
|
858 'background 'ediff-odd-diff-face-B "light grey"))
|
|
859 (t
|
|
860 (copy-face 'italic 'ediff-odd-diff-face-B))))
|
|
861 'ediff-odd-diff-face-B)
|
|
862 "Face used to highlight odd-numbered differences in buffer B.")
|
|
863
|
|
864 (defvar ediff-odd-diff-face-C
|
|
865 (progn
|
|
866 (make-face 'ediff-odd-diff-face-C)
|
|
867 (copy-face 'ediff-odd-diff-face-A 'ediff-odd-diff-face-C)
|
|
868 'ediff-odd-diff-face-C)
|
|
869 "Face used to highlight odd-numbered differences in buffer C.")
|
|
870
|
|
871 ;; Create *-var faces. These are the actual faces used to highlight
|
|
872 ;; odd-numbered difference regions.
|
|
873 ;; They are used as follows: when highlighting is turned on,
|
|
874 ;; ediff-odd/even-diff-face-A/B/C are copied
|
|
875 ;; into ediff-odd/even-diff-face-A/B/C-var, and all odd/even overlays become
|
|
876 ;; highlighted. When highlighting is turned off, then the face 'default is
|
|
877 ;; copied into ediff-odd/even-diff-face-A/B/C-var, thereby unhighlighting all
|
|
878 ;; difference regions.
|
|
879 (make-face 'ediff-even-diff-face-A-var)
|
|
880 (make-face 'ediff-even-diff-face-B-var)
|
|
881 (make-face 'ediff-even-diff-face-C-var)
|
|
882 (make-face 'ediff-odd-diff-face-A-var)
|
|
883 (make-face 'ediff-odd-diff-face-B-var)
|
|
884 (make-face 'ediff-odd-diff-face-C-var)
|
|
885
|
|
886 ;; initialize *-var faces
|
|
887 (defun ediff-init-var-faces ()
|
|
888 (copy-face (if (and ediff-use-faces ediff-highlight-all-diffs)
|
|
889 ediff-even-diff-face-A 'default)
|
|
890 'ediff-even-diff-face-A-var)
|
|
891 (copy-face (if (and ediff-use-faces ediff-highlight-all-diffs)
|
|
892 ediff-even-diff-face-B 'default)
|
|
893 'ediff-even-diff-face-B-var)
|
|
894 (copy-face (if (and ediff-use-faces ediff-highlight-all-diffs)
|
|
895 ediff-even-diff-face-C 'default)
|
|
896 'ediff-even-diff-face-C-var)
|
|
897 (copy-face (if (and ediff-use-faces ediff-highlight-all-diffs)
|
|
898 ediff-odd-diff-face-A 'default)
|
|
899 'ediff-odd-diff-face-A-var)
|
|
900 (copy-face (if (and ediff-use-faces ediff-highlight-all-diffs)
|
|
901 ediff-odd-diff-face-B 'default)
|
|
902 'ediff-odd-diff-face-B-var)
|
|
903 (copy-face (if (and ediff-use-faces ediff-highlight-all-diffs)
|
|
904 ediff-odd-diff-face-C 'default)
|
|
905 'ediff-odd-diff-face-C-var)
|
|
906 )
|
|
907
|
|
908
|
|
909 ;;; Overlays
|
|
910
|
|
911 (ediff-defvar-local ediff-current-diff-overlay-A nil
|
|
912 "Overlay for the current difference region in buffer A.")
|
|
913 (ediff-defvar-local ediff-current-diff-overlay-B nil
|
|
914 "Overlay for the current difference region in buffer B.")
|
|
915 (ediff-defvar-local ediff-current-diff-overlay-C nil
|
|
916 "Overlay for the current difference region in buffer C.")
|
|
917
|
|
918 (defun ediff-make-current-diff-overlay (type)
|
|
919 (let ((overlay (intern (format "ediff-current-diff-overlay-%S" type)))
|
|
920 (buffer (ediff-get-buffer type))
|
|
921 (face (face-name
|
|
922 (symbol-value
|
|
923 (intern (format "ediff-current-diff-face-%S" type))))))
|
|
924 (set overlay
|
|
925 (ediff-make-bullet-proof-overlay (point-max) (point-max) buffer))
|
|
926 (ediff-overlay-put (symbol-value overlay) 'face face)
|
|
927 (ediff-overlay-put (symbol-value overlay) 'ediff ediff-control-buffer)
|
|
928 ))
|
|
929
|
|
930 ;; Compute priority of ediff overlay.
|
|
931 (defun ediff-highest-priority (start end buffer)
|
|
932 (let ((pos (max 1 (1- start)))
|
|
933 ovr-list)
|
|
934 (if ediff-xemacs-p
|
|
935 (1+ ediff-shadow-overlay-priority)
|
|
936 (ediff-eval-in-buffer buffer
|
|
937 (while (< pos (min (point-max) (1+ end)))
|
|
938 (setq ovr-list (append (overlays-at pos) ovr-list))
|
|
939 (setq pos (next-overlay-change pos)))
|
|
940 (1+ (apply '+
|
|
941 (mapcar (function
|
|
942 (lambda (ovr)
|
|
943 (if ovr
|
|
944 (or (ediff-overlay-get ovr 'priority) 0)
|
|
945 0)))
|
|
946 ovr-list)
|
|
947 ))
|
|
948 ))))
|
|
949
|
|
950 ) ; end of window-system-only code.
|
|
951
|
|
952
|
|
953 (defvar ediff-toggle-read-only-function nil
|
|
954 "*Specifies the function to be used to toggle read-only.
|
|
955 If nil, Ediff tries to deduce the function from the binding of C-x C-q.
|
|
956 Normally, this is the `toggle-read-only' function, but, if version
|
|
957 control is used, it could be `vc-toggle-read-only' or `rcs-toggle-read-only'.")
|
|
958
|
|
959 (ediff-defvar-local ediff-file-checked-out-flag nil
|
|
960 "If t, indicates that buffer has been already checked out.")
|
|
961
|
|
962
|
|
963
|
|
964 ;;; Misc
|
|
965
|
|
966 ;; when emacs will have before/after-string in overlays, this variable will
|
|
967 ;; be deleted
|
|
968 (defconst ediff-saved-variables
|
|
969 '(;;buffer-read-only
|
|
970 buffer-auto-save-file-name)
|
|
971 "Buffer-local variables saved and restored during an Ediff session.")
|
|
972
|
|
973 ;; to be deleted in due time
|
|
974 (defconst ediff-working-values '(nil)
|
|
975 "Values to be assigned to `ediff-saved-variables' during diff.")
|
|
976
|
|
977 ;; if nil, this silences some messages
|
|
978 (defconst ediff-verbose-p t)
|
|
979
|
|
980 (defvar ediff-no-emacs-help-in-control-buffer nil
|
|
981 "*Non-nil means C-h should not invoke Emacs help in control buffer.
|
|
982 Instead, C-h jumps to previous difference.")
|
|
983
|
|
984 (defvar ediff-temp-file-prefix
|
|
985 (let ((env (or (getenv "TMPDIR")
|
|
986 (getenv "TMP")
|
|
987 (getenv "TEMP")))
|
|
988 d)
|
|
989 (setq d (if (and env (> (length env) 0))
|
|
990 env
|
|
991 (if (memq system-type '(vax-vms axp-vms))
|
|
992 "SYS$SCRATCH:"
|
|
993 "/tmp")))
|
|
994 ;; The following is to make sure we get something to which we can
|
|
995 ;; add directory levels on VMS.
|
|
996 (setq d (file-name-as-directory (directory-file-name d)))
|
|
997 ;;(concat d "ediff")
|
|
998 )
|
|
999 "*Prefix to put on Ediff temporary file names.
|
|
1000 Do not start with `~/' or `~user-name/'.")
|
|
1001
|
|
1002 (defvar ediff-temp-file-mode 384 ; u=rw only
|
|
1003 "*Mode for Ediff temporary files.")
|
|
1004
|
|
1005 ;; Metacharacters that have to be protected from the shell when executing
|
|
1006 ;; a diff/diff3 command.
|
|
1007 (defvar ediff-metachars "[ \t\n!\"#$&'()*;<=>?[\\^`{|~]"
|
|
1008 "Characters that must be quoted with \\ when used in a shell command line.
|
|
1009 More precisely, a regexp to match any one such character.")
|
|
1010
|
|
1011
|
|
1012 (ediff-defvar-local ediff-temp-file-A nil
|
|
1013 "Temporary file used for refining difference regions in buffer A.")
|
|
1014 (ediff-defvar-local ediff-temp-file-B nil
|
|
1015 "Temporary file used for refining difference regions in buffer B.")
|
|
1016 (ediff-defvar-local ediff-temp-file-C nil
|
|
1017 "Temporary file used for refining difference regions in buffer C.")
|
|
1018
|
|
1019 ;;; In-line functions
|
|
1020
|
|
1021 (defsubst ediff-file-remote-p (file-name)
|
|
1022 (if (fboundp ediff-ange-ftp-ftp-name)
|
|
1023 (funcall ediff-ange-ftp-ftp-name file-name)))
|
|
1024
|
|
1025 (defsubst ediff-frame-has-menubar ()
|
|
1026 (and window-system
|
|
1027 (if ediff-xemacs-p
|
|
1028 current-menubar
|
|
1029 (let ((lines (cdr (assq 'menu-bar-lines
|
|
1030 (frame-parameters (ediff-selected-frame))))))
|
|
1031 (or (eq lines t) (and (numberp lines) (< 0 lines))))
|
|
1032 )))
|
|
1033
|
|
1034 (defsubst ediff-frame-unsplittable-p (frame)
|
|
1035 (cdr (assq 'unsplittable (ediff-frame-parameters frame))))
|
|
1036
|
|
1037 (defsubst ediff-get-next-window (wind prev-wind)
|
|
1038 (or (window-live-p wind)
|
|
1039 (setq wind (if prev-wind
|
|
1040 (next-window wind)
|
|
1041 (selected-window)))))
|
|
1042
|
|
1043 (defsubst ediff-convert-diffs-to-overlays (diff-list)
|
|
1044 (ediff-set-diff-overlays-in-one-buffer 'A diff-list)
|
|
1045 (ediff-set-diff-overlays-in-one-buffer 'B diff-list)
|
|
1046 (if ediff-3way-job
|
|
1047 (ediff-set-diff-overlays-in-one-buffer 'C diff-list))
|
|
1048 (message "Processing difference regions ... done"))
|
|
1049
|
|
1050
|
|
1051 (defsubst ediff-kill-buffer-carefully (buf)
|
|
1052 "Kill buffer BUF if it exists."
|
|
1053 (if (ediff-buffer-live-p buf)
|
|
1054 (kill-buffer (get-buffer buf))))
|
|
1055
|
|
1056
|
|
1057 (defsubst ediff-highlight-diff (n)
|
|
1058 "Put face on diff N. Invoked for X displays only."
|
|
1059 (ediff-highlight-diff-in-one-buffer n 'A)
|
|
1060 (ediff-highlight-diff-in-one-buffer n 'B)
|
|
1061 (ediff-highlight-diff-in-one-buffer n 'C))
|
|
1062
|
|
1063
|
|
1064 (defsubst ediff-unhighlight-diff ()
|
|
1065 "Remove overlays from buffers A, B, and C."
|
|
1066 (ediff-unhighlight-diff-in-one-buffer 'A)
|
|
1067 (ediff-unhighlight-diff-in-one-buffer 'B)
|
|
1068 (ediff-unhighlight-diff-in-one-buffer 'C))
|
|
1069
|
|
1070 ;; delete highlighting overlays, restore faces to their original form
|
|
1071 (defsubst ediff-unhighlight-diffs-totally ()
|
|
1072 (ediff-unhighlight-diffs-totally-in-one-buffer 'A)
|
|
1073 (ediff-unhighlight-diffs-totally-in-one-buffer 'B)
|
|
1074 (ediff-unhighlight-diffs-totally-in-one-buffer 'C))
|
|
1075
|
|
1076
|
|
1077 ;; arg is a record for a given diff in a difference vector
|
|
1078 ;; this record is itself a vector
|
|
1079 (defsubst ediff-clear-fine-diff-vector (diff-record)
|
|
1080 (if diff-record
|
|
1081 (mapcar 'ediff-delete-overlay
|
|
1082 (ediff-get-fine-diff-vector-from-diff-record diff-record))))
|
|
1083
|
|
1084 (defsubst ediff-clear-fine-differences-in-one-buffer (n buf-type)
|
|
1085 (ediff-clear-fine-diff-vector (ediff-get-difference n buf-type))
|
|
1086 (ediff-set-fine-diff-vector n buf-type nil))
|
|
1087
|
|
1088 (defsubst ediff-clear-fine-differences (n)
|
|
1089 (ediff-clear-fine-differences-in-one-buffer n 'A)
|
|
1090 (ediff-clear-fine-differences-in-one-buffer n 'B)
|
|
1091 (if ediff-3way-job
|
|
1092 (ediff-clear-fine-differences-in-one-buffer n 'C)))
|
|
1093
|
|
1094
|
|
1095 (defsubst ediff-convert-fine-diffs-to-overlays (diff-list region-num)
|
|
1096 (ediff-set-fine-overlays-in-one-buffer 'A diff-list region-num)
|
|
1097 (ediff-set-fine-overlays-in-one-buffer 'B diff-list region-num)
|
|
1098 (if ediff-3way-job
|
|
1099 (ediff-set-fine-overlays-in-one-buffer 'C diff-list region-num)
|
|
1100 ))
|
|
1101
|
|
1102 (defsubst ediff-mouse-event-p (event)
|
|
1103 (if ediff-xemacs-p
|
|
1104 (button-event-p event)
|
|
1105 (string-match "mouse" (format "%S" (event-basic-type event)))
|
|
1106 ))
|
|
1107
|
|
1108 (defsubst ediff-frame-iconified-p (frame)
|
|
1109 (if (and window-system (ediff-frame-live-p frame))
|
|
1110 (if ediff-xemacs-p
|
|
1111 (screen-iconified-p frame)
|
|
1112 (eq (frame-visible-p frame) 'icon))))
|
|
1113
|
|
1114 (defsubst ediff-window-visible-p (wind)
|
|
1115 (and (window-live-p wind)
|
|
1116 ;; under non-wondow system, window-live-p also means window is visible
|
|
1117 (or (not window-system)
|
|
1118 (ediff-frame-visible-p (ediff-window-frame wind)))))
|
|
1119
|
|
1120
|
|
1121 (defsubst ediff-frame-char-width (frame)
|
|
1122 (if ediff-xemacs-p
|
|
1123 (/ (screen-pixel-width frame) (screen-width frame))
|
|
1124 (frame-char-width frame)))
|
|
1125
|
|
1126 (defsubst ediff-frame-char-height (frame)
|
|
1127 (if ediff-xemacs-p
|
|
1128 (/ (screen-pixel-height frame) (screen-height frame))
|
|
1129 (frame-char-height frame)))
|
|
1130
|
|
1131
|
|
1132 (defsubst ediff-empty-overlay-p (overl)
|
|
1133 (= (ediff-overlay-start overl) (ediff-overlay-end overl)))
|
|
1134
|
|
1135 ;; t if diff region is empty.
|
|
1136 ;; In case of buffer C, t also if it is not a 3way
|
|
1137 ;; comparison job (merging jobs return t as well).
|
|
1138 (defun ediff-empty-diff-region-p (n buf-type)
|
|
1139 (if (eq buf-type 'C)
|
|
1140 (or (not ediff-3way-comparison-job)
|
|
1141 (= (ediff-get-diff-posn 'C 'beg n)
|
|
1142 (ediff-get-diff-posn 'C 'end n)))
|
|
1143 (= (ediff-get-diff-posn buf-type 'beg n)
|
|
1144 (ediff-get-diff-posn buf-type 'end n))))
|
|
1145
|
|
1146 ;; Test if diff region is white space only.
|
|
1147 ;; If 2-way job and buf-type = C, then returns t.
|
|
1148 (defun ediff-whitespace-diff-region-p (n buf-type)
|
|
1149 (or (and (eq buf-type 'C) (not ediff-3way-job))
|
|
1150 (let ((beg (ediff-get-diff-posn buf-type 'beg n))
|
|
1151 (end (ediff-get-diff-posn buf-type 'end n)))
|
|
1152 (ediff-eval-in-buffer (ediff-get-buffer buf-type)
|
|
1153 (save-excursion
|
|
1154 (goto-char beg)
|
|
1155 (skip-chars-forward ediff-whitespace)
|
|
1156 (>= (point) end))))))
|
|
1157
|
|
1158 ;; temporarily uses DIR to abbreviate file name
|
|
1159 ;; if DIR is nil, use default-directory
|
|
1160 (defsubst ediff-abbreviate-filename (file dir)
|
|
1161 (let* ((dir (or dir default-directory))
|
|
1162 (directory-abbrev-alist (list (cons dir ""))))
|
|
1163 (abbreviate-file-name file)))
|
|
1164
|
|
1165 (defsubst ediff-get-region-contents (n buf-type ctrl-buf &optional start end)
|
|
1166 (ediff-eval-in-buffer
|
|
1167 (ediff-eval-in-buffer ctrl-buf (ediff-get-buffer buf-type))
|
|
1168 (buffer-substring
|
|
1169 (or start (ediff-get-diff-posn buf-type 'beg n ctrl-buf))
|
|
1170 (or end (ediff-get-diff-posn buf-type 'end n ctrl-buf)))))
|
|
1171
|
|
1172 ;; If ediff modified mode line, strip the modification
|
|
1173 (defsubst ediff-strip-mode-line-format ()
|
|
1174 (if (member (car mode-line-format) '(" A: " " B: " " C: "))
|
|
1175 (setq mode-line-format (nth 2 mode-line-format))))
|
|
1176
|
|
1177 ;; Verify that we have a difference selected.
|
|
1178 (defsubst ediff-valid-difference-p (&optional n)
|
|
1179 (or n (setq n ediff-current-difference))
|
|
1180 (and (>= n 0) (< n ediff-number-of-differences)))
|
|
1181
|
|
1182 (defsubst ediff-show-all-diffs (n)
|
|
1183 "Don't skip difference regions."
|
|
1184 nil)
|
|
1185
|
|
1186 (provide 'ediff-init)
|
|
1187
|
|
1188
|
|
1189 ;;; ediff-init.el ends here
|