(Frename_file): Undo last change: no need to ifdef away
[bpt/emacs.git] / lisp / ediff-init.el
CommitLineData
4960e757 1;;; ediff-init.el --- Macros, variables, and defsubsts used by Ediff
b578f267 2
1e39fa26
KS
3;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
4;; 2004, 2005 Free Software Foundation, Inc.
475f9031 5
50a07e18 6;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
475f9031
KH
7
8;; This file is part of GNU Emacs.
9
10;; GNU Emacs is free software; you can redistribute it and/or modify
11;; it under the terms of the GNU General Public License as published by
12;; the Free Software Foundation; either version 2, or (at your option)
13;; any later version.
14
15;; GNU Emacs is distributed in the hope that it will be useful,
16;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;; GNU General Public License for more details.
19
20;; You should have received a copy of the GNU General Public License
b578f267
EN
21;; along with GNU Emacs; see the file COPYING. If not, write to the
22;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23;; Boston, MA 02111-1307, USA.
475f9031 24
3afbc435
PJ
25;;; Commentary:
26
b578f267 27;;; Code:
475f9031 28
bbe6126c
MK
29;; Start compiler pacifier
30(defvar ediff-metajob-name)
31(defvar ediff-meta-buffer)
32(defvar pm-color-alist)
33(defvar ediff-grab-mouse)
34(defvar ediff-mouse-pixel-position)
35(defvar ediff-mouse-pixel-threshold)
36(defvar ediff-whitespace)
37(defvar ediff-multiframe)
2eb4bdca 38(defvar ediff-use-toolbar-p)
50a07e18 39(defvar mswindowsx-bitmap-file-path)
ddc90f39
MK
40
41(and noninteractive
42 (eval-when-compile
43 (load "ange-ftp" 'noerror)))
bbe6126c
MK
44;; end pacifier
45
41d25ad0 46;; Is it XEmacs?
1e39fa26 47(defconst ediff-xemacs-p (featurep 'xemacs))
41d25ad0
KH
48;; Is it Emacs?
49(defconst ediff-emacs-p (not ediff-xemacs-p))
bbe6126c 50
50a07e18
MK
51;; This is used to avoid compilation warnings. When emacs/xemacs forms can
52;; generate compile time warnings, we use this macro.
53;; In this case, the macro will expand into the form that is appropriate to the
54;; compiler at hand.
55;; Suggested by rms.
56(defmacro ediff-cond-compile-for-xemacs-or-emacs (xemacs-form emacs-form)
1e39fa26 57 (if (featurep 'xemacs)
50a07e18
MK
58 xemacs-form emacs-form))
59
bbe6126c
MK
60(defvar ediff-force-faces nil
61 "If t, Ediff will think that it is running on a display that supports faces.
62This is provided as a temporary relief for users of face-capable displays
63that Ediff doesn't know about.")
64
41d25ad0
KH
65;; Are we running as a window application or on a TTY?
66(defsubst ediff-device-type ()
50a07e18
MK
67 (ediff-cond-compile-for-xemacs-or-emacs
68 (device-type (selected-device)) ; xemacs form
69 window-system ; emacs form
70 ))
bbe6126c 71
41d25ad0 72;; in XEmacs: device-type is tty on tty and stream in batch.
4ae69eac
MK
73(defun ediff-window-display-p ()
74 (and (ediff-device-type) (not (memq (ediff-device-type) '(tty pc stream)))))
75
76;; test if supports faces
4ae69eac
MK
77(defun ediff-has-face-support-p ()
78 (cond ((ediff-window-display-p))
79 (ediff-force-faces)
d396e521
MK
80 ((ediff-color-display-p))
81 (ediff-emacs-p (memq (ediff-device-type) '(pc)))
743a79af
MK
82 (ediff-xemacs-p (memq (ediff-device-type) '(tty pc)))
83 ))
bf5d92c5 84
50a07e18 85;; toolbar support for emacs hasn't been implemented in ediff
2eb4bdca 86(defun ediff-has-toolbar-support-p ()
50a07e18
MK
87 (ediff-cond-compile-for-xemacs-or-emacs
88 (and (featurep 'toolbar) (console-on-window-system-p)) ; xemacs form
89 nil ; emacs form
90 ))
2eb4bdca 91
8bdd0bf7
MK
92
93(defun ediff-has-gutter-support-p ()
94 (ediff-cond-compile-for-xemacs-or-emacs
95 (and (featurep 'gutter) (console-on-window-system-p)) ; xemacs form
96 nil ; emacs form
97 ))
98
99
2eb4bdca
MK
100(defun ediff-use-toolbar-p ()
101 (and (ediff-has-toolbar-support-p) ;Can it do it ?
102 (boundp 'ediff-use-toolbar-p)
103 ediff-use-toolbar-p)) ;Does the user want it ?
104
acce6d21 105;; Defines SYMBOL as an advertised local variable.
bbe6126c
MK
106;; Performs a defvar, then executes `make-variable-buffer-local' on
107;; the variable. Also sets the `permanent-local' property,
108;; so that `kill-all-local-variables' (called by major-mode setting
109;; commands) won't destroy Ediff control variables.
acce6d21 110;;
bbe6126c 111;; Plagiarised from `emerge-defvar-local' for XEmacs.
acce6d21 112(defmacro ediff-defvar-local (var value doc)
086171bf
MK
113 `(progn
114 (defvar ,var ,value ,doc)
115 (make-variable-buffer-local ',var)
116 (put ',var 'permanent-local t)))
acce6d21 117
bbe6126c
MK
118
119
120;; Variables that control each Ediff session---local to the control buffer.
121
122;; Mode variables
123;; The buffer in which the A variant is stored.
124(ediff-defvar-local ediff-buffer-A nil "")
125;; The buffer in which the B variant is stored.
126(ediff-defvar-local ediff-buffer-B nil "")
3af0304a 127;; The buffer in which the C variant is stored or where the merge buffer lives.
bbe6126c
MK
128(ediff-defvar-local ediff-buffer-C nil "")
129;; Ancestor buffer
130(ediff-defvar-local ediff-ancestor-buffer nil "")
ddc90f39 131;; The Ediff control buffer
bbe6126c 132(ediff-defvar-local ediff-control-buffer nil "")
475f9031 133
50a07e18
MK
134(ediff-defvar-local ediff-temp-indirect-buffer nil
135 "If t, the buffer is a temporary indirect buffer.
136It needs to be killed when we quit the session.")
137
e756eb9f
MK
138
139;; Association between buff-type and ediff-buffer-*
140(defconst ediff-buffer-alist
141 '((?A . ediff-buffer-A)
142 (?B . ediff-buffer-B)
143 (?C . ediff-buffer-C)))
144
475f9031
KH
145;;; Macros
146(defmacro ediff-odd-p (arg)
086171bf 147 `(eq (logand ,arg 1) 1))
475f9031
KH
148
149(defmacro ediff-buffer-live-p (buf)
086171bf 150 `(and ,buf (get-buffer ,buf) (buffer-name (get-buffer ,buf))))
475f9031
KH
151
152(defmacro ediff-get-buffer (arg)
086171bf
MK
153 `(cond ((eq ,arg 'A) ediff-buffer-A)
154 ((eq ,arg 'B) ediff-buffer-B)
155 ((eq ,arg 'C) ediff-buffer-C)
156 ((eq ,arg 'Ancestor) ediff-ancestor-buffer)
157 ))
acce6d21 158
475f9031 159(defmacro ediff-get-value-according-to-buffer-type (buf-type list)
086171bf
MK
160 `(cond ((eq ,buf-type 'A) (nth 0 ,list))
161 ((eq ,buf-type 'B) (nth 1 ,list))
162 ((eq ,buf-type 'C) (nth 2 ,list))
163 ))
acce6d21 164
475f9031 165(defmacro ediff-char-to-buftype (arg)
086171bf
MK
166 `(cond ((memq ,arg '(?a ?A)) 'A)
167 ((memq ,arg '(?b ?B)) 'B)
168 ((memq ,arg '(?c ?C)) 'C)
169 ))
e756eb9f 170
985d0dad 171
e756eb9f
MK
172;; A-list is supposed to be of the form (A . symb) (B . symb)...)
173;; where the first part of any association is a buffer type and the second is
3af0304a
MK
174;; an appropriate symbol. Given buffer-type, this function returns the
175;; symbol. This is used to avoid using `intern'
e756eb9f
MK
176(defsubst ediff-get-symbol-from-alist (buf-type alist)
177 (cdr (assoc buf-type alist)))
acce6d21 178
e756eb9f
MK
179(defconst ediff-difference-vector-alist
180 '((A . ediff-difference-vector-A)
181 (B . ediff-difference-vector-B)
182 (C . ediff-difference-vector-C)
183 (Ancestor . ediff-difference-vector-Ancestor)))
184
475f9031 185(defmacro ediff-get-difference (n buf-type)
086171bf
MK
186 `(aref
187 (symbol-value
188 (ediff-get-symbol-from-alist
189 ,buf-type ediff-difference-vector-alist))
190 ,n))
acce6d21 191
ddc90f39 192;; Tell if it has been previously determined that the region has
475f9031
KH
193;; no diffs other than the white space and newlines
194;; The argument, N, is the diff region number used by Ediff to index the
3af0304a 195;; diff vector. It is 1 less than the number seen by the user.
ddc90f39
MK
196;; Returns:
197;; t if the diffs are whitespace in all buffers
198;; 'A (in 3-buf comparison only) if there are only whitespace
199;; diffs in bufs B and C
200;; 'B (in 3-buf comparison only) if there are only whitespace
201;; diffs in bufs A and C
202;; 'C (in 3-buf comparison only) if there are only whitespace
203;; diffs in bufs A and B
475f9031 204;;
3af0304a 205;; A Difference Vector has the form:
475f9031
KH
206;; [diff diff diff ...]
207;; where each diff has the form:
3af0304a 208;; [overlay fine-diff-vector no-fine-diffs-flag state-of-difference]
475f9031 209;; fine-diff-vector is a vector [fine-diff fine-diff fine-diff ...]
3af0304a
MK
210;; no-fine-diffs-flag says if there are fine differences.
211;; state-of-difference is A, B, C, or nil, indicating which buffer is
212;; different from the other two (used only in 3-way jobs).
475f9031 213(defmacro ediff-no-fine-diffs-p (n)
086171bf 214 `(aref (ediff-get-difference ,n 'A) 2))
acce6d21 215
475f9031 216(defmacro ediff-get-diff-overlay-from-diff-record (diff-rec)
086171bf 217 `(aref ,diff-rec 0))
acce6d21
TTN
218
219(defmacro ediff-get-diff-overlay (n buf-type)
086171bf
MK
220 `(ediff-get-diff-overlay-from-diff-record
221 (ediff-get-difference ,n ,buf-type)))
475f9031
KH
222
223(defmacro ediff-get-fine-diff-vector-from-diff-record (diff-rec)
086171bf 224 `(aref ,diff-rec 1))
acce6d21 225
475f9031 226(defmacro ediff-set-fine-diff-vector (n buf-type fine-vec)
086171bf 227 `(aset (ediff-get-difference ,n ,buf-type) 1 ,fine-vec))
acce6d21 228
475f9031 229(defmacro ediff-get-state-of-diff (n buf-type)
086171bf
MK
230 `(if (ediff-buffer-live-p ediff-buffer-C)
231 (aref (ediff-get-difference ,n ,buf-type) 3)))
475f9031 232(defmacro ediff-set-state-of-diff (n buf-type val)
086171bf 233 `(aset (ediff-get-difference ,n ,buf-type) 3 ,val))
3af0304a 234
475f9031 235(defmacro ediff-get-state-of-merge (n)
086171bf
MK
236 `(if ediff-state-of-merge
237 (aref (aref ediff-state-of-merge ,n) 0)))
475f9031 238(defmacro ediff-set-state-of-merge (n val)
086171bf
MK
239 `(if ediff-state-of-merge
240 (aset (aref ediff-state-of-merge ,n) 0 ,val)))
475f9031 241
3af0304a 242(defmacro ediff-get-state-of-ancestor (n)
086171bf
MK
243 `(if ediff-state-of-merge
244 (aref (aref ediff-state-of-merge ,n) 1)))
3af0304a 245
acce6d21 246;; if flag is t, puts a mark on diff region saying that
3af0304a 247;; the differences are in white space only. If flag is nil,
475f9031
KH
248;; the region is marked as essential (i.e., differences are
249;; not just in the white space and newlines.)
250(defmacro ediff-mark-diff-as-space-only (n flag)
086171bf 251 `(aset (ediff-get-difference ,n 'A) 2 ,flag))
acce6d21 252
475f9031 253(defmacro ediff-get-fine-diff-vector (n buf-type)
086171bf
MK
254 `(ediff-get-fine-diff-vector-from-diff-record
255 (ediff-get-difference ,n ,buf-type)))
acce6d21 256
e756eb9f
MK
257;; Macro to switch to BUFFER, evaluate BODY, returns to original buffer.
258;; Doesn't save the point and mark.
259;; This is `with-current-buffer' with the added test for live buffers."
260(defmacro ediff-with-current-buffer (buffer &rest body)
086171bf 261 `(if (ediff-buffer-live-p ,buffer)
e756eb9f 262 (save-current-buffer
086171bf
MK
263 (set-buffer ,buffer)
264 ,@body)
e756eb9f
MK
265 (or (eq this-command 'ediff-quit)
266 (error ediff-KILLED-VITAL-BUFFER))
086171bf 267 ))
acce6d21 268
475f9031 269
8343426b
MK
270(defsubst ediff-multiframe-setup-p ()
271 (and (ediff-window-display-p) ediff-multiframe))
acce6d21 272
475f9031 273(defmacro ediff-narrow-control-frame-p ()
086171bf
MK
274 `(and (ediff-multiframe-setup-p)
275 (equal ediff-help-message ediff-brief-message-string)))
acce6d21 276
475f9031 277(defmacro ediff-3way-comparison-job ()
086171bf
MK
278 `(memq
279 ediff-job-name
280 '(ediff-files3 ediff-buffers3)))
475f9031 281(ediff-defvar-local ediff-3way-comparison-job nil "")
acce6d21 282
475f9031 283(defmacro ediff-merge-job ()
086171bf
MK
284 `(memq
285 ediff-job-name
286 '(ediff-merge-files
287 ediff-merge-buffers
288 ediff-merge-files-with-ancestor
289 ediff-merge-buffers-with-ancestor
290 ediff-merge-revisions
291 ediff-merge-revisions-with-ancestor)))
475f9031
KH
292(ediff-defvar-local ediff-merge-job nil "")
293
743a79af
MK
294(defmacro ediff-patch-job ()
295 `(eq ediff-job-name 'epatch))
296
475f9031 297(defmacro ediff-merge-with-ancestor-job ()
086171bf
MK
298 `(memq
299 ediff-job-name
300 '(ediff-merge-files-with-ancestor
301 ediff-merge-buffers-with-ancestor
302 ediff-merge-revisions-with-ancestor)))
475f9031
KH
303(ediff-defvar-local ediff-merge-with-ancestor-job nil "")
304
305(defmacro ediff-3way-job ()
086171bf 306 `(or ediff-3way-comparison-job ediff-merge-job))
475f9031
KH
307(ediff-defvar-local ediff-3way-job nil "")
308
309;; A diff3 job is like a 3way job, but ediff-merge doesn't require the use
310;; of diff3.
311(defmacro ediff-diff3-job ()
086171bf
MK
312 `(or ediff-3way-comparison-job
313 ediff-merge-with-ancestor-job))
475f9031 314(ediff-defvar-local ediff-diff3-job nil "")
acce6d21 315
41d25ad0 316(defmacro ediff-windows-job ()
086171bf 317 `(memq ediff-job-name '(ediff-windows-wordwise ediff-windows-linewise)))
41d25ad0
KH
318(ediff-defvar-local ediff-windows-job nil "")
319
475f9031 320(defmacro ediff-word-mode-job ()
086171bf 321 `(memq ediff-job-name '(ediff-windows-wordwise ediff-regions-wordwise)))
475f9031
KH
322(ediff-defvar-local ediff-word-mode-job nil "")
323
41d25ad0 324(defmacro ediff-narrow-job ()
086171bf
MK
325 `(memq ediff-job-name '(ediff-windows-wordwise
326 ediff-regions-wordwise
327 ediff-windows-linewise
328 ediff-regions-linewise)))
41d25ad0
KH
329(ediff-defvar-local ediff-narrow-job nil "")
330
8343426b
MK
331;; Note: ediff-merge-directory-revisions-with-ancestor is not treated as an
332;; ancestor metajob, since it behaves differently.
333(defsubst ediff-ancestor-metajob (&optional metajob)
334 (memq (or metajob ediff-metajob-name)
335 '(ediff-merge-directories-with-ancestor
336 ediff-merge-filegroups-with-ancestor)))
337(defsubst ediff-revision-metajob (&optional metajob)
338 (memq (or metajob ediff-metajob-name)
acce6d21 339 '(ediff-directory-revisions
8343426b
MK
340 ediff-merge-directory-revisions
341 ediff-merge-directory-revisions-with-ancestor)))
bbe6126c
MK
342(defsubst ediff-patch-metajob (&optional metajob)
343 (memq (or metajob ediff-metajob-name)
344 '(ediff-multifile-patch)))
345;; metajob involving only one group of files, such as multipatch or directory
346;; revision
347(defsubst ediff-one-filegroup-metajob (&optional metajob)
8343426b 348 (or (ediff-revision-metajob metajob)
bbe6126c 349 (ediff-patch-metajob metajob)
8343426b
MK
350 ;; add more here
351 ))
c3912d54 352;; jobs suitable for the operation of collecting diffs into a multifile patch
8343426b 353(defsubst ediff-collect-diffs-metajob (&optional metajob)
4ae69eac
MK
354 (memq (or metajob ediff-metajob-name)
355 '(ediff-directories
4ae69eac
MK
356 ediff-merge-directories
357 ediff-merge-directories-with-ancestor
c3912d54 358 ediff-directory-revisions
4ae69eac
MK
359 ediff-merge-directory-revisions
360 ediff-merge-directory-revisions-with-ancestor
361 ;; add more here
362 )))
92c51e07
MK
363(defsubst ediff-merge-metajob (&optional metajob)
364 (memq (or metajob ediff-metajob-name)
365 '(ediff-merge-directories
366 ediff-merge-directories-with-ancestor
367 ediff-merge-directory-revisions
368 ediff-merge-directory-revisions-with-ancestor
acce6d21 369 ediff-merge-filegroups-with-ancestor
92c51e07
MK
370 ;; add more here
371 )))
4ae69eac 372
8343426b
MK
373(defsubst ediff-metajob3 (&optional metajob)
374 (memq (or metajob ediff-metajob-name)
375 '(ediff-merge-directories-with-ancestor
acce6d21 376 ediff-merge-filegroups-with-ancestor
8343426b
MK
377 ediff-directories3
378 ediff-filegroups3)))
379(defsubst ediff-comparison-metajob3 (&optional metajob)
380 (memq (or metajob ediff-metajob-name)
381 '(ediff-directories3 ediff-filegroups3)))
382
bf5d92c5
MK
383;; with no argument, checks if we are in ediff-control-buffer
384;; with argument, checks if we are in ediff-meta-buffer
385(defun ediff-in-control-buffer-p (&optional meta-buf-p)
386 (and (boundp 'ediff-control-buffer)
387 (eq (if meta-buf-p ediff-meta-buffer ediff-control-buffer)
388 (current-buffer))))
389
390(defsubst ediff-barf-if-not-control-buffer (&optional meta-buf-p)
391 (or (ediff-in-control-buffer-p meta-buf-p)
8343426b
MK
392 (error "%S: This command runs in Ediff Control Buffer only!"
393 this-command)))
394
328b4b70
MK
395(defgroup ediff-highlighting nil
396 "Hilighting of difference regions in Ediff"
397 :prefix "ediff-"
398 :group 'ediff)
399
400(defgroup ediff-merge nil
401 "Merging utilities"
402 :prefix "ediff-"
403 :group 'ediff)
404
405(defgroup ediff-hook nil
acce6d21 406 "Hooks run by Ediff"
328b4b70
MK
407 :prefix "ediff-"
408 :group 'ediff)
409
475f9031
KH
410;; Hook variables
411
657f9cb8
MK
412(defcustom ediff-before-setup-hook nil
413 "*Hooks to run before Ediff begins to set up windows and buffers.
414This hook can be used to save the previous window config, which can be restored
415on ediff-quit or ediff-suspend."
416 :type 'hook
acce6d21 417 :group 'ediff-hook)
1e70790f 418(defcustom ediff-before-setup-windows-hook nil
acce6d21
TTN
419 "*Hooks to run before Ediff sets its window configuration.
420This hook is run every time when Ediff arranges its windows.
657f9cb8
MK
421This happens each time Ediff detects that the windows were messed up by the
422user."
1e70790f 423 :type 'hook
acce6d21 424 :group 'ediff-hook)
1e70790f 425(defcustom ediff-after-setup-windows-hook nil
acce6d21 426 "*Hooks to run after Ediff sets its window configuration.
1e70790f
MK
427This can be used to set up control window or icon in a desired place."
428 :type 'hook
328b4b70 429 :group 'ediff-hook)
1e70790f 430(defcustom ediff-before-setup-control-frame-hook nil
475f9031
KH
431 "*Hooks run before setting up the frame to display Ediff Control Panel.
432Can be used to change control frame parameters to position it where it
1e70790f
MK
433is desirable."
434 :type 'hook
328b4b70 435 :group 'ediff-hook)
1e70790f 436(defcustom ediff-after-setup-control-frame-hook nil
475f9031 437 "*Hooks run after setting up the frame to display Ediff Control Panel.
1e70790f
MK
438Can be used to move the frame where it is desired."
439 :type 'hook
328b4b70 440 :group 'ediff-hook)
1e70790f 441(defcustom ediff-startup-hook nil
657f9cb8 442 "*Hooks to run in the control buffer after Ediff has been set up and is ready for the job."
1e70790f 443 :type 'hook
328b4b70 444 :group 'ediff-hook)
1e70790f
MK
445(defcustom ediff-select-hook nil
446 "*Hooks to run after a difference has been selected."
447 :type 'hook
328b4b70 448 :group 'ediff-hook)
1e70790f
MK
449(defcustom ediff-unselect-hook nil
450 "*Hooks to run after a difference has been unselected."
451 :type 'hook
328b4b70 452 :group 'ediff-hook)
1e70790f 453(defcustom ediff-prepare-buffer-hook nil
acce6d21
TTN
454 "*Hooks run after buffers A, B, and C are set up.
455For each buffer, the hooks are run with that buffer made current."
1e70790f 456 :type 'hook
328b4b70 457 :group 'ediff-hook)
1e70790f
MK
458(defcustom ediff-load-hook nil
459 "*Hook run after Ediff is loaded. Can be used to change defaults."
460 :type 'hook
328b4b70 461 :group 'ediff-hook)
acce6d21 462
1e70790f 463(defcustom ediff-mode-hook nil
acce6d21 464 "*Hook run just after ediff-mode is set up in the control buffer.
3af0304a 465This is done before any windows or frames are created. One can use it to
1e70790f
MK
466set local variables that determine how the display looks like."
467 :type 'hook
328b4b70 468 :group 'ediff-hook)
1e70790f
MK
469(defcustom ediff-keymap-setup-hook nil
470 "*Hook run just after the default bindings in Ediff keymap are set up."
471 :type 'hook
328b4b70 472 :group 'ediff-hook)
acce6d21 473
1e70790f
MK
474(defcustom ediff-display-help-hook nil
475 "*Hooks run after preparing the help message."
476 :type 'hook
328b4b70 477 :group 'ediff-hook)
1e70790f 478
7261ece3 479(defcustom ediff-suspend-hook nil
1e70790f
MK
480 "*Hooks to run in the Ediff control buffer when Ediff is suspended."
481 :type 'hook
328b4b70 482 :group 'ediff-hook)
7261ece3 483(defcustom ediff-quit-hook nil
1e70790f
MK
484 "*Hooks to run in the Ediff control buffer after finishing Ediff."
485 :type 'hook
acce6d21 486 :group 'ediff-hook)
1e70790f 487(defcustom ediff-cleanup-hook nil
3af0304a 488 "*Hooks to run on exiting Ediff but before killing the control and variant buffers."
1e70790f 489 :type 'hook
328b4b70 490 :group 'ediff-hook)
475f9031 491
4ae69eac
MK
492;; Error messages
493(defconst ediff-KILLED-VITAL-BUFFER
494 "You have killed a vital Ediff buffer---you must leave Ediff now!")
495(defconst ediff-NO-DIFFERENCES
bbe6126c
MK
496 "Sorry, comparison of identical variants is not what I am made for...")
497(defconst ediff-BAD-DIFF-NUMBER
498 ;; %S stands for this-command, %d - diff number, %d - max diff
3af0304a 499 "%S: Bad diff region number, %d. Valid numbers are 1 to %d")
92c51e07
MK
500(defconst ediff-BAD-INFO (format "
501*** The Info file for Ediff, a part of the standard distribution
502*** of %sEmacs, does not seem to be properly installed.
acce6d21 503***
92c51e07
MK
504*** Please contact your system administrator. "
505 (if ediff-xemacs-p "X" "")))
acce6d21 506
475f9031
KH
507;; Selective browsing
508
509(ediff-defvar-local ediff-skip-diff-region-function 'ediff-show-all-diffs
510 "Function that determines the next/previous diff region to show.
511Should return t for regions to be ignored and nil otherwise.
3af0304a
MK
512This function gets a region number as an argument. The region number
513is the one used internally by Ediff. It is 1 less than the number seen
475f9031
KH
514by the user.")
515
8343426b 516(ediff-defvar-local ediff-hide-regexp-matches-function
acce6d21 517 'ediff-hide-regexp-matches
8343426b
MK
518 "Function to use in determining which regions to hide.
519See the documentation string of `ediff-hide-regexp-matches' for details.")
520(ediff-defvar-local ediff-focus-on-regexp-matches-function
521 'ediff-focus-on-regexp-matches
522 "Function to use in determining which regions to focus on.
523See the documentation string of `ediff-focus-on-regexp-matches' for details.")
524
475f9031
KH
525;; Regexp that determines buf A regions to focus on when skipping to diff
526(ediff-defvar-local ediff-regexp-focus-A "" "")
527;; Regexp that determines buf B regions to focus on when skipping to diff
528(ediff-defvar-local ediff-regexp-focus-B "" "")
529;; Regexp that determines buf C regions to focus on when skipping to diff
530(ediff-defvar-local ediff-regexp-focus-C "" "")
531;; connective that determines whether to focus regions that match both or
532;; one of the regexps
533(ediff-defvar-local ediff-focus-regexp-connective 'and "")
acce6d21 534
475f9031
KH
535;; Regexp that determines buf A regions to ignore when skipping to diff
536(ediff-defvar-local ediff-regexp-hide-A "" "")
537;; Regexp that determines buf B regions to ignore when skipping to diff
538(ediff-defvar-local ediff-regexp-hide-B "" "")
539;; Regexp that determines buf C regions to ignore when skipping to diff
540(ediff-defvar-local ediff-regexp-hide-C "" "")
541;; connective that determines whether to hide regions that match both or
542;; one of the regexps
543(ediff-defvar-local ediff-hide-regexp-connective 'and "")
1e70790f 544
acce6d21
TTN
545
546;;; Copying difference regions between buffers.
547
548;; A list of killed diffs.
1e70790f
MK
549;; A diff is saved here if it is replaced by a diff
550;; from another buffer. This alist has the form:
551;; \((num (buff-object . diff) (buff-object . diff) (buff-object . diff)) ...),
552;; where some buffer-objects may be missing.
553(ediff-defvar-local ediff-killed-diffs-alist nil "")
475f9031 554
4986c2c6
MK
555;; Syntax table to use in ediff-forward-word-function
556;; This is chosen by a heuristic. The important thing is for all buffers to
557;; have the same syntax table. Which is not too important.
558(ediff-defvar-local ediff-syntax-table nil "")
559
475f9031
KH
560
561;; Highlighting
1e70790f
MK
562(defcustom ediff-before-flag-bol (if ediff-xemacs-p (make-glyph "->>") "->>")
563 "*Flag placed before a highlighted block of differences, if block starts at beginning of a line."
564 :type 'string
565 :tag "Region before-flag at beginning of line"
566 :group 'ediff)
567
568(defcustom ediff-after-flag-eol (if ediff-xemacs-p (make-glyph "<<-") "<<-")
569 "*Flag placed after a highlighted block of differences, if block ends at end of a line."
570 :type 'string
571 :tag "Region after-flag at end of line"
572 :group 'ediff)
573
574(defcustom ediff-before-flag-mol (if ediff-xemacs-p (make-glyph "->>") "->>")
575 "*Flag placed before a highlighted block of differences, if block starts in mid-line."
576 :type 'string
577 :tag "Region before-flag in the middle of line"
578 :group 'ediff)
579(defcustom ediff-after-flag-mol (if ediff-xemacs-p (make-glyph "<<-") "<<-")
580 "*Flag placed after a highlighted block of differences, if block ends in mid-line."
581 :type 'string
582 :tag "Region after-flag in the middle of line"
583 :group 'ediff)
475f9031 584
acce6d21
TTN
585
586(ediff-defvar-local ediff-use-faces t "")
587(defcustom ediff-use-faces t
4ae69eac
MK
588 "If t, differences are highlighted using faces, if device supports faces.
589If nil, differences are highlighted using ASCII flags, ediff-before-flag
475f9031 590and ediff-after-flag. On a non-window system, differences are always
2eb4bdca
MK
591highlighted using ASCII flags."
592 :type 'boolean
593 :group 'ediff-highlighting)
475f9031 594
475f9031 595;; this indicates that diff regions are word-size, so fine diffs are
41d25ad0 596;; permanently nixed; used in ediff-windows-wordwise and ediff-regions-wordwise
475f9031 597(ediff-defvar-local ediff-word-mode nil "")
8343426b 598;; Name of the job (ediff-files, ediff-windows, etc.)
475f9031
KH
599(ediff-defvar-local ediff-job-name nil "")
600
601;; Narrowing and ediff-region/windows support
602;; This is a list (overlay-A overlay-B overlay-C)
603;; If set, Ediff compares only those parts of buffers A/B/C that lie within
604;; the bounds of these overlays.
605(ediff-defvar-local ediff-narrow-bounds nil "")
606
607;; List (overlay-A overlay-B overlay-C), where each overlay spans the
608;; entire corresponding buffer.
609(ediff-defvar-local ediff-wide-bounds nil "")
610
611;; Current visibility boundaries in buffers A, B, and C.
3af0304a 612;; This is also a list of overlays. When the user toggles narrow/widen,
475f9031
KH
613;; this list changes from ediff-wide-bounds to ediff-narrow-bounds.
614;; and back.
615(ediff-defvar-local ediff-visible-bounds nil "")
616
617(ediff-defvar-local ediff-start-narrowed t
41d25ad0 618 "Non-nil means start narrowed, if doing ediff-windows-* or ediff-regions-*")
475f9031
KH
619(ediff-defvar-local ediff-quit-widened t
620 "*Non-nil means: when finished, Ediff widens buffers A/B.
621Actually, Ediff restores the scope of visibility that existed at startup.")
1e70790f
MK
622
623(defcustom ediff-keep-variants t
b9fe4732 624 "*nil means prompt to remove unmodified buffers A/B/C at session end.
ceb0ea8b 625Supplying a prefix argument to the quit command `q' temporarily reverses the
1e70790f
MK
626meaning of this variable."
627 :type 'boolean
628 :group 'ediff)
475f9031 629
d84b06ef 630(ediff-defvar-local ediff-highlight-all-diffs t "")
2eb4bdca 631(defcustom ediff-highlight-all-diffs t
475f9031 632 "If nil, only the selected differences are highlighted.
2eb4bdca
MK
633Otherwise, all difference regions are highlighted, but the selected region is
634shown in brighter colors."
635 :type 'boolean
636 :group 'ediff-highlighting)
475f9031 637
acce6d21 638
475f9031
KH
639;; The suffix of the control buffer name.
640(ediff-defvar-local ediff-control-buffer-suffix nil "")
acce6d21 641;; Same as ediff-control-buffer-suffix, but without <,>.
475f9031
KH
642;; It's a number rather than string.
643(ediff-defvar-local ediff-control-buffer-number nil "")
644
645
475f9031 646;; The original values of ediff-protected-variables for buffer A
41d25ad0 647(ediff-defvar-local ediff-buffer-values-orig-A nil "")
475f9031 648;; The original values of ediff-protected-variables for buffer B
41d25ad0 649(ediff-defvar-local ediff-buffer-values-orig-B nil "")
475f9031 650;; The original values of ediff-protected-variables for buffer C
41d25ad0 651(ediff-defvar-local ediff-buffer-values-orig-C nil "")
8343426b
MK
652;; The original values of ediff-protected-variables for buffer Ancestor
653(ediff-defvar-local ediff-buffer-values-orig-Ancestor nil "")
1e70790f 654
e756eb9f
MK
655;; association between buff-type and ediff-buffer-values-orig-*
656(defconst ediff-buffer-values-orig-alist
657 '((A . ediff-buffer-values-orig-A)
658 (B . ediff-buffer-values-orig-B)
659 (C . ediff-buffer-values-orig-C)
660 (Ancestor . ediff-buffer-values-orig-Ancestor)))
661
475f9031 662;; Buffer-local variables to be saved then restored during Ediff sessions
92c51e07 663(defconst ediff-protected-variables '(
acce6d21 664 ;;buffer-read-only
475f9031
KH
665 mode-line-format))
666
475f9031
KH
667;; Vector of differences between the variants. Each difference is
668;; represented by a vector of two overlays plus a vector of fine diffs,
669;; plus a no-fine-diffs flag. The first overlay spans the
670;; difference region in the A buffer and the second overlays the diff in
3af0304a 671;; the B buffer. If a difference section is empty, the corresponding
475f9031
KH
672;; overlay's endpoints coincide.
673;;
3af0304a 674;; The precise form of a Difference Vector for one buffer is:
475f9031
KH
675;; [diff diff diff ...]
676;; where each diff has the form:
3af0304a 677;; [diff-overlay fine-diff-vector no-fine-diffs-flag state-of-diff]
475f9031
KH
678;; fine-diff-vector is a vector [fine-diff-overlay fine-diff-overlay ...]
679;; no-fine-diffs-flag says if there are fine differences.
680;; state-of-difference is A, B, C, or nil, indicating which buffer is
3af0304a 681;; different from the other two (used only in 3-way jobs.
475f9031
KH
682(ediff-defvar-local ediff-difference-vector-A nil "")
683(ediff-defvar-local ediff-difference-vector-B nil "")
684(ediff-defvar-local ediff-difference-vector-C nil "")
8343426b 685(ediff-defvar-local ediff-difference-vector-Ancestor nil "")
e756eb9f
MK
686;; A-list of diff vector types associated with buffer types
687(defconst ediff-difference-vector-alist
688 '((A . ediff-difference-vector-A)
689 (B . ediff-difference-vector-B)
690 (C . ediff-difference-vector-C)
691 (Ancestor . ediff-difference-vector-Ancestor)))
8343426b
MK
692
693;; [ status status status ...]
694;; Each status: [state-of-merge state-of-ancestor]
3af0304a 695;; state-of-merge is default-A, default-B, prefer-A, or prefer-B. It
8343426b
MK
696;; indicates the way a diff region was created in buffer C.
697;; state-of-ancestor says if the corresponding region in ancestor buffer is
698;; empty.
699(ediff-defvar-local ediff-state-of-merge nil "")
475f9031
KH
700
701;; The difference that is currently selected.
702(ediff-defvar-local ediff-current-difference -1 "")
703;; Number of differences found.
704(ediff-defvar-local ediff-number-of-differences nil "")
acce6d21 705
475f9031
KH
706;; Buffer containing the output of diff, which is used by Ediff to step
707;; through files.
708(ediff-defvar-local ediff-diff-buffer nil "")
3af0304a 709;; Like ediff-diff-buffer, but contains context diff. It is not used by
475f9031
KH
710;; Ediff, but it is saved in a file, if user requests so.
711(ediff-defvar-local ediff-custom-diff-buffer nil "")
712;; Buffer used for diff-style fine differences between regions.
713(ediff-defvar-local ediff-fine-diff-buffer nil "")
714;; Temporary buffer used for computing fine differences.
715(defconst ediff-tmp-buffer " *ediff-tmp*" "")
716;; Buffer used for messages
717(defconst ediff-msg-buffer " *ediff-message*" "")
718;; Buffer containing the output of diff when diff returns errors.
719(ediff-defvar-local ediff-error-buffer nil "")
720;; Buffer to display debug info
721(ediff-defvar-local ediff-debug-buffer "*ediff-debug*" "")
722
8343426b
MK
723;; List of ediff control panels associated with each buffer A/B/C/Ancestor.
724;; Not used any more, but may be needed in the future.
725(ediff-defvar-local ediff-this-buffer-ediff-sessions nil "")
475f9031
KH
726
727;; to be deleted in due time
728;; List of difference overlays disturbed by working with the current diff.
729(defvar ediff-disturbed-overlays nil "")
acce6d21 730
475f9031
KH
731;; Priority of non-selected overlays.
732(defvar ediff-shadow-overlay-priority 100 "")
733
1e70790f 734(defcustom ediff-version-control-package 'vc
8343426b 735 "Version control package used.
3af0304a
MK
736Currently, Ediff supports vc.el, rcs.el, pcl-cvs.el, and generic-sc.el. The
737standard Emacs interface to RCS, CVS, SCCS, etc., is vc.el. However, some
738people find the other two packages more convenient. Set this variable to the
1e70790f
MK
739appropriate symbol: `rcs', `pcl-cvs', or `generic-sc' if you so desire."
740 :type 'symbol
741 :group 'ediff)
8343426b 742
4960e757 743(defcustom ediff-coding-system-for-read 'raw-text
71296446 744 "*The coding system for read to use when running the diff program as a subprocess.
4960e757
MK
745In most cases, the default will do. However, under certain circumstances in
746Windows NT/98/95 you might need to use something like 'raw-text-dos here.
747So, if the output that your diff program sends to Emacs contains extra ^M's,
748you might need to experiment here, if the default or 'raw-text-dos doesn't
749work."
750 :type 'symbol
751 :group 'ediff)
752
753(defcustom ediff-coding-system-for-write 'no-conversion
754 "*The coding system for write to use when writing out difference regions
755to temp files when Ediff needs to find fine differences."
756 :type 'symbol
757 :group 'ediff)
758
475f9031 759
50a07e18
MK
760(ediff-cond-compile-for-xemacs-or-emacs
761 (progn ; xemacs
f3eabcdf
MK
762 (defalias 'ediff-read-event 'next-command-event)
763 (defalias 'ediff-overlayp 'extentp)
764 (defalias 'ediff-make-overlay 'make-extent)
765 (defalias 'ediff-delete-overlay 'delete-extent))
50a07e18 766 (progn ; emacs
f3eabcdf
MK
767 (defalias 'ediff-read-event 'read-event)
768 (defalias 'ediff-overlayp 'overlayp)
769 (defalias 'ediff-make-overlay 'make-overlay)
770 (defalias 'ediff-delete-overlay 'delete-overlay))
50a07e18 771 )
acce6d21 772
41d25ad0
KH
773;; Check the current version against the major and minor version numbers
774;; using op: cur-vers op major.minor If emacs-major-version or
775;; emacs-minor-version are not defined, we assume that the current version
776;; is hopelessly outdated. We assume that emacs-major-version and
777;; emacs-minor-version are defined. Otherwise, for Emacs/XEmacs 19, if the
778;; current minor version is < 10 (xemacs) or < 23 (emacs) the return value
779;; will be nil (when op is =, >, or >=) and t (when op is <, <=), which may be
3af0304a 780;; incorrect. However, this gives correct result in our cases, since we are
41d25ad0
KH
781;; testing for sufficiently high Emacs versions.
782(defun ediff-check-version (op major minor &optional type-of-emacs)
783 (if (and (boundp 'emacs-major-version) (boundp 'emacs-minor-version))
784 (and (cond ((eq type-of-emacs 'xemacs) ediff-xemacs-p)
785 ((eq type-of-emacs 'emacs) ediff-emacs-p)
786 (t t))
787 (cond ((eq op '=) (and (= emacs-minor-version minor)
788 (= emacs-major-version major)))
789 ((memq op '(> >= < <=))
790 (and (or (funcall op emacs-major-version major)
791 (= emacs-major-version major))
792 (if (= emacs-major-version major)
793 (funcall op emacs-minor-version minor)
794 t)))
795 (t
796 (error "%S: Invalid op in ediff-check-version" op))))
797 (cond ((memq op '(= > >=)) nil)
798 ((memq op '(< <=)) t))))
acce6d21
TTN
799
800
d396e521
MK
801(defun ediff-color-display-p ()
802 (condition-case nil
50a07e18
MK
803 (ediff-cond-compile-for-xemacs-or-emacs
804 (eq (device-class (selected-device)) 'color) ; xemacs form
805 (if (fboundp 'display-color-p) ; emacs form
806 (display-color-p)
807 (x-display-color-p))
808 )
809 (error nil)))
8343426b 810
acce6d21 811
743a79af
MK
812;; A var local to each control panel buffer. Indicates highlighting style
813;; in effect for this buffer: `face', `ascii',
814;; `off' -- turned off \(on a dumb terminal only\).
71296446 815(ediff-defvar-local ediff-highlighting-style
743a79af
MK
816 (if (and (ediff-has-face-support-p) ediff-use-faces) 'face 'ascii)
817 "")
818
819
4ae69eac 820(if (ediff-has-face-support-p)
50a07e18
MK
821 (ediff-cond-compile-for-xemacs-or-emacs
822 (progn ; xemacs
823 (defalias 'ediff-valid-color-p 'valid-color-name-p)
824 (defalias 'ediff-get-face 'get-face))
825 (progn ; emacs
826 (defalias 'ediff-valid-color-p (if (fboundp 'color-defined-p)
827 'color-defined-p
828 'x-color-defined-p))
829 (defalias 'ediff-get-face 'internal-get-face))
830 ))
4ae69eac
MK
831
832(if (ediff-window-display-p)
50a07e18
MK
833 (ediff-cond-compile-for-xemacs-or-emacs
834 (progn ; xemacs
f3eabcdf
MK
835 (defalias 'ediff-display-pixel-width 'device-pixel-width)
836 (defalias 'ediff-display-pixel-height 'device-pixel-height))
50a07e18 837 (progn ; emacs
f3eabcdf 838 (defalias 'ediff-display-pixel-width
50a07e18 839 (if (fboundp 'display-pixel-width)
f3eabcdf
MK
840 'display-pixel-width
841 'x-display-pixel-width))
842 (defalias 'ediff-display-pixel-height
50a07e18 843 (if (fboundp 'display-pixel-height)
f3eabcdf
MK
844 'display-pixel-height
845 'x-display-pixel-height)))
50a07e18 846 ))
acce6d21 847
657f9cb8 848;; A-list of current-diff-overlay symbols associated with buf types
e756eb9f
MK
849(defconst ediff-current-diff-overlay-alist
850 '((A . ediff-current-diff-overlay-A)
851 (B . ediff-current-diff-overlay-B)
852 (C . ediff-current-diff-overlay-C)
853 (Ancestor . ediff-current-diff-overlay-Ancestor)))
acce6d21 854
657f9cb8 855;; A-list of current-diff-face-* symbols associated with buf types
e756eb9f
MK
856(defconst ediff-current-diff-face-alist
857 '((A . ediff-current-diff-face-A)
858 (B . ediff-current-diff-face-B)
859 (C . ediff-current-diff-face-C)
860 (Ancestor . ediff-current-diff-face-Ancestor)))
acce6d21 861
475f9031 862
8343426b
MK
863(defun ediff-set-overlay-face (extent face)
864 (ediff-overlay-put extent 'face face)
865 (ediff-overlay-put extent 'help-echo 'ediff-region-help-echo))
acce6d21 866
475de6f4
DL
867(defun ediff-region-help-echo (extent-or-window &optional overlay point)
868 (unless overlay
869 (setq overlay extent-or-window))
870 (let ((is-current (ediff-overlay-get overlay 'ediff))
871 (face (ediff-overlay-get overlay 'face))
a21f0bd5
DL
872 (diff-num (ediff-overlay-get overlay 'ediff-diff-num))
873 face-help)
8343426b
MK
874
875 ;; This happens only for refinement overlays
475de6f4
DL
876 (if (stringp face)
877 (setq face (intern face)))
8343426b
MK
878 (setq face-help (and face (get face 'ediff-help-echo)))
879
50575ec2 880 (cond ((and is-current diff-num) ; current diff region
bbe6126c 881 (format "Difference region %S -- current" (1+ diff-num)))
475de6f4 882 (face-help) ; refinement of current diff region
50575ec2 883 (diff-num ; non-current
bbe6126c 884 (format "Difference region %S -- non-current" (1+ diff-num)))
50575ec2 885 (t "")) ; none
30729019 886 ))
8343426b 887
36d57fa9 888
92c51e07
MK
889(defun ediff-set-face-pixmap (face pixmap)
890 "Set face pixmap on a monochrome display."
891 (if (and (ediff-window-display-p) (not (ediff-color-display-p)))
892 (condition-case nil
893 (set-face-background-pixmap face pixmap)
894 (error
895 (message "Pixmap not found for %S: %s" (face-name face) pixmap)
896 (sit-for 1)))))
897
4ae69eac 898(defun ediff-hide-face (face)
17561e4f
MK
899 (if (and (ediff-has-face-support-p)
900 (boundp 'add-to-list)
7d0b18b1 901 (boundp 'facemenu-unlisted-faces))
4ae69eac 902 (add-to-list 'facemenu-unlisted-faces face)))
acce6d21 903
475f9031 904
985d0dad 905
fa735daa 906(defface ediff-current-diff-A
66507a7a
KS
907 (if ediff-emacs-p
908 '((((class color) (min-colors 16))
909 (:foreground "firebrick" :background "pale green"))
910 (((class color))
911 (:foreground "blue3" :background "yellow3"))
912 (t (:inverse-video t)))
913 '((((type tty)) (:foreground "blue3" :background "yellow3"))
914 (((class color)) (:foreground "firebrick" :background "pale green"))
915 (t (:inverse-video t))))
985d0dad
MK
916 "Face for highlighting the selected difference in buffer A."
917 :group 'ediff-highlighting)
fa735daa
MB
918;; backward-compatibility alias
919(put 'ediff-current-diff-face-A 'face-alias 'ediff-current-diff-A)
3af0304a 920;; An internal variable. Ediff takes the face from here. When unhighlighting,
985d0dad 921;; this variable is set to nil, then again to the appropriate face.
fa735daa 922(defvar ediff-current-diff-face-A 'ediff-current-diff-A
8e41a31c 923 "Face for highlighting the selected difference in buffer A.
3af0304a 924DO NOT CHANGE this variable. Instead, use the customization
fa735daa 925widget to customize the actual face object `ediff-current-diff-A'
8e41a31c 926this variable represents.")
fa735daa 927(ediff-hide-face 'ediff-current-diff-A)
985d0dad
MK
928;; Until custom.el for XEmacs starts supporting :inverse-video we do this.
929;; This means that some user customization may be trashed.
930(if (and ediff-xemacs-p
931 (ediff-has-face-support-p)
acce6d21 932 (not (ediff-color-display-p)))
fa735daa 933 (copy-face 'modeline 'ediff-current-diff-A))
985d0dad
MK
934
935
936
fa735daa 937(defface ediff-current-diff-B
66507a7a
KS
938 (if ediff-emacs-p
939 '((((class color) (min-colors 16))
940 (:foreground "DarkOrchid" :background "Yellow"))
941 (((class color))
942 (:foreground "magenta3" :background "yellow3"
943 :weight bold))
944 (t (:inverse-video t)))
945 '((((type tty)) (:foreground "magenta3" :background "yellow3"
946 :weight bold))
947 (((class color)) (:foreground "DarkOrchid" :background "Yellow"))
948 (t (:inverse-video t))))
985d0dad
MK
949 "Face for highlighting the selected difference in buffer B."
950 :group 'ediff-highlighting)
fa735daa
MB
951;; backward-compatibility alias
952(put 'ediff-current-diff-face-B 'face-alias 'ediff-current-diff-B)
3af0304a 953;; An internal variable. Ediff takes the face from here. When unhighlighting,
985d0dad 954;; this variable is set to nil, then again to the appropriate face.
fa735daa 955(defvar ediff-current-diff-face-B 'ediff-current-diff-B
8e41a31c 956 "Face for highlighting the selected difference in buffer B.
3af0304a 957 this variable. Instead, use the customization
fa735daa 958widget to customize the actual face `ediff-current-diff-B'
8e41a31c 959this variable represents.")
fa735daa 960(ediff-hide-face 'ediff-current-diff-B)
985d0dad
MK
961;; Until custom.el for XEmacs starts supporting :inverse-video we do this.
962;; This means that some user customization may be trashed.
963(if (and ediff-xemacs-p
964 (ediff-has-face-support-p)
acce6d21 965 (not (ediff-color-display-p)))
fa735daa 966 (copy-face 'modeline 'ediff-current-diff-B))
985d0dad 967
985d0dad 968
fa735daa 969(defface ediff-current-diff-C
66507a7a
KS
970 (if ediff-emacs-p
971 '((((class color) (min-colors 16))
972 (:foreground "Navy" :background "Pink"))
973 (((class color))
974 (:foreground "cyan3" :background "yellow3" :weight bold))
975 (t (:inverse-video t)))
976 '((((type tty)) (:foreground "cyan3" :background "yellow3" :weight bold))
977 (((class color)) (:foreground "Navy" :background "Pink"))
978 (t (:inverse-video t))))
985d0dad
MK
979 "Face for highlighting the selected difference in buffer C."
980 :group 'ediff-highlighting)
fa735daa
MB
981;; backward-compatibility alias
982(put 'ediff-current-diff-face-C 'face-alias 'ediff-current-diff-C)
3af0304a 983;; An internal variable. Ediff takes the face from here. When unhighlighting,
985d0dad 984;; this variable is set to nil, then again to the appropriate face.
fa735daa 985(defvar ediff-current-diff-face-C 'ediff-current-diff-C
8e41a31c 986 "Face for highlighting the selected difference in buffer C.
3af0304a 987DO NOT CHANGE this variable. Instead, use the customization
fa735daa 988widget to customize the actual face object `ediff-current-diff-C'
8e41a31c 989this variable represents.")
fa735daa 990(ediff-hide-face 'ediff-current-diff-C)
985d0dad
MK
991;; Until custom.el for XEmacs starts supporting :inverse-video we do this.
992;; This means that some user customization may be trashed.
993(if (and ediff-xemacs-p
994 (ediff-has-face-support-p)
acce6d21 995 (not (ediff-color-display-p)))
fa735daa 996 (copy-face 'modeline 'ediff-current-diff-C))
985d0dad 997
985d0dad 998
fa735daa 999(defface ediff-current-diff-Ancestor
66507a7a
KS
1000 (if ediff-emacs-p
1001 '((((class color) (min-colors 16))
1002 (:foreground "Black" :background "VioletRed"))
1003 (((class color))
1004 (:foreground "black" :background "magenta3"))
1005 (t (:inverse-video t)))
1006 '((((type tty)) (:foreground "black" :background "magenta3"))
1007 (((class color)) (:foreground "Black" :background "VioletRed"))
1008 (t (:inverse-video t))))
985d0dad
MK
1009 "Face for highlighting the selected difference in buffer Ancestor."
1010 :group 'ediff-highlighting)
fa735daa
MB
1011;; backward-compatibility alias
1012(put 'ediff-current-diff-face-Ancestor 'face-alias 'ediff-current-diff-Ancestor)
3af0304a 1013;; An internal variable. Ediff takes the face from here. When unhighlighting,
985d0dad 1014;; this variable is set to nil, then again to the appropriate face.
fa735daa 1015(defvar ediff-current-diff-face-Ancestor 'ediff-current-diff-Ancestor
8e41a31c 1016 "Face for highlighting the selected difference in buffer Ancestor.
3af0304a 1017DO NOT CHANGE this variable. Instead, use the customization
fa735daa 1018widget to customize the actual face object `ediff-current-diff-Ancestor'
8e41a31c 1019this variable represents.")
fa735daa 1020(ediff-hide-face 'ediff-current-diff-Ancestor)
985d0dad
MK
1021;; Until custom.el for XEmacs starts supporting :inverse-video we do this.
1022;; This means that some user customization may be trashed.
1023(if (and ediff-xemacs-p
1024 (ediff-has-face-support-p)
acce6d21 1025 (not (ediff-color-display-p)))
fa735daa 1026 (copy-face 'modeline 'ediff-current-diff-Ancestor))
985d0dad 1027
985d0dad 1028
fa735daa 1029(defface ediff-fine-diff-A
66507a7a
KS
1030 (if ediff-emacs-p
1031 '((((class color) (min-colors 16))
1032 (:foreground "Navy" :background "sky blue"))
1033 (((class color))
1034 (:foreground "white" :background "sky blue" :weight bold))
1035 (t (:underline t :stipple "gray3")))
1036 '((((type tty)) (:foreground "white" :background "sky blue" :weight bold))
1037 (((class color)) (:foreground "Navy" :background "sky blue"))
1038 (t (:underline t :stipple "gray3"))))
985d0dad
MK
1039 "Face for highlighting the refinement of the selected diff in buffer A."
1040 :group 'ediff-highlighting)
fa735daa
MB
1041;; backward-compatibility alias
1042(put 'ediff-fine-diff-face-A 'face-alias 'ediff-fine-diff-A)
3af0304a 1043;; An internal variable. Ediff takes the face from here. When unhighlighting,
985d0dad 1044;; this variable is set to nil, then again to the appropriate face.
fa735daa 1045(defvar ediff-fine-diff-face-A 'ediff-fine-diff-A
8e41a31c 1046 "Face for highlighting the fine differences in buffer A.
3af0304a 1047DO NOT CHANGE this variable. Instead, use the customization
fa735daa 1048widget to customize the actual face object `ediff-fine-diff-A'
8e41a31c 1049this variable represents.")
fa735daa 1050(ediff-hide-face 'ediff-fine-diff-A)
c004db97 1051
fa735daa 1052(defface ediff-fine-diff-B
66507a7a
KS
1053 (if ediff-emacs-p
1054 '((((class color) (min-colors 16))
1055 (:foreground "Black" :background "cyan"))
1056 (((class color))
1057 (:foreground "magenta3" :background "cyan3"))
1058 (t (:underline t :stipple "gray3")))
1059 '((((type tty)) (:foreground "magenta3" :background "cyan3"))
1060 (((class color)) (:foreground "Black" :background "cyan"))
1061 (t (:underline t :stipple "gray3"))))
985d0dad
MK
1062 "Face for highlighting the refinement of the selected diff in buffer B."
1063 :group 'ediff-highlighting)
fa735daa
MB
1064;; backward-compatibility alias
1065(put 'ediff-fine-diff-face-B 'face-alias 'ediff-fine-diff-B)
3af0304a 1066;; An internal variable. Ediff takes the face from here. When unhighlighting,
985d0dad 1067;; this variable is set to nil, then again to the appropriate face.
fa735daa 1068(defvar ediff-fine-diff-face-B 'ediff-fine-diff-B
8e41a31c 1069 "Face for highlighting the fine differences in buffer B.
3af0304a 1070DO NOT CHANGE this variable. Instead, use the customization
fa735daa 1071widget to customize the actual face object `ediff-fine-diff-B'
8e41a31c 1072this variable represents.")
fa735daa 1073(ediff-hide-face 'ediff-fine-diff-B)
c004db97 1074
fa735daa 1075(defface ediff-fine-diff-C
66507a7a
KS
1076 (if ediff-emacs-p
1077 '((((type pc))
1078 (:foreground "white" :background "Turquoise"))
1079 (((class color) (min-colors 16))
1080 (:foreground "Black" :background "Turquoise"))
1081 (((class color))
1082 (:foreground "yellow3" :background "Turquoise"
1083 :weight bold))
1084 (t (:underline t :stipple "gray3")))
1085 '((((type tty)) (:foreground "yellow3" :background "Turquoise"
1086 :weight bold))
1087 (((type pc)) (:foreground "white" :background "Turquoise"))
1088 (((class color)) (:foreground "Black" :background "Turquoise"))
1089 (t (:underline t :stipple "gray3"))))
985d0dad
MK
1090 "Face for highlighting the refinement of the selected diff in buffer C."
1091 :group 'ediff-highlighting)
fa735daa
MB
1092;; backward-compatibility alias
1093(put 'ediff-fine-diff-face-C 'face-alias 'ediff-fine-diff-C)
3af0304a 1094;; An internal variable. Ediff takes the face from here. When unhighlighting,
985d0dad 1095;; this variable is set to nil, then again to the appropriate face.
fa735daa 1096(defvar ediff-fine-diff-face-C 'ediff-fine-diff-C
8e41a31c 1097 "Face for highlighting the fine differences in buffer C.
3af0304a 1098DO NOT CHANGE this variable. Instead, use the customization
fa735daa 1099widget to customize the actual face object `ediff-fine-diff-C'
8e41a31c 1100this variable represents.")
fa735daa 1101(ediff-hide-face 'ediff-fine-diff-C)
c004db97 1102
fa735daa 1103(defface ediff-fine-diff-Ancestor
66507a7a
KS
1104 (if ediff-emacs-p
1105 '((((class color) (min-colors 16))
1106 (:foreground "Black" :background "Green"))
1107 (((class color))
1108 (:foreground "red3" :background "green"))
1109 (t (:underline t :stipple "gray3")))
1110 '((((type tty)) (:foreground "red3" :background "green"))
1111 (((class color)) (:foreground "Black" :background "Green"))
1112 (t (:underline t :stipple "gray3"))))
985d0dad
MK
1113 "Face for highlighting the refinement of the selected diff in the ancestor buffer.
1114At present, this face is not used and no fine differences are computed for the
1115ancestor buffer."
1116 :group 'ediff-highlighting)
fa735daa
MB
1117;; backward-compatibility alias
1118(put 'ediff-fine-diff-face-Ancestor 'face-alias 'ediff-fine-diff-Ancestor)
3af0304a 1119;; An internal variable. Ediff takes the face from here. When unhighlighting,
985d0dad 1120;; this variable is set to nil, then again to the appropriate face.
fa735daa 1121(defvar ediff-fine-diff-face-Ancestor 'ediff-fine-diff-Ancestor
8e41a31c 1122 "Face for highlighting the fine differences in buffer Ancestor.
3af0304a 1123DO NOT CHANGE this variable. Instead, use the customization
fa735daa 1124widget to customize the actual face object `ediff-fine-diff-Ancestor'
8e41a31c 1125this variable represents.")
fa735daa 1126(ediff-hide-face 'ediff-fine-diff-Ancestor)
c004db97 1127
3af0304a
MK
1128;; Some installs don't have stipple or Stipple. So, try them in turn.
1129(defvar stipple-pixmap
086171bf 1130 (cond ((not (ediff-has-face-support-p)) nil)
3af0304a
MK
1131 ((and (boundp 'x-bitmap-file-path)
1132 (locate-library "stipple" t x-bitmap-file-path)) "stipple")
1133 ((and (boundp 'mswindowsx-bitmap-file-path)
1134 (locate-library "stipple" t mswindowsx-bitmap-file-path)) "stipple")
1135 (t "Stipple")))
1136
fa735daa 1137(defface ediff-even-diff-A
66507a7a
KS
1138 (if ediff-emacs-p
1139 `((((type pc))
1140 (:foreground "green3" :background "light grey"))
1141 (((class color) (min-colors 16))
1142 (:foreground "Black" :background "light grey"))
1143 (((class color))
1144 (:foreground "red3" :background "light grey"
1145 :weight bold))
1146 (t (:italic t :stipple ,stipple-pixmap)))
1147 `((((type tty)) (:foreground "red3" :background "light grey"
1148 :weight bold))
1149 (((type pc)) (:foreground "green3" :background "light grey"))
1150 (((class color)) (:foreground "Black" :background "light grey"))
1151 (t (:italic t :stipple ,stipple-pixmap))))
985d0dad
MK
1152 "Face for highlighting even-numbered non-current differences in buffer A."
1153 :group 'ediff-highlighting)
fa735daa
MB
1154;; backward-compatibility alias
1155(put 'ediff-even-diff-face-A 'face-alias 'ediff-even-diff-A)
3af0304a 1156;; An internal variable. Ediff takes the face from here. When unhighlighting,
985d0dad 1157;; this variable is set to nil, then again to the appropriate face.
fa735daa 1158(defvar ediff-even-diff-face-A 'ediff-even-diff-A
8e41a31c 1159 "Face for highlighting even-numbered non-current differences in buffer A.
3af0304a 1160DO NOT CHANGE this variable. Instead, use the customization
fa735daa 1161widget to customize the actual face object `ediff-even-diff-A'
8e41a31c 1162this variable represents.")
fa735daa 1163(ediff-hide-face 'ediff-even-diff-A)
c004db97 1164
fa735daa 1165(defface ediff-even-diff-B
66507a7a 1166 (if ediff-emacs-p
1e39fa26 1167 `((((class color) (min-colors 16))
66507a7a 1168 (:foreground "White" :background "Grey"))
1e39fa26 1169 (((class color))
66507a7a
KS
1170 (:foreground "blue3" :background "Grey" :weight bold))
1171 (t (:italic t :stipple ,stipple-pixmap)))
1172 `((((type tty)) (:foreground "blue3" :background "Grey" :weight bold))
1173 (((class color)) (:foreground "White" :background "Grey"))
1174 (t (:italic t :stipple ,stipple-pixmap))))
985d0dad
MK
1175 "Face for highlighting even-numbered non-current differences in buffer B."
1176 :group 'ediff-highlighting)
fa735daa
MB
1177;; backward-compatibility alias
1178(put 'ediff-even-diff-face-B 'face-alias 'ediff-even-diff-B)
3af0304a 1179;; An internal variable. Ediff takes the face from here. When unhighlighting,
985d0dad 1180;; this variable is set to nil, then again to the appropriate face.
fa735daa 1181(defvar ediff-even-diff-face-B 'ediff-even-diff-B
8e41a31c 1182 "Face for highlighting even-numbered non-current differences in buffer B.
3af0304a 1183DO NOT CHANGE this variable. Instead, use the customization
fa735daa 1184widget to customize the actual face object `ediff-even-diff-B'
8e41a31c 1185this variable represents.")
fa735daa 1186(ediff-hide-face 'ediff-even-diff-B)
c004db97 1187
fa735daa 1188(defface ediff-even-diff-C
66507a7a
KS
1189 (if ediff-emacs-p
1190 `((((type pc))
1191 (:foreground "yellow3" :background "light grey"))
1192 (((class color) (min-colors 16))
1193 (:foreground "Black" :background "light grey"))
1194 (((class color))
1195 (:foreground "yellow3" :background "light grey"
1196 :weight bold))
1197 (t (:italic t :stipple ,stipple-pixmap)))
1198 `((((type tty)) (:foreground "yellow3" :background "light grey"
1199 :weight bold))
1200 (((type pc)) (:foreground "yellow3" :background "light grey"))
1201 (((class color)) (:foreground "Black" :background "light grey"))
1202 (t (:italic t :stipple ,stipple-pixmap))))
985d0dad
MK
1203 "Face for highlighting even-numbered non-current differences in buffer C."
1204 :group 'ediff-highlighting)
fa735daa
MB
1205;; backward-compatibility alias
1206(put 'ediff-even-diff-face-C 'face-alias 'ediff-even-diff-C)
3af0304a 1207;; An internal variable. Ediff takes the face from here. When unhighlighting,
985d0dad 1208;; this variable is set to nil, then again to the appropriate face.
fa735daa 1209(defvar ediff-even-diff-face-C 'ediff-even-diff-C
8e41a31c 1210 "Face for highlighting even-numbered non-current differences in buffer C.
3af0304a 1211DO NOT CHANGE this variable. Instead, use the customization
fa735daa 1212widget to customize the actual face object `ediff-even-diff-C'
8e41a31c 1213this variable represents.")
fa735daa 1214(ediff-hide-face 'ediff-even-diff-C)
c004db97 1215
fa735daa 1216(defface ediff-even-diff-Ancestor
66507a7a
KS
1217 (if ediff-emacs-p
1218 `((((type pc))
1219 (:foreground "cyan3" :background "light grey"))
1220 (((class color) (min-colors 16))
1221 (:foreground "White" :background "Grey"))
1222 (((class color))
1223 (:foreground "cyan3" :background "light grey"
1224 :weight bold))
1225 (t (:italic t :stipple ,stipple-pixmap)))
1226 `((((type tty)) (:foreground "cyan3" :background "light grey"
1227 :weight bold))
1228 (((type pc)) (:foreground "cyan3" :background "light grey"))
1229 (((class color)) (:foreground "White" :background "Grey"))
1230 (t (:italic t :stipple ,stipple-pixmap))))
985d0dad
MK
1231 "Face for highlighting even-numbered non-current differences in the ancestor buffer."
1232 :group 'ediff-highlighting)
fa735daa
MB
1233;; backward-compatibility alias
1234(put 'ediff-even-diff-face-Ancestor 'face-alias 'ediff-even-diff-Ancestor)
3af0304a 1235;; An internal variable. Ediff takes the face from here. When unhighlighting,
985d0dad 1236;; this variable is set to nil, then again to the appropriate face.
fa735daa 1237(defvar ediff-even-diff-face-Ancestor 'ediff-even-diff-Ancestor
8e41a31c 1238 "Face for highlighting even-numbered non-current differences in buffer Ancestor.
3af0304a 1239DO NOT CHANGE this variable. Instead, use the customization
fa735daa 1240widget to customize the actual face object `ediff-even-diff-Ancestor'
8e41a31c 1241this variable represents.")
fa735daa 1242(ediff-hide-face 'ediff-even-diff-Ancestor)
c004db97 1243
e756eb9f
MK
1244;; Association between buffer types and even-diff-face symbols
1245(defconst ediff-even-diff-face-alist
fa735daa
MB
1246 '((A . ediff-even-diff-A)
1247 (B . ediff-even-diff-B)
1248 (C . ediff-even-diff-C)
1249 (Ancestor . ediff-even-diff-Ancestor)))
e756eb9f 1250
fa735daa 1251(defface ediff-odd-diff-A
66507a7a
KS
1252 (if ediff-emacs-p
1253 '((((type pc))
1254 (:foreground "green3" :background "gray40"))
1255 (((class color) (min-colors 16))
1256 (:foreground "White" :background "Grey"))
1257 (((class color))
1258 (:foreground "red3" :background "black" :weight bold))
1259 (t (:italic t :stipple "gray1")))
1260 '((((type tty)) (:foreground "red3" :background "black" :weight bold))
1261 (((type pc)) (:foreground "green3" :background "gray40"))
1262 (((class color)) (:foreground "White" :background "Grey"))
1263 (t (:italic t :stipple "gray1"))))
985d0dad
MK
1264 "Face for highlighting odd-numbered non-current differences in buffer A."
1265 :group 'ediff-highlighting)
fa735daa
MB
1266;; backward-compatibility alias
1267(put 'ediff-odd-diff-face-A 'face-alias 'ediff-odd-diff-A)
3af0304a 1268;; An internal variable. Ediff takes the face from here. When unhighlighting,
985d0dad 1269;; this variable is set to nil, then again to the appropriate face.
fa735daa 1270(defvar ediff-odd-diff-face-A 'ediff-odd-diff-A
8e41a31c 1271 "Face for highlighting odd-numbered non-current differences in buffer A.
3af0304a 1272DO NOT CHANGE this variable. Instead, use the customization
fa735daa 1273widget to customize the actual face object `ediff-odd-diff-A'
8e41a31c 1274this variable represents.")
fa735daa 1275(ediff-hide-face 'ediff-odd-diff-A)
c004db97 1276
985d0dad 1277
fa735daa 1278(defface ediff-odd-diff-B
66507a7a
KS
1279 (if ediff-emacs-p
1280 '((((type pc))
1281 (:foreground "White" :background "gray40"))
1282 (((class color) (min-colors 16))
1283 (:foreground "Black" :background "light grey"))
1284 (((class color))
1285 (:foreground "cyan3" :background "black" :weight bold))
1286 (t (:italic t :stipple "gray1")))
1287 '((((type tty)) (:foreground "cyan3" :background "black" :weight bold))
1288 (((type pc)) (:foreground "White" :background "gray40"))
1289 (((class color)) (:foreground "Black" :background "light grey"))
1290 (t (:italic t :stipple "gray1"))))
985d0dad
MK
1291 "Face for highlighting odd-numbered non-current differences in buffer B."
1292 :group 'ediff-highlighting)
fa735daa
MB
1293;; backward-compatibility alias
1294(put 'ediff-odd-diff-face-B 'face-alias 'ediff-odd-diff-B)
3af0304a 1295;; An internal variable. Ediff takes the face from here. When unhighlighting,
985d0dad 1296;; this variable is set to nil, then again to the appropriate face.
fa735daa 1297(defvar ediff-odd-diff-face-B 'ediff-odd-diff-B
8e41a31c 1298 "Face for highlighting odd-numbered non-current differences in buffer B.
3af0304a 1299DO NOT CHANGE this variable. Instead, use the customization
fa735daa 1300widget to customize the actual face object `ediff-odd-diff-B'
8e41a31c 1301this variable represents.")
fa735daa 1302(ediff-hide-face 'ediff-odd-diff-B)
c004db97 1303
fa735daa 1304(defface ediff-odd-diff-C
66507a7a
KS
1305 (if ediff-emacs-p
1306 '((((type pc))
1307 (:foreground "yellow3" :background "gray40"))
1308 (((class color) (min-colors 16))
1309 (:foreground "White" :background "Grey"))
1310 (((class color))
1311 (:foreground "yellow3" :background "black" :weight bold))
1312 (t (:italic t :stipple "gray1")))
1313 '((((type tty)) (:foreground "yellow3" :background "black" :weight bold))
1314 (((type pc)) (:foreground "yellow3" :background "gray40"))
1315 (((class color)) (:foreground "White" :background "Grey"))
1316 (t (:italic t :stipple "gray1"))))
985d0dad
MK
1317 "Face for highlighting odd-numbered non-current differences in buffer C."
1318 :group 'ediff-highlighting)
fa735daa
MB
1319;; backward-compatibility alias
1320(put 'ediff-odd-diff-face-C 'face-alias 'ediff-odd-diff-C)
3af0304a 1321;; An internal variable. Ediff takes the face from here. When unhighlighting,
985d0dad 1322;; this variable is set to nil, then again to the appropriate face.
fa735daa 1323(defvar ediff-odd-diff-face-C 'ediff-odd-diff-C
8e41a31c 1324 "Face for highlighting odd-numbered non-current differences in buffer C.
3af0304a 1325DO NOT CHANGE this variable. Instead, use the customization
fa735daa 1326widget to customize the actual face object `ediff-odd-diff-C'
8e41a31c 1327this variable represents.")
fa735daa 1328(ediff-hide-face 'ediff-odd-diff-C)
c004db97 1329
fa735daa 1330(defface ediff-odd-diff-Ancestor
66507a7a
KS
1331 (if ediff-emacs-p
1332 '((((class color) (min-colors 16))
1333 (:foreground "cyan3" :background "gray40"))
1334 (((class color))
1335 (:foreground "green3" :background "black" :weight bold))
1336 (t (:italic t :stipple "gray1")))
1337 '((((type tty)) (:foreground "green3" :background "black" :weight bold))
1338 (((class color)) (:foreground "cyan3" :background "gray40"))
1339 (t (:italic t :stipple "gray1"))))
985d0dad
MK
1340 "Face for highlighting odd-numbered non-current differences in the ancestor buffer."
1341 :group 'ediff-highlighting)
fa735daa
MB
1342;; backward-compatibility alias
1343(put 'ediff-odd-diff-face-Ancestor 'face-alias 'ediff-odd-diff-Ancestor)
3af0304a 1344;; An internal variable. Ediff takes the face from here. When unhighlighting,
985d0dad 1345;; this variable is set to nil, then again to the appropriate face.
fa735daa 1346(defvar ediff-odd-diff-face-Ancestor 'ediff-odd-diff-Ancestor
8e41a31c 1347 "Face for highlighting odd-numbered non-current differences in buffer Ancestor.
3af0304a 1348DO NOT CHANGE this variable. Instead, use the customization
fa735daa 1349widget to customize the actual face object `ediff-odd-diff-Ancestor'
8e41a31c 1350this variable represents.")
fa735daa 1351(ediff-hide-face 'ediff-odd-diff-Ancestor)
c004db97 1352
e756eb9f
MK
1353;; Association between buffer types and odd-diff-face symbols
1354(defconst ediff-odd-diff-face-alist
1355 '((A . ediff-odd-diff-face-A)
1356 (B . ediff-odd-diff-face-B)
1357 (C . ediff-odd-diff-face-C)
1358 (Ancestor . ediff-odd-diff-face-Ancestor)))
acce6d21 1359
e756eb9f
MK
1360;; A-list of fine-diff face symbols associated with buffer types
1361(defconst ediff-fine-diff-face-alist
1362 '((A . ediff-fine-diff-face-A)
1363 (B . ediff-fine-diff-face-B)
1364 (C . ediff-fine-diff-face-C)
1365 (Ancestor . ediff-fine-diff-face-Ancestor)))
1366
8343426b 1367;; Help echo
fa735daa 1368(put 'ediff-fine-diff-A 'ediff-help-echo
8343426b 1369 "A `refinement' of the current difference region")
fa735daa 1370(put 'ediff-fine-diff-B 'ediff-help-echo
8343426b 1371 "A `refinement' of the current difference region")
fa735daa 1372(put 'ediff-fine-diff-C 'ediff-help-echo
8343426b 1373 "A `refinement' of the current difference region")
fa735daa 1374(put 'ediff-fine-diff-Ancestor 'ediff-help-echo
8343426b
MK
1375 "A `refinement' of the current difference region")
1376
7261ece3
MK
1377(add-hook 'ediff-quit-hook 'ediff-cleanup-mess)
1378(add-hook 'ediff-suspend-hook 'ediff-default-suspend-function)
1379
475f9031
KH
1380
1381;;; Overlays
1382
8343426b
MK
1383(ediff-defvar-local ediff-current-diff-overlay-A nil
1384 "Overlay for the current difference region in buffer A.")
1385(ediff-defvar-local ediff-current-diff-overlay-B nil
1386 "Overlay for the current difference region in buffer B.")
1387(ediff-defvar-local ediff-current-diff-overlay-C nil
1388 "Overlay for the current difference region in buffer C.")
1389(ediff-defvar-local ediff-current-diff-overlay-Ancestor nil
1390 "Overlay for the current difference region in the ancestor buffer.")
e756eb9f 1391
4960e757 1392;; Compute priority of a current ediff overlay.
8343426b
MK
1393(defun ediff-highest-priority (start end buffer)
1394 (let ((pos (max 1 (1- start)))
1395 ovr-list)
50a07e18
MK
1396 (ediff-cond-compile-for-xemacs-or-emacs
1397 (1+ ediff-shadow-overlay-priority) ; xemacs form
1398 ;; emacs form
1399 (ediff-with-current-buffer buffer
1400 (while (< pos (min (point-max) (1+ end)))
1401 (setq ovr-list (append (overlays-at pos) ovr-list))
1402 (setq pos (next-overlay-change pos)))
1403 (+ 1 ediff-shadow-overlay-priority
1404 (apply 'max
1405 (cons
1406 1
1407 (mapcar
1408 (lambda (ovr)
1409 (if (and ovr
1410 ;; exclude ediff overlays from priority
1411 ;; calculation, or else priority will keep
1412 ;; increasing
1413 (null (ediff-overlay-get ovr 'ediff))
1414 (null (ediff-overlay-get ovr 'ediff-diff-num)))
1415 ;; use the overlay priority or 0
1416 (or (ediff-overlay-get ovr 'priority) 0)
1417 0))
1418 ovr-list)
1419 )
1420 )))
1421 ) ; ediff-cond-compile-for-xemacs-or-emacs
1422 ))
acce6d21
TTN
1423
1424
475f9031
KH
1425(defvar ediff-toggle-read-only-function nil
1426 "*Specifies the function to be used to toggle read-only.
1427If nil, Ediff tries to deduce the function from the binding of C-x C-q.
1428Normally, this is the `toggle-read-only' function, but, if version
1429control is used, it could be `vc-toggle-read-only' or `rcs-toggle-read-only'.")
1430
1e70790f
MK
1431(defcustom ediff-make-buffers-readonly-at-startup nil
1432 "*Make all variant buffers read-only when Ediff starts up.
1433This property can be toggled interactively."
1434 :type 'boolean
1435 :group 'ediff)
1436
475f9031
KH
1437
1438;;; Misc
1439
475f9031 1440;; if nil, this silences some messages
17561e4f 1441(defconst ediff-verbose-p t)
92c51e07 1442
328b4b70 1443(defcustom ediff-autostore-merges 'group-jobs-only
92c51e07 1444 "*Save the results of merge jobs automatically.
b9fe4732 1445nil means don't save automatically. t means always save. Anything else
92c51e07 1446means save automatically only if the merge job is part of a group of jobs, such
2eb4bdca 1447as `ediff-merge-directory' or `ediff-merge-directory-revisions'."
3af0304a 1448 :type '(choice (const nil) (const t) (const group-jobs-only))
328b4b70
MK
1449 :group 'ediff-merge)
1450(make-variable-buffer-local 'ediff-autostore-merges)
92c51e07 1451
3af0304a 1452;; file where the result of the merge is to be saved. used internally
92c51e07 1453(ediff-defvar-local ediff-merge-store-file nil "")
6de3983f
MK
1454
1455(defcustom ediff-merge-filename-prefix "merge_"
1456 "*Prefix to be attached to saved merge buffers."
1457 :type 'string
1458 :group 'ediff-merge)
acce6d21 1459
1e70790f 1460(defcustom ediff-no-emacs-help-in-control-buffer nil
475f9031 1461 "*Non-nil means C-h should not invoke Emacs help in control buffer.
1e70790f
MK
1462Instead, C-h would jump to previous difference."
1463 :type 'boolean
1464 :group 'ediff)
acce6d21 1465
3af0304a
MK
1466;; This is the same as temporary-file-directory from Emacs 20.3.
1467;; Copied over here because XEmacs doesn't have this variable.
acce6d21
TTN
1468(defcustom ediff-temp-file-prefix
1469 (file-name-as-directory
3af0304a
MK
1470 (cond ((boundp 'temporary-file-directory) temporary-file-directory)
1471 ((fboundp 'temp-directory) (temp-directory))
1472 (t "/tmp/")))
acce6d21 1473;;; (file-name-as-directory
3af0304a
MK
1474;;; (cond ((memq system-type '(ms-dos windows-nt))
1475;;; (or (getenv "TEMP") (getenv "TMPDIR") (getenv "TMP") "c:/temp"))
1476;;; ((memq system-type '(vax-vms axp-vms))
1477;;; (or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP") "SYS$SCRATCH:"))
1478;;; (t
1479;;; (or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP") "/tmp"))))
475f9031 1480 "*Prefix to put on Ediff temporary file names.
61d5c492 1481Do not start with `~/' or `~USERNAME/'."
328b4b70
MK
1482 :type 'string
1483 :group 'ediff)
475f9031 1484
328b4b70
MK
1485(defcustom ediff-temp-file-mode 384 ; u=rw only
1486 "*Mode for Ediff temporary files."
1487 :type 'integer
1488 :group 'ediff)
acce6d21 1489
475f9031
KH
1490;; Metacharacters that have to be protected from the shell when executing
1491;; a diff/diff3 command.
328b4b70
MK
1492(defcustom ediff-metachars "[ \t\n!\"#$&'()*;<=>?[\\^`{|~]"
1493 "Regexp that matches characters that must be quoted with `\\' in shell command line.
1494This default should work without changes."
1495 :type 'string
1496 :group 'ediff)
475f9031 1497
4ae69eac
MK
1498;; needed to simulate frame-char-width in XEmacs.
1499(defvar ediff-H-glyph (if ediff-xemacs-p (make-glyph "H")))
1500
acce6d21 1501
1e70790f
MK
1502;; Temporary file used for refining difference regions in buffer A.
1503(ediff-defvar-local ediff-temp-file-A nil "")
1504;; Temporary file used for refining difference regions in buffer B.
1505(ediff-defvar-local ediff-temp-file-B nil "")
1506;; Temporary file used for refining difference regions in buffer C.
1507(ediff-defvar-local ediff-temp-file-C nil "")
1508
475f9031 1509
4960e757 1510(defun ediff-file-remote-p (file-name)
17561e4f 1511 (file-remote-p file-name))
4960e757
MK
1512
1513;; File for which we can get attributes, such as size or date
1514(defun ediff-listable-file (file-name)
1515 (let ((handler (find-file-name-handler file-name 'file-local-copy)))
1516 (or (null handler) (eq handler 'dired-handler-fn))))
475f9031 1517
acce6d21 1518
475f9031 1519(defsubst ediff-frame-unsplittable-p (frame)
41d25ad0 1520 (cdr (assq 'unsplittable (frame-parameters frame))))
475f9031
KH
1521
1522(defsubst ediff-get-next-window (wind prev-wind)
cadc57d2
MK
1523 (cond ((window-live-p wind) wind)
1524 (prev-wind (next-window wind))
1525 (t (selected-window))
1526 ))
475f9031 1527
475f9031
KH
1528
1529(defsubst ediff-kill-buffer-carefully (buf)
1530 "Kill buffer BUF if it exists."
1531 (if (ediff-buffer-live-p buf)
1532 (kill-buffer (get-buffer buf))))
92c51e07 1533
ddc90f39
MK
1534(defsubst ediff-background-face (buf-type dif-num)
1535 ;; The value of dif-num is always 1- the one that user sees.
1536 ;; This is why even face is used when dif-num is odd.
e756eb9f
MK
1537 (ediff-get-symbol-from-alist
1538 buf-type (if (ediff-odd-p dif-num)
1539 ediff-even-diff-face-alist
1540 ediff-odd-diff-face-alist)
1541 ))
ddc90f39 1542
92c51e07
MK
1543
1544;; activate faces on diff regions in buffer
1545(defun ediff-paint-background-regions-in-one-buffer (buf-type unhighlight)
acce6d21 1546 (let ((diff-vector
e756eb9f
MK
1547 (eval (ediff-get-symbol-from-alist
1548 buf-type ediff-difference-vector-alist)))
92c51e07 1549 overl diff-num)
3af0304a
MK
1550 (mapcar (lambda (rec)
1551 (setq overl (ediff-get-diff-overlay-from-diff-record rec)
1552 diff-num (ediff-overlay-get overl 'ediff-diff-num))
1553 (if (ediff-overlay-buffer overl)
1554 ;; only if overlay is alive
1555 (ediff-set-overlay-face
1556 overl
1557 (if (not unhighlight)
1558 (ediff-background-face buf-type diff-num))))
1559 )
92c51e07
MK
1560 diff-vector)))
1561
1562
1563;; activate faces on diff regions in all buffers
1564(defun ediff-paint-background-regions (&optional unhighlight)
1565 (ediff-paint-background-regions-in-one-buffer
1566 'A unhighlight)
1567 (ediff-paint-background-regions-in-one-buffer
1568 'B unhighlight)
1569 (ediff-paint-background-regions-in-one-buffer
1570 'C unhighlight)
1571 (ediff-paint-background-regions-in-one-buffer
1572 'Ancestor unhighlight))
1573
acce6d21 1574
475f9031
KH
1575;; arg is a record for a given diff in a difference vector
1576;; this record is itself a vector
1577(defsubst ediff-clear-fine-diff-vector (diff-record)
1578 (if diff-record
1579 (mapcar 'ediff-delete-overlay
1580 (ediff-get-fine-diff-vector-from-diff-record diff-record))))
acce6d21 1581
475f9031
KH
1582(defsubst ediff-clear-fine-differences-in-one-buffer (n buf-type)
1583 (ediff-clear-fine-diff-vector (ediff-get-difference n buf-type))
1584 (ediff-set-fine-diff-vector n buf-type nil))
acce6d21 1585
475f9031
KH
1586(defsubst ediff-clear-fine-differences (n)
1587 (ediff-clear-fine-differences-in-one-buffer n 'A)
1588 (ediff-clear-fine-differences-in-one-buffer n 'B)
1589 (if ediff-3way-job
1590 (ediff-clear-fine-differences-in-one-buffer n 'C)))
acce6d21 1591
475f9031 1592
475f9031 1593(defsubst ediff-mouse-event-p (event)
50a07e18
MK
1594 (ediff-cond-compile-for-xemacs-or-emacs
1595 (button-event-p event) ; xemacs form
1596 (string-match "mouse" (format "%S" (event-basic-type event))) ; emacs form
1597 ))
8343426b
MK
1598
1599
1600(defsubst ediff-key-press-event-p (event)
50a07e18
MK
1601 (ediff-cond-compile-for-xemacs-or-emacs
1602 (key-press-event-p event) ; xemacs form
1603 (or (char-or-string-p event) (symbolp event)) ; emacs form
1604 ))
8343426b
MK
1605
1606(defun ediff-event-point (event)
1607 (cond ((ediff-mouse-event-p event)
50a07e18
MK
1608 (ediff-cond-compile-for-xemacs-or-emacs
1609 (event-point event) ; xemacs form
1610 (posn-point (event-start event)) ; emacs form
1611 )
1612 )
8343426b
MK
1613 ((ediff-key-press-event-p event)
1614 (point))
50a07e18 1615 (t (error nil))))
8343426b
MK
1616
1617(defun ediff-event-buffer (event)
1618 (cond ((ediff-mouse-event-p event)
50a07e18
MK
1619 (ediff-cond-compile-for-xemacs-or-emacs
1620 (event-buffer event) ; xemacs form
1621 (window-buffer (posn-window (event-start event))) ; emacs form
1622 )
1623 )
8343426b
MK
1624 ((ediff-key-press-event-p event)
1625 (current-buffer))
50a07e18
MK
1626 (t (error nil))))
1627
1628(defun ediff-event-key (event-or-key)
1629 (ediff-cond-compile-for-xemacs-or-emacs
1630 (if (eventp event-or-key) (event-key event-or-key) event-or-key) ; xemacs
1631 event-or-key ; emacs form
1632 ))
acce6d21
TTN
1633
1634
475f9031 1635(defsubst ediff-frame-iconified-p (frame)
41d25ad0 1636 (if (and (ediff-window-display-p) (frame-live-p frame))
50a07e18
MK
1637 (ediff-cond-compile-for-xemacs-or-emacs
1638 (frame-iconified-p frame) ; xemacs form
1639 (eq (frame-visible-p frame) 'icon) ; emacs form
1640 )
1641 ))
acce6d21 1642
475f9031 1643(defsubst ediff-window-visible-p (wind)
41d25ad0 1644 ;; under TTY, window-live-p also means window is visible
475f9031 1645 (and (window-live-p wind)
41d25ad0
KH
1646 (or (not (ediff-window-display-p))
1647 (frame-visible-p (window-frame wind)))))
acce6d21 1648
475f9031
KH
1649
1650(defsubst ediff-frame-char-width (frame)
50a07e18
MK
1651 (ediff-cond-compile-for-xemacs-or-emacs
1652 (/ (frame-pixel-width frame) (frame-width frame)) ; xemacs
1653 (frame-char-width frame) ; emacs
1654 ))
acce6d21 1655
8343426b
MK
1656(defun ediff-reset-mouse (&optional frame do-not-grab-mouse)
1657 (or frame (setq frame (selected-frame)))
41d25ad0 1658 (if (ediff-window-display-p)
8343426b 1659 (let ((frame-or-wind frame))
acce6d21 1660 (if ediff-xemacs-p
8343426b
MK
1661 (setq frame-or-wind (frame-selected-window frame)))
1662 (or do-not-grab-mouse
1663 ;; don't set mouse if the user said to never do this
acce6d21 1664 (not ediff-grab-mouse)
8343426b
MK
1665 ;; Don't grab on quit, if the user doesn't want to.
1666 ;; If ediff-grab-mouse = t, then mouse won't be grabbed for
1667 ;; sessions that are not part of a group (this is done in
3af0304a 1668 ;; ediff-recenter). The condition below affects only terminating
ceb0ea8b 1669 ;; sessions in session groups (in which case mouse is warped into
8343426b
MK
1670 ;; a meta buffer).
1671 (and (eq ediff-grab-mouse 'maybe)
1672 (memq this-command '(ediff-quit ediff-update-diffs)))
1673 (set-mouse-position frame-or-wind 1 0))
1674 )))
1675
1676(defsubst ediff-spy-after-mouse ()
1677 (setq ediff-mouse-pixel-position (mouse-pixel-position)))
1678
4ae69eac 1679;; It is not easy to find out when the user grabs the mouse, since emacs and
3af0304a 1680;; xemacs behave differently when mouse is not in any frame. Also, this is
4ae69eac 1681;; sensitive to when the user grabbed mouse. Not used for now.
8343426b
MK
1682(defun ediff-user-grabbed-mouse ()
1683 (if ediff-mouse-pixel-position
1684 (cond ((not (eq (car ediff-mouse-pixel-position)
1685 (car (mouse-pixel-position)))))
1686 ((and (car (cdr ediff-mouse-pixel-position))
1687 (car (cdr (mouse-pixel-position)))
1688 (cdr (cdr ediff-mouse-pixel-position))
1689 (cdr (cdr (mouse-pixel-position))))
1690 (not (and (< (abs (- (car (cdr ediff-mouse-pixel-position))
1691 (car (cdr (mouse-pixel-position)))))
ceb0ea8b 1692 ediff-mouse-pixel-threshold)
8343426b
MK
1693 (< (abs (- (cdr (cdr ediff-mouse-pixel-position))
1694 (cdr (cdr (mouse-pixel-position)))))
ceb0ea8b 1695 ediff-mouse-pixel-threshold))))
8343426b 1696 (t nil))))
acce6d21 1697
475f9031 1698(defsubst ediff-frame-char-height (frame)
71296446 1699 (ediff-cond-compile-for-xemacs-or-emacs
2e955a8b 1700 (glyph-height ediff-H-glyph (frame-selected-window frame)) ; xemacs case
50a07e18
MK
1701 (frame-char-height frame) ; emacs case
1702 )
1703 )
acce6d21 1704
92c51e07 1705;; Some overlay functions
475f9031 1706
ddc90f39
MK
1707(defsubst ediff-overlay-start (overl)
1708 (if (ediff-overlayp overl)
50a07e18
MK
1709 (ediff-cond-compile-for-xemacs-or-emacs
1710 (extent-start-position overl) ; xemacs form
1711 (overlay-start overl) ; emacs form
1712 )
1713 ))
acce6d21 1714
ddc90f39
MK
1715(defsubst ediff-overlay-end (overl)
1716 (if (ediff-overlayp overl)
50a07e18
MK
1717 (ediff-cond-compile-for-xemacs-or-emacs
1718 (extent-end-position overl) ; xemacs form
1719 (overlay-end overl) ; emacs form
1720 )
1721 ))
ddc90f39 1722
475f9031
KH
1723(defsubst ediff-empty-overlay-p (overl)
1724 (= (ediff-overlay-start overl) (ediff-overlay-end overl)))
4ae69eac 1725
3af0304a
MK
1726;; like overlay-buffer in Emacs. In XEmacs, returns nil if the extent is
1727;; dead. Otherwise, works like extent-buffer
4ae69eac 1728(defun ediff-overlay-buffer (overl)
50a07e18
MK
1729 (ediff-cond-compile-for-xemacs-or-emacs
1730 (and (extent-live-p overl) (extent-object overl)) ; xemacs form
1731 (overlay-buffer overl) ; emacs form
1732 ))
4ae69eac 1733
3af0304a
MK
1734;; like overlay-get in Emacs. In XEmacs, returns nil if the extent is
1735;; dead. Otherwise, like extent-property
4ae69eac 1736(defun ediff-overlay-get (overl property)
50a07e18
MK
1737 (ediff-cond-compile-for-xemacs-or-emacs
1738 (and (extent-live-p overl) (extent-property overl property)) ; xemacs form
1739 (overlay-get overl property) ; emacs form
1740 ))
92c51e07
MK
1741
1742
1743;; These two functions are here because XEmacs refuses to
1744;; handle overlays whose buffers were deleted.
1745(defun ediff-move-overlay (overlay beg end &optional buffer)
1746 "Calls `move-overlay' in Emacs and `set-extent-endpoints' in Lemacs.
1747Checks if overlay's buffer exists before actually doing the move."
1748 (let ((buf (and overlay (ediff-overlay-buffer overlay))))
1749 (if (ediff-buffer-live-p buf)
50a07e18
MK
1750 (ediff-cond-compile-for-xemacs-or-emacs
1751 (set-extent-endpoints overlay beg end) ; xemacs form
1752 (move-overlay overlay beg end buffer) ; emacs form
1753 )
92c51e07
MK
1754 ;; buffer's dead
1755 (if overlay
1756 (ediff-delete-overlay overlay)))))
acce6d21 1757
92c51e07
MK
1758(defun ediff-overlay-put (overlay prop value)
1759 "Calls `overlay-put' or `set-extent-property' depending on Emacs version.
1760Checks if overlay's buffer exists."
1761 (if (ediff-buffer-live-p (ediff-overlay-buffer overlay))
50a07e18
MK
1762 (ediff-cond-compile-for-xemacs-or-emacs
1763 (set-extent-property overlay prop value) ; xemacs form
1764 (overlay-put overlay prop value) ; emacs form
1765 )
92c51e07
MK
1766 (ediff-delete-overlay overlay)))
1767
475f9031
KH
1768;; temporarily uses DIR to abbreviate file name
1769;; if DIR is nil, use default-directory
4ae69eac 1770(defun ediff-abbreviate-file-name (file &optional dir)
8343426b
MK
1771 (cond ((stringp dir)
1772 (let ((directory-abbrev-alist (list (cons dir ""))))
1773 (abbreviate-file-name file)))
50a07e18
MK
1774 (t
1775 (ediff-cond-compile-for-xemacs-or-emacs
1776 ;; XEmacs requires addl argument
1777 (abbreviate-file-name file t) ; xemacs form
1778 (abbreviate-file-name file)) ; emacs form
1779 )
1780 ))
8343426b
MK
1781
1782;; Takes a directory and returns the parent directory.
3af0304a 1783;; does nothing to `/'. If the ARG is a regular file,
8343426b
MK
1784;; strip the file AND the last dir.
1785(defun ediff-strip-last-dir (dir)
1786 (if (not (stringp dir)) (setq dir default-directory))
1787 (setq dir (expand-file-name dir))
1788 (or (file-directory-p dir) (setq dir (file-name-directory dir)))
1789 (let* ((pos (1- (length dir)))
1790 (last-char (aref dir pos)))
1791 (if (and (> pos 0) (= last-char ?/))
1792 (setq dir (substring dir 0 pos)))
1793 (ediff-abbreviate-file-name (file-name-directory dir))))
1794
1795(defun ediff-truncate-string-left (str newlen)
1796 ;; leave space for ... on the left
1797 (let ((len (length str))
1798 substr)
1799 (if (<= len newlen)
1800 str
1801 (setq newlen (max 0 (- newlen 3)))
1802 (setq substr (substring str (max 0 (- len 1 newlen))))
1803 (concat "..." substr))))
1804
3af0304a
MK
1805(defsubst ediff-nonempty-string-p (string)
1806 (and (stringp string) (not (string= string ""))))
1807
2550055a
MK
1808(unless (fboundp 'subst-char-in-string)
1809 (defun subst-char-in-string (fromchar tochar string &optional inplace)
1810 "Replace FROMCHAR with TOCHAR in STRING each time it occurs.
1811Unless optional argument INPLACE is non-nil, return a new string."
1812 (let ((i (length string))
1813 (newstr (if inplace string (copy-sequence string))))
1814 (while (> i 0)
1815 (setq i (1- i))
1816 (if (eq (aref newstr i) fromchar)
1817 (aset newstr i tochar)))
1818 newstr)))
1819
8343426b
MK
1820(defun ediff-abbrev-jobname (jobname)
1821 (cond ((eq jobname 'ediff-directories)
1822 "Compare two directories")
1823 ((eq jobname 'ediff-files)
1824 "Compare two files")
1825 ((eq jobname 'ediff-buffers)
1826 "Compare two buffers")
1827 ((eq jobname 'ediff-directories3)
1828 "Compare three directories")
1829 ((eq jobname 'ediff-files3)
1830 "Compare three files")
1831 ((eq jobname 'ediff-buffers3)
1832 "Compare three buffers")
1833 ((eq jobname 'ediff-revision)
1834 "Compare file with a version")
1835 ((eq jobname 'ediff-directory-revisions)
1836 "Compare dir files with versions")
1837 ((eq jobname 'ediff-merge-directory-revisions)
1838 "Merge dir files with versions")
1839 ((eq jobname 'ediff-merge-directory-revisions-with-ancestor)
1840 "Merge dir versions via ancestors")
1841 (t
7d027816
MK
1842 (capitalize
1843 (subst-char-in-string ?- ?\ (substring (symbol-name jobname) 6))))
1844 ))
acce6d21
TTN
1845
1846
475f9031
KH
1847;; If ediff modified mode line, strip the modification
1848(defsubst ediff-strip-mode-line-format ()
8343426b 1849 (if (member (car mode-line-format) '(" A: " " B: " " C: " " Ancestor: "))
475f9031
KH
1850 (setq mode-line-format (nth 2 mode-line-format))))
1851
1852;; Verify that we have a difference selected.
1853(defsubst ediff-valid-difference-p (&optional n)
1854 (or n (setq n ediff-current-difference))
1855 (and (>= n 0) (< n ediff-number-of-differences)))
acce6d21 1856
475f9031
KH
1857(defsubst ediff-show-all-diffs (n)
1858 "Don't skip difference regions."
1859 nil)
8343426b
MK
1860
1861(defsubst Xor (a b)
1862 (or (and a (not b)) (and (not a) b)))
009650b3
MK
1863
1864(defsubst ediff-message-if-verbose (string &rest args)
1865 (if ediff-verbose-p
1866 (apply 'message string args)))
4ae69eac 1867
bbe6126c 1868(defun ediff-file-attributes (filename attr-number)
4960e757
MK
1869 (if (ediff-listable-file filename)
1870 (nth attr-number (file-attributes filename))
1871 -1)
1872 )
ddc90f39 1873
bbe6126c
MK
1874(defsubst ediff-file-size (filename)
1875 (ediff-file-attributes filename 7))
1876(defsubst ediff-file-modtime (filename)
1877 (ediff-file-attributes filename 5))
1878
1879
92c51e07 1880(defun ediff-convert-standard-filename (fname)
ddc90f39 1881 (if (fboundp 'convert-standard-filename)
92c51e07 1882 (convert-standard-filename fname)
92c51e07 1883 fname))
bbe6126c
MK
1884
1885
4986c2c6 1886(if (fboundp 'with-syntax-table)
f3eabcdf 1887 (defalias 'ediff-with-syntax-table 'with-syntax-table)
4986c2c6
MK
1888 ;; stolen from subr.el in emacs 21
1889 (defmacro ediff-with-syntax-table (table &rest body)
1890 (let ((old-table (make-symbol "table"))
1891 (old-buffer (make-symbol "buffer")))
1892 `(let ((,old-table (syntax-table))
1893 (,old-buffer (current-buffer)))
1894 (unwind-protect
1895 (progn
1896 (set-syntax-table (copy-syntax-table ,table))
1897 ,@body)
1898 (save-current-buffer
1899 (set-buffer ,old-buffer)
1900 (set-syntax-table ,old-table)))))))
1901
1902
1903
92c51e07
MK
1904;;; Local Variables:
1905;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun)
e756eb9f
MK
1906;;; eval: (put 'ediff-with-current-buffer 'lisp-indent-hook 1)
1907;;; eval: (put 'ediff-with-current-buffer 'edebug-form-spec '(form body))
92c51e07 1908;;; End:
acce6d21 1909
475f9031
KH
1910(provide 'ediff-init)
1911
ab5796a9 1912;;; arch-tag: fa31d384-1e70-4d4b-82a7-3e96307c46f5
3afbc435 1913;;; ediff-init.el ends here