0
|
1 ;;; ediff-init.el --- Macros, variables, and defsubsts used by Ediff
|
|
2
|
16
|
3 ;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
|
0
|
4
|
|
5 ;; Author: Michael Kifer <kifer@cs.sunysb.edu>
|
|
6
|
|
7 ;; This file is part of GNU Emacs.
|
|
8
|
|
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
|
|
10 ;; it under the terms of the GNU General Public License as published by
|
|
11 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
12 ;; any later version.
|
|
13
|
|
14 ;; GNU Emacs is distributed in the hope that it will be useful,
|
|
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17 ;; GNU General Public License for more details.
|
|
18
|
|
19 ;; You should have received a copy of the GNU General Public License
|
|
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
|
|
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
22 ;; Boston, MA 02111-1307, USA.
|
|
23
|
|
24 ;;; Code:
|
|
25
|
|
26 ;; Start compiler pacifier
|
|
27 (defvar ediff-metajob-name)
|
|
28 (defvar ediff-meta-buffer)
|
|
29 (defvar pm-color-alist)
|
|
30 (defvar ediff-grab-mouse)
|
|
31 (defvar ediff-mouse-pixel-position)
|
|
32 (defvar ediff-mouse-pixel-threshold)
|
|
33 (defvar ediff-whitespace)
|
|
34 (defvar ediff-multiframe)
|
16
|
35
|
|
36 (and noninteractive
|
|
37 (eval-when-compile
|
|
38 (load "ange-ftp" 'noerror)))
|
0
|
39 ;; end pacifier
|
|
40
|
|
41 ;; Is it XEmacs?
|
|
42 (defconst ediff-xemacs-p (string-match "XEmacs" emacs-version))
|
|
43 ;; Is it Emacs?
|
|
44 (defconst ediff-emacs-p (not ediff-xemacs-p))
|
|
45
|
|
46 (defvar ediff-force-faces nil
|
|
47 "If t, Ediff will think that it is running on a display that supports faces.
|
|
48 This is provided as a temporary relief for users of face-capable displays
|
|
49 that Ediff doesn't know about.")
|
|
50
|
|
51 ;; Are we running as a window application or on a TTY?
|
|
52 (defsubst ediff-device-type ()
|
|
53 (if ediff-emacs-p
|
|
54 window-system
|
|
55 (device-type (selected-device))))
|
|
56
|
|
57 ;; in XEmacs: device-type is tty on tty and stream in batch.
|
|
58 (defun ediff-window-display-p ()
|
|
59 (and (ediff-device-type) (not (memq (ediff-device-type) '(tty pc stream)))))
|
|
60
|
|
61 ;; test if supports faces
|
|
62 ;; ediff-force-faces is for those devices that support faces, but we don't know
|
|
63 ;; this yet
|
|
64 (defun ediff-has-face-support-p ()
|
|
65 (cond ((ediff-window-display-p))
|
|
66 (ediff-force-faces)
|
|
67 (ediff-emacs-p (memq (ediff-device-type) '(pc)))
|
|
68 (ediff-xemacs-p (memq (ediff-device-type) '(tty pc)))))
|
12
|
69
|
14
|
70
|
0
|
71 ;; Defines SYMBOL as an advertised local variable.
|
|
72 ;; Performs a defvar, then executes `make-variable-buffer-local' on
|
|
73 ;; the variable. Also sets the `permanent-local' property,
|
|
74 ;; so that `kill-all-local-variables' (called by major-mode setting
|
|
75 ;; commands) won't destroy Ediff control variables.
|
|
76 ;;
|
|
77 ;; Plagiarised from `emerge-defvar-local' for XEmacs.
|
|
78 (defmacro ediff-defvar-local (var value doc)
|
|
79 (` (progn
|
|
80 (defvar (, var) (, value) (, doc))
|
|
81 (make-variable-buffer-local '(, var))
|
|
82 (put '(, var) 'permanent-local t))))
|
|
83
|
|
84
|
|
85
|
|
86 ;; Variables that control each Ediff session---local to the control buffer.
|
|
87
|
|
88 ;; Mode variables
|
|
89 ;; The buffer in which the A variant is stored.
|
|
90 (ediff-defvar-local ediff-buffer-A nil "")
|
|
91 ;; The buffer in which the B variant is stored.
|
|
92 (ediff-defvar-local ediff-buffer-B nil "")
|
|
93 ;; The buffer in which the C variant is stored.
|
|
94 (ediff-defvar-local ediff-buffer-C nil "")
|
|
95 ;; Ancestor buffer
|
|
96 (ediff-defvar-local ediff-ancestor-buffer nil "")
|
16
|
97 ;; The Ediff control buffer
|
0
|
98 (ediff-defvar-local ediff-control-buffer nil "")
|
|
99
|
|
100 ;;; Macros
|
|
101 (defmacro ediff-odd-p (arg)
|
|
102 (` (eq (logand (, arg) 1) 1)))
|
|
103
|
|
104 (defmacro ediff-buffer-live-p (buf)
|
|
105 (` (and (, buf) (get-buffer (, buf)) (buffer-name (get-buffer (, buf))))))
|
|
106
|
|
107 (defmacro ediff-get-buffer (arg)
|
|
108 (` (cond ((eq (, arg) 'A) ediff-buffer-A)
|
|
109 ((eq (, arg) 'B) ediff-buffer-B)
|
|
110 ((eq (, arg) 'C) ediff-buffer-C)
|
|
111 ((eq (, arg) 'Ancestor) ediff-ancestor-buffer)
|
|
112 )
|
|
113 ))
|
|
114
|
|
115 (defmacro ediff-get-value-according-to-buffer-type (buf-type list)
|
|
116 (` (cond ((eq (, buf-type) 'A) (nth 0 (, list)))
|
|
117 ((eq (, buf-type) 'B) (nth 1 (, list)))
|
|
118 ((eq (, buf-type) 'C) (nth 2 (, list))))))
|
|
119
|
|
120 (defmacro ediff-char-to-buftype (arg)
|
|
121 (` (cond ((memq (, arg) '(?a ?A)) 'A)
|
|
122 ((memq (, arg) '(?b ?B)) 'B)
|
|
123 ((memq (, arg) '(?c ?C)) 'C)
|
|
124 )
|
|
125 ))
|
|
126
|
|
127 (defmacro ediff-get-difference (n buf-type)
|
|
128 (` (aref
|
|
129 (symbol-value
|
|
130 (intern (format "ediff-difference-vector-%S" (, buf-type)))) (, n))))
|
|
131
|
|
132 ;; tell if it has been previously determined that the region has
|
|
133 ;; no diffs other than the white space and newlines
|
|
134 ;; The argument, N, is the diff region number used by Ediff to index the
|
|
135 ;; diff vector. It is 1 less than the number seen by the user.
|
|
136 ;;
|
|
137 ;; A difference vector has the form:
|
|
138 ;; [diff diff diff ...]
|
|
139 ;; where each diff has the form:
|
|
140 ;; [overlay fine-diff-vector no-fine-diffs-flag]
|
|
141 ;; fine-diff-vector is a vector [fine-diff fine-diff fine-diff ...]
|
|
142 (defmacro ediff-no-fine-diffs-p (n)
|
|
143 (` (aref (ediff-get-difference (, n) 'A) 2)))
|
|
144
|
|
145 (defmacro ediff-get-diff-overlay-from-diff-record (diff-rec)
|
|
146 (` (aref (, diff-rec) 0)))
|
|
147
|
|
148 (defmacro ediff-get-diff-overlay (n buf-type)
|
|
149 (` (ediff-get-diff-overlay-from-diff-record
|
|
150 (ediff-get-difference (, n) (, buf-type)))))
|
|
151
|
|
152 (defmacro ediff-get-fine-diff-vector-from-diff-record (diff-rec)
|
|
153 (` (aref (, diff-rec) 1)))
|
|
154
|
|
155 (defmacro ediff-set-fine-diff-vector (n buf-type fine-vec)
|
|
156 (` (aset (ediff-get-difference (, n) (, buf-type)) 1 (, fine-vec))))
|
|
157
|
|
158 (defmacro ediff-get-state-of-diff (n buf-type)
|
|
159 (` (if (ediff-buffer-live-p ediff-buffer-C)
|
|
160 (aref (ediff-get-difference (, n) (, buf-type)) 3))))
|
|
161 (defmacro ediff-set-state-of-diff (n buf-type val)
|
|
162 (` (aset (ediff-get-difference (, n) (, buf-type)) 3 (, val))))
|
|
163 (defmacro ediff-get-state-of-merge (n)
|
|
164 (` (if ediff-state-of-merge
|
|
165 (aref (aref ediff-state-of-merge (, n)) 0))))
|
|
166 (defmacro ediff-get-state-of-ancestor (n)
|
|
167 (` (if ediff-state-of-merge
|
|
168 (aref (aref ediff-state-of-merge (, n)) 1))))
|
|
169 (defmacro ediff-set-state-of-merge (n val)
|
|
170 (` (if ediff-state-of-merge
|
|
171 (aset (aref ediff-state-of-merge (, n)) 0 (, val)))))
|
|
172
|
|
173 ;; if flag is t, puts a mark on diff region saying that
|
|
174 ;; the differences are in white space only. If flag is nil,
|
|
175 ;; the region is marked as essential (i.e., differences are
|
|
176 ;; not just in the white space and newlines.)
|
|
177 (defmacro ediff-mark-diff-as-space-only (n flag)
|
|
178 (` (aset (ediff-get-difference (, n) 'A) 2 (, flag))))
|
|
179
|
|
180 (defmacro ediff-get-fine-diff-vector (n buf-type)
|
|
181 (` (ediff-get-fine-diff-vector-from-diff-record
|
|
182 (ediff-get-difference (, n) (, buf-type)))))
|
|
183
|
|
184 ;; Macro to switch to BUFFER, evaluate FORMS, returns to original buffer.
|
|
185 ;; Differs from `save-excursion' in that it doesn't save the point and mark.
|
|
186 ;; This is essentially `emerge-eval-in-buffer' with the test for live buffers."
|
|
187 (defmacro ediff-eval-in-buffer (buffer &rest forms)
|
|
188 (` (let ((StartBuffer (current-buffer)))
|
|
189 (if (ediff-buffer-live-p (, buffer))
|
|
190 (unwind-protect
|
|
191 (progn
|
|
192 (set-buffer (, buffer))
|
|
193 (,@ forms))
|
|
194 (set-buffer StartBuffer))
|
|
195 (or (eq this-command 'ediff-quit)
|
|
196 (error ediff-KILLED-VITAL-BUFFER))
|
|
197 ))))
|
|
198
|
|
199
|
|
200 (defsubst ediff-multiframe-setup-p ()
|
|
201 (and (ediff-window-display-p) ediff-multiframe))
|
|
202
|
|
203 (defmacro ediff-narrow-control-frame-p ()
|
|
204 (` (and (ediff-multiframe-setup-p)
|
|
205 (equal ediff-help-message ediff-brief-message-string))))
|
|
206
|
|
207 (defmacro ediff-3way-comparison-job ()
|
|
208 (` (memq
|
|
209 ediff-job-name
|
|
210 '(ediff-files3 ediff-buffers3))))
|
|
211 (ediff-defvar-local ediff-3way-comparison-job nil "")
|
|
212
|
|
213 (defmacro ediff-merge-job ()
|
|
214 (` (memq
|
|
215 ediff-job-name
|
|
216 '(ediff-merge-files
|
|
217 ediff-merge-buffers
|
|
218 ediff-merge-files-with-ancestor
|
|
219 ediff-merge-buffers-with-ancestor
|
|
220 ediff-merge-revisions
|
|
221 ediff-merge-revisions-with-ancestor))))
|
|
222 (ediff-defvar-local ediff-merge-job nil "")
|
|
223
|
|
224 (defmacro ediff-merge-with-ancestor-job ()
|
|
225 (` (memq
|
|
226 ediff-job-name
|
|
227 '(ediff-merge-files-with-ancestor
|
|
228 ediff-merge-buffers-with-ancestor
|
|
229 ediff-merge-revisions-with-ancestor))))
|
|
230 (ediff-defvar-local ediff-merge-with-ancestor-job nil "")
|
|
231
|
|
232 (defmacro ediff-3way-job ()
|
|
233 (` (or ediff-3way-comparison-job ediff-merge-job)))
|
|
234 (ediff-defvar-local ediff-3way-job nil "")
|
|
235
|
|
236 ;; A diff3 job is like a 3way job, but ediff-merge doesn't require the use
|
|
237 ;; of diff3.
|
|
238 (defmacro ediff-diff3-job ()
|
|
239 (` (or ediff-3way-comparison-job
|
|
240 ediff-merge-with-ancestor-job)))
|
|
241 (ediff-defvar-local ediff-diff3-job nil "")
|
|
242
|
|
243 (defmacro ediff-windows-job ()
|
|
244 (` (memq ediff-job-name '(ediff-windows-wordwise ediff-windows-linewise))))
|
|
245 (ediff-defvar-local ediff-windows-job nil "")
|
|
246
|
|
247 (defmacro ediff-word-mode-job ()
|
|
248 (` (memq ediff-job-name '(ediff-windows-wordwise ediff-regions-wordwise))))
|
|
249 (ediff-defvar-local ediff-word-mode-job nil "")
|
|
250
|
|
251 (defmacro ediff-narrow-job ()
|
|
252 (` (memq ediff-job-name '(ediff-windows-wordwise
|
|
253 ediff-regions-wordwise
|
|
254 ediff-windows-linewise
|
|
255 ediff-regions-linewise))))
|
|
256 (ediff-defvar-local ediff-narrow-job nil "")
|
|
257
|
|
258 ;; Note: ediff-merge-directory-revisions-with-ancestor is not treated as an
|
|
259 ;; ancestor metajob, since it behaves differently.
|
|
260 (defsubst ediff-ancestor-metajob (&optional metajob)
|
|
261 (memq (or metajob ediff-metajob-name)
|
|
262 '(ediff-merge-directories-with-ancestor
|
|
263 ediff-merge-filegroups-with-ancestor)))
|
|
264 (defsubst ediff-revision-metajob (&optional metajob)
|
|
265 (memq (or metajob ediff-metajob-name)
|
|
266 '(ediff-directory-revisions
|
|
267 ediff-merge-directory-revisions
|
|
268 ediff-merge-directory-revisions-with-ancestor)))
|
|
269 (defsubst ediff-patch-metajob (&optional metajob)
|
|
270 (memq (or metajob ediff-metajob-name)
|
|
271 '(ediff-multifile-patch)))
|
|
272 ;; metajob involving only one group of files, such as multipatch or directory
|
|
273 ;; revision
|
|
274 (defsubst ediff-one-filegroup-metajob (&optional metajob)
|
|
275 (or (ediff-revision-metajob metajob)
|
|
276 (ediff-patch-metajob metajob)
|
|
277 ;; add more here
|
|
278 ))
|
|
279 (defsubst ediff-collect-diffs-metajob (&optional metajob)
|
|
280 (memq (or metajob ediff-metajob-name)
|
|
281 '(ediff-directories
|
|
282 ediff-directory-revisions
|
|
283 ediff-merge-directories
|
|
284 ediff-merge-directories-with-ancestor
|
|
285 ediff-merge-directory-revisions
|
|
286 ediff-merge-directory-revisions-with-ancestor
|
|
287 ;; add more here
|
|
288 )))
|
12
|
289 (defsubst ediff-merge-metajob (&optional metajob)
|
|
290 (memq (or metajob ediff-metajob-name)
|
|
291 '(ediff-merge-directories
|
|
292 ediff-merge-directories-with-ancestor
|
|
293 ediff-merge-directory-revisions
|
|
294 ediff-merge-directory-revisions-with-ancestor
|
|
295 ediff-merge-filegroups-with-ancestor
|
|
296 ;; add more here
|
|
297 )))
|
0
|
298
|
|
299 (defsubst ediff-metajob3 (&optional metajob)
|
|
300 (memq (or metajob ediff-metajob-name)
|
|
301 '(ediff-merge-directories-with-ancestor
|
|
302 ediff-merge-filegroups-with-ancestor
|
|
303 ediff-directories3
|
|
304 ediff-filegroups3)))
|
|
305 (defsubst ediff-comparison-metajob3 (&optional metajob)
|
|
306 (memq (or metajob ediff-metajob-name)
|
|
307 '(ediff-directories3 ediff-filegroups3)))
|
|
308
|
12
|
309 ;; with no argument, checks if we are in ediff-control-buffer
|
|
310 ;; with argument, checks if we are in ediff-meta-buffer
|
|
311 (defun ediff-in-control-buffer-p (&optional meta-buf-p)
|
|
312 (and (boundp 'ediff-control-buffer)
|
|
313 (eq (if meta-buf-p ediff-meta-buffer ediff-control-buffer)
|
|
314 (current-buffer))))
|
|
315
|
|
316 (defsubst ediff-barf-if-not-control-buffer (&optional meta-buf-p)
|
|
317 (or (ediff-in-control-buffer-p meta-buf-p)
|
0
|
318 (error "%S: This command runs in Ediff Control Buffer only!"
|
|
319 this-command)))
|
|
320
|
|
321 ;; Hook variables
|
|
322
|
|
323 (defvar ediff-before-setup-windows-hook nil
|
|
324 "*Hooks to run before Ediff sets its window configuration.
|
|
325 This can be used to save the previous window config, which can be restored
|
|
326 on ediff-quit or ediff-suspend.")
|
|
327 (defvar ediff-after-setup-windows-hook nil
|
|
328 "*Hooks to run after Ediff sets its window configuration.
|
|
329 This can be used to set up control window or icon in a desired place.")
|
|
330 (defvar ediff-before-setup-control-frame-hook nil
|
|
331 "*Hooks run before setting up the frame to display Ediff Control Panel.
|
|
332 Can be used to change control frame parameters to position it where it
|
|
333 is desirable.")
|
|
334 (defvar ediff-after-setup-control-frame-hook nil
|
|
335 "*Hooks run after setting up the frame to display Ediff Control Panel.
|
|
336 Can be used to move the frame where it is desired.")
|
|
337 (defvar ediff-startup-hook nil
|
|
338 "*Hooks to run in the control buffer after Ediff has been set up.")
|
|
339 (defvar ediff-select-hook nil
|
|
340 "*Hooks to run after a difference has been selected.")
|
|
341 (defvar ediff-unselect-hook nil
|
|
342 "*Hooks to run after a difference has been unselected.")
|
|
343 (defvar ediff-prepare-buffer-hook nil
|
|
344 "*Hooks called after buffers A, B, and C are set up.")
|
|
345 (defvar ediff-load-hook nil
|
|
346 "*Hook run after Ediff is loaded. Can be used to change defaults.")
|
|
347
|
|
348 (defvar ediff-mode-hook nil
|
|
349 "*Hook run just after ediff-mode is set up in the control buffer.
|
|
350 This is done before any windows or frames are created. One can use it to
|
|
351 set local variables that determine how the display looks like.")
|
|
352 (defvar ediff-keymap-setup-hook nil
|
|
353 "*Hook run just after the default bindings in Ediff keymap are set up.")
|
|
354
|
|
355 (defvar ediff-display-help-hook nil
|
|
356 "*Hooks run after preparing the help message.")
|
|
357
|
|
358 (defvar ediff-suspend-hook (list 'ediff-default-suspend-function)
|
|
359 "*Hooks to run in the Ediff control buffer when Ediff is suspended.")
|
|
360 (defvar ediff-quit-hook (list 'ediff-cleanup-mess)
|
|
361 "*Hooks to run in the Ediff control buffer after finishing Ediff.")
|
|
362 (defvar ediff-cleanup-hook nil
|
|
363 "*Hooks to run on exiting Ediff but before killing the control buffer.
|
|
364 This is a place to do various cleanups, such as deleting the variant buffers.
|
|
365 Ediff provides a function, `ediff-janitor', as one such possible hook.")
|
12
|
366 (defvar ediff-quit-merge-hook 'ediff-maybe-save-and-delete-merge
|
|
367 "*Hooks to run before quitting a merge job.
|
|
368 The most common use is to save and delete the merge buffer.")
|
0
|
369
|
|
370
|
|
371 ;; Error messages
|
|
372 (defconst ediff-KILLED-VITAL-BUFFER
|
|
373 "You have killed a vital Ediff buffer---you must leave Ediff now!")
|
|
374 (defconst ediff-NO-DIFFERENCES
|
|
375 "Sorry, comparison of identical variants is not what I am made for...")
|
|
376 (defconst ediff-BAD-DIFF-NUMBER
|
|
377 ;; %S stands for this-command, %d - diff number, %d - max diff
|
|
378 "%S: Bad diff region number, %d. Valid numbers are 1 to %d")
|
12
|
379 (defconst ediff-BAD-INFO (format "
|
|
380 *** The Info file for Ediff, a part of the standard distribution
|
|
381 *** of %sEmacs, does not seem to be properly installed.
|
|
382 ***
|
|
383 *** Please contact your system administrator. "
|
|
384 (if ediff-xemacs-p "X" "")))
|
0
|
385
|
|
386 ;; Selective browsing
|
|
387
|
|
388 (ediff-defvar-local ediff-skip-diff-region-function 'ediff-show-all-diffs
|
|
389 "Function that determines the next/previous diff region to show.
|
|
390 Should return t for regions to be ignored and nil otherwise.
|
|
391 This function gets a region number as an argument. The region number
|
|
392 is the one used internally by Ediff. It is 1 less than the number seen
|
|
393 by the user.")
|
|
394
|
|
395 (ediff-defvar-local ediff-hide-regexp-matches-function
|
|
396 'ediff-hide-regexp-matches
|
|
397 "Function to use in determining which regions to hide.
|
|
398 See the documentation string of `ediff-hide-regexp-matches' for details.")
|
|
399 (ediff-defvar-local ediff-focus-on-regexp-matches-function
|
|
400 'ediff-focus-on-regexp-matches
|
|
401 "Function to use in determining which regions to focus on.
|
|
402 See the documentation string of `ediff-focus-on-regexp-matches' for details.")
|
|
403
|
|
404 ;; Regexp that determines buf A regions to focus on when skipping to diff
|
|
405 (ediff-defvar-local ediff-regexp-focus-A "" "")
|
|
406 ;; Regexp that determines buf B regions to focus on when skipping to diff
|
|
407 (ediff-defvar-local ediff-regexp-focus-B "" "")
|
|
408 ;; Regexp that determines buf C regions to focus on when skipping to diff
|
|
409 (ediff-defvar-local ediff-regexp-focus-C "" "")
|
|
410 ;; connective that determines whether to focus regions that match both or
|
|
411 ;; one of the regexps
|
|
412 (ediff-defvar-local ediff-focus-regexp-connective 'and "")
|
|
413
|
|
414 ;; Regexp that determines buf A regions to ignore when skipping to diff
|
|
415 (ediff-defvar-local ediff-regexp-hide-A "" "")
|
|
416 ;; Regexp that determines buf B regions to ignore when skipping to diff
|
|
417 (ediff-defvar-local ediff-regexp-hide-B "" "")
|
|
418 ;; Regexp that determines buf C regions to ignore when skipping to diff
|
|
419 (ediff-defvar-local ediff-regexp-hide-C "" "")
|
|
420 ;; connective that determines whether to hide regions that match both or
|
|
421 ;; one of the regexps
|
|
422 (ediff-defvar-local ediff-hide-regexp-connective 'and "")
|
|
423
|
|
424
|
|
425 ;; Copying difference regions between buffers.
|
|
426 (ediff-defvar-local ediff-killed-diffs-alist nil
|
|
427 "A list of killed diffs.
|
|
428 A diff is saved here if it is replaced by a diff
|
|
429 from another buffer. This alist has the form:
|
|
430 \((num (buff-object . diff) (buff-object . diff) (buff-object . diff)) ...),
|
|
431 where some buffer-objects may be missing.")
|
|
432
|
|
433
|
|
434 ;; Highlighting
|
|
435 ;;(defvar ediff-before-flag-bol (if ediff-emacs-p "->>\n" (make-glyph "->>\n"))
|
|
436 (defvar ediff-before-flag-bol (if ediff-xemacs-p (make-glyph "->>") "->>")
|
|
437 "*Flag placed above the highlighted block of differences.
|
|
438 Must end with newline.")
|
|
439 ;;(defvar ediff-after-flag-eol (if ediff-emacs-p "<<-\n" (make-glyph "<<-"))
|
|
440 (defvar ediff-after-flag-eol (if ediff-xemacs-p (make-glyph "<<-") "<<-")
|
|
441 "*Flag placed below the highlighted block of differences.
|
|
442 Must end with newline.")
|
|
443
|
|
444 (defvar ediff-before-flag-mol (if ediff-xemacs-p (make-glyph "->>") "->>")
|
|
445 "*Like ediff-before-flag, used when a difference starts in mid-line.")
|
|
446 (defvar ediff-after-flag-mol (if ediff-xemacs-p (make-glyph "<<-") "<<-")
|
|
447 "*Like ediff-after-flag, used when a difference starts in mid-line.")
|
|
448
|
|
449
|
|
450 (ediff-defvar-local ediff-use-faces t
|
|
451 "If t, differences are highlighted using faces, if device supports faces.
|
|
452 If nil, differences are highlighted using ASCII flags, ediff-before-flag
|
|
453 and ediff-after-flag. On a non-window system, differences are always
|
|
454 highlighted using ASCII flags.
|
|
455 This variable can be set either in .emacs or toggled interactively.
|
|
456 Use `setq-default' if setting it in .emacs")
|
|
457
|
|
458 ;; this indicates that diff regions are word-size, so fine diffs are
|
|
459 ;; permanently nixed; used in ediff-windows-wordwise and ediff-regions-wordwise
|
|
460 (ediff-defvar-local ediff-word-mode nil "")
|
|
461 ;; Name of the job (ediff-files, ediff-windows, etc.)
|
|
462 (ediff-defvar-local ediff-job-name nil "")
|
|
463
|
|
464 ;; Narrowing and ediff-region/windows support
|
|
465 ;; This is a list (overlay-A overlay-B overlay-C)
|
|
466 ;; If set, Ediff compares only those parts of buffers A/B/C that lie within
|
|
467 ;; the bounds of these overlays.
|
|
468 (ediff-defvar-local ediff-narrow-bounds nil "")
|
|
469
|
|
470 ;; List (overlay-A overlay-B overlay-C), where each overlay spans the
|
|
471 ;; entire corresponding buffer.
|
|
472 (ediff-defvar-local ediff-wide-bounds nil "")
|
|
473
|
|
474 ;; Current visibility boundaries in buffers A, B, and C.
|
|
475 ;; This is also a list of overlays. When the user toggles narrow/widen,
|
|
476 ;; this list changes from ediff-wide-bounds to ediff-narrow-bounds.
|
|
477 ;; and back.
|
|
478 (ediff-defvar-local ediff-visible-bounds nil "")
|
|
479
|
|
480 (ediff-defvar-local ediff-start-narrowed t
|
|
481 "Non-nil means start narrowed, if doing ediff-windows-* or ediff-regions-*")
|
|
482 (ediff-defvar-local ediff-quit-widened t
|
|
483 "*Non-nil means: when finished, Ediff widens buffers A/B.
|
|
484 Actually, Ediff restores the scope of visibility that existed at startup.")
|
|
485 (defvar ediff-keep-variants t
|
|
486 "*Nil means that non-modified variant buffers should be removed after some
|
|
487 interrogation.
|
|
488 Supplying a prefix argument to the quit command `q' temporarily reverses the
|
|
489 meaning of this variable.")
|
|
490
|
|
491 (ediff-defvar-local ediff-highlight-all-diffs t
|
|
492 "If nil, only the selected differences are highlighted.
|
|
493 This variable can be set either in .emacs or toggled interactively, using
|
|
494 ediff-toggle-hilit. Use `setq-default' to set it.")
|
|
495
|
|
496 ;; A var local to each control panel buffer. Indicates highlighting style
|
|
497 ;; in effect for this buffer: `face', `ascii', nil -- temporarily
|
|
498 ;; unhighlighted, `off' -- turned off \(on a dumb terminal only\).
|
|
499 (ediff-defvar-local ediff-highlighting-style nil "")
|
|
500
|
|
501
|
|
502 ;; The suffix of the control buffer name.
|
|
503 (ediff-defvar-local ediff-control-buffer-suffix nil "")
|
|
504 ;; Same as ediff-control-buffer-suffix, but without <,>.
|
|
505 ;; It's a number rather than string.
|
|
506 (ediff-defvar-local ediff-control-buffer-number nil "")
|
|
507
|
|
508
|
|
509 ;; The original values of ediff-protected-variables for buffer A
|
|
510 (ediff-defvar-local ediff-buffer-values-orig-A nil "")
|
|
511 ;; The original values of ediff-protected-variables for buffer B
|
|
512 (ediff-defvar-local ediff-buffer-values-orig-B nil "")
|
|
513 ;; The original values of ediff-protected-variables for buffer C
|
|
514 (ediff-defvar-local ediff-buffer-values-orig-C nil "")
|
|
515 ;; The original values of ediff-protected-variables for buffer Ancestor
|
|
516 (ediff-defvar-local ediff-buffer-values-orig-Ancestor nil "")
|
|
517 ;; Buffer-local variables to be saved then restored during Ediff sessions
|
|
518 ;; Buffer-local variables to be saved then restored during Ediff sessions
|
12
|
519 (defconst ediff-protected-variables '(
|
14
|
520 ;;buffer-read-only
|
0
|
521 mode-line-format))
|
|
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 ;; fine-diff-vector is a vector [fine-diff-overlay fine-diff-overlay ...]
|
|
535 ;; no-fine-diffs-flag says if there are fine differences.
|
|
536 ;; state-of-difference is A, B, C, or nil, indicating which buffer is
|
|
537 ;; different from the other two (used only in 3-way jobs.
|
|
538 (ediff-defvar-local ediff-difference-vector-A nil "")
|
|
539 (ediff-defvar-local ediff-difference-vector-B nil "")
|
|
540 (ediff-defvar-local ediff-difference-vector-C nil "")
|
|
541 (ediff-defvar-local ediff-difference-vector-Ancestor nil "")
|
|
542
|
|
543 ;; [ status status status ...]
|
|
544 ;; Each status: [state-of-merge state-of-ancestor]
|
|
545 ;; state-of-merge is default-A, default-B, prefer-A, or prefer-B. It
|
|
546 ;; indicates the way a diff region was created in buffer C.
|
|
547 ;; state-of-ancestor says if the corresponding region in ancestor buffer is
|
|
548 ;; empty.
|
|
549 (ediff-defvar-local ediff-state-of-merge nil "")
|
|
550
|
|
551 ;; The difference that is currently selected.
|
|
552 (ediff-defvar-local ediff-current-difference -1 "")
|
|
553 ;; Number of differences found.
|
|
554 (ediff-defvar-local ediff-number-of-differences nil "")
|
|
555
|
|
556 ;; Buffer containing the output of diff, which is used by Ediff to step
|
|
557 ;; through files.
|
|
558 (ediff-defvar-local ediff-diff-buffer nil "")
|
|
559 ;; Like ediff-diff-buffer, but contains context diff. It is not used by
|
|
560 ;; Ediff, but it is saved in a file, if user requests so.
|
|
561 (ediff-defvar-local ediff-custom-diff-buffer nil "")
|
|
562 ;; Buffer used for diff-style fine differences between regions.
|
|
563 (ediff-defvar-local ediff-fine-diff-buffer nil "")
|
|
564 ;; Temporary buffer used for computing fine differences.
|
|
565 (defconst ediff-tmp-buffer " *ediff-tmp*" "")
|
|
566 ;; Buffer used for messages
|
|
567 (defconst ediff-msg-buffer " *ediff-message*" "")
|
|
568 ;; Buffer containing the output of diff when diff returns errors.
|
|
569 (ediff-defvar-local ediff-error-buffer nil "")
|
|
570 ;; Buffer to display debug info
|
|
571 (ediff-defvar-local ediff-debug-buffer "*ediff-debug*" "")
|
|
572
|
|
573 ;; List of ediff control panels associated with each buffer A/B/C/Ancestor.
|
|
574 ;; Not used any more, but may be needed in the future.
|
|
575 (ediff-defvar-local ediff-this-buffer-ediff-sessions nil "")
|
|
576
|
|
577 ;; to be deleted in due time
|
|
578 ;; List of difference overlays disturbed by working with the current diff.
|
|
579 (defvar ediff-disturbed-overlays nil "")
|
|
580
|
|
581 ;; Priority of non-selected overlays.
|
|
582 (defvar ediff-shadow-overlay-priority 100 "")
|
|
583
|
|
584 (defvar ediff-version-control-package 'vc
|
|
585 "Version control package used.
|
|
586 Currently, Ediff supports vc.el, rcs.el, pcl-cvs.el, and generic-sc.el. The
|
|
587 standard Emacs interface to RCS, CVS, SCCS, etc., is vc.el. However, some
|
|
588 people find the other two packages more convenient. Set this variable to the
|
|
589 appropriate symbol: `rcs', `pcl-cvs', or `generic-sc' if you so desire.")
|
|
590
|
|
591
|
|
592 (if ediff-xemacs-p
|
|
593 (progn
|
|
594 (fset 'ediff-read-event (symbol-function 'next-command-event))
|
|
595 (fset 'ediff-overlayp (symbol-function 'extentp))
|
|
596 (fset 'ediff-make-overlay (symbol-function 'make-extent))
|
|
597 (fset 'ediff-delete-overlay (symbol-function 'delete-extent)))
|
|
598 (fset 'ediff-read-event (symbol-function 'read-event))
|
|
599 (fset 'ediff-overlayp (symbol-function 'overlayp))
|
|
600 (fset 'ediff-make-overlay (symbol-function 'make-overlay))
|
|
601 (fset 'ediff-delete-overlay (symbol-function 'delete-overlay)))
|
|
602
|
|
603 ;; Check the current version against the major and minor version numbers
|
|
604 ;; using op: cur-vers op major.minor If emacs-major-version or
|
|
605 ;; emacs-minor-version are not defined, we assume that the current version
|
|
606 ;; is hopelessly outdated. We assume that emacs-major-version and
|
|
607 ;; emacs-minor-version are defined. Otherwise, for Emacs/XEmacs 19, if the
|
|
608 ;; current minor version is < 10 (xemacs) or < 23 (emacs) the return value
|
|
609 ;; will be nil (when op is =, >, or >=) and t (when op is <, <=), which may be
|
|
610 ;; incorrect. However, this gives correct result in our cases, since we are
|
|
611 ;; testing for sufficiently high Emacs versions.
|
|
612 (defun ediff-check-version (op major minor &optional type-of-emacs)
|
|
613 (if (and (boundp 'emacs-major-version) (boundp 'emacs-minor-version))
|
|
614 (and (cond ((eq type-of-emacs 'xemacs) ediff-xemacs-p)
|
|
615 ((eq type-of-emacs 'emacs) ediff-emacs-p)
|
|
616 (t t))
|
|
617 (cond ((eq op '=) (and (= emacs-minor-version minor)
|
|
618 (= emacs-major-version major)))
|
|
619 ((memq op '(> >= < <=))
|
|
620 (and (or (funcall op emacs-major-version major)
|
|
621 (= emacs-major-version major))
|
|
622 (if (= emacs-major-version major)
|
|
623 (funcall op emacs-minor-version minor)
|
|
624 t)))
|
|
625 (t
|
|
626 (error "%S: Invalid op in ediff-check-version" op))))
|
|
627 (cond ((memq op '(= > >=)) nil)
|
|
628 ((memq op '(< <=)) t))))
|
|
629
|
|
630
|
|
631 ;;;; warn if it is a wrong version of emacs
|
16
|
632 ;;(if (or (ediff-check-version '< 19 35 'emacs)
|
|
633 ;; (ediff-check-version '< 19 15 'xemacs))
|
0
|
634 ;; (progn
|
|
635 ;; (with-output-to-temp-buffer ediff-msg-buffer
|
|
636 ;; (switch-to-buffer ediff-msg-buffer)
|
|
637 ;; (insert
|
|
638 ;; (format "
|
|
639 ;;
|
|
640 ;;This version of Ediff requires
|
|
641 ;;
|
16
|
642 ;;\t Emacs 19.35 and higher
|
0
|
643 ;;\t OR
|
16
|
644 ;;\t XEmacs 19.15 and higher
|
0
|
645 ;;
|
|
646 ;;It is unlikely to work under Emacs version %s
|
|
647 ;;that you are using... " emacs-version))
|
|
648 ;; (if noninteractive
|
|
649 ;; ()
|
|
650 ;; (beep 1)
|
|
651 ;; (beep 1)
|
|
652 ;; (insert "\n\nType any key to continue...")
|
|
653 ;; (ediff-read-event)))
|
|
654 ;; (kill-buffer ediff-msg-buffer)))
|
|
655
|
|
656 ;; A fix for NeXT Step
|
|
657 ;; Should probably be eliminated in later versions.
|
|
658 (if (and (ediff-window-display-p) (eq (ediff-device-type) 'ns))
|
|
659 (progn
|
|
660 (fset 'x-display-color-p (symbol-function 'ns-display-color-p))
|
|
661 (fset 'x-color-defined-p (symbol-function 'ns-color-defined-p))
|
|
662 (fset 'x-display-pixel-height (symbol-function 'ns-display-pixel-height))
|
|
663 (fset 'x-display-pixel-width (symbol-function 'ns-display-pixel-width))
|
|
664 ))
|
|
665
|
|
666
|
|
667 (defsubst ediff-color-display-p ()
|
|
668 (if ediff-emacs-p
|
|
669 (x-display-color-p)
|
|
670 (eq (device-class (selected-device)) 'color)))
|
|
671
|
|
672
|
|
673 (if (ediff-has-face-support-p)
|
|
674 (if ediff-xemacs-p
|
|
675 (progn
|
|
676 (fset 'ediff-valid-color-p (symbol-function 'valid-color-name-p))
|
|
677 (fset 'ediff-get-face (symbol-function 'get-face)))
|
|
678 ;; Temporary fix for OS/2 port of Emacs
|
|
679 ;; pm-win.el in PM-Emacs should be fixed.
|
|
680 (if (eq (ediff-device-type) 'pm)
|
|
681 (fset 'ediff-valid-color-p
|
|
682 (function (lambda (color) (assoc color pm-color-alist))))
|
|
683 (fset 'ediff-valid-color-p (symbol-function 'x-color-defined-p)))
|
|
684 (fset 'ediff-get-face (symbol-function 'internal-get-face))))
|
|
685
|
|
686 (if (ediff-window-display-p)
|
|
687 (if ediff-xemacs-p
|
|
688 (progn
|
|
689 (fset 'ediff-display-pixel-width
|
|
690 (symbol-function 'device-pixel-width))
|
|
691 (fset 'ediff-display-pixel-height
|
|
692 (symbol-function 'device-pixel-height)))
|
|
693 (fset 'ediff-display-pixel-width
|
|
694 (symbol-function 'x-display-pixel-width))
|
|
695 (fset 'ediff-display-pixel-height
|
|
696 (symbol-function 'x-display-pixel-height))))
|
|
697
|
|
698
|
|
699 (defun ediff-make-current-diff-overlay (type)
|
|
700 (if (ediff-has-face-support-p)
|
|
701 (let ((overlay (intern (format "ediff-current-diff-overlay-%S" type)))
|
|
702 (buffer (ediff-get-buffer type))
|
|
703 (face (face-name
|
|
704 (symbol-value
|
|
705 (intern (format "ediff-current-diff-face-%S" type))))))
|
|
706 (set overlay
|
|
707 (ediff-make-bullet-proof-overlay (point-max) (point-max) buffer))
|
|
708 (ediff-set-overlay-face (symbol-value overlay) face)
|
|
709 (ediff-overlay-put (symbol-value overlay) 'ediff ediff-control-buffer))
|
|
710 ))
|
|
711
|
|
712 (defun ediff-set-overlay-face (extent face)
|
|
713 (ediff-overlay-put extent 'face face)
|
|
714 (ediff-overlay-put extent 'help-echo 'ediff-region-help-echo))
|
|
715
|
|
716 ;; This does nothing in Emacs, since overlays there have no help-echo property
|
|
717 (defun ediff-region-help-echo (extent)
|
|
718 (let ((is-current (ediff-overlay-get extent 'ediff))
|
|
719 (face (ediff-overlay-get extent 'face))
|
|
720 (diff-num (ediff-overlay-get extent 'ediff-diff-num))
|
|
721 face-help)
|
|
722
|
|
723 ;; This happens only for refinement overlays
|
|
724 (setq face-help (and face (get face 'ediff-help-echo)))
|
|
725
|
|
726 (cond ((and is-current diff-num) ; current diff region
|
|
727 (format "Difference region %S -- current" (1+ diff-num)))
|
|
728 (face-help) ; refinement of current diff region
|
|
729 (diff-num ; non-current
|
|
730 (format "Difference region %S -- non-current" (1+ diff-num)))
|
|
731 (t "")) ; none
|
|
732 ))
|
|
733
|
|
734 (defun ediff-set-face (ground face color)
|
|
735 "Set face foreground/background."
|
|
736 (if (ediff-has-face-support-p)
|
|
737 (if (ediff-valid-color-p color)
|
|
738 (if (eq ground 'foreground)
|
|
739 (set-face-foreground face color)
|
|
740 (set-face-background face color))
|
|
741 (cond ((memq face
|
|
742 '(ediff-current-diff-face-A
|
|
743 ediff-current-diff-face-B
|
|
744 ediff-current-diff-face-C
|
|
745 ediff-current-diff-face-Ancestor))
|
|
746 (copy-face 'highlight face))
|
|
747 ((memq face
|
|
748 '(ediff-fine-diff-face-A
|
|
749 ediff-fine-diff-face-B
|
|
750 ediff-fine-diff-face-C
|
|
751 ediff-fine-diff-face-Ancestor))
|
|
752 (copy-face 'secondary-selection face)
|
|
753 (set-face-underline-p face t))
|
|
754 ((memq face
|
|
755 '(ediff-even-diff-face-A
|
|
756 ediff-odd-diff-face-A
|
|
757 ediff-even-diff-face-B ediff-odd-diff-face-B
|
|
758 ediff-even-diff-face-C ediff-odd-diff-face-C
|
|
759 ediff-even-diff-face-Ancestor
|
|
760 ediff-odd-diff-face-Ancestor))
|
|
761 (copy-face 'secondary-selection face))))
|
|
762 ))
|
|
763
|
12
|
764 (defun ediff-set-face-pixmap (face pixmap)
|
|
765 "Set face pixmap on a monochrome display."
|
|
766 (if (and (ediff-window-display-p) (not (ediff-color-display-p)))
|
|
767 (condition-case nil
|
|
768 (set-face-background-pixmap face pixmap)
|
|
769 (error
|
|
770 (message "Pixmap not found for %S: %s" (face-name face) pixmap)
|
|
771 (sit-for 1)))))
|
|
772
|
0
|
773 (defun ediff-hide-face (face)
|
|
774 (if (and (ediff-has-face-support-p) ediff-emacs-p)
|
|
775 (add-to-list 'facemenu-unlisted-faces face)))
|
|
776
|
|
777 (defvar ediff-current-diff-face-A
|
|
778 (if (ediff-has-face-support-p)
|
|
779 (progn
|
|
780 (make-face 'ediff-current-diff-face-A)
|
|
781 (ediff-hide-face 'ediff-current-diff-face-A)
|
|
782 (or (face-differs-from-default-p 'ediff-current-diff-face-A)
|
|
783 (cond ((ediff-color-display-p)
|
|
784 (ediff-set-face
|
|
785 'foreground 'ediff-current-diff-face-A "firebrick")
|
|
786 (ediff-set-face
|
|
787 'background 'ediff-current-diff-face-A "pale green"))
|
|
788 (t
|
|
789 (if ediff-xemacs-p
|
|
790 (copy-face 'modeline 'ediff-current-diff-face-A)
|
|
791 (copy-face 'highlight 'ediff-current-diff-face-A))
|
|
792 )))
|
|
793 'ediff-current-diff-face-A))
|
|
794 "Face for highlighting the selected difference in buffer A.")
|
|
795
|
|
796 (defvar ediff-current-diff-face-B
|
|
797 (if (ediff-has-face-support-p)
|
|
798 (progn
|
|
799 (make-face 'ediff-current-diff-face-B)
|
|
800 (ediff-hide-face 'ediff-current-diff-face-B)
|
|
801 (or (face-differs-from-default-p 'ediff-current-diff-face-B)
|
|
802 (cond ((ediff-color-display-p)
|
|
803 (ediff-set-face
|
|
804 'foreground 'ediff-current-diff-face-B "DarkOrchid")
|
|
805 (ediff-set-face
|
|
806 'background 'ediff-current-diff-face-B "Yellow"))
|
|
807 (t
|
|
808 (if ediff-xemacs-p
|
|
809 (copy-face 'modeline 'ediff-current-diff-face-B)
|
|
810 (copy-face 'highlight 'ediff-current-diff-face-B))
|
|
811 )))
|
|
812 'ediff-current-diff-face-B))
|
|
813 "Face for highlighting the selected difference in buffer B.")
|
|
814
|
|
815
|
|
816 (defvar ediff-current-diff-face-C
|
|
817 (if (ediff-has-face-support-p)
|
|
818 (progn
|
|
819 (make-face 'ediff-current-diff-face-C)
|
|
820 (ediff-hide-face 'ediff-current-diff-face-C)
|
|
821 (or (face-differs-from-default-p 'ediff-current-diff-face-C)
|
|
822 (cond ((ediff-color-display-p)
|
|
823 (ediff-set-face
|
|
824 'foreground 'ediff-current-diff-face-C "Navy")
|
|
825 (ediff-set-face
|
|
826 'background 'ediff-current-diff-face-C "Pink"))
|
|
827 (t
|
|
828 (if ediff-xemacs-p
|
|
829 (copy-face 'modeline 'ediff-current-diff-face-C)
|
|
830 (copy-face 'highlight 'ediff-current-diff-face-C))
|
|
831 )))
|
|
832 'ediff-current-diff-face-C))
|
|
833 "Face for highlighting the selected difference in buffer C.")
|
|
834
|
|
835 (defvar ediff-current-diff-face-Ancestor
|
|
836 (if (ediff-has-face-support-p)
|
|
837 (progn
|
|
838 (make-face 'ediff-current-diff-face-Ancestor)
|
|
839 (ediff-hide-face 'ediff-current-diff-face-Ancestor)
|
|
840 (or (face-differs-from-default-p 'ediff-current-diff-face-Ancestor)
|
|
841 (copy-face
|
12
|
842 'ediff-current-diff-face-C 'ediff-current-diff-face-Ancestor))
|
|
843 'ediff-current-diff-face-Ancestor))
|
0
|
844 "Face for highlighting the selected difference in the ancestor buffer.")
|
|
845
|
12
|
846 (defvar ediff-fine-diff-pixmap "gray3"
|
|
847 "Pixmap to use for highlighting fine differences.")
|
|
848 (defvar ediff-odd-diff-pixmap "gray1"
|
|
849 "Pixmap to use for highlighting odd differences.")
|
|
850 (defvar ediff-even-diff-pixmap "Stipple"
|
|
851 "Pixmap to use for highlighting even differences.")
|
|
852
|
0
|
853 (defvar ediff-fine-diff-face-A
|
|
854 (if (ediff-has-face-support-p)
|
|
855 (progn
|
|
856 (make-face 'ediff-fine-diff-face-A)
|
|
857 (ediff-hide-face 'ediff-fine-diff-face-A)
|
|
858 (or (face-differs-from-default-p 'ediff-fine-diff-face-A)
|
|
859 (cond ((ediff-color-display-p)
|
|
860 (ediff-set-face 'foreground 'ediff-fine-diff-face-A
|
|
861 "Navy")
|
|
862 (ediff-set-face 'background 'ediff-fine-diff-face-A
|
|
863 "sky blue"))
|
12
|
864 (t
|
|
865 (set-face-underline-p 'ediff-fine-diff-face-A t)
|
|
866 (ediff-set-face-pixmap 'ediff-fine-diff-face-A
|
|
867 ediff-fine-diff-pixmap)
|
|
868 )))
|
0
|
869 'ediff-fine-diff-face-A))
|
|
870 "Face for highlighting the refinement of the selected diff in buffer A.")
|
|
871
|
|
872 (defvar ediff-fine-diff-face-B
|
|
873 (if (ediff-has-face-support-p)
|
|
874 (progn
|
|
875 (make-face 'ediff-fine-diff-face-B)
|
|
876 (ediff-hide-face 'ediff-fine-diff-face-B)
|
|
877 (or (face-differs-from-default-p 'ediff-fine-diff-face-B)
|
|
878 (cond ((ediff-color-display-p)
|
|
879 (ediff-set-face 'foreground 'ediff-fine-diff-face-B "Black")
|
|
880 (ediff-set-face 'background 'ediff-fine-diff-face-B "cyan"))
|
12
|
881 (t
|
|
882 (set-face-underline-p 'ediff-fine-diff-face-B t)
|
|
883 (ediff-set-face-pixmap 'ediff-fine-diff-face-B
|
|
884 ediff-fine-diff-pixmap)
|
|
885 )))
|
0
|
886 'ediff-fine-diff-face-B))
|
|
887 "Face for highlighting the refinement of the selected diff in buffer B.")
|
|
888
|
|
889 (defvar ediff-fine-diff-face-C
|
|
890 (if (ediff-has-face-support-p)
|
|
891 (progn
|
|
892 (make-face 'ediff-fine-diff-face-C)
|
|
893 (ediff-hide-face 'ediff-fine-diff-face-C)
|
|
894 (or (face-differs-from-default-p 'ediff-fine-diff-face-C)
|
|
895 (cond ((ediff-color-display-p)
|
|
896 (ediff-set-face 'foreground 'ediff-fine-diff-face-C "black")
|
|
897 (ediff-set-face
|
|
898 'background 'ediff-fine-diff-face-C "Turquoise"))
|
12
|
899 (t
|
|
900 (set-face-underline-p 'ediff-fine-diff-face-C t)
|
|
901 (ediff-set-face-pixmap 'ediff-fine-diff-face-C
|
|
902 ediff-fine-diff-pixmap)
|
|
903 )))
|
0
|
904 'ediff-fine-diff-face-C))
|
|
905 "Face for highlighting the refinement of the selected diff in buffer C.")
|
|
906
|
|
907 (defvar ediff-fine-diff-face-Ancestor
|
|
908 (if (ediff-has-face-support-p)
|
|
909 (progn
|
|
910 (make-face 'ediff-fine-diff-face-Ancestor)
|
|
911 (ediff-hide-face 'ediff-fine-diff-face-Ancestor)
|
|
912 (or (face-differs-from-default-p 'ediff-fine-diff-face-Ancestor)
|
12
|
913 (progn
|
|
914 (copy-face
|
|
915 'ediff-fine-diff-face-C 'ediff-fine-diff-face-Ancestor)
|
|
916 (ediff-set-face-pixmap 'ediff-fine-diff-face-Ancestor
|
|
917 ediff-fine-diff-pixmap))
|
|
918 )))
|
0
|
919 "Face highlighting refinements of the selected diff in ancestor buffer.
|
|
920 Presently, this is not used, as difference regions are not refined in the
|
|
921 ancestor buffer.")
|
|
922
|
|
923 (defvar ediff-even-diff-face-A
|
|
924 (if (ediff-has-face-support-p)
|
|
925 (progn
|
|
926 (make-face 'ediff-even-diff-face-A)
|
|
927 (ediff-hide-face 'ediff-even-diff-face-A)
|
|
928 (or (face-differs-from-default-p 'ediff-even-diff-face-A)
|
|
929 (cond ((ediff-color-display-p)
|
|
930 (ediff-set-face
|
|
931 'foreground 'ediff-even-diff-face-A "black")
|
|
932 (ediff-set-face
|
|
933 'background 'ediff-even-diff-face-A "light grey"))
|
|
934 (t
|
12
|
935 (copy-face 'italic 'ediff-even-diff-face-A)
|
|
936 (ediff-set-face-pixmap 'ediff-even-diff-face-A
|
|
937 ediff-even-diff-pixmap)
|
|
938 )))
|
0
|
939 'ediff-even-diff-face-A))
|
|
940 "Face used to highlight even-numbered differences in buffer A.")
|
|
941
|
|
942 (defvar ediff-even-diff-face-B
|
|
943 (if (ediff-has-face-support-p)
|
|
944 (progn
|
|
945 (make-face 'ediff-even-diff-face-B)
|
|
946 (ediff-hide-face 'ediff-even-diff-face-B)
|
|
947 (or (face-differs-from-default-p 'ediff-even-diff-face-B)
|
|
948 (cond ((ediff-color-display-p)
|
|
949 (ediff-set-face
|
|
950 'foreground 'ediff-even-diff-face-B "White")
|
|
951 (ediff-set-face
|
|
952 'background 'ediff-even-diff-face-B "Gray"))
|
|
953 (t
|
12
|
954 (copy-face 'italic 'ediff-even-diff-face-B)
|
|
955 (ediff-set-face-pixmap 'ediff-even-diff-face-B
|
|
956 ediff-even-diff-pixmap)
|
|
957 )))
|
0
|
958 'ediff-even-diff-face-B))
|
|
959 "Face used to highlight even-numbered differences in buffer B.")
|
|
960
|
|
961 (defvar ediff-even-diff-face-C
|
|
962 (if (ediff-has-face-support-p)
|
|
963 (progn
|
|
964 (make-face 'ediff-even-diff-face-C)
|
|
965 (ediff-hide-face 'ediff-even-diff-face-C)
|
|
966 (or (face-differs-from-default-p 'ediff-even-diff-face-C)
|
12
|
967 (progn
|
|
968 (copy-face 'ediff-even-diff-face-A 'ediff-even-diff-face-C)
|
|
969 (ediff-set-face-pixmap 'ediff-even-diff-face-C
|
|
970 ediff-even-diff-pixmap)))
|
0
|
971 'ediff-even-diff-face-C))
|
|
972 "Face used to highlight even-numbered differences in buffer C.")
|
|
973
|
|
974 (defvar ediff-even-diff-face-Ancestor
|
|
975 (if (ediff-has-face-support-p)
|
|
976 (progn
|
|
977 (make-face 'ediff-even-diff-face-Ancestor)
|
|
978 (ediff-hide-face 'ediff-even-diff-face-Ancestor)
|
|
979 (or (face-differs-from-default-p 'ediff-even-diff-face-Ancestor)
|
12
|
980 (progn
|
|
981 (copy-face
|
|
982 'ediff-even-diff-face-C 'ediff-even-diff-face-Ancestor)
|
|
983 (ediff-set-face-pixmap 'ediff-even-diff-face-Ancestor
|
|
984 ediff-even-diff-pixmap)))
|
0
|
985 'ediff-even-diff-face-Ancestor))
|
|
986 "Face highlighting even-numbered differences in the ancestor buffer.")
|
|
987
|
|
988 (defvar ediff-odd-diff-face-A
|
|
989 (if (ediff-has-face-support-p)
|
|
990 (progn
|
|
991 (make-face 'ediff-odd-diff-face-A)
|
|
992 (ediff-hide-face 'ediff-odd-diff-face-A)
|
|
993 (or (face-differs-from-default-p 'ediff-odd-diff-face-A)
|
|
994 (cond ((ediff-color-display-p)
|
|
995 (ediff-set-face
|
|
996 'foreground 'ediff-odd-diff-face-A "White")
|
|
997 (ediff-set-face
|
|
998 'background 'ediff-odd-diff-face-A "Gray"))
|
|
999 (t
|
12
|
1000 (copy-face 'italic 'ediff-odd-diff-face-A)
|
|
1001 (ediff-set-face-pixmap 'ediff-odd-diff-face-A
|
|
1002 ediff-odd-diff-pixmap)
|
|
1003 )))
|
0
|
1004 'ediff-odd-diff-face-A))
|
|
1005 "Face used to highlight odd-numbered differences in buffer A.")
|
|
1006
|
|
1007 (defvar ediff-odd-diff-face-B
|
|
1008 (if (ediff-has-face-support-p)
|
|
1009 (progn
|
|
1010 (make-face 'ediff-odd-diff-face-B)
|
|
1011 (ediff-hide-face 'ediff-odd-diff-face-B)
|
|
1012 (or (face-differs-from-default-p 'ediff-odd-diff-face-B)
|
|
1013 (cond ((ediff-color-display-p)
|
|
1014 (ediff-set-face
|
|
1015 'foreground 'ediff-odd-diff-face-B "Black")
|
|
1016 (ediff-set-face
|
|
1017 'background 'ediff-odd-diff-face-B "light grey"))
|
|
1018 (t
|
12
|
1019 (copy-face 'italic 'ediff-odd-diff-face-B)
|
|
1020 (ediff-set-face-pixmap 'ediff-odd-diff-face-B
|
|
1021 ediff-odd-diff-pixmap)
|
|
1022 )))
|
0
|
1023 'ediff-odd-diff-face-B))
|
|
1024 "Face used to highlight odd-numbered differences in buffer B.")
|
|
1025
|
|
1026 (defvar ediff-odd-diff-face-C
|
|
1027 (if (ediff-has-face-support-p)
|
|
1028 (progn
|
|
1029 (make-face 'ediff-odd-diff-face-C)
|
|
1030 (ediff-hide-face 'ediff-odd-diff-face-C)
|
|
1031 (or (face-differs-from-default-p 'ediff-odd-diff-face-C)
|
12
|
1032 (progn
|
|
1033 (copy-face 'ediff-odd-diff-face-A 'ediff-odd-diff-face-C)
|
|
1034 (ediff-set-face-pixmap 'ediff-odd-diff-face-C
|
|
1035 ediff-odd-diff-pixmap)))
|
0
|
1036 'ediff-odd-diff-face-C))
|
|
1037 "Face used to highlight odd-numbered differences in buffer C.")
|
|
1038
|
|
1039 (defvar ediff-odd-diff-face-Ancestor
|
|
1040 (if (ediff-has-face-support-p)
|
|
1041 (progn
|
|
1042 (make-face 'ediff-odd-diff-face-Ancestor)
|
|
1043 (ediff-hide-face 'ediff-odd-diff-face-Ancestor)
|
|
1044 (or (face-differs-from-default-p 'ediff-odd-diff-face-Ancestor)
|
12
|
1045 (progn
|
|
1046 (copy-face 'ediff-odd-diff-face-C 'ediff-odd-diff-face-Ancestor)
|
|
1047 (ediff-set-face-pixmap 'ediff-odd-diff-face-Ancestor
|
|
1048 ediff-odd-diff-pixmap)))
|
0
|
1049 'ediff-odd-diff-face-Ancestor))
|
|
1050 "Face used to highlight even-numbered differences in the ancestor buffer.")
|
|
1051
|
|
1052 ;; Help echo
|
|
1053 (put 'ediff-fine-diff-face-A 'ediff-help-echo
|
|
1054 "A `refinement' of the current difference region")
|
|
1055 (put 'ediff-fine-diff-face-B 'ediff-help-echo
|
|
1056 "A `refinement' of the current difference region")
|
|
1057 (put 'ediff-fine-diff-face-C 'ediff-help-echo
|
|
1058 "A `refinement' of the current difference region")
|
|
1059 (put 'ediff-fine-diff-face-Ancestor 'ediff-help-echo
|
|
1060 "A `refinement' of the current difference region")
|
|
1061
|
|
1062
|
|
1063 ;;; Overlays
|
|
1064
|
|
1065 (ediff-defvar-local ediff-current-diff-overlay-A nil
|
|
1066 "Overlay for the current difference region in buffer A.")
|
|
1067 (ediff-defvar-local ediff-current-diff-overlay-B nil
|
|
1068 "Overlay for the current difference region in buffer B.")
|
|
1069 (ediff-defvar-local ediff-current-diff-overlay-C nil
|
|
1070 "Overlay for the current difference region in buffer C.")
|
|
1071 (ediff-defvar-local ediff-current-diff-overlay-Ancestor nil
|
|
1072 "Overlay for the current difference region in the ancestor buffer.")
|
|
1073
|
|
1074 ;; Compute priority of ediff overlay.
|
|
1075 (defun ediff-highest-priority (start end buffer)
|
|
1076 (let ((pos (max 1 (1- start)))
|
|
1077 ovr-list)
|
|
1078 (if ediff-xemacs-p
|
|
1079 (1+ ediff-shadow-overlay-priority)
|
|
1080 (ediff-eval-in-buffer buffer
|
|
1081 (while (< pos (min (point-max) (1+ end)))
|
|
1082 (setq ovr-list (append (overlays-at pos) ovr-list))
|
|
1083 (setq pos (next-overlay-change pos)))
|
|
1084 (1+ (apply '+
|
|
1085 (mapcar (function
|
|
1086 (lambda (ovr)
|
|
1087 (if ovr
|
|
1088 (or (ediff-overlay-get ovr 'priority) 0)
|
|
1089 0)))
|
|
1090 ovr-list)
|
|
1091 ))
|
|
1092 ))))
|
|
1093
|
|
1094
|
|
1095 (defvar ediff-toggle-read-only-function nil
|
|
1096 "*Specifies the function to be used to toggle read-only.
|
|
1097 If nil, Ediff tries to deduce the function from the binding of C-x C-q.
|
|
1098 Normally, this is the `toggle-read-only' function, but, if version
|
|
1099 control is used, it could be `vc-toggle-read-only' or `rcs-toggle-read-only'.")
|
|
1100
|
|
1101
|
|
1102 ;;; Misc
|
|
1103
|
|
1104 ;; if nil, this silences some messages
|
|
1105 (defconst ediff-verbose-p t)
|
12
|
1106
|
|
1107 (ediff-defvar-local ediff-autostore-merges 'group-jobs-only
|
|
1108 "*Save the results of merge jobs automatically.
|
|
1109 Nil means don't save automatically. t means always save. Anything but nil or t
|
|
1110 means save automatically only if the merge job is part of a group of jobs, such
|
|
1111 as `ediff-merge-directory' or `ediff-merge-directory-revisions'.")
|
|
1112
|
|
1113 ;; file where the result of the merge is to be saved. used internally
|
|
1114 (ediff-defvar-local ediff-merge-store-file nil "")
|
0
|
1115
|
|
1116 (defvar ediff-no-emacs-help-in-control-buffer nil
|
|
1117 "*Non-nil means C-h should not invoke Emacs help in control buffer.
|
|
1118 Instead, C-h jumps to previous difference.")
|
|
1119
|
|
1120 (defvar ediff-temp-file-prefix
|
|
1121 (let ((env (or (getenv "TMPDIR")
|
|
1122 (getenv "TMP")
|
|
1123 (getenv "TEMP")))
|
|
1124 d)
|
|
1125 (setq d (if (and env (> (length env) 0))
|
|
1126 env
|
|
1127 (cond ((memq system-type '(vax-vms axp-vms)) "SYS$SCRATCH:")
|
|
1128 ((eq system-type 'ms-dos) "c:/")
|
|
1129 (t "/tmp"))))
|
|
1130 ;; The following is to make sure we get something to which we can
|
|
1131 ;; add directory levels on VMS.
|
|
1132 (setq d (file-name-as-directory (directory-file-name d)))
|
|
1133 )
|
|
1134 "*Prefix to put on Ediff temporary file names.
|
|
1135 Do not start with `~/' or `~user-name/'.")
|
|
1136
|
|
1137 (defvar ediff-temp-file-mode 384 ; u=rw only
|
|
1138 "*Mode for Ediff temporary files.")
|
|
1139
|
|
1140 ;; Metacharacters that have to be protected from the shell when executing
|
|
1141 ;; a diff/diff3 command.
|
|
1142 (defvar ediff-metachars "[ \t\n!\"#$&'()*;<=>?[\\^`{|~]"
|
|
1143 "Characters that must be quoted with \\ when used in a shell command line.
|
|
1144 More precisely, a regexp to match any one such character.")
|
|
1145
|
|
1146 ;; needed to simulate frame-char-width in XEmacs.
|
|
1147 (defvar ediff-H-glyph (if ediff-xemacs-p (make-glyph "H")))
|
|
1148
|
|
1149
|
|
1150 (ediff-defvar-local ediff-temp-file-A nil
|
|
1151 "Temporary file used for refining difference regions in buffer A.")
|
|
1152 (ediff-defvar-local ediff-temp-file-B nil
|
|
1153 "Temporary file used for refining difference regions in buffer B.")
|
|
1154 (ediff-defvar-local ediff-temp-file-C nil
|
|
1155 "Temporary file used for refining difference regions in buffer C.")
|
|
1156
|
|
1157 ;;; In-line functions
|
|
1158
|
|
1159 (defsubst ediff-file-remote-p (file-name)
|
12
|
1160 (require 'ange-ftp)
|
|
1161 (car (if ediff-xemacs-p
|
|
1162 (ange-ftp-ftp-path file-name)
|
|
1163 (ange-ftp-ftp-name file-name))))
|
14
|
1164
|
0
|
1165
|
|
1166 (defsubst ediff-frame-unsplittable-p (frame)
|
|
1167 (cdr (assq 'unsplittable (frame-parameters frame))))
|
|
1168
|
|
1169 (defsubst ediff-get-next-window (wind prev-wind)
|
|
1170 (or (window-live-p wind)
|
|
1171 (setq wind (if prev-wind
|
|
1172 (next-window wind)
|
|
1173 (selected-window)))))
|
|
1174
|
|
1175
|
|
1176 (defsubst ediff-kill-buffer-carefully (buf)
|
|
1177 "Kill buffer BUF if it exists."
|
|
1178 (if (ediff-buffer-live-p buf)
|
|
1179 (kill-buffer (get-buffer buf))))
|
12
|
1180
|
14
|
1181 (defsubst ediff-background-face (buf-type dif-num)
|
|
1182 ;; The value of dif-num is always 1- the one that user sees.
|
|
1183 ;; This is why even face is used when dif-num is odd.
|
|
1184 (intern (format (if (ediff-odd-p dif-num)
|
|
1185 "ediff-even-diff-face-%S"
|
|
1186 "ediff-odd-diff-face-%S")
|
|
1187 buf-type)))
|
|
1188
|
12
|
1189
|
|
1190 ;; activate faces on diff regions in buffer
|
|
1191 (defun ediff-paint-background-regions-in-one-buffer (buf-type unhighlight)
|
|
1192 (let ((diff-vector
|
|
1193 (eval (intern (format "ediff-difference-vector-%S" buf-type))))
|
|
1194 overl diff-num)
|
|
1195 (mapcar (function
|
|
1196 (lambda (rec)
|
|
1197 (setq overl (ediff-get-diff-overlay-from-diff-record rec)
|
|
1198 diff-num (ediff-overlay-get overl 'ediff-diff-num))
|
14
|
1199 (if (ediff-overlay-buffer overl)
|
|
1200 ;; only if overlay is alive
|
|
1201 (ediff-set-overlay-face
|
|
1202 overl
|
|
1203 (if (not unhighlight)
|
|
1204 (ediff-background-face buf-type diff-num))))
|
|
1205 ))
|
12
|
1206 diff-vector)))
|
|
1207
|
|
1208
|
|
1209 ;; activate faces on diff regions in all buffers
|
|
1210 (defun ediff-paint-background-regions (&optional unhighlight)
|
|
1211 (ediff-paint-background-regions-in-one-buffer
|
|
1212 'A unhighlight)
|
|
1213 (ediff-paint-background-regions-in-one-buffer
|
|
1214 'B unhighlight)
|
|
1215 (ediff-paint-background-regions-in-one-buffer
|
|
1216 'C unhighlight)
|
|
1217 (ediff-paint-background-regions-in-one-buffer
|
|
1218 'Ancestor unhighlight))
|
|
1219
|
|
1220 (defun ediff-highlight-diff-in-one-buffer (n buf-type)
|
|
1221 (if (ediff-buffer-live-p (ediff-get-buffer buf-type))
|
|
1222 (let* ((buff (ediff-get-buffer buf-type))
|
|
1223 (last (ediff-eval-in-buffer buff (point-max)))
|
|
1224 (begin (ediff-get-diff-posn buf-type 'beg n))
|
|
1225 (end (ediff-get-diff-posn buf-type 'end n))
|
|
1226 (xtra (if (equal begin end) 1 0))
|
|
1227 (end-hilit (min last (+ end xtra)))
|
|
1228 (current-diff-overlay
|
|
1229 (symbol-value
|
|
1230 (intern (format "ediff-current-diff-overlay-%S" buf-type)))))
|
|
1231
|
|
1232 (if ediff-xemacs-p
|
|
1233 (ediff-move-overlay current-diff-overlay begin end-hilit)
|
|
1234 (ediff-move-overlay current-diff-overlay begin end-hilit buff))
|
|
1235 (ediff-overlay-put current-diff-overlay 'priority
|
|
1236 (ediff-highest-priority begin end-hilit buff))
|
|
1237 (ediff-overlay-put current-diff-overlay 'ediff-diff-num n)
|
|
1238
|
|
1239 ;; unhighlight the background overlay for diff n so it won't
|
|
1240 ;; interfere with the current diff overlay
|
|
1241 (ediff-set-overlay-face (ediff-get-diff-overlay n buf-type) nil)
|
|
1242 )))
|
|
1243
|
|
1244
|
|
1245 (defun ediff-unhighlight-diff-in-one-buffer (buf-type)
|
|
1246 (if (ediff-buffer-live-p (ediff-get-buffer buf-type))
|
|
1247 (let ((current-diff-overlay
|
|
1248 (symbol-value
|
|
1249 (intern (format "ediff-current-diff-overlay-%S" buf-type))))
|
|
1250 (overlay
|
|
1251 (ediff-get-diff-overlay ediff-current-difference buf-type))
|
|
1252 )
|
|
1253
|
|
1254 (ediff-move-overlay current-diff-overlay 1 1)
|
14
|
1255
|
12
|
1256 ;; rehighlight the overlay in the background of the
|
|
1257 ;; current difference region
|
|
1258 (ediff-set-overlay-face
|
|
1259 overlay
|
|
1260 (if (and (ediff-has-face-support-p)
|
|
1261 ediff-use-faces ediff-highlight-all-diffs)
|
|
1262 (ediff-background-face buf-type ediff-current-difference)))
|
|
1263 )))
|
|
1264
|
|
1265 (defun ediff-unhighlight-diffs-totally-in-one-buffer (buf-type)
|
|
1266 (ediff-unselect-and-select-difference -1)
|
|
1267 (if (and (ediff-has-face-support-p) ediff-use-faces)
|
|
1268 (let* ((inhibit-quit t)
|
|
1269 (current-diff-overlay-var
|
|
1270 (intern (format "ediff-current-diff-overlay-%S" buf-type)))
|
|
1271 (current-diff-overlay (symbol-value current-diff-overlay-var)))
|
|
1272 (ediff-paint-background-regions 'unhighlight)
|
|
1273 (if (ediff-overlayp current-diff-overlay)
|
|
1274 (ediff-delete-overlay current-diff-overlay))
|
|
1275 (set current-diff-overlay-var nil)
|
|
1276 )))
|
14
|
1277
|
0
|
1278
|
|
1279 (defsubst ediff-highlight-diff (n)
|
|
1280 "Put face on diff N. Invoked for X displays only."
|
|
1281 (ediff-highlight-diff-in-one-buffer n 'A)
|
|
1282 (ediff-highlight-diff-in-one-buffer n 'B)
|
|
1283 (ediff-highlight-diff-in-one-buffer n 'C)
|
|
1284 (ediff-highlight-diff-in-one-buffer n 'Ancestor)
|
|
1285 )
|
|
1286
|
|
1287
|
|
1288 (defsubst ediff-unhighlight-diff ()
|
|
1289 "Remove overlays from buffers A, B, and C."
|
|
1290 (ediff-unhighlight-diff-in-one-buffer 'A)
|
|
1291 (ediff-unhighlight-diff-in-one-buffer 'B)
|
|
1292 (ediff-unhighlight-diff-in-one-buffer 'C)
|
|
1293 (ediff-unhighlight-diff-in-one-buffer 'Ancestor)
|
|
1294 )
|
|
1295
|
|
1296 ;; delete highlighting overlays, restore faces to their original form
|
|
1297 (defsubst ediff-unhighlight-diffs-totally ()
|
|
1298 (ediff-unhighlight-diffs-totally-in-one-buffer 'A)
|
|
1299 (ediff-unhighlight-diffs-totally-in-one-buffer 'B)
|
|
1300 (ediff-unhighlight-diffs-totally-in-one-buffer 'C)
|
|
1301 (ediff-unhighlight-diffs-totally-in-one-buffer 'Ancestor)
|
|
1302 )
|
|
1303
|
|
1304
|
|
1305 ;; arg is a record for a given diff in a difference vector
|
|
1306 ;; this record is itself a vector
|
|
1307 (defsubst ediff-clear-fine-diff-vector (diff-record)
|
|
1308 (if diff-record
|
|
1309 (mapcar 'ediff-delete-overlay
|
|
1310 (ediff-get-fine-diff-vector-from-diff-record diff-record))))
|
|
1311
|
|
1312 (defsubst ediff-clear-fine-differences-in-one-buffer (n buf-type)
|
|
1313 (ediff-clear-fine-diff-vector (ediff-get-difference n buf-type))
|
|
1314 (ediff-set-fine-diff-vector n buf-type nil))
|
|
1315
|
|
1316 (defsubst ediff-clear-fine-differences (n)
|
|
1317 (ediff-clear-fine-differences-in-one-buffer n 'A)
|
|
1318 (ediff-clear-fine-differences-in-one-buffer n 'B)
|
|
1319 (if ediff-3way-job
|
|
1320 (ediff-clear-fine-differences-in-one-buffer n 'C)))
|
|
1321
|
|
1322
|
|
1323 (defsubst ediff-convert-fine-diffs-to-overlays (diff-list region-num)
|
|
1324 (ediff-set-fine-overlays-in-one-buffer 'A diff-list region-num)
|
|
1325 (ediff-set-fine-overlays-in-one-buffer 'B diff-list region-num)
|
|
1326 (if ediff-3way-job
|
|
1327 (ediff-set-fine-overlays-in-one-buffer 'C diff-list region-num)
|
|
1328 ))
|
|
1329
|
|
1330 (defsubst ediff-mouse-event-p (event)
|
|
1331 (if ediff-xemacs-p
|
|
1332 (button-event-p event)
|
|
1333 (string-match "mouse" (format "%S" (event-basic-type event)))
|
|
1334 ))
|
|
1335
|
|
1336
|
|
1337 (defsubst ediff-key-press-event-p (event)
|
|
1338 (if ediff-xemacs-p
|
|
1339 (key-press-event-p event)
|
|
1340 (or (char-or-string-p event) (symbolp event))))
|
|
1341
|
|
1342 (defun ediff-event-point (event)
|
|
1343 (cond ((ediff-mouse-event-p event)
|
|
1344 (if ediff-xemacs-p
|
|
1345 (event-point event)
|
|
1346 (posn-point (event-start event))))
|
|
1347 ((ediff-key-press-event-p event)
|
|
1348 (point))
|
|
1349 (t (error))))
|
|
1350
|
|
1351 (defun ediff-event-buffer (event)
|
|
1352 (cond ((ediff-mouse-event-p event)
|
|
1353 (if ediff-xemacs-p
|
|
1354 (event-buffer event)
|
|
1355 (window-buffer (posn-window (event-start event)))))
|
|
1356 ((ediff-key-press-event-p event)
|
|
1357 (current-buffer))
|
|
1358 (t (error))))
|
|
1359
|
|
1360
|
|
1361 (defsubst ediff-frame-iconified-p (frame)
|
|
1362 (if (and (ediff-window-display-p) (frame-live-p frame))
|
|
1363 (if ediff-xemacs-p
|
|
1364 (frame-iconified-p frame)
|
|
1365 (eq (frame-visible-p frame) 'icon))))
|
|
1366
|
|
1367 (defsubst ediff-window-visible-p (wind)
|
|
1368 ;; under TTY, window-live-p also means window is visible
|
|
1369 (and (window-live-p wind)
|
|
1370 (or (not (ediff-window-display-p))
|
|
1371 (frame-visible-p (window-frame wind)))))
|
|
1372
|
|
1373
|
|
1374 (defsubst ediff-frame-char-width (frame)
|
|
1375 (if ediff-xemacs-p
|
|
1376 (/ (frame-pixel-width frame) (frame-width frame))
|
|
1377 (frame-char-width frame)))
|
|
1378
|
|
1379 (defun ediff-reset-mouse (&optional frame do-not-grab-mouse)
|
|
1380 (or frame (setq frame (selected-frame)))
|
|
1381 (if (ediff-window-display-p)
|
|
1382 (let ((frame-or-wind frame))
|
|
1383 (if ediff-xemacs-p
|
|
1384 (setq frame-or-wind (frame-selected-window frame)))
|
|
1385 (or do-not-grab-mouse
|
|
1386 ;; don't set mouse if the user said to never do this
|
|
1387 (not ediff-grab-mouse)
|
|
1388 ;; Don't grab on quit, if the user doesn't want to.
|
|
1389 ;; If ediff-grab-mouse = t, then mouse won't be grabbed for
|
|
1390 ;; sessions that are not part of a group (this is done in
|
|
1391 ;; ediff-recenter). The condition below affects only terminating
|
|
1392 ;; sessions in session groups (in which case mouse is warped into
|
|
1393 ;; a meta buffer).
|
|
1394 (and (eq ediff-grab-mouse 'maybe)
|
|
1395 (memq this-command '(ediff-quit ediff-update-diffs)))
|
|
1396 (set-mouse-position frame-or-wind 1 0))
|
|
1397 )))
|
|
1398
|
|
1399 (defsubst ediff-spy-after-mouse ()
|
|
1400 (setq ediff-mouse-pixel-position (mouse-pixel-position)))
|
|
1401
|
|
1402 ;; It is not easy to find out when the user grabs the mouse, since emacs and
|
|
1403 ;; xemacs behave differently when mouse is not in any frame. Also, this is
|
|
1404 ;; sensitive to when the user grabbed mouse. Not used for now.
|
|
1405 (defun ediff-user-grabbed-mouse ()
|
|
1406 (if ediff-mouse-pixel-position
|
|
1407 (cond ((not (eq (car ediff-mouse-pixel-position)
|
|
1408 (car (mouse-pixel-position)))))
|
|
1409 ((and (car (cdr ediff-mouse-pixel-position))
|
|
1410 (car (cdr (mouse-pixel-position)))
|
|
1411 (cdr (cdr ediff-mouse-pixel-position))
|
|
1412 (cdr (cdr (mouse-pixel-position))))
|
|
1413 (not (and (< (abs (- (car (cdr ediff-mouse-pixel-position))
|
|
1414 (car (cdr (mouse-pixel-position)))))
|
|
1415 ediff-mouse-pixel-threshold)
|
|
1416 (< (abs (- (cdr (cdr ediff-mouse-pixel-position))
|
|
1417 (cdr (cdr (mouse-pixel-position)))))
|
|
1418 ediff-mouse-pixel-threshold))))
|
|
1419 (t nil))))
|
|
1420
|
|
1421 (defsubst ediff-frame-char-height (frame)
|
|
1422 (if ediff-xemacs-p
|
|
1423 (glyph-height ediff-H-glyph (selected-window frame))
|
|
1424 (frame-char-height frame)))
|
|
1425
|
12
|
1426 ;; Some overlay functions
|
0
|
1427
|
14
|
1428 (defsubst ediff-overlay-start (overl)
|
|
1429 (if (ediff-overlayp overl)
|
|
1430 (if ediff-emacs-p
|
|
1431 (overlay-start overl)
|
|
1432 (extent-start-position overl))))
|
|
1433
|
|
1434 (defsubst ediff-overlay-end (overl)
|
|
1435 (if (ediff-overlayp overl)
|
|
1436 (if ediff-emacs-p
|
|
1437 (overlay-end overl)
|
|
1438 (extent-end-position overl))))
|
|
1439
|
0
|
1440 (defsubst ediff-empty-overlay-p (overl)
|
|
1441 (= (ediff-overlay-start overl) (ediff-overlay-end overl)))
|
|
1442
|
|
1443 ;; like overlay-buffer in Emacs. In XEmacs, returns nil if the extent is
|
|
1444 ;; dead. Otherwise, works like extent-buffer
|
|
1445 (defun ediff-overlay-buffer (overl)
|
|
1446 (if ediff-emacs-p
|
|
1447 (overlay-buffer overl)
|
|
1448 (and (extent-live-p overl) (extent-object overl))))
|
|
1449
|
|
1450 ;; like overlay-get in Emacs. In XEmacs, returns nil if the extent is
|
|
1451 ;; dead. Otherwise, like extent-property
|
|
1452 (defun ediff-overlay-get (overl property)
|
|
1453 (if ediff-emacs-p
|
|
1454 (overlay-get overl property)
|
|
1455 (and (extent-live-p overl) (extent-property overl property))))
|
12
|
1456
|
|
1457
|
|
1458 ;; These two functions are here because XEmacs refuses to
|
|
1459 ;; handle overlays whose buffers were deleted.
|
|
1460 (defun ediff-move-overlay (overlay beg end &optional buffer)
|
|
1461 "Calls `move-overlay' in Emacs and `set-extent-endpoints' in Lemacs.
|
|
1462 Checks if overlay's buffer exists before actually doing the move."
|
|
1463 (let ((buf (and overlay (ediff-overlay-buffer overlay))))
|
|
1464 (if (ediff-buffer-live-p buf)
|
|
1465 (if ediff-xemacs-p
|
|
1466 (set-extent-endpoints overlay beg end)
|
|
1467 (move-overlay overlay beg end buffer))
|
|
1468 ;; buffer's dead
|
|
1469 (if overlay
|
|
1470 (ediff-delete-overlay overlay)))))
|
|
1471
|
|
1472 (defun ediff-overlay-put (overlay prop value)
|
|
1473 "Calls `overlay-put' or `set-extent-property' depending on Emacs version.
|
|
1474 Checks if overlay's buffer exists."
|
|
1475 (if (ediff-buffer-live-p (ediff-overlay-buffer overlay))
|
|
1476 (if ediff-xemacs-p
|
|
1477 (set-extent-property overlay prop value)
|
|
1478 (overlay-put overlay prop value))
|
|
1479 (ediff-delete-overlay overlay)))
|
|
1480
|
|
1481 ;; Some diff region tests
|
0
|
1482
|
|
1483 ;; t if diff region is empty.
|
|
1484 ;; In case of buffer C, t also if it is not a 3way
|
|
1485 ;; comparison job (merging jobs return t as well).
|
|
1486 (defun ediff-empty-diff-region-p (n buf-type)
|
|
1487 (if (eq buf-type 'C)
|
|
1488 (or (not ediff-3way-comparison-job)
|
|
1489 (= (ediff-get-diff-posn 'C 'beg n)
|
|
1490 (ediff-get-diff-posn 'C 'end n)))
|
|
1491 (= (ediff-get-diff-posn buf-type 'beg n)
|
|
1492 (ediff-get-diff-posn buf-type 'end n))))
|
|
1493
|
|
1494 ;; Test if diff region is white space only.
|
|
1495 ;; If 2-way job and buf-type = C, then returns t.
|
|
1496 (defun ediff-whitespace-diff-region-p (n buf-type)
|
|
1497 (or (and (eq buf-type 'C) (not ediff-3way-job))
|
|
1498 (ediff-empty-diff-region-p n buf-type)
|
|
1499 (let ((beg (ediff-get-diff-posn buf-type 'beg n))
|
|
1500 (end (ediff-get-diff-posn buf-type 'end n)))
|
|
1501 (ediff-eval-in-buffer (ediff-get-buffer buf-type)
|
|
1502 (save-excursion
|
|
1503 (goto-char beg)
|
|
1504 (skip-chars-forward ediff-whitespace)
|
|
1505 (>= (point) end))))))
|
|
1506
|
|
1507 ;; temporarily uses DIR to abbreviate file name
|
|
1508 ;; if DIR is nil, use default-directory
|
|
1509 (defun ediff-abbreviate-file-name (file &optional dir)
|
|
1510 (cond ((stringp dir)
|
|
1511 (let ((directory-abbrev-alist (list (cons dir ""))))
|
|
1512 (abbreviate-file-name file)))
|
|
1513 (ediff-emacs-p (abbreviate-file-name file))
|
|
1514 (t ; XEmacs requires addl argument
|
|
1515 (abbreviate-file-name file t))))
|
|
1516
|
|
1517 ;; Takes a directory and returns the parent directory.
|
|
1518 ;; does nothing to `/'. If the ARG is a regular file,
|
|
1519 ;; strip the file AND the last dir.
|
|
1520 (defun ediff-strip-last-dir (dir)
|
|
1521 (if (not (stringp dir)) (setq dir default-directory))
|
|
1522 (setq dir (expand-file-name dir))
|
|
1523 (or (file-directory-p dir) (setq dir (file-name-directory dir)))
|
|
1524 (let* ((pos (1- (length dir)))
|
|
1525 (last-char (aref dir pos)))
|
|
1526 (if (and (> pos 0) (= last-char ?/))
|
|
1527 (setq dir (substring dir 0 pos)))
|
|
1528 (ediff-abbreviate-file-name (file-name-directory dir))))
|
|
1529
|
|
1530 (defun ediff-truncate-string-left (str newlen)
|
|
1531 ;; leave space for ... on the left
|
|
1532 (let ((len (length str))
|
|
1533 substr)
|
|
1534 (if (<= len newlen)
|
|
1535 str
|
|
1536 (setq newlen (max 0 (- newlen 3)))
|
|
1537 (setq substr (substring str (max 0 (- len 1 newlen))))
|
|
1538 (concat "..." substr))))
|
|
1539
|
|
1540 (defun ediff-abbrev-jobname (jobname)
|
|
1541 (cond ((eq jobname 'ediff-directories)
|
|
1542 "Compare two directories")
|
|
1543 ((eq jobname 'ediff-files)
|
|
1544 "Compare two files")
|
|
1545 ((eq jobname 'ediff-buffers)
|
|
1546 "Compare two buffers")
|
|
1547 ((eq jobname 'ediff-directories3)
|
|
1548 "Compare three directories")
|
|
1549 ((eq jobname 'ediff-files3)
|
|
1550 "Compare three files")
|
|
1551 ((eq jobname 'ediff-buffers3)
|
|
1552 "Compare three buffers")
|
|
1553 ((eq jobname 'ediff-revision)
|
|
1554 "Compare file with a version")
|
|
1555 ((eq jobname 'ediff-directory-revisions)
|
|
1556 "Compare dir files with versions")
|
|
1557 ((eq jobname 'ediff-merge-directory-revisions)
|
|
1558 "Merge dir files with versions")
|
|
1559 ((eq jobname 'ediff-merge-directory-revisions-with-ancestor)
|
|
1560 "Merge dir versions via ancestors")
|
|
1561 (t
|
|
1562 (let* ((str (substring (symbol-name jobname) 6))
|
|
1563 (len (length str))
|
|
1564 (pos 0))
|
|
1565 (while (< pos len)
|
|
1566 (if (= pos 0)
|
|
1567 (aset str pos (upcase (aref str pos))))
|
|
1568 (if (= (aref str pos) ?-)
|
|
1569 (aset str pos ?\ ))
|
|
1570 (setq pos (1+ pos)))
|
|
1571 str))))
|
|
1572
|
|
1573
|
|
1574
|
|
1575 (defsubst ediff-get-region-contents (n buf-type ctrl-buf &optional start end)
|
|
1576 (ediff-eval-in-buffer
|
|
1577 (ediff-eval-in-buffer ctrl-buf (ediff-get-buffer buf-type))
|
|
1578 (buffer-substring
|
|
1579 (or start (ediff-get-diff-posn buf-type 'beg n ctrl-buf))
|
|
1580 (or end (ediff-get-diff-posn buf-type 'end n ctrl-buf)))))
|
|
1581
|
|
1582 ;; If ediff modified mode line, strip the modification
|
|
1583 (defsubst ediff-strip-mode-line-format ()
|
|
1584 (if (member (car mode-line-format) '(" A: " " B: " " C: " " Ancestor: "))
|
|
1585 (setq mode-line-format (nth 2 mode-line-format))))
|
|
1586
|
|
1587 ;; Verify that we have a difference selected.
|
|
1588 (defsubst ediff-valid-difference-p (&optional n)
|
|
1589 (or n (setq n ediff-current-difference))
|
|
1590 (and (>= n 0) (< n ediff-number-of-differences)))
|
|
1591
|
|
1592 (defsubst ediff-show-all-diffs (n)
|
|
1593 "Don't skip difference regions."
|
|
1594 nil)
|
|
1595
|
|
1596 (defsubst Xor (a b)
|
|
1597 (or (and a (not b)) (and (not a) b)))
|
|
1598
|
|
1599 (defsubst ediff-message-if-verbose (string &rest args)
|
|
1600 (if ediff-verbose-p
|
|
1601 (apply 'message string args)))
|
|
1602
|
|
1603 (defun ediff-file-attributes (filename attr-number)
|
|
1604 (let ((handler (find-file-name-handler filename 'find-file-noselect)))
|
|
1605 (if (and handler (string-match "ange-ftp" (format "%S" handler)))
|
|
1606 -1
|
|
1607 (nth attr-number (file-attributes filename)))))
|
|
1608 (defsubst ediff-file-size (filename)
|
|
1609 (ediff-file-attributes filename 7))
|
|
1610 (defsubst ediff-file-modtime (filename)
|
|
1611 (ediff-file-attributes filename 5))
|
|
1612
|
|
1613
|
12
|
1614 (defun ediff-convert-standard-filename (fname)
|
14
|
1615 (if (fboundp 'convert-standard-filename)
|
12
|
1616 (convert-standard-filename fname)
|
|
1617 fname))
|
0
|
1618
|
14
|
1619
|
12
|
1620 ;;; Local Variables:
|
|
1621 ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun)
|
|
1622 ;;; eval: (put 'ediff-eval-in-buffer 'lisp-indent-hook 1)
|
|
1623 ;;; eval: (put 'ediff-eval-in-buffer 'edebug-form-spec '(form body))
|
|
1624 ;;; End:
|
14
|
1625
|
0
|
1626 (provide 'ediff-init)
|
|
1627
|
|
1628
|
|
1629 ;;; ediff-init.el ends here
|