1 ;;; ediff-init.el --- Macros, variables, and defsubsts used by Ediff
3 ;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 01, 02 Free Software Foundation, Inc.
5 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
7 ;; This file is part of GNU Emacs.
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)
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.
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.
28 ;; Start compiler pacifier
29 (defvar ediff-metajob-name
)
30 (defvar ediff-meta-buffer
)
31 (defvar pm-color-alist
)
32 (defvar ediff-grab-mouse
)
33 (defvar ediff-mouse-pixel-position
)
34 (defvar ediff-mouse-pixel-threshold
)
35 (defvar ediff-whitespace
)
36 (defvar ediff-multiframe
)
37 (defvar ediff-use-toolbar-p
)
38 (defvar mswindowsx-bitmap-file-path
)
42 (load "ange-ftp" 'noerror
)))
46 (defconst ediff-xemacs-p
(string-match "XEmacs" emacs-version
))
48 (defconst ediff-emacs-p
(not ediff-xemacs-p
))
50 ;; This is used to avoid compilation warnings. When emacs/xemacs forms can
51 ;; generate compile time warnings, we use this macro.
52 ;; In this case, the macro will expand into the form that is appropriate to the
55 (defmacro ediff-cond-compile-for-xemacs-or-emacs
(xemacs-form emacs-form
)
56 (if (string-match "XEmacs" emacs-version
)
57 xemacs-form emacs-form
))
59 (defvar ediff-force-faces nil
60 "If t, Ediff will think that it is running on a display that supports faces.
61 This is provided as a temporary relief for users of face-capable displays
62 that Ediff doesn't know about.")
64 ;; Are we running as a window application or on a TTY?
65 (defsubst ediff-device-type
()
66 (ediff-cond-compile-for-xemacs-or-emacs
67 (device-type (selected-device)) ; xemacs form
68 window-system
; emacs form
71 ;; in XEmacs: device-type is tty on tty and stream in batch.
72 (defun ediff-window-display-p ()
73 (and (ediff-device-type) (not (memq (ediff-device-type) '(tty pc stream
)))))
75 ;; test if supports faces
76 (defun ediff-has-face-support-p ()
77 (cond ((ediff-window-display-p))
79 ((ediff-color-display-p))
80 (ediff-emacs-p (memq (ediff-device-type) '(pc)))
81 (ediff-xemacs-p (memq (ediff-device-type) '(tty pc
)))
84 ;; toolbar support for emacs hasn't been implemented in ediff
85 (defun ediff-has-toolbar-support-p ()
86 (ediff-cond-compile-for-xemacs-or-emacs
87 (and (featurep 'toolbar
) (console-on-window-system-p)) ; xemacs form
92 (defun ediff-has-gutter-support-p ()
93 (ediff-cond-compile-for-xemacs-or-emacs
94 (and (featurep 'gutter
) (console-on-window-system-p)) ; xemacs form
99 (defun ediff-use-toolbar-p ()
100 (and (ediff-has-toolbar-support-p) ;Can it do it ?
101 (boundp 'ediff-use-toolbar-p
)
102 ediff-use-toolbar-p
)) ;Does the user want it ?
104 ;; Defines SYMBOL as an advertised local variable.
105 ;; Performs a defvar, then executes `make-variable-buffer-local' on
106 ;; the variable. Also sets the `permanent-local' property,
107 ;; so that `kill-all-local-variables' (called by major-mode setting
108 ;; commands) won't destroy Ediff control variables.
110 ;; Plagiarised from `emerge-defvar-local' for XEmacs.
111 (defmacro ediff-defvar-local
(var value doc
)
113 (defvar ,var
,value
,doc
)
114 (make-variable-buffer-local ',var
)
115 (put ',var
'permanent-local t
)))
119 ;; Variables that control each Ediff session---local to the control buffer.
122 ;; The buffer in which the A variant is stored.
123 (ediff-defvar-local ediff-buffer-A nil
"")
124 ;; The buffer in which the B variant is stored.
125 (ediff-defvar-local ediff-buffer-B nil
"")
126 ;; The buffer in which the C variant is stored or where the merge buffer lives.
127 (ediff-defvar-local ediff-buffer-C nil
"")
129 (ediff-defvar-local ediff-ancestor-buffer nil
"")
130 ;; The Ediff control buffer
131 (ediff-defvar-local ediff-control-buffer nil
"")
133 (ediff-defvar-local ediff-temp-indirect-buffer nil
134 "If t, the buffer is a temporary indirect buffer.
135 It needs to be killed when we quit the session.")
138 ;; Association between buff-type and ediff-buffer-*
139 (defconst ediff-buffer-alist
140 '((?A . ediff-buffer-A
)
141 (?B . ediff-buffer-B
)
142 (?C . ediff-buffer-C
)))
145 (defmacro ediff-odd-p
(arg)
146 `(eq (logand ,arg
1) 1))
148 (defmacro ediff-buffer-live-p
(buf)
149 `(and ,buf
(get-buffer ,buf
) (buffer-name (get-buffer ,buf
))))
151 (defmacro ediff-get-buffer
(arg)
152 `(cond ((eq ,arg
'A
) ediff-buffer-A
)
153 ((eq ,arg
'B
) ediff-buffer-B
)
154 ((eq ,arg
'C
) ediff-buffer-C
)
155 ((eq ,arg
'Ancestor
) ediff-ancestor-buffer
)
158 (defmacro ediff-get-value-according-to-buffer-type
(buf-type list
)
159 `(cond ((eq ,buf-type
'A
) (nth 0 ,list
))
160 ((eq ,buf-type
'B
) (nth 1 ,list
))
161 ((eq ,buf-type
'C
) (nth 2 ,list
))
164 (defmacro ediff-char-to-buftype
(arg)
165 `(cond ((memq ,arg
'(?a ?A
)) 'A
)
166 ((memq ,arg
'(?b ?B
)) 'B
)
167 ((memq ,arg
'(?c ?C
)) 'C
)
171 ;; A-list is supposed to be of the form (A . symb) (B . symb)...)
172 ;; where the first part of any association is a buffer type and the second is
173 ;; an appropriate symbol. Given buffer-type, this function returns the
174 ;; symbol. This is used to avoid using `intern'
175 (defsubst ediff-get-symbol-from-alist
(buf-type alist
)
176 (cdr (assoc buf-type alist
)))
178 (defconst ediff-difference-vector-alist
179 '((A . ediff-difference-vector-A
)
180 (B . ediff-difference-vector-B
)
181 (C . ediff-difference-vector-C
)
182 (Ancestor . ediff-difference-vector-Ancestor
)))
184 (defmacro ediff-get-difference
(n buf-type
)
187 (ediff-get-symbol-from-alist
188 ,buf-type ediff-difference-vector-alist
))
191 ;; Tell if it has been previously determined that the region has
192 ;; no diffs other than the white space and newlines
193 ;; The argument, N, is the diff region number used by Ediff to index the
194 ;; diff vector. It is 1 less than the number seen by the user.
196 ;; t if the diffs are whitespace in all buffers
197 ;; 'A (in 3-buf comparison only) if there are only whitespace
198 ;; diffs in bufs B and C
199 ;; 'B (in 3-buf comparison only) if there are only whitespace
200 ;; diffs in bufs A and C
201 ;; 'C (in 3-buf comparison only) if there are only whitespace
202 ;; diffs in bufs A and B
204 ;; A Difference Vector has the form:
205 ;; [diff diff diff ...]
206 ;; where each diff has the form:
207 ;; [overlay fine-diff-vector no-fine-diffs-flag state-of-difference]
208 ;; fine-diff-vector is a vector [fine-diff fine-diff fine-diff ...]
209 ;; no-fine-diffs-flag says if there are fine differences.
210 ;; state-of-difference is A, B, C, or nil, indicating which buffer is
211 ;; different from the other two (used only in 3-way jobs).
212 (defmacro ediff-no-fine-diffs-p
(n)
213 `(aref (ediff-get-difference ,n
'A
) 2))
215 (defmacro ediff-get-diff-overlay-from-diff-record
(diff-rec)
218 (defmacro ediff-get-diff-overlay
(n buf-type
)
219 `(ediff-get-diff-overlay-from-diff-record
220 (ediff-get-difference ,n
,buf-type
)))
222 (defmacro ediff-get-fine-diff-vector-from-diff-record
(diff-rec)
225 (defmacro ediff-set-fine-diff-vector
(n buf-type fine-vec
)
226 `(aset (ediff-get-difference ,n
,buf-type
) 1 ,fine-vec
))
228 (defmacro ediff-get-state-of-diff
(n buf-type
)
229 `(if (ediff-buffer-live-p ediff-buffer-C
)
230 (aref (ediff-get-difference ,n
,buf-type
) 3)))
231 (defmacro ediff-set-state-of-diff
(n buf-type val
)
232 `(aset (ediff-get-difference ,n
,buf-type
) 3 ,val
))
234 (defmacro ediff-get-state-of-merge
(n)
235 `(if ediff-state-of-merge
236 (aref (aref ediff-state-of-merge
,n
) 0)))
237 (defmacro ediff-set-state-of-merge
(n val
)
238 `(if ediff-state-of-merge
239 (aset (aref ediff-state-of-merge
,n
) 0 ,val
)))
241 (defmacro ediff-get-state-of-ancestor
(n)
242 `(if ediff-state-of-merge
243 (aref (aref ediff-state-of-merge
,n
) 1)))
245 ;; if flag is t, puts a mark on diff region saying that
246 ;; the differences are in white space only. If flag is nil,
247 ;; the region is marked as essential (i.e., differences are
248 ;; not just in the white space and newlines.)
249 (defmacro ediff-mark-diff-as-space-only
(n flag
)
250 `(aset (ediff-get-difference ,n
'A
) 2 ,flag
))
252 (defmacro ediff-get-fine-diff-vector
(n buf-type
)
253 `(ediff-get-fine-diff-vector-from-diff-record
254 (ediff-get-difference ,n
,buf-type
)))
256 ;; Macro to switch to BUFFER, evaluate BODY, returns to original buffer.
257 ;; Doesn't save the point and mark.
258 ;; This is `with-current-buffer' with the added test for live buffers."
259 (defmacro ediff-with-current-buffer
(buffer &rest body
)
260 `(if (ediff-buffer-live-p ,buffer
)
264 (or (eq this-command
'ediff-quit
)
265 (error ediff-KILLED-VITAL-BUFFER
))
269 (defsubst ediff-multiframe-setup-p
()
270 (and (ediff-window-display-p) ediff-multiframe
))
272 (defmacro ediff-narrow-control-frame-p
()
273 `(and (ediff-multiframe-setup-p)
274 (equal ediff-help-message ediff-brief-message-string
)))
276 (defmacro ediff-3way-comparison-job
()
279 '(ediff-files3 ediff-buffers3
)))
280 (ediff-defvar-local ediff-3way-comparison-job nil
"")
282 (defmacro ediff-merge-job
()
287 ediff-merge-files-with-ancestor
288 ediff-merge-buffers-with-ancestor
289 ediff-merge-revisions
290 ediff-merge-revisions-with-ancestor
)))
291 (ediff-defvar-local ediff-merge-job nil
"")
293 (defmacro ediff-patch-job
()
294 `(eq ediff-job-name
'epatch
))
296 (defmacro ediff-merge-with-ancestor-job
()
299 '(ediff-merge-files-with-ancestor
300 ediff-merge-buffers-with-ancestor
301 ediff-merge-revisions-with-ancestor
)))
302 (ediff-defvar-local ediff-merge-with-ancestor-job nil
"")
304 (defmacro ediff-3way-job
()
305 `(or ediff-3way-comparison-job ediff-merge-job
))
306 (ediff-defvar-local ediff-3way-job nil
"")
308 ;; A diff3 job is like a 3way job, but ediff-merge doesn't require the use
310 (defmacro ediff-diff3-job
()
311 `(or ediff-3way-comparison-job
312 ediff-merge-with-ancestor-job
))
313 (ediff-defvar-local ediff-diff3-job nil
"")
315 (defmacro ediff-windows-job
()
316 `(memq ediff-job-name
'(ediff-windows-wordwise ediff-windows-linewise
)))
317 (ediff-defvar-local ediff-windows-job nil
"")
319 (defmacro ediff-word-mode-job
()
320 `(memq ediff-job-name
'(ediff-windows-wordwise ediff-regions-wordwise
)))
321 (ediff-defvar-local ediff-word-mode-job nil
"")
323 (defmacro ediff-narrow-job
()
324 `(memq ediff-job-name
'(ediff-windows-wordwise
325 ediff-regions-wordwise
326 ediff-windows-linewise
327 ediff-regions-linewise
)))
328 (ediff-defvar-local ediff-narrow-job nil
"")
330 ;; Note: ediff-merge-directory-revisions-with-ancestor is not treated as an
331 ;; ancestor metajob, since it behaves differently.
332 (defsubst ediff-ancestor-metajob
(&optional metajob
)
333 (memq (or metajob ediff-metajob-name
)
334 '(ediff-merge-directories-with-ancestor
335 ediff-merge-filegroups-with-ancestor
)))
336 (defsubst ediff-revision-metajob
(&optional metajob
)
337 (memq (or metajob ediff-metajob-name
)
338 '(ediff-directory-revisions
339 ediff-merge-directory-revisions
340 ediff-merge-directory-revisions-with-ancestor
)))
341 (defsubst ediff-patch-metajob
(&optional metajob
)
342 (memq (or metajob ediff-metajob-name
)
343 '(ediff-multifile-patch)))
344 ;; metajob involving only one group of files, such as multipatch or directory
346 (defsubst ediff-one-filegroup-metajob
(&optional metajob
)
347 (or (ediff-revision-metajob metajob
)
348 (ediff-patch-metajob metajob
)
351 ;; jobs suitable for the operation of collecting diffs into a multifile patch
352 (defsubst ediff-collect-diffs-metajob
(&optional metajob
)
353 (memq (or metajob ediff-metajob-name
)
355 ediff-merge-directories
356 ediff-merge-directories-with-ancestor
357 ediff-directory-revisions
358 ediff-merge-directory-revisions
359 ediff-merge-directory-revisions-with-ancestor
362 (defsubst ediff-merge-metajob
(&optional metajob
)
363 (memq (or metajob ediff-metajob-name
)
364 '(ediff-merge-directories
365 ediff-merge-directories-with-ancestor
366 ediff-merge-directory-revisions
367 ediff-merge-directory-revisions-with-ancestor
368 ediff-merge-filegroups-with-ancestor
372 (defsubst ediff-metajob3
(&optional metajob
)
373 (memq (or metajob ediff-metajob-name
)
374 '(ediff-merge-directories-with-ancestor
375 ediff-merge-filegroups-with-ancestor
378 (defsubst ediff-comparison-metajob3
(&optional metajob
)
379 (memq (or metajob ediff-metajob-name
)
380 '(ediff-directories3 ediff-filegroups3
)))
382 ;; with no argument, checks if we are in ediff-control-buffer
383 ;; with argument, checks if we are in ediff-meta-buffer
384 (defun ediff-in-control-buffer-p (&optional meta-buf-p
)
385 (and (boundp 'ediff-control-buffer
)
386 (eq (if meta-buf-p ediff-meta-buffer ediff-control-buffer
)
389 (defsubst ediff-barf-if-not-control-buffer
(&optional meta-buf-p
)
390 (or (ediff-in-control-buffer-p meta-buf-p
)
391 (error "%S: This command runs in Ediff Control Buffer only!"
394 (defgroup ediff-highlighting nil
395 "Hilighting of difference regions in Ediff"
399 (defgroup ediff-merge nil
404 (defgroup ediff-hook nil
411 (defcustom ediff-before-setup-hook nil
412 "*Hooks to run before Ediff begins to set up windows and buffers.
413 This hook can be used to save the previous window config, which can be restored
414 on ediff-quit or ediff-suspend."
417 (defcustom ediff-before-setup-windows-hook nil
418 "*Hooks to run before Ediff sets its window configuration.
419 This hook is run every time when Ediff arranges its windows.
420 This happens each time Ediff detects that the windows were messed up by the
424 (defcustom ediff-after-setup-windows-hook nil
425 "*Hooks to run after Ediff sets its window configuration.
426 This can be used to set up control window or icon in a desired place."
429 (defcustom ediff-before-setup-control-frame-hook nil
430 "*Hooks run before setting up the frame to display Ediff Control Panel.
431 Can be used to change control frame parameters to position it where it
435 (defcustom ediff-after-setup-control-frame-hook nil
436 "*Hooks run after setting up the frame to display Ediff Control Panel.
437 Can be used to move the frame where it is desired."
440 (defcustom ediff-startup-hook nil
441 "*Hooks to run in the control buffer after Ediff has been set up and is ready for the job."
444 (defcustom ediff-select-hook nil
445 "*Hooks to run after a difference has been selected."
448 (defcustom ediff-unselect-hook nil
449 "*Hooks to run after a difference has been unselected."
452 (defcustom ediff-prepare-buffer-hook nil
453 "*Hooks run after buffers A, B, and C are set up.
454 For each buffer, the hooks are run with that buffer made current."
457 (defcustom ediff-load-hook nil
458 "*Hook run after Ediff is loaded. Can be used to change defaults."
462 (defcustom ediff-mode-hook nil
463 "*Hook run just after ediff-mode is set up in the control buffer.
464 This is done before any windows or frames are created. One can use it to
465 set local variables that determine how the display looks like."
468 (defcustom ediff-keymap-setup-hook nil
469 "*Hook run just after the default bindings in Ediff keymap are set up."
473 (defcustom ediff-display-help-hook nil
474 "*Hooks run after preparing the help message."
478 (defcustom ediff-suspend-hook nil
479 "*Hooks to run in the Ediff control buffer when Ediff is suspended."
482 (defcustom ediff-quit-hook nil
483 "*Hooks to run in the Ediff control buffer after finishing Ediff."
486 (defcustom ediff-cleanup-hook nil
487 "*Hooks to run on exiting Ediff but before killing the control and variant buffers."
492 (defconst ediff-KILLED-VITAL-BUFFER
493 "You have killed a vital Ediff buffer---you must leave Ediff now!")
494 (defconst ediff-NO-DIFFERENCES
495 "Sorry, comparison of identical variants is not what I am made for...")
496 (defconst ediff-BAD-DIFF-NUMBER
497 ;; %S stands for this-command, %d - diff number, %d - max diff
498 "%S: Bad diff region number, %d. Valid numbers are 1 to %d")
499 (defconst ediff-BAD-INFO
(format "
500 *** The Info file for Ediff, a part of the standard distribution
501 *** of %sEmacs, does not seem to be properly installed.
503 *** Please contact your system administrator. "
504 (if ediff-xemacs-p
"X" "")))
506 ;; Selective browsing
508 (ediff-defvar-local ediff-skip-diff-region-function
'ediff-show-all-diffs
509 "Function that determines the next/previous diff region to show.
510 Should return t for regions to be ignored and nil otherwise.
511 This function gets a region number as an argument. The region number
512 is the one used internally by Ediff. It is 1 less than the number seen
515 (ediff-defvar-local ediff-hide-regexp-matches-function
516 'ediff-hide-regexp-matches
517 "Function to use in determining which regions to hide.
518 See the documentation string of `ediff-hide-regexp-matches' for details.")
519 (ediff-defvar-local ediff-focus-on-regexp-matches-function
520 'ediff-focus-on-regexp-matches
521 "Function to use in determining which regions to focus on.
522 See the documentation string of `ediff-focus-on-regexp-matches' for details.")
524 ;; Regexp that determines buf A regions to focus on when skipping to diff
525 (ediff-defvar-local ediff-regexp-focus-A
"" "")
526 ;; Regexp that determines buf B regions to focus on when skipping to diff
527 (ediff-defvar-local ediff-regexp-focus-B
"" "")
528 ;; Regexp that determines buf C regions to focus on when skipping to diff
529 (ediff-defvar-local ediff-regexp-focus-C
"" "")
530 ;; connective that determines whether to focus regions that match both or
531 ;; one of the regexps
532 (ediff-defvar-local ediff-focus-regexp-connective
'and
"")
534 ;; Regexp that determines buf A regions to ignore when skipping to diff
535 (ediff-defvar-local ediff-regexp-hide-A
"" "")
536 ;; Regexp that determines buf B regions to ignore when skipping to diff
537 (ediff-defvar-local ediff-regexp-hide-B
"" "")
538 ;; Regexp that determines buf C regions to ignore when skipping to diff
539 (ediff-defvar-local ediff-regexp-hide-C
"" "")
540 ;; connective that determines whether to hide regions that match both or
541 ;; one of the regexps
542 (ediff-defvar-local ediff-hide-regexp-connective
'and
"")
545 ;;; Copying difference regions between buffers.
547 ;; A list of killed diffs.
548 ;; A diff is saved here if it is replaced by a diff
549 ;; from another buffer. This alist has the form:
550 ;; \((num (buff-object . diff) (buff-object . diff) (buff-object . diff)) ...),
551 ;; where some buffer-objects may be missing.
552 (ediff-defvar-local ediff-killed-diffs-alist nil
"")
554 ;; Syntax table to use in ediff-forward-word-function
555 ;; This is chosen by a heuristic. The important thing is for all buffers to
556 ;; have the same syntax table. Which is not too important.
557 (ediff-defvar-local ediff-syntax-table nil
"")
561 (defcustom ediff-before-flag-bol
(if ediff-xemacs-p
(make-glyph "->>") "->>")
562 "*Flag placed before a highlighted block of differences, if block starts at beginning of a line."
564 :tag
"Region before-flag at beginning of line"
567 (defcustom ediff-after-flag-eol
(if ediff-xemacs-p
(make-glyph "<<-") "<<-")
568 "*Flag placed after a highlighted block of differences, if block ends at end of a line."
570 :tag
"Region after-flag at end of line"
573 (defcustom ediff-before-flag-mol
(if ediff-xemacs-p
(make-glyph "->>") "->>")
574 "*Flag placed before a highlighted block of differences, if block starts in mid-line."
576 :tag
"Region before-flag in the middle of line"
578 (defcustom ediff-after-flag-mol
(if ediff-xemacs-p
(make-glyph "<<-") "<<-")
579 "*Flag placed after a highlighted block of differences, if block ends in mid-line."
581 :tag
"Region after-flag in the middle of line"
585 (ediff-defvar-local ediff-use-faces t
"")
586 (defcustom ediff-use-faces t
587 "If t, differences are highlighted using faces, if device supports faces.
588 If nil, differences are highlighted using ASCII flags, ediff-before-flag
589 and ediff-after-flag. On a non-window system, differences are always
590 highlighted using ASCII flags."
592 :group
'ediff-highlighting
)
594 ;; this indicates that diff regions are word-size, so fine diffs are
595 ;; permanently nixed; used in ediff-windows-wordwise and ediff-regions-wordwise
596 (ediff-defvar-local ediff-word-mode nil
"")
597 ;; Name of the job (ediff-files, ediff-windows, etc.)
598 (ediff-defvar-local ediff-job-name nil
"")
600 ;; Narrowing and ediff-region/windows support
601 ;; This is a list (overlay-A overlay-B overlay-C)
602 ;; If set, Ediff compares only those parts of buffers A/B/C that lie within
603 ;; the bounds of these overlays.
604 (ediff-defvar-local ediff-narrow-bounds nil
"")
606 ;; List (overlay-A overlay-B overlay-C), where each overlay spans the
607 ;; entire corresponding buffer.
608 (ediff-defvar-local ediff-wide-bounds nil
"")
610 ;; Current visibility boundaries in buffers A, B, and C.
611 ;; This is also a list of overlays. When the user toggles narrow/widen,
612 ;; this list changes from ediff-wide-bounds to ediff-narrow-bounds.
614 (ediff-defvar-local ediff-visible-bounds nil
"")
616 (ediff-defvar-local ediff-start-narrowed t
617 "Non-nil means start narrowed, if doing ediff-windows-* or ediff-regions-*")
618 (ediff-defvar-local ediff-quit-widened t
619 "*Non-nil means: when finished, Ediff widens buffers A/B.
620 Actually, Ediff restores the scope of visibility that existed at startup.")
622 (defcustom ediff-keep-variants t
623 "*nil means prompt to remove unmodified buffers A/B/C at session end.
624 Supplying a prefix argument to the quit command `q' temporarily reverses the
625 meaning of this variable."
629 (ediff-defvar-local ediff-highlight-all-diffs t
"")
630 (defcustom ediff-highlight-all-diffs t
631 "If nil, only the selected differences are highlighted.
632 Otherwise, all difference regions are highlighted, but the selected region is
633 shown in brighter colors."
635 :group
'ediff-highlighting
)
638 ;; The suffix of the control buffer name.
639 (ediff-defvar-local ediff-control-buffer-suffix nil
"")
640 ;; Same as ediff-control-buffer-suffix, but without <,>.
641 ;; It's a number rather than string.
642 (ediff-defvar-local ediff-control-buffer-number nil
"")
645 ;; The original values of ediff-protected-variables for buffer A
646 (ediff-defvar-local ediff-buffer-values-orig-A nil
"")
647 ;; The original values of ediff-protected-variables for buffer B
648 (ediff-defvar-local ediff-buffer-values-orig-B nil
"")
649 ;; The original values of ediff-protected-variables for buffer C
650 (ediff-defvar-local ediff-buffer-values-orig-C nil
"")
651 ;; The original values of ediff-protected-variables for buffer Ancestor
652 (ediff-defvar-local ediff-buffer-values-orig-Ancestor nil
"")
654 ;; association between buff-type and ediff-buffer-values-orig-*
655 (defconst ediff-buffer-values-orig-alist
656 '((A . ediff-buffer-values-orig-A
)
657 (B . ediff-buffer-values-orig-B
)
658 (C . ediff-buffer-values-orig-C
)
659 (Ancestor . ediff-buffer-values-orig-Ancestor
)))
661 ;; Buffer-local variables to be saved then restored during Ediff sessions
662 (defconst ediff-protected-variables
'(
666 ;; Vector of differences between the variants. Each difference is
667 ;; represented by a vector of two overlays plus a vector of fine diffs,
668 ;; plus a no-fine-diffs flag. The first overlay spans the
669 ;; difference region in the A buffer and the second overlays the diff in
670 ;; the B buffer. If a difference section is empty, the corresponding
671 ;; overlay's endpoints coincide.
673 ;; The precise form of a Difference Vector for one buffer is:
674 ;; [diff diff diff ...]
675 ;; where each diff has the form:
676 ;; [diff-overlay fine-diff-vector no-fine-diffs-flag state-of-diff]
677 ;; fine-diff-vector is a vector [fine-diff-overlay fine-diff-overlay ...]
678 ;; no-fine-diffs-flag says if there are fine differences.
679 ;; state-of-difference is A, B, C, or nil, indicating which buffer is
680 ;; different from the other two (used only in 3-way jobs.
681 (ediff-defvar-local ediff-difference-vector-A nil
"")
682 (ediff-defvar-local ediff-difference-vector-B nil
"")
683 (ediff-defvar-local ediff-difference-vector-C nil
"")
684 (ediff-defvar-local ediff-difference-vector-Ancestor nil
"")
685 ;; A-list of diff vector types associated with buffer types
686 (defconst ediff-difference-vector-alist
687 '((A . ediff-difference-vector-A
)
688 (B . ediff-difference-vector-B
)
689 (C . ediff-difference-vector-C
)
690 (Ancestor . ediff-difference-vector-Ancestor
)))
692 ;; [ status status status ...]
693 ;; Each status: [state-of-merge state-of-ancestor]
694 ;; state-of-merge is default-A, default-B, prefer-A, or prefer-B. It
695 ;; indicates the way a diff region was created in buffer C.
696 ;; state-of-ancestor says if the corresponding region in ancestor buffer is
698 (ediff-defvar-local ediff-state-of-merge nil
"")
700 ;; The difference that is currently selected.
701 (ediff-defvar-local ediff-current-difference -
1 "")
702 ;; Number of differences found.
703 (ediff-defvar-local ediff-number-of-differences nil
"")
705 ;; Buffer containing the output of diff, which is used by Ediff to step
707 (ediff-defvar-local ediff-diff-buffer nil
"")
708 ;; Like ediff-diff-buffer, but contains context diff. It is not used by
709 ;; Ediff, but it is saved in a file, if user requests so.
710 (ediff-defvar-local ediff-custom-diff-buffer nil
"")
711 ;; Buffer used for diff-style fine differences between regions.
712 (ediff-defvar-local ediff-fine-diff-buffer nil
"")
713 ;; Temporary buffer used for computing fine differences.
714 (defconst ediff-tmp-buffer
" *ediff-tmp*" "")
715 ;; Buffer used for messages
716 (defconst ediff-msg-buffer
" *ediff-message*" "")
717 ;; Buffer containing the output of diff when diff returns errors.
718 (ediff-defvar-local ediff-error-buffer nil
"")
719 ;; Buffer to display debug info
720 (ediff-defvar-local ediff-debug-buffer
"*ediff-debug*" "")
722 ;; List of ediff control panels associated with each buffer A/B/C/Ancestor.
723 ;; Not used any more, but may be needed in the future.
724 (ediff-defvar-local ediff-this-buffer-ediff-sessions nil
"")
726 ;; to be deleted in due time
727 ;; List of difference overlays disturbed by working with the current diff.
728 (defvar ediff-disturbed-overlays nil
"")
730 ;; Priority of non-selected overlays.
731 (defvar ediff-shadow-overlay-priority
100 "")
733 (defcustom ediff-version-control-package
'vc
734 "Version control package used.
735 Currently, Ediff supports vc.el, rcs.el, pcl-cvs.el, and generic-sc.el. The
736 standard Emacs interface to RCS, CVS, SCCS, etc., is vc.el. However, some
737 people find the other two packages more convenient. Set this variable to the
738 appropriate symbol: `rcs', `pcl-cvs', or `generic-sc' if you so desire."
742 (defcustom ediff-coding-system-for-read
'raw-text
743 "*The coding system for read to use when running the diff program as a subprocess.
744 In most cases, the default will do. However, under certain circumstances in
745 Windows NT/98/95 you might need to use something like 'raw-text-dos here.
746 So, if the output that your diff program sends to Emacs contains extra ^M's,
747 you might need to experiment here, if the default or 'raw-text-dos doesn't
752 (defcustom ediff-coding-system-for-write
'no-conversion
753 "*The coding system for write to use when writing out difference regions
754 to temp files when Ediff needs to find fine differences."
759 (ediff-cond-compile-for-xemacs-or-emacs
761 (fset 'ediff-read-event
(symbol-function 'next-command-event
))
762 (fset 'ediff-overlayp
(symbol-function 'extentp
))
763 (fset 'ediff-make-overlay
(symbol-function 'make-extent
))
764 (fset 'ediff-delete-overlay
(symbol-function 'delete-extent
)))
766 (fset 'ediff-read-event
(symbol-function 'read-event
))
767 (fset 'ediff-overlayp
(symbol-function 'overlayp
))
768 (fset 'ediff-make-overlay
(symbol-function 'make-overlay
))
769 (fset 'ediff-delete-overlay
(symbol-function 'delete-overlay
)))
772 ;; Check the current version against the major and minor version numbers
773 ;; using op: cur-vers op major.minor If emacs-major-version or
774 ;; emacs-minor-version are not defined, we assume that the current version
775 ;; is hopelessly outdated. We assume that emacs-major-version and
776 ;; emacs-minor-version are defined. Otherwise, for Emacs/XEmacs 19, if the
777 ;; current minor version is < 10 (xemacs) or < 23 (emacs) the return value
778 ;; will be nil (when op is =, >, or >=) and t (when op is <, <=), which may be
779 ;; incorrect. However, this gives correct result in our cases, since we are
780 ;; testing for sufficiently high Emacs versions.
781 (defun ediff-check-version (op major minor
&optional type-of-emacs
)
782 (if (and (boundp 'emacs-major-version
) (boundp 'emacs-minor-version
))
783 (and (cond ((eq type-of-emacs
'xemacs
) ediff-xemacs-p
)
784 ((eq type-of-emacs
'emacs
) ediff-emacs-p
)
786 (cond ((eq op
'=) (and (= emacs-minor-version minor
)
787 (= emacs-major-version major
)))
788 ((memq op
'(> >= < <=))
789 (and (or (funcall op emacs-major-version major
)
790 (= emacs-major-version major
))
791 (if (= emacs-major-version major
)
792 (funcall op emacs-minor-version minor
)
795 (error "%S: Invalid op in ediff-check-version" op
))))
796 (cond ((memq op
'(= > >=)) nil
)
797 ((memq op
'(< <=)) t
))))
800 (defun ediff-color-display-p ()
802 (ediff-cond-compile-for-xemacs-or-emacs
803 (eq (device-class (selected-device)) 'color
) ; xemacs form
804 (if (fboundp 'display-color-p
) ; emacs form
811 ;; A var local to each control panel buffer. Indicates highlighting style
812 ;; in effect for this buffer: `face', `ascii',
813 ;; `off' -- turned off \(on a dumb terminal only\).
814 (ediff-defvar-local ediff-highlighting-style
815 (if (and (ediff-has-face-support-p) ediff-use-faces
) 'face
'ascii
)
819 (if (ediff-has-face-support-p)
820 (ediff-cond-compile-for-xemacs-or-emacs
822 (defalias 'ediff-valid-color-p
'valid-color-name-p
)
823 (defalias 'ediff-get-face
'get-face
))
825 (defalias 'ediff-valid-color-p
(if (fboundp 'color-defined-p
)
828 (defalias 'ediff-get-face
'internal-get-face
))
831 (if (ediff-window-display-p)
832 (ediff-cond-compile-for-xemacs-or-emacs
834 (fset 'ediff-display-pixel-width
(symbol-function 'device-pixel-width
))
835 (fset 'ediff-display-pixel-height
836 (symbol-function 'device-pixel-height
)))
838 (fset 'ediff-display-pixel-width
839 (if (fboundp 'display-pixel-width
)
840 (symbol-function 'display-pixel-width
)
841 (symbol-function 'x-display-pixel-width
)))
842 (fset 'ediff-display-pixel-height
843 (if (fboundp 'display-pixel-height
)
844 (symbol-function 'display-pixel-height
)
845 (symbol-function 'x-display-pixel-height
))))
848 ;; A-list of current-diff-overlay symbols associated with buf types
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
)))
855 ;; A-list of current-diff-face-* symbols associated with buf types
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
)))
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
))
867 (defun ediff-region-help-echo (extent-or-window &optional overlay point
)
869 (setq overlay extent-or-window
))
870 (let ((is-current (ediff-overlay-get overlay
'ediff
))
871 (face (ediff-overlay-get overlay
'face
))
872 (diff-num (ediff-overlay-get overlay
'ediff-diff-num
))
875 ;; This happens only for refinement overlays
877 (setq face
(intern face
)))
878 (setq face-help
(and face
(get face
'ediff-help-echo
)))
880 (cond ((and is-current diff-num
) ; current diff region
881 (format "Difference region %S -- current" (1+ diff-num
)))
882 (face-help) ; refinement of current diff region
883 (diff-num ; non-current
884 (format "Difference region %S -- non-current" (1+ diff-num
)))
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)))
893 (set-face-background-pixmap face pixmap
)
895 (message "Pixmap not found for %S: %s" (face-name face
) pixmap
)
898 (defun ediff-hide-face (face)
899 (if (and (ediff-has-face-support-p) ediff-emacs-p
)
900 (add-to-list 'facemenu-unlisted-faces face
)))
904 (defface ediff-current-diff-face-A
905 '((((type tty
)) (:foreground
"blue3" :background
"yellow3"))
906 (((class color
)) (:foreground
"firebrick" :background
"pale green"))
907 (t (:inverse-video t
)))
908 "Face for highlighting the selected difference in buffer A."
909 :group
'ediff-highlighting
)
910 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
911 ;; this variable is set to nil, then again to the appropriate face.
912 (defvar ediff-current-diff-face-A
'ediff-current-diff-face-A
913 "Face for highlighting the selected difference in buffer A.
914 DO NOT CHANGE this variable. Instead, use the customization
915 widget to customize the actual face object `ediff-current-diff-face-A'
916 this variable represents.")
917 (ediff-hide-face 'ediff-current-diff-face-A
)
918 ;; Until custom.el for XEmacs starts supporting :inverse-video we do this.
919 ;; This means that some user customization may be trashed.
920 (if (and ediff-xemacs-p
921 (ediff-has-face-support-p)
922 (not (ediff-color-display-p)))
923 (copy-face 'modeline
'ediff-current-diff-face-A
))
927 (defface ediff-current-diff-face-B
928 '((((type tty
)) (:foreground
"magenta3" :background
"yellow3"
930 (((class color
)) (:foreground
"DarkOrchid" :background
"Yellow"))
931 (t (:inverse-video t
)))
932 "Face for highlighting the selected difference in buffer B."
933 :group
'ediff-highlighting
)
934 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
935 ;; this variable is set to nil, then again to the appropriate face.
936 (defvar ediff-current-diff-face-B
'ediff-current-diff-face-B
937 "Face for highlighting the selected difference in buffer B.
938 this variable. Instead, use the customization
939 widget to customize the actual face `ediff-current-diff-face-B'
940 this variable represents.")
941 (ediff-hide-face 'ediff-current-diff-face-B
)
942 ;; Until custom.el for XEmacs starts supporting :inverse-video we do this.
943 ;; This means that some user customization may be trashed.
944 (if (and ediff-xemacs-p
945 (ediff-has-face-support-p)
946 (not (ediff-color-display-p)))
947 (copy-face 'modeline
'ediff-current-diff-face-B
))
950 (defface ediff-current-diff-face-C
951 '((((type tty
)) (:foreground
"cyan3" :background
"yellow3" :weight bold
))
952 (((class color
)) (:foreground
"Navy" :background
"Pink"))
953 (t (:inverse-video t
)))
954 "Face for highlighting the selected difference in buffer C."
955 :group
'ediff-highlighting
)
956 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
957 ;; this variable is set to nil, then again to the appropriate face.
958 (defvar ediff-current-diff-face-C
'ediff-current-diff-face-C
959 "Face for highlighting the selected difference in buffer C.
960 DO NOT CHANGE this variable. Instead, use the customization
961 widget to customize the actual face object `ediff-current-diff-face-C'
962 this variable represents.")
963 (ediff-hide-face 'ediff-current-diff-face-C
)
964 ;; Until custom.el for XEmacs starts supporting :inverse-video we do this.
965 ;; This means that some user customization may be trashed.
966 (if (and ediff-xemacs-p
967 (ediff-has-face-support-p)
968 (not (ediff-color-display-p)))
969 (copy-face 'modeline
'ediff-current-diff-face-C
))
972 (defface ediff-current-diff-face-Ancestor
973 '((((type tty
)) (:foreground
"black" :background
"magenta3"))
974 (((class color
)) (:foreground
"Black" :background
"VioletRed"))
975 (t (:inverse-video t
)))
976 "Face for highlighting the selected difference in buffer Ancestor."
977 :group
'ediff-highlighting
)
978 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
979 ;; this variable is set to nil, then again to the appropriate face.
980 (defvar ediff-current-diff-face-Ancestor
'ediff-current-diff-face-Ancestor
981 "Face for highlighting the selected difference in buffer Ancestor.
982 DO NOT CHANGE this variable. Instead, use the customization
983 widget to customize the actual face object `ediff-current-diff-face-Ancestor'
984 this variable represents.")
985 (ediff-hide-face 'ediff-current-diff-face-Ancestor
)
986 ;; Until custom.el for XEmacs starts supporting :inverse-video we do this.
987 ;; This means that some user customization may be trashed.
988 (if (and ediff-xemacs-p
989 (ediff-has-face-support-p)
990 (not (ediff-color-display-p)))
991 (copy-face 'modeline
'ediff-current-diff-face-Ancestor
))
994 (defface ediff-fine-diff-face-A
995 '((((type tty
)) (:foreground
"white" :background
"sky blue" :weight bold
))
996 (((class color
)) (:foreground
"Navy" :background
"sky blue"))
997 (t (:underline t
:stipple
"gray3")))
998 "Face for highlighting the refinement of the selected diff in buffer A."
999 :group
'ediff-highlighting
)
1000 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
1001 ;; this variable is set to nil, then again to the appropriate face.
1002 (defvar ediff-fine-diff-face-A
'ediff-fine-diff-face-A
1003 "Face for highlighting the fine differences in buffer A.
1004 DO NOT CHANGE this variable. Instead, use the customization
1005 widget to customize the actual face object `ediff-fine-diff-face-A'
1006 this variable represents.")
1007 (ediff-hide-face 'ediff-fine-diff-face-A
)
1009 (defface ediff-fine-diff-face-B
1010 '((((type tty
)) (:foreground
"magenta3" :background
"cyan3"))
1011 (((class color
)) (:foreground
"Black" :background
"cyan"))
1012 (t (:underline t
:stipple
"gray3")))
1013 "Face for highlighting the refinement of the selected diff in buffer B."
1014 :group
'ediff-highlighting
)
1015 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
1016 ;; this variable is set to nil, then again to the appropriate face.
1017 (defvar ediff-fine-diff-face-B
'ediff-fine-diff-face-B
1018 "Face for highlighting the fine differences in buffer B.
1019 DO NOT CHANGE this variable. Instead, use the customization
1020 widget to customize the actual face object `ediff-fine-diff-face-B'
1021 this variable represents.")
1022 (ediff-hide-face 'ediff-fine-diff-face-B
)
1024 (defface ediff-fine-diff-face-C
1025 '((((type tty
)) (:foreground
"yellow3" :background
"Turquoise"
1027 (((type pc
)) (:foreground
"white" :background
"Turquoise"))
1028 (((class color
)) (:foreground
"Black" :background
"Turquoise"))
1029 (t (:underline t
:stipple
"gray3")))
1030 "Face for highlighting the refinement of the selected diff in buffer C."
1031 :group
'ediff-highlighting
)
1032 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
1033 ;; this variable is set to nil, then again to the appropriate face.
1034 (defvar ediff-fine-diff-face-C
'ediff-fine-diff-face-C
1035 "Face for highlighting the fine differences in buffer C.
1036 DO NOT CHANGE this variable. Instead, use the customization
1037 widget to customize the actual face object `ediff-fine-diff-face-C'
1038 this variable represents.")
1039 (ediff-hide-face 'ediff-fine-diff-face-C
)
1041 (defface ediff-fine-diff-face-Ancestor
1042 '((((type tty
)) (:foreground
"red3" :background
"green"))
1043 (((class color
)) (:foreground
"Black" :background
"Green"))
1044 (t (:underline t
:stipple
"gray3")))
1045 "Face for highlighting the refinement of the selected diff in the ancestor buffer.
1046 At present, this face is not used and no fine differences are computed for the
1048 :group
'ediff-highlighting
)
1049 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
1050 ;; this variable is set to nil, then again to the appropriate face.
1051 (defvar ediff-fine-diff-face-Ancestor
'ediff-fine-diff-face-Ancestor
1052 "Face for highlighting the fine differences in buffer Ancestor.
1053 DO NOT CHANGE this variable. Instead, use the customization
1054 widget to customize the actual face object `ediff-fine-diff-face-Ancestor'
1055 this variable represents.")
1056 (ediff-hide-face 'ediff-fine-diff-face-Ancestor
)
1058 ;; Some installs don't have stipple or Stipple. So, try them in turn.
1059 (defvar stipple-pixmap
1060 (cond ((not (ediff-has-face-support-p)) nil
)
1061 ((and (boundp 'x-bitmap-file-path
)
1062 (locate-library "stipple" t x-bitmap-file-path
)) "stipple")
1063 ((and (boundp 'mswindowsx-bitmap-file-path
)
1064 (locate-library "stipple" t mswindowsx-bitmap-file-path
)) "stipple")
1067 (defface ediff-even-diff-face-A
1068 `((((type tty
)) (:foreground
"red3" :background
"light grey"
1070 (((type pc
)) (:foreground
"green3" :background
"light grey"))
1071 (((class color
)) (:foreground
"Black" :background
"light grey"))
1072 (t (:italic t
:stipple
,stipple-pixmap
)))
1073 "Face for highlighting even-numbered non-current differences in buffer A."
1074 :group
'ediff-highlighting
)
1075 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
1076 ;; this variable is set to nil, then again to the appropriate face.
1077 (defvar ediff-even-diff-face-A
'ediff-even-diff-face-A
1078 "Face for highlighting even-numbered non-current differences in buffer A.
1079 DO NOT CHANGE this variable. Instead, use the customization
1080 widget to customize the actual face object `ediff-even-diff-face-A'
1081 this variable represents.")
1082 (ediff-hide-face 'ediff-even-diff-face-A
)
1084 (defface ediff-even-diff-face-B
1085 `((((type tty
)) (:foreground
"blue3" :background
"Grey" :weight bold
))
1086 (((class color
)) (:foreground
"White" :background
"Grey"))
1087 (t (:italic t
:stipple
,stipple-pixmap
)))
1088 "Face for highlighting even-numbered non-current differences in buffer B."
1089 :group
'ediff-highlighting
)
1090 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
1091 ;; this variable is set to nil, then again to the appropriate face.
1092 (defvar ediff-even-diff-face-B
'ediff-even-diff-face-B
1093 "Face for highlighting even-numbered non-current differences in buffer B.
1094 DO NOT CHANGE this variable. Instead, use the customization
1095 widget to customize the actual face object `ediff-even-diff-face-B'
1096 this variable represents.")
1097 (ediff-hide-face 'ediff-even-diff-face-B
)
1099 (defface ediff-even-diff-face-C
1100 `((((type tty
)) (:foreground
"yellow3" :background
"light grey"
1102 (((type pc
)) (:foreground
"yellow3" :background
"light grey"))
1103 (((class color
)) (:foreground
"Black" :background
"light grey"))
1104 (t (:italic t
:stipple
,stipple-pixmap
)))
1105 "Face for highlighting even-numbered non-current differences in buffer C."
1106 :group
'ediff-highlighting
)
1107 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
1108 ;; this variable is set to nil, then again to the appropriate face.
1109 (defvar ediff-even-diff-face-C
'ediff-even-diff-face-C
1110 "Face for highlighting even-numbered non-current differences in buffer C.
1111 DO NOT CHANGE this variable. Instead, use the customization
1112 widget to customize the actual face object `ediff-even-diff-face-C'
1113 this variable represents.")
1114 (ediff-hide-face 'ediff-even-diff-face-C
)
1116 (defface ediff-even-diff-face-Ancestor
1117 `((((type tty
)) (:foreground
"cyan3" :background
"light grey"
1119 (((type pc
)) (:foreground
"cyan3" :background
"light grey"))
1120 (((class color
)) (:foreground
"White" :background
"Grey"))
1121 (t (:italic t
:stipple
,stipple-pixmap
)))
1122 "Face for highlighting even-numbered non-current differences in the ancestor buffer."
1123 :group
'ediff-highlighting
)
1124 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
1125 ;; this variable is set to nil, then again to the appropriate face.
1126 (defvar ediff-even-diff-face-Ancestor
'ediff-even-diff-face-Ancestor
1127 "Face for highlighting even-numbered non-current differences in buffer Ancestor.
1128 DO NOT CHANGE this variable. Instead, use the customization
1129 widget to customize the actual face object `ediff-even-diff-face-Ancestor'
1130 this variable represents.")
1131 (ediff-hide-face 'ediff-even-diff-face-Ancestor
)
1133 ;; Association between buffer types and even-diff-face symbols
1134 (defconst ediff-even-diff-face-alist
1135 '((A . ediff-even-diff-face-A
)
1136 (B . ediff-even-diff-face-B
)
1137 (C . ediff-even-diff-face-C
)
1138 (Ancestor . ediff-even-diff-face-Ancestor
)))
1140 (defface ediff-odd-diff-face-A
1141 '((((type tty
)) (:foreground
"red3" :background
"black" :weight bold
))
1142 (((type pc
)) (:foreground
"green3" :background
"gray40"))
1143 (((class color
)) (:foreground
"White" :background
"Grey"))
1144 (t (:italic t
:stipple
"gray1")))
1145 "Face for highlighting odd-numbered non-current differences in buffer A."
1146 :group
'ediff-highlighting
)
1147 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
1148 ;; this variable is set to nil, then again to the appropriate face.
1149 (defvar ediff-odd-diff-face-A
'ediff-odd-diff-face-A
1150 "Face for highlighting odd-numbered non-current differences in buffer A.
1151 DO NOT CHANGE this variable. Instead, use the customization
1152 widget to customize the actual face object `ediff-odd-diff-face-A'
1153 this variable represents.")
1154 (ediff-hide-face 'ediff-odd-diff-face-A
)
1157 (defface ediff-odd-diff-face-B
1158 '((((type tty
)) (:foreground
"cyan3" :background
"black" :weight bold
))
1159 (((type pc
)) (:foreground
"White" :background
"gray40"))
1160 (((class color
)) (:foreground
"Black" :background
"light grey"))
1161 (t (:italic t
:stipple
"gray1")))
1162 "Face for highlighting odd-numbered non-current differences in buffer B."
1163 :group
'ediff-highlighting
)
1164 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
1165 ;; this variable is set to nil, then again to the appropriate face.
1166 (defvar ediff-odd-diff-face-B
'ediff-odd-diff-face-B
1167 "Face for highlighting odd-numbered non-current differences in buffer B.
1168 DO NOT CHANGE this variable. Instead, use the customization
1169 widget to customize the actual face object `ediff-odd-diff-face-B'
1170 this variable represents.")
1171 (ediff-hide-face 'ediff-odd-diff-face-B
)
1173 (defface ediff-odd-diff-face-C
1174 '((((type tty
)) (:foreground
"yellow3" :background
"black" :weight bold
))
1175 (((type pc
)) (:foreground
"yellow3" :background
"gray40"))
1176 (((class color
)) (:foreground
"White" :background
"Grey"))
1177 (t (:italic t
:stipple
"gray1")))
1178 "Face for highlighting odd-numbered non-current differences in buffer C."
1179 :group
'ediff-highlighting
)
1180 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
1181 ;; this variable is set to nil, then again to the appropriate face.
1182 (defvar ediff-odd-diff-face-C
'ediff-odd-diff-face-C
1183 "Face for highlighting odd-numbered non-current differences in buffer C.
1184 DO NOT CHANGE this variable. Instead, use the customization
1185 widget to customize the actual face object `ediff-odd-diff-face-C'
1186 this variable represents.")
1187 (ediff-hide-face 'ediff-odd-diff-face-C
)
1189 (defface ediff-odd-diff-face-Ancestor
1190 '((((type tty
)) (:foreground
"green3" :background
"black" :weight bold
))
1191 (((class color
)) (:foreground
"cyan3" :background
"gray40"))
1192 (t (:italic t
:stipple
"gray1")))
1193 "Face for highlighting odd-numbered non-current differences in the ancestor buffer."
1194 :group
'ediff-highlighting
)
1195 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
1196 ;; this variable is set to nil, then again to the appropriate face.
1197 (defvar ediff-odd-diff-face-Ancestor
'ediff-odd-diff-face-Ancestor
1198 "Face for highlighting odd-numbered non-current differences in buffer Ancestor.
1199 DO NOT CHANGE this variable. Instead, use the customization
1200 widget to customize the actual face object `ediff-odd-diff-face-Ancestor'
1201 this variable represents.")
1202 (ediff-hide-face 'ediff-odd-diff-face-Ancestor
)
1204 ;; Association between buffer types and odd-diff-face symbols
1205 (defconst ediff-odd-diff-face-alist
1206 '((A . ediff-odd-diff-face-A
)
1207 (B . ediff-odd-diff-face-B
)
1208 (C . ediff-odd-diff-face-C
)
1209 (Ancestor . ediff-odd-diff-face-Ancestor
)))
1211 ;; A-list of fine-diff face symbols associated with buffer types
1212 (defconst ediff-fine-diff-face-alist
1213 '((A . ediff-fine-diff-face-A
)
1214 (B . ediff-fine-diff-face-B
)
1215 (C . ediff-fine-diff-face-C
)
1216 (Ancestor . ediff-fine-diff-face-Ancestor
)))
1219 (put 'ediff-fine-diff-face-A
'ediff-help-echo
1220 "A `refinement' of the current difference region")
1221 (put 'ediff-fine-diff-face-B
'ediff-help-echo
1222 "A `refinement' of the current difference region")
1223 (put 'ediff-fine-diff-face-C
'ediff-help-echo
1224 "A `refinement' of the current difference region")
1225 (put 'ediff-fine-diff-face-Ancestor
'ediff-help-echo
1226 "A `refinement' of the current difference region")
1228 (add-hook 'ediff-quit-hook
'ediff-cleanup-mess
)
1229 (add-hook 'ediff-suspend-hook
'ediff-default-suspend-function
)
1234 (ediff-defvar-local ediff-current-diff-overlay-A nil
1235 "Overlay for the current difference region in buffer A.")
1236 (ediff-defvar-local ediff-current-diff-overlay-B nil
1237 "Overlay for the current difference region in buffer B.")
1238 (ediff-defvar-local ediff-current-diff-overlay-C nil
1239 "Overlay for the current difference region in buffer C.")
1240 (ediff-defvar-local ediff-current-diff-overlay-Ancestor nil
1241 "Overlay for the current difference region in the ancestor buffer.")
1243 ;; Compute priority of a current ediff overlay.
1244 (defun ediff-highest-priority (start end buffer
)
1245 (let ((pos (max 1 (1- start
)))
1247 (ediff-cond-compile-for-xemacs-or-emacs
1248 (1+ ediff-shadow-overlay-priority
) ; xemacs form
1250 (ediff-with-current-buffer buffer
1251 (while (< pos
(min (point-max) (1+ end
)))
1252 (setq ovr-list
(append (overlays-at pos
) ovr-list
))
1253 (setq pos
(next-overlay-change pos
)))
1254 (+ 1 ediff-shadow-overlay-priority
1261 ;; exclude ediff overlays from priority
1262 ;; calculation, or else priority will keep
1264 (null (ediff-overlay-get ovr
'ediff
))
1265 (null (ediff-overlay-get ovr
'ediff-diff-num
)))
1266 ;; use the overlay priority or 0
1267 (or (ediff-overlay-get ovr
'priority
) 0)
1272 ) ; ediff-cond-compile-for-xemacs-or-emacs
1276 (defvar ediff-toggle-read-only-function nil
1277 "*Specifies the function to be used to toggle read-only.
1278 If nil, Ediff tries to deduce the function from the binding of C-x C-q.
1279 Normally, this is the `toggle-read-only' function, but, if version
1280 control is used, it could be `vc-toggle-read-only' or `rcs-toggle-read-only'.")
1282 (defcustom ediff-make-buffers-readonly-at-startup nil
1283 "*Make all variant buffers read-only when Ediff starts up.
1284 This property can be toggled interactively."
1291 ;; if nil, this silences some messages
1292 (defconst ediff-verbose-p t
)
1294 (defcustom ediff-autostore-merges
'group-jobs-only
1295 "*Save the results of merge jobs automatically.
1296 nil means don't save automatically. t means always save. Anything else
1297 means save automatically only if the merge job is part of a group of jobs, such
1298 as `ediff-merge-directory' or `ediff-merge-directory-revisions'."
1299 :type
'(choice (const nil
) (const t
) (const group-jobs-only
))
1300 :group
'ediff-merge
)
1301 (make-variable-buffer-local 'ediff-autostore-merges
)
1303 ;; file where the result of the merge is to be saved. used internally
1304 (ediff-defvar-local ediff-merge-store-file nil
"")
1306 (defcustom ediff-merge-filename-prefix
"merge_"
1307 "*Prefix to be attached to saved merge buffers."
1309 :group
'ediff-merge
)
1311 (defcustom ediff-no-emacs-help-in-control-buffer nil
1312 "*Non-nil means C-h should not invoke Emacs help in control buffer.
1313 Instead, C-h would jump to previous difference."
1317 ;; This is the same as temporary-file-directory from Emacs 20.3.
1318 ;; Copied over here because XEmacs doesn't have this variable.
1319 (defcustom ediff-temp-file-prefix
1320 (file-name-as-directory
1321 (cond ((boundp 'temporary-file-directory
) temporary-file-directory
)
1322 ((fboundp 'temp-directory
) (temp-directory))
1324 ;;; (file-name-as-directory
1325 ;;; (cond ((memq system-type '(ms-dos windows-nt))
1326 ;;; (or (getenv "TEMP") (getenv "TMPDIR") (getenv "TMP") "c:/temp"))
1327 ;;; ((memq system-type '(vax-vms axp-vms))
1328 ;;; (or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP") "SYS$SCRATCH:"))
1330 ;;; (or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP") "/tmp"))))
1331 "*Prefix to put on Ediff temporary file names.
1332 Do not start with `~/' or `~USERNAME/'."
1336 (defcustom ediff-temp-file-mode
384 ; u=rw only
1337 "*Mode for Ediff temporary files."
1341 ;; Metacharacters that have to be protected from the shell when executing
1342 ;; a diff/diff3 command.
1343 (defcustom ediff-metachars
"[ \t\n!\"#$&'()*;<=>?[\\^`{|~]"
1344 "Regexp that matches characters that must be quoted with `\\' in shell command line.
1345 This default should work without changes."
1349 ;; needed to simulate frame-char-width in XEmacs.
1350 (defvar ediff-H-glyph
(if ediff-xemacs-p
(make-glyph "H")))
1353 ;; Temporary file used for refining difference regions in buffer A.
1354 (ediff-defvar-local ediff-temp-file-A nil
"")
1355 ;; Temporary file used for refining difference regions in buffer B.
1356 (ediff-defvar-local ediff-temp-file-B nil
"")
1357 ;; Temporary file used for refining difference regions in buffer C.
1358 (ediff-defvar-local ediff-temp-file-C nil
"")
1361 ;; If file-remote-p is defined (as in XEmacs, use it. Otherwise, check
1362 ;; if find-file-name-handler is defined for 'file-local-copy
1363 (defun ediff-file-remote-p (file-name)
1364 (or (and (fboundp 'file-remote-p
) (file-remote-p file-name
))
1365 (find-file-name-handler file-name
'file-local-copy
)))
1367 ;; File for which we can get attributes, such as size or date
1368 (defun ediff-listable-file (file-name)
1369 (let ((handler (find-file-name-handler file-name
'file-local-copy
)))
1370 (or (null handler
) (eq handler
'dired-handler-fn
))))
1373 (defsubst ediff-frame-unsplittable-p
(frame)
1374 (cdr (assq 'unsplittable
(frame-parameters frame
))))
1376 (defsubst ediff-get-next-window
(wind prev-wind
)
1377 (or (window-live-p wind
)
1378 (setq wind
(if prev-wind
1380 (selected-window)))))
1383 (defsubst ediff-kill-buffer-carefully
(buf)
1384 "Kill buffer BUF if it exists."
1385 (if (ediff-buffer-live-p buf
)
1386 (kill-buffer (get-buffer buf
))))
1388 (defsubst ediff-background-face
(buf-type dif-num
)
1389 ;; The value of dif-num is always 1- the one that user sees.
1390 ;; This is why even face is used when dif-num is odd.
1391 (ediff-get-symbol-from-alist
1392 buf-type
(if (ediff-odd-p dif-num
)
1393 ediff-even-diff-face-alist
1394 ediff-odd-diff-face-alist
)
1398 ;; activate faces on diff regions in buffer
1399 (defun ediff-paint-background-regions-in-one-buffer (buf-type unhighlight
)
1401 (eval (ediff-get-symbol-from-alist
1402 buf-type ediff-difference-vector-alist
)))
1404 (mapcar (lambda (rec)
1405 (setq overl
(ediff-get-diff-overlay-from-diff-record rec
)
1406 diff-num
(ediff-overlay-get overl
'ediff-diff-num
))
1407 (if (ediff-overlay-buffer overl
)
1408 ;; only if overlay is alive
1409 (ediff-set-overlay-face
1411 (if (not unhighlight
)
1412 (ediff-background-face buf-type diff-num
))))
1417 ;; activate faces on diff regions in all buffers
1418 (defun ediff-paint-background-regions (&optional unhighlight
)
1419 (ediff-paint-background-regions-in-one-buffer
1421 (ediff-paint-background-regions-in-one-buffer
1423 (ediff-paint-background-regions-in-one-buffer
1425 (ediff-paint-background-regions-in-one-buffer
1426 'Ancestor unhighlight
))
1429 ;; arg is a record for a given diff in a difference vector
1430 ;; this record is itself a vector
1431 (defsubst ediff-clear-fine-diff-vector
(diff-record)
1433 (mapcar 'ediff-delete-overlay
1434 (ediff-get-fine-diff-vector-from-diff-record diff-record
))))
1436 (defsubst ediff-clear-fine-differences-in-one-buffer
(n buf-type
)
1437 (ediff-clear-fine-diff-vector (ediff-get-difference n buf-type
))
1438 (ediff-set-fine-diff-vector n buf-type nil
))
1440 (defsubst ediff-clear-fine-differences
(n)
1441 (ediff-clear-fine-differences-in-one-buffer n
'A
)
1442 (ediff-clear-fine-differences-in-one-buffer n
'B
)
1444 (ediff-clear-fine-differences-in-one-buffer n
'C
)))
1447 (defsubst ediff-mouse-event-p
(event)
1448 (ediff-cond-compile-for-xemacs-or-emacs
1449 (button-event-p event
) ; xemacs form
1450 (string-match "mouse" (format "%S" (event-basic-type event
))) ; emacs form
1454 (defsubst ediff-key-press-event-p
(event)
1455 (ediff-cond-compile-for-xemacs-or-emacs
1456 (key-press-event-p event
) ; xemacs form
1457 (or (char-or-string-p event
) (symbolp event
)) ; emacs form
1460 (defun ediff-event-point (event)
1461 (cond ((ediff-mouse-event-p event
)
1462 (ediff-cond-compile-for-xemacs-or-emacs
1463 (event-point event
) ; xemacs form
1464 (posn-point (event-start event
)) ; emacs form
1467 ((ediff-key-press-event-p event
)
1471 (defun ediff-event-buffer (event)
1472 (cond ((ediff-mouse-event-p event
)
1473 (ediff-cond-compile-for-xemacs-or-emacs
1474 (event-buffer event
) ; xemacs form
1475 (window-buffer (posn-window (event-start event
))) ; emacs form
1478 ((ediff-key-press-event-p event
)
1482 (defun ediff-event-key (event-or-key)
1483 (ediff-cond-compile-for-xemacs-or-emacs
1484 (if (eventp event-or-key
) (event-key event-or-key
) event-or-key
) ; xemacs
1485 event-or-key
; emacs form
1489 (defsubst ediff-frame-iconified-p
(frame)
1490 (if (and (ediff-window-display-p) (frame-live-p frame
))
1491 (ediff-cond-compile-for-xemacs-or-emacs
1492 (frame-iconified-p frame
) ; xemacs form
1493 (eq (frame-visible-p frame
) 'icon
) ; emacs form
1497 (defsubst ediff-window-visible-p
(wind)
1498 ;; under TTY, window-live-p also means window is visible
1499 (and (window-live-p wind
)
1500 (or (not (ediff-window-display-p))
1501 (frame-visible-p (window-frame wind
)))))
1504 (defsubst ediff-frame-char-width
(frame)
1505 (ediff-cond-compile-for-xemacs-or-emacs
1506 (/ (frame-pixel-width frame
) (frame-width frame
)) ; xemacs
1507 (frame-char-width frame
) ; emacs
1510 (defun ediff-reset-mouse (&optional frame do-not-grab-mouse
)
1511 (or frame
(setq frame
(selected-frame)))
1512 (if (ediff-window-display-p)
1513 (let ((frame-or-wind frame
))
1515 (setq frame-or-wind
(frame-selected-window frame
)))
1516 (or do-not-grab-mouse
1517 ;; don't set mouse if the user said to never do this
1518 (not ediff-grab-mouse
)
1519 ;; Don't grab on quit, if the user doesn't want to.
1520 ;; If ediff-grab-mouse = t, then mouse won't be grabbed for
1521 ;; sessions that are not part of a group (this is done in
1522 ;; ediff-recenter). The condition below affects only terminating
1523 ;; sessions in session groups (in which case mouse is warped into
1525 (and (eq ediff-grab-mouse
'maybe
)
1526 (memq this-command
'(ediff-quit ediff-update-diffs
)))
1527 (set-mouse-position frame-or-wind
1 0))
1530 (defsubst ediff-spy-after-mouse
()
1531 (setq ediff-mouse-pixel-position
(mouse-pixel-position)))
1533 ;; It is not easy to find out when the user grabs the mouse, since emacs and
1534 ;; xemacs behave differently when mouse is not in any frame. Also, this is
1535 ;; sensitive to when the user grabbed mouse. Not used for now.
1536 (defun ediff-user-grabbed-mouse ()
1537 (if ediff-mouse-pixel-position
1538 (cond ((not (eq (car ediff-mouse-pixel-position
)
1539 (car (mouse-pixel-position)))))
1540 ((and (car (cdr ediff-mouse-pixel-position
))
1541 (car (cdr (mouse-pixel-position)))
1542 (cdr (cdr ediff-mouse-pixel-position
))
1543 (cdr (cdr (mouse-pixel-position))))
1544 (not (and (< (abs (- (car (cdr ediff-mouse-pixel-position
))
1545 (car (cdr (mouse-pixel-position)))))
1546 ediff-mouse-pixel-threshold
)
1547 (< (abs (- (cdr (cdr ediff-mouse-pixel-position
))
1548 (cdr (cdr (mouse-pixel-position)))))
1549 ediff-mouse-pixel-threshold
))))
1552 (defsubst ediff-frame-char-height
(frame)
1553 (ediff-cond-compile-for-xemacs-or-emacs
1554 (glyph-height ediff-H-glyph
(selected-window frame
)) ; xemacs cse
1555 (frame-char-height frame
) ; emacs case
1559 ;; Some overlay functions
1561 (defsubst ediff-overlay-start
(overl)
1562 (if (ediff-overlayp overl
)
1563 (ediff-cond-compile-for-xemacs-or-emacs
1564 (extent-start-position overl
) ; xemacs form
1565 (overlay-start overl
) ; emacs form
1569 (defsubst ediff-overlay-end
(overl)
1570 (if (ediff-overlayp overl
)
1571 (ediff-cond-compile-for-xemacs-or-emacs
1572 (extent-end-position overl
) ; xemacs form
1573 (overlay-end overl
) ; emacs form
1577 (defsubst ediff-empty-overlay-p
(overl)
1578 (= (ediff-overlay-start overl
) (ediff-overlay-end overl
)))
1580 ;; like overlay-buffer in Emacs. In XEmacs, returns nil if the extent is
1581 ;; dead. Otherwise, works like extent-buffer
1582 (defun ediff-overlay-buffer (overl)
1583 (ediff-cond-compile-for-xemacs-or-emacs
1584 (and (extent-live-p overl
) (extent-object overl
)) ; xemacs form
1585 (overlay-buffer overl
) ; emacs form
1588 ;; like overlay-get in Emacs. In XEmacs, returns nil if the extent is
1589 ;; dead. Otherwise, like extent-property
1590 (defun ediff-overlay-get (overl property
)
1591 (ediff-cond-compile-for-xemacs-or-emacs
1592 (and (extent-live-p overl
) (extent-property overl property
)) ; xemacs form
1593 (overlay-get overl property
) ; emacs form
1597 ;; These two functions are here because XEmacs refuses to
1598 ;; handle overlays whose buffers were deleted.
1599 (defun ediff-move-overlay (overlay beg end
&optional buffer
)
1600 "Calls `move-overlay' in Emacs and `set-extent-endpoints' in Lemacs.
1601 Checks if overlay's buffer exists before actually doing the move."
1602 (let ((buf (and overlay
(ediff-overlay-buffer overlay
))))
1603 (if (ediff-buffer-live-p buf
)
1604 (ediff-cond-compile-for-xemacs-or-emacs
1605 (set-extent-endpoints overlay beg end
) ; xemacs form
1606 (move-overlay overlay beg end buffer
) ; emacs form
1610 (ediff-delete-overlay overlay
)))))
1612 (defun ediff-overlay-put (overlay prop value
)
1613 "Calls `overlay-put' or `set-extent-property' depending on Emacs version.
1614 Checks if overlay's buffer exists."
1615 (if (ediff-buffer-live-p (ediff-overlay-buffer overlay
))
1616 (ediff-cond-compile-for-xemacs-or-emacs
1617 (set-extent-property overlay prop value
) ; xemacs form
1618 (overlay-put overlay prop value
) ; emacs form
1620 (ediff-delete-overlay overlay
)))
1622 ;; temporarily uses DIR to abbreviate file name
1623 ;; if DIR is nil, use default-directory
1624 (defun ediff-abbreviate-file-name (file &optional dir
)
1625 (cond ((stringp dir
)
1626 (let ((directory-abbrev-alist (list (cons dir
""))))
1627 (abbreviate-file-name file
)))
1629 (ediff-cond-compile-for-xemacs-or-emacs
1630 ;; XEmacs requires addl argument
1631 (abbreviate-file-name file t
) ; xemacs form
1632 (abbreviate-file-name file
)) ; emacs form
1636 ;; Takes a directory and returns the parent directory.
1637 ;; does nothing to `/'. If the ARG is a regular file,
1638 ;; strip the file AND the last dir.
1639 (defun ediff-strip-last-dir (dir)
1640 (if (not (stringp dir
)) (setq dir default-directory
))
1641 (setq dir
(expand-file-name dir
))
1642 (or (file-directory-p dir
) (setq dir
(file-name-directory dir
)))
1643 (let* ((pos (1- (length dir
)))
1644 (last-char (aref dir pos
)))
1645 (if (and (> pos
0) (= last-char ?
/))
1646 (setq dir
(substring dir
0 pos
)))
1647 (ediff-abbreviate-file-name (file-name-directory dir
))))
1649 (defun ediff-truncate-string-left (str newlen
)
1650 ;; leave space for ... on the left
1651 (let ((len (length str
))
1655 (setq newlen
(max 0 (- newlen
3)))
1656 (setq substr
(substring str
(max 0 (- len
1 newlen
))))
1657 (concat "..." substr
))))
1659 (defsubst ediff-nonempty-string-p
(string)
1660 (and (stringp string
) (not (string= string
""))))
1662 (unless (fboundp 'subst-char-in-string
)
1663 (defun subst-char-in-string (fromchar tochar string
&optional inplace
)
1664 "Replace FROMCHAR with TOCHAR in STRING each time it occurs.
1665 Unless optional argument INPLACE is non-nil, return a new string."
1666 (let ((i (length string
))
1667 (newstr (if inplace string
(copy-sequence string
))))
1670 (if (eq (aref newstr i
) fromchar
)
1671 (aset newstr i tochar
)))
1674 (defun ediff-abbrev-jobname (jobname)
1675 (cond ((eq jobname
'ediff-directories
)
1676 "Compare two directories")
1677 ((eq jobname
'ediff-files
)
1678 "Compare two files")
1679 ((eq jobname
'ediff-buffers
)
1680 "Compare two buffers")
1681 ((eq jobname
'ediff-directories3
)
1682 "Compare three directories")
1683 ((eq jobname
'ediff-files3
)
1684 "Compare three files")
1685 ((eq jobname
'ediff-buffers3
)
1686 "Compare three buffers")
1687 ((eq jobname
'ediff-revision
)
1688 "Compare file with a version")
1689 ((eq jobname
'ediff-directory-revisions
)
1690 "Compare dir files with versions")
1691 ((eq jobname
'ediff-merge-directory-revisions
)
1692 "Merge dir files with versions")
1693 ((eq jobname
'ediff-merge-directory-revisions-with-ancestor
)
1694 "Merge dir versions via ancestors")
1697 (subst-char-in-string ?- ?\
(substring (symbol-name jobname
) 6))))
1701 ;; If ediff modified mode line, strip the modification
1702 (defsubst ediff-strip-mode-line-format
()
1703 (if (member (car mode-line-format
) '(" A: " " B: " " C: " " Ancestor: "))
1704 (setq mode-line-format
(nth 2 mode-line-format
))))
1706 ;; Verify that we have a difference selected.
1707 (defsubst ediff-valid-difference-p
(&optional n
)
1708 (or n
(setq n ediff-current-difference
))
1709 (and (>= n
0) (< n ediff-number-of-differences
)))
1711 (defsubst ediff-show-all-diffs
(n)
1712 "Don't skip difference regions."
1716 (or (and a
(not b
)) (and (not a
) b
)))
1718 (defsubst ediff-message-if-verbose
(string &rest args
)
1720 (apply 'message string args
)))
1722 (defun ediff-file-attributes (filename attr-number
)
1723 (if (ediff-listable-file filename
)
1724 (nth attr-number
(file-attributes filename
))
1728 (defsubst ediff-file-size
(filename)
1729 (ediff-file-attributes filename
7))
1730 (defsubst ediff-file-modtime
(filename)
1731 (ediff-file-attributes filename
5))
1734 (defun ediff-convert-standard-filename (fname)
1735 (if (fboundp 'convert-standard-filename
)
1736 (convert-standard-filename fname
)
1740 (if (fboundp 'with-syntax-table
)
1741 (fset 'ediff-with-syntax-table
'with-syntax-table
)
1742 ;; stolen from subr.el in emacs 21
1743 (defmacro ediff-with-syntax-table
(table &rest body
)
1744 (let ((old-table (make-symbol "table"))
1745 (old-buffer (make-symbol "buffer")))
1746 `(let ((,old-table
(syntax-table))
1747 (,old-buffer
(current-buffer)))
1750 (set-syntax-table (copy-syntax-table ,table
))
1752 (save-current-buffer
1753 (set-buffer ,old-buffer
)
1754 (set-syntax-table ,old-table
)))))))
1758 ;;; Local Variables:
1759 ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun)
1760 ;;; eval: (put 'ediff-with-current-buffer 'lisp-indent-hook 1)
1761 ;;; eval: (put 'ediff-with-current-buffer 'edebug-form-spec '(form body))
1764 (provide 'ediff-init
)
1766 ;;; ediff-init.el ends here