(update_frame): Move the variable `tem' to the block where it is used.
[emacs.git] / lisp / ediff-init.el
blob729d6f76e195ea5b09349f6a4e1d9ec3dec50d78
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)
12 ;; any later version.
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.
24 ;;; Commentary:
26 ;;; Code:
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)
40 (and noninteractive
41 (eval-when-compile
42 (load "ange-ftp" 'noerror)))
43 ;; end pacifier
45 ;; Is it XEmacs?
46 (defconst ediff-xemacs-p (string-match "XEmacs" emacs-version))
47 ;; Is it Emacs?
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
53 ;; compiler at hand.
54 ;; Suggested by rms.
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))
78 (ediff-force-faces)
79 ((ediff-color-display-p))
80 (ediff-emacs-p (memq (ediff-device-type) '(pc)))
81 (ediff-xemacs-p (memq (ediff-device-type) '(tty pc)))))
83 ;; toolbar support for emacs hasn't been implemented in ediff
84 (defun ediff-has-toolbar-support-p ()
85 (ediff-cond-compile-for-xemacs-or-emacs
86 (and (featurep 'toolbar) (console-on-window-system-p)) ; xemacs form
87 nil ; emacs form
90 (defun ediff-use-toolbar-p ()
91 (and (ediff-has-toolbar-support-p) ;Can it do it ?
92 (boundp 'ediff-use-toolbar-p)
93 ediff-use-toolbar-p)) ;Does the user want it ?
95 ;; Defines SYMBOL as an advertised local variable.
96 ;; Performs a defvar, then executes `make-variable-buffer-local' on
97 ;; the variable. Also sets the `permanent-local' property,
98 ;; so that `kill-all-local-variables' (called by major-mode setting
99 ;; commands) won't destroy Ediff control variables.
101 ;; Plagiarised from `emerge-defvar-local' for XEmacs.
102 (defmacro ediff-defvar-local (var value doc)
103 `(progn
104 (defvar ,var ,value ,doc)
105 (make-variable-buffer-local ',var)
106 (put ',var 'permanent-local t)))
110 ;; Variables that control each Ediff session---local to the control buffer.
112 ;; Mode variables
113 ;; The buffer in which the A variant is stored.
114 (ediff-defvar-local ediff-buffer-A nil "")
115 ;; The buffer in which the B variant is stored.
116 (ediff-defvar-local ediff-buffer-B nil "")
117 ;; The buffer in which the C variant is stored or where the merge buffer lives.
118 (ediff-defvar-local ediff-buffer-C nil "")
119 ;; Ancestor buffer
120 (ediff-defvar-local ediff-ancestor-buffer nil "")
121 ;; The Ediff control buffer
122 (ediff-defvar-local ediff-control-buffer nil "")
124 (ediff-defvar-local ediff-temp-indirect-buffer nil
125 "If t, the buffer is a temporary indirect buffer.
126 It needs to be killed when we quit the session.")
129 ;; Association between buff-type and ediff-buffer-*
130 (defconst ediff-buffer-alist
131 '((?A . ediff-buffer-A)
132 (?B . ediff-buffer-B)
133 (?C . ediff-buffer-C)))
135 ;;; Macros
136 (defmacro ediff-odd-p (arg)
137 `(eq (logand ,arg 1) 1))
139 (defmacro ediff-buffer-live-p (buf)
140 `(and ,buf (get-buffer ,buf) (buffer-name (get-buffer ,buf))))
142 (defmacro ediff-get-buffer (arg)
143 `(cond ((eq ,arg 'A) ediff-buffer-A)
144 ((eq ,arg 'B) ediff-buffer-B)
145 ((eq ,arg 'C) ediff-buffer-C)
146 ((eq ,arg 'Ancestor) ediff-ancestor-buffer)
149 (defmacro ediff-get-value-according-to-buffer-type (buf-type list)
150 `(cond ((eq ,buf-type 'A) (nth 0 ,list))
151 ((eq ,buf-type 'B) (nth 1 ,list))
152 ((eq ,buf-type 'C) (nth 2 ,list))
155 (defmacro ediff-char-to-buftype (arg)
156 `(cond ((memq ,arg '(?a ?A)) 'A)
157 ((memq ,arg '(?b ?B)) 'B)
158 ((memq ,arg '(?c ?C)) 'C)
162 ;; A-list is supposed to be of the form (A . symb) (B . symb)...)
163 ;; where the first part of any association is a buffer type and the second is
164 ;; an appropriate symbol. Given buffer-type, this function returns the
165 ;; symbol. This is used to avoid using `intern'
166 (defsubst ediff-get-symbol-from-alist (buf-type alist)
167 (cdr (assoc buf-type alist)))
169 (defconst ediff-difference-vector-alist
170 '((A . ediff-difference-vector-A)
171 (B . ediff-difference-vector-B)
172 (C . ediff-difference-vector-C)
173 (Ancestor . ediff-difference-vector-Ancestor)))
175 (defmacro ediff-get-difference (n buf-type)
176 `(aref
177 (symbol-value
178 (ediff-get-symbol-from-alist
179 ,buf-type ediff-difference-vector-alist))
180 ,n))
182 ;; Tell if it has been previously determined that the region has
183 ;; no diffs other than the white space and newlines
184 ;; The argument, N, is the diff region number used by Ediff to index the
185 ;; diff vector. It is 1 less than the number seen by the user.
186 ;; Returns:
187 ;; t if the diffs are whitespace in all buffers
188 ;; 'A (in 3-buf comparison only) if there are only whitespace
189 ;; diffs in bufs B and C
190 ;; 'B (in 3-buf comparison only) if there are only whitespace
191 ;; diffs in bufs A and C
192 ;; 'C (in 3-buf comparison only) if there are only whitespace
193 ;; diffs in bufs A and B
195 ;; A Difference Vector has the form:
196 ;; [diff diff diff ...]
197 ;; where each diff has the form:
198 ;; [overlay fine-diff-vector no-fine-diffs-flag state-of-difference]
199 ;; fine-diff-vector is a vector [fine-diff fine-diff fine-diff ...]
200 ;; no-fine-diffs-flag says if there are fine differences.
201 ;; state-of-difference is A, B, C, or nil, indicating which buffer is
202 ;; different from the other two (used only in 3-way jobs).
203 (defmacro ediff-no-fine-diffs-p (n)
204 `(aref (ediff-get-difference ,n 'A) 2))
206 (defmacro ediff-get-diff-overlay-from-diff-record (diff-rec)
207 `(aref ,diff-rec 0))
209 (defmacro ediff-get-diff-overlay (n buf-type)
210 `(ediff-get-diff-overlay-from-diff-record
211 (ediff-get-difference ,n ,buf-type)))
213 (defmacro ediff-get-fine-diff-vector-from-diff-record (diff-rec)
214 `(aref ,diff-rec 1))
216 (defmacro ediff-set-fine-diff-vector (n buf-type fine-vec)
217 `(aset (ediff-get-difference ,n ,buf-type) 1 ,fine-vec))
219 (defmacro ediff-get-state-of-diff (n buf-type)
220 `(if (ediff-buffer-live-p ediff-buffer-C)
221 (aref (ediff-get-difference ,n ,buf-type) 3)))
222 (defmacro ediff-set-state-of-diff (n buf-type val)
223 `(aset (ediff-get-difference ,n ,buf-type) 3 ,val))
225 (defmacro ediff-get-state-of-merge (n)
226 `(if ediff-state-of-merge
227 (aref (aref ediff-state-of-merge ,n) 0)))
228 (defmacro ediff-set-state-of-merge (n val)
229 `(if ediff-state-of-merge
230 (aset (aref ediff-state-of-merge ,n) 0 ,val)))
232 (defmacro ediff-get-state-of-ancestor (n)
233 `(if ediff-state-of-merge
234 (aref (aref ediff-state-of-merge ,n) 1)))
236 ;; if flag is t, puts a mark on diff region saying that
237 ;; the differences are in white space only. If flag is nil,
238 ;; the region is marked as essential (i.e., differences are
239 ;; not just in the white space and newlines.)
240 (defmacro ediff-mark-diff-as-space-only (n flag)
241 `(aset (ediff-get-difference ,n 'A) 2 ,flag))
243 (defmacro ediff-get-fine-diff-vector (n buf-type)
244 `(ediff-get-fine-diff-vector-from-diff-record
245 (ediff-get-difference ,n ,buf-type)))
247 ;; Macro to switch to BUFFER, evaluate BODY, returns to original buffer.
248 ;; Doesn't save the point and mark.
249 ;; This is `with-current-buffer' with the added test for live buffers."
250 (defmacro ediff-with-current-buffer (buffer &rest body)
251 `(if (ediff-buffer-live-p ,buffer)
252 (save-current-buffer
253 (set-buffer ,buffer)
254 ,@body)
255 (or (eq this-command 'ediff-quit)
256 (error ediff-KILLED-VITAL-BUFFER))
260 (defsubst ediff-multiframe-setup-p ()
261 (and (ediff-window-display-p) ediff-multiframe))
263 (defmacro ediff-narrow-control-frame-p ()
264 `(and (ediff-multiframe-setup-p)
265 (equal ediff-help-message ediff-brief-message-string)))
267 (defmacro ediff-3way-comparison-job ()
268 `(memq
269 ediff-job-name
270 '(ediff-files3 ediff-buffers3)))
271 (ediff-defvar-local ediff-3way-comparison-job nil "")
273 (defmacro ediff-merge-job ()
274 `(memq
275 ediff-job-name
276 '(ediff-merge-files
277 ediff-merge-buffers
278 ediff-merge-files-with-ancestor
279 ediff-merge-buffers-with-ancestor
280 ediff-merge-revisions
281 ediff-merge-revisions-with-ancestor)))
282 (ediff-defvar-local ediff-merge-job nil "")
284 (defmacro ediff-merge-with-ancestor-job ()
285 `(memq
286 ediff-job-name
287 '(ediff-merge-files-with-ancestor
288 ediff-merge-buffers-with-ancestor
289 ediff-merge-revisions-with-ancestor)))
290 (ediff-defvar-local ediff-merge-with-ancestor-job nil "")
292 (defmacro ediff-3way-job ()
293 `(or ediff-3way-comparison-job ediff-merge-job))
294 (ediff-defvar-local ediff-3way-job nil "")
296 ;; A diff3 job is like a 3way job, but ediff-merge doesn't require the use
297 ;; of diff3.
298 (defmacro ediff-diff3-job ()
299 `(or ediff-3way-comparison-job
300 ediff-merge-with-ancestor-job))
301 (ediff-defvar-local ediff-diff3-job nil "")
303 (defmacro ediff-windows-job ()
304 `(memq ediff-job-name '(ediff-windows-wordwise ediff-windows-linewise)))
305 (ediff-defvar-local ediff-windows-job nil "")
307 (defmacro ediff-word-mode-job ()
308 `(memq ediff-job-name '(ediff-windows-wordwise ediff-regions-wordwise)))
309 (ediff-defvar-local ediff-word-mode-job nil "")
311 (defmacro ediff-narrow-job ()
312 `(memq ediff-job-name '(ediff-windows-wordwise
313 ediff-regions-wordwise
314 ediff-windows-linewise
315 ediff-regions-linewise)))
316 (ediff-defvar-local ediff-narrow-job nil "")
318 ;; Note: ediff-merge-directory-revisions-with-ancestor is not treated as an
319 ;; ancestor metajob, since it behaves differently.
320 (defsubst ediff-ancestor-metajob (&optional metajob)
321 (memq (or metajob ediff-metajob-name)
322 '(ediff-merge-directories-with-ancestor
323 ediff-merge-filegroups-with-ancestor)))
324 (defsubst ediff-revision-metajob (&optional metajob)
325 (memq (or metajob ediff-metajob-name)
326 '(ediff-directory-revisions
327 ediff-merge-directory-revisions
328 ediff-merge-directory-revisions-with-ancestor)))
329 (defsubst ediff-patch-metajob (&optional metajob)
330 (memq (or metajob ediff-metajob-name)
331 '(ediff-multifile-patch)))
332 ;; metajob involving only one group of files, such as multipatch or directory
333 ;; revision
334 (defsubst ediff-one-filegroup-metajob (&optional metajob)
335 (or (ediff-revision-metajob metajob)
336 (ediff-patch-metajob metajob)
337 ;; add more here
339 (defsubst ediff-collect-diffs-metajob (&optional metajob)
340 (memq (or metajob ediff-metajob-name)
341 '(ediff-directories
342 ediff-directory-revisions
343 ediff-merge-directories
344 ediff-merge-directories-with-ancestor
345 ediff-merge-directory-revisions
346 ediff-merge-directory-revisions-with-ancestor
347 ;; add more here
349 (defsubst ediff-merge-metajob (&optional metajob)
350 (memq (or metajob ediff-metajob-name)
351 '(ediff-merge-directories
352 ediff-merge-directories-with-ancestor
353 ediff-merge-directory-revisions
354 ediff-merge-directory-revisions-with-ancestor
355 ediff-merge-filegroups-with-ancestor
356 ;; add more here
359 (defsubst ediff-metajob3 (&optional metajob)
360 (memq (or metajob ediff-metajob-name)
361 '(ediff-merge-directories-with-ancestor
362 ediff-merge-filegroups-with-ancestor
363 ediff-directories3
364 ediff-filegroups3)))
365 (defsubst ediff-comparison-metajob3 (&optional metajob)
366 (memq (or metajob ediff-metajob-name)
367 '(ediff-directories3 ediff-filegroups3)))
369 ;; with no argument, checks if we are in ediff-control-buffer
370 ;; with argument, checks if we are in ediff-meta-buffer
371 (defun ediff-in-control-buffer-p (&optional meta-buf-p)
372 (and (boundp 'ediff-control-buffer)
373 (eq (if meta-buf-p ediff-meta-buffer ediff-control-buffer)
374 (current-buffer))))
376 (defsubst ediff-barf-if-not-control-buffer (&optional meta-buf-p)
377 (or (ediff-in-control-buffer-p meta-buf-p)
378 (error "%S: This command runs in Ediff Control Buffer only!"
379 this-command)))
381 (defgroup ediff-highlighting nil
382 "Hilighting of difference regions in Ediff"
383 :prefix "ediff-"
384 :group 'ediff)
386 (defgroup ediff-merge nil
387 "Merging utilities"
388 :prefix "ediff-"
389 :group 'ediff)
391 (defgroup ediff-hook nil
392 "Hooks run by Ediff"
393 :prefix "ediff-"
394 :group 'ediff)
396 ;; Hook variables
398 (defcustom ediff-before-setup-hook nil
399 "*Hooks to run before Ediff begins to set up windows and buffers.
400 This hook can be used to save the previous window config, which can be restored
401 on ediff-quit or ediff-suspend."
402 :type 'hook
403 :group 'ediff-hook)
404 (defcustom ediff-before-setup-windows-hook nil
405 "*Hooks to run before Ediff sets its window configuration.
406 This hook is run every time when Ediff arranges its windows.
407 This happens each time Ediff detects that the windows were messed up by the
408 user."
409 :type 'hook
410 :group 'ediff-hook)
411 (defcustom ediff-after-setup-windows-hook nil
412 "*Hooks to run after Ediff sets its window configuration.
413 This can be used to set up control window or icon in a desired place."
414 :type 'hook
415 :group 'ediff-hook)
416 (defcustom ediff-before-setup-control-frame-hook nil
417 "*Hooks run before setting up the frame to display Ediff Control Panel.
418 Can be used to change control frame parameters to position it where it
419 is desirable."
420 :type 'hook
421 :group 'ediff-hook)
422 (defcustom ediff-after-setup-control-frame-hook nil
423 "*Hooks run after setting up the frame to display Ediff Control Panel.
424 Can be used to move the frame where it is desired."
425 :type 'hook
426 :group 'ediff-hook)
427 (defcustom ediff-startup-hook nil
428 "*Hooks to run in the control buffer after Ediff has been set up and is ready for the job."
429 :type 'hook
430 :group 'ediff-hook)
431 (defcustom ediff-select-hook nil
432 "*Hooks to run after a difference has been selected."
433 :type 'hook
434 :group 'ediff-hook)
435 (defcustom ediff-unselect-hook nil
436 "*Hooks to run after a difference has been unselected."
437 :type 'hook
438 :group 'ediff-hook)
439 (defcustom ediff-prepare-buffer-hook nil
440 "*Hooks run after buffers A, B, and C are set up.
441 For each buffer, the hooks are run with that buffer made current."
442 :type 'hook
443 :group 'ediff-hook)
444 (defcustom ediff-load-hook nil
445 "*Hook run after Ediff is loaded. Can be used to change defaults."
446 :type 'hook
447 :group 'ediff-hook)
449 (defcustom ediff-mode-hook nil
450 "*Hook run just after ediff-mode is set up in the control buffer.
451 This is done before any windows or frames are created. One can use it to
452 set local variables that determine how the display looks like."
453 :type 'hook
454 :group 'ediff-hook)
455 (defcustom ediff-keymap-setup-hook nil
456 "*Hook run just after the default bindings in Ediff keymap are set up."
457 :type 'hook
458 :group 'ediff-hook)
460 (defcustom ediff-display-help-hook nil
461 "*Hooks run after preparing the help message."
462 :type 'hook
463 :group 'ediff-hook)
465 (defcustom ediff-suspend-hook nil
466 "*Hooks to run in the Ediff control buffer when Ediff is suspended."
467 :type 'hook
468 :group 'ediff-hook)
469 (defcustom ediff-quit-hook nil
470 "*Hooks to run in the Ediff control buffer after finishing Ediff."
471 :type 'hook
472 :group 'ediff-hook)
473 (defcustom ediff-cleanup-hook nil
474 "*Hooks to run on exiting Ediff but before killing the control and variant buffers."
475 :type 'hook
476 :group 'ediff-hook)
478 ;; Error messages
479 (defconst ediff-KILLED-VITAL-BUFFER
480 "You have killed a vital Ediff buffer---you must leave Ediff now!")
481 (defconst ediff-NO-DIFFERENCES
482 "Sorry, comparison of identical variants is not what I am made for...")
483 (defconst ediff-BAD-DIFF-NUMBER
484 ;; %S stands for this-command, %d - diff number, %d - max diff
485 "%S: Bad diff region number, %d. Valid numbers are 1 to %d")
486 (defconst ediff-BAD-INFO (format "
487 *** The Info file for Ediff, a part of the standard distribution
488 *** of %sEmacs, does not seem to be properly installed.
490 *** Please contact your system administrator. "
491 (if ediff-xemacs-p "X" "")))
493 ;; Selective browsing
495 (ediff-defvar-local ediff-skip-diff-region-function 'ediff-show-all-diffs
496 "Function that determines the next/previous diff region to show.
497 Should return t for regions to be ignored and nil otherwise.
498 This function gets a region number as an argument. The region number
499 is the one used internally by Ediff. It is 1 less than the number seen
500 by the user.")
502 (ediff-defvar-local ediff-hide-regexp-matches-function
503 'ediff-hide-regexp-matches
504 "Function to use in determining which regions to hide.
505 See the documentation string of `ediff-hide-regexp-matches' for details.")
506 (ediff-defvar-local ediff-focus-on-regexp-matches-function
507 'ediff-focus-on-regexp-matches
508 "Function to use in determining which regions to focus on.
509 See the documentation string of `ediff-focus-on-regexp-matches' for details.")
511 ;; Regexp that determines buf A regions to focus on when skipping to diff
512 (ediff-defvar-local ediff-regexp-focus-A "" "")
513 ;; Regexp that determines buf B regions to focus on when skipping to diff
514 (ediff-defvar-local ediff-regexp-focus-B "" "")
515 ;; Regexp that determines buf C regions to focus on when skipping to diff
516 (ediff-defvar-local ediff-regexp-focus-C "" "")
517 ;; connective that determines whether to focus regions that match both or
518 ;; one of the regexps
519 (ediff-defvar-local ediff-focus-regexp-connective 'and "")
521 ;; Regexp that determines buf A regions to ignore when skipping to diff
522 (ediff-defvar-local ediff-regexp-hide-A "" "")
523 ;; Regexp that determines buf B regions to ignore when skipping to diff
524 (ediff-defvar-local ediff-regexp-hide-B "" "")
525 ;; Regexp that determines buf C regions to ignore when skipping to diff
526 (ediff-defvar-local ediff-regexp-hide-C "" "")
527 ;; connective that determines whether to hide regions that match both or
528 ;; one of the regexps
529 (ediff-defvar-local ediff-hide-regexp-connective 'and "")
532 ;;; Copying difference regions between buffers.
534 ;; A list of killed diffs.
535 ;; A diff is saved here if it is replaced by a diff
536 ;; from another buffer. This alist has the form:
537 ;; \((num (buff-object . diff) (buff-object . diff) (buff-object . diff)) ...),
538 ;; where some buffer-objects may be missing.
539 (ediff-defvar-local ediff-killed-diffs-alist nil "")
541 ;; Syntax table to use in ediff-forward-word-function
542 ;; This is chosen by a heuristic. The important thing is for all buffers to
543 ;; have the same syntax table. Which is not too important.
544 (ediff-defvar-local ediff-syntax-table nil "")
547 ;; Highlighting
548 (defcustom ediff-before-flag-bol (if ediff-xemacs-p (make-glyph "->>") "->>")
549 "*Flag placed before a highlighted block of differences, if block starts at beginning of a line."
550 :type 'string
551 :tag "Region before-flag at beginning of line"
552 :group 'ediff)
554 (defcustom ediff-after-flag-eol (if ediff-xemacs-p (make-glyph "<<-") "<<-")
555 "*Flag placed after a highlighted block of differences, if block ends at end of a line."
556 :type 'string
557 :tag "Region after-flag at end of line"
558 :group 'ediff)
560 (defcustom ediff-before-flag-mol (if ediff-xemacs-p (make-glyph "->>") "->>")
561 "*Flag placed before a highlighted block of differences, if block starts in mid-line."
562 :type 'string
563 :tag "Region before-flag in the middle of line"
564 :group 'ediff)
565 (defcustom ediff-after-flag-mol (if ediff-xemacs-p (make-glyph "<<-") "<<-")
566 "*Flag placed after a highlighted block of differences, if block ends in mid-line."
567 :type 'string
568 :tag "Region after-flag in the middle of line"
569 :group 'ediff)
572 (ediff-defvar-local ediff-use-faces t "")
573 (defcustom ediff-use-faces t
574 "If t, differences are highlighted using faces, if device supports faces.
575 If nil, differences are highlighted using ASCII flags, ediff-before-flag
576 and ediff-after-flag. On a non-window system, differences are always
577 highlighted using ASCII flags."
578 :type 'boolean
579 :group 'ediff-highlighting)
581 ;; this indicates that diff regions are word-size, so fine diffs are
582 ;; permanently nixed; used in ediff-windows-wordwise and ediff-regions-wordwise
583 (ediff-defvar-local ediff-word-mode nil "")
584 ;; Name of the job (ediff-files, ediff-windows, etc.)
585 (ediff-defvar-local ediff-job-name nil "")
587 ;; Narrowing and ediff-region/windows support
588 ;; This is a list (overlay-A overlay-B overlay-C)
589 ;; If set, Ediff compares only those parts of buffers A/B/C that lie within
590 ;; the bounds of these overlays.
591 (ediff-defvar-local ediff-narrow-bounds nil "")
593 ;; List (overlay-A overlay-B overlay-C), where each overlay spans the
594 ;; entire corresponding buffer.
595 (ediff-defvar-local ediff-wide-bounds nil "")
597 ;; Current visibility boundaries in buffers A, B, and C.
598 ;; This is also a list of overlays. When the user toggles narrow/widen,
599 ;; this list changes from ediff-wide-bounds to ediff-narrow-bounds.
600 ;; and back.
601 (ediff-defvar-local ediff-visible-bounds nil "")
603 (ediff-defvar-local ediff-start-narrowed t
604 "Non-nil means start narrowed, if doing ediff-windows-* or ediff-regions-*")
605 (ediff-defvar-local ediff-quit-widened t
606 "*Non-nil means: when finished, Ediff widens buffers A/B.
607 Actually, Ediff restores the scope of visibility that existed at startup.")
609 (defcustom ediff-keep-variants t
610 "*nil means prompt to remove unmodified buffers A/B/C at session end.
611 Supplying a prefix argument to the quit command `q' temporarily reverses the
612 meaning of this variable."
613 :type 'boolean
614 :group 'ediff)
616 (ediff-defvar-local ediff-highlight-all-diffs t "")
617 (defcustom ediff-highlight-all-diffs t
618 "If nil, only the selected differences are highlighted.
619 Otherwise, all difference regions are highlighted, but the selected region is
620 shown in brighter colors."
621 :type 'boolean
622 :group 'ediff-highlighting)
624 ;; A var local to each control panel buffer. Indicates highlighting style
625 ;; in effect for this buffer: `face', `ascii', nil -- temporarily
626 ;; unhighlighted, `off' -- turned off \(on a dumb terminal only\).
627 (ediff-defvar-local ediff-highlighting-style nil "")
630 ;; The suffix of the control buffer name.
631 (ediff-defvar-local ediff-control-buffer-suffix nil "")
632 ;; Same as ediff-control-buffer-suffix, but without <,>.
633 ;; It's a number rather than string.
634 (ediff-defvar-local ediff-control-buffer-number nil "")
637 ;; The original values of ediff-protected-variables for buffer A
638 (ediff-defvar-local ediff-buffer-values-orig-A nil "")
639 ;; The original values of ediff-protected-variables for buffer B
640 (ediff-defvar-local ediff-buffer-values-orig-B nil "")
641 ;; The original values of ediff-protected-variables for buffer C
642 (ediff-defvar-local ediff-buffer-values-orig-C nil "")
643 ;; The original values of ediff-protected-variables for buffer Ancestor
644 (ediff-defvar-local ediff-buffer-values-orig-Ancestor nil "")
646 ;; association between buff-type and ediff-buffer-values-orig-*
647 (defconst ediff-buffer-values-orig-alist
648 '((A . ediff-buffer-values-orig-A)
649 (B . ediff-buffer-values-orig-B)
650 (C . ediff-buffer-values-orig-C)
651 (Ancestor . ediff-buffer-values-orig-Ancestor)))
653 ;; Buffer-local variables to be saved then restored during Ediff sessions
654 (defconst ediff-protected-variables '(
655 ;;buffer-read-only
656 mode-line-format))
658 ;; Vector of differences between the variants. Each difference is
659 ;; represented by a vector of two overlays plus a vector of fine diffs,
660 ;; plus a no-fine-diffs flag. The first overlay spans the
661 ;; difference region in the A buffer and the second overlays the diff in
662 ;; the B buffer. If a difference section is empty, the corresponding
663 ;; overlay's endpoints coincide.
665 ;; The precise form of a Difference Vector for one buffer is:
666 ;; [diff diff diff ...]
667 ;; where each diff has the form:
668 ;; [diff-overlay fine-diff-vector no-fine-diffs-flag state-of-diff]
669 ;; fine-diff-vector is a vector [fine-diff-overlay fine-diff-overlay ...]
670 ;; no-fine-diffs-flag says if there are fine differences.
671 ;; state-of-difference is A, B, C, or nil, indicating which buffer is
672 ;; different from the other two (used only in 3-way jobs.
673 (ediff-defvar-local ediff-difference-vector-A nil "")
674 (ediff-defvar-local ediff-difference-vector-B nil "")
675 (ediff-defvar-local ediff-difference-vector-C nil "")
676 (ediff-defvar-local ediff-difference-vector-Ancestor nil "")
677 ;; A-list of diff vector types associated with buffer types
678 (defconst ediff-difference-vector-alist
679 '((A . ediff-difference-vector-A)
680 (B . ediff-difference-vector-B)
681 (C . ediff-difference-vector-C)
682 (Ancestor . ediff-difference-vector-Ancestor)))
684 ;; [ status status status ...]
685 ;; Each status: [state-of-merge state-of-ancestor]
686 ;; state-of-merge is default-A, default-B, prefer-A, or prefer-B. It
687 ;; indicates the way a diff region was created in buffer C.
688 ;; state-of-ancestor says if the corresponding region in ancestor buffer is
689 ;; empty.
690 (ediff-defvar-local ediff-state-of-merge nil "")
692 ;; The difference that is currently selected.
693 (ediff-defvar-local ediff-current-difference -1 "")
694 ;; Number of differences found.
695 (ediff-defvar-local ediff-number-of-differences nil "")
697 ;; Buffer containing the output of diff, which is used by Ediff to step
698 ;; through files.
699 (ediff-defvar-local ediff-diff-buffer nil "")
700 ;; Like ediff-diff-buffer, but contains context diff. It is not used by
701 ;; Ediff, but it is saved in a file, if user requests so.
702 (ediff-defvar-local ediff-custom-diff-buffer nil "")
703 ;; Buffer used for diff-style fine differences between regions.
704 (ediff-defvar-local ediff-fine-diff-buffer nil "")
705 ;; Temporary buffer used for computing fine differences.
706 (defconst ediff-tmp-buffer " *ediff-tmp*" "")
707 ;; Buffer used for messages
708 (defconst ediff-msg-buffer " *ediff-message*" "")
709 ;; Buffer containing the output of diff when diff returns errors.
710 (ediff-defvar-local ediff-error-buffer nil "")
711 ;; Buffer to display debug info
712 (ediff-defvar-local ediff-debug-buffer "*ediff-debug*" "")
714 ;; List of ediff control panels associated with each buffer A/B/C/Ancestor.
715 ;; Not used any more, but may be needed in the future.
716 (ediff-defvar-local ediff-this-buffer-ediff-sessions nil "")
718 ;; to be deleted in due time
719 ;; List of difference overlays disturbed by working with the current diff.
720 (defvar ediff-disturbed-overlays nil "")
722 ;; Priority of non-selected overlays.
723 (defvar ediff-shadow-overlay-priority 100 "")
725 (defcustom ediff-version-control-package 'vc
726 "Version control package used.
727 Currently, Ediff supports vc.el, rcs.el, pcl-cvs.el, and generic-sc.el. The
728 standard Emacs interface to RCS, CVS, SCCS, etc., is vc.el. However, some
729 people find the other two packages more convenient. Set this variable to the
730 appropriate symbol: `rcs', `pcl-cvs', or `generic-sc' if you so desire."
731 :type 'symbol
732 :group 'ediff)
734 (defcustom ediff-coding-system-for-read 'raw-text
735 "*The coding system for read to use when running the diff program as a subprocess.
736 In most cases, the default will do. However, under certain circumstances in
737 Windows NT/98/95 you might need to use something like 'raw-text-dos here.
738 So, if the output that your diff program sends to Emacs contains extra ^M's,
739 you might need to experiment here, if the default or 'raw-text-dos doesn't
740 work."
741 :type 'symbol
742 :group 'ediff)
744 (defcustom ediff-coding-system-for-write 'no-conversion
745 "*The coding system for write to use when writing out difference regions
746 to temp files when Ediff needs to find fine differences."
747 :type 'symbol
748 :group 'ediff)
751 (ediff-cond-compile-for-xemacs-or-emacs
752 (progn ; xemacs
753 (fset 'ediff-read-event (symbol-function 'next-command-event))
754 (fset 'ediff-overlayp (symbol-function 'extentp))
755 (fset 'ediff-make-overlay (symbol-function 'make-extent))
756 (fset 'ediff-delete-overlay (symbol-function 'delete-extent)))
757 (progn ; emacs
758 (fset 'ediff-read-event (symbol-function 'read-event))
759 (fset 'ediff-overlayp (symbol-function 'overlayp))
760 (fset 'ediff-make-overlay (symbol-function 'make-overlay))
761 (fset 'ediff-delete-overlay (symbol-function 'delete-overlay)))
764 ;; Check the current version against the major and minor version numbers
765 ;; using op: cur-vers op major.minor If emacs-major-version or
766 ;; emacs-minor-version are not defined, we assume that the current version
767 ;; is hopelessly outdated. We assume that emacs-major-version and
768 ;; emacs-minor-version are defined. Otherwise, for Emacs/XEmacs 19, if the
769 ;; current minor version is < 10 (xemacs) or < 23 (emacs) the return value
770 ;; will be nil (when op is =, >, or >=) and t (when op is <, <=), which may be
771 ;; incorrect. However, this gives correct result in our cases, since we are
772 ;; testing for sufficiently high Emacs versions.
773 (defun ediff-check-version (op major minor &optional type-of-emacs)
774 (if (and (boundp 'emacs-major-version) (boundp 'emacs-minor-version))
775 (and (cond ((eq type-of-emacs 'xemacs) ediff-xemacs-p)
776 ((eq type-of-emacs 'emacs) ediff-emacs-p)
777 (t t))
778 (cond ((eq op '=) (and (= emacs-minor-version minor)
779 (= emacs-major-version major)))
780 ((memq op '(> >= < <=))
781 (and (or (funcall op emacs-major-version major)
782 (= emacs-major-version major))
783 (if (= emacs-major-version major)
784 (funcall op emacs-minor-version minor)
785 t)))
787 (error "%S: Invalid op in ediff-check-version" op))))
788 (cond ((memq op '(= > >=)) nil)
789 ((memq op '(< <=)) t))))
792 (defun ediff-color-display-p ()
793 (condition-case nil
794 (ediff-cond-compile-for-xemacs-or-emacs
795 (eq (device-class (selected-device)) 'color) ; xemacs form
796 (if (fboundp 'display-color-p) ; emacs form
797 (display-color-p)
798 (x-display-color-p))
800 (error nil)))
803 (if (ediff-has-face-support-p)
804 (ediff-cond-compile-for-xemacs-or-emacs
805 (progn ; xemacs
806 (defalias 'ediff-valid-color-p 'valid-color-name-p)
807 (defalias 'ediff-get-face 'get-face))
808 (progn ; emacs
809 (defalias 'ediff-valid-color-p (if (fboundp 'color-defined-p)
810 'color-defined-p
811 'x-color-defined-p))
812 (defalias 'ediff-get-face 'internal-get-face))
815 (if (ediff-window-display-p)
816 (ediff-cond-compile-for-xemacs-or-emacs
817 (progn ; xemacs
818 (fset 'ediff-display-pixel-width (symbol-function 'device-pixel-width))
819 (fset 'ediff-display-pixel-height
820 (symbol-function 'device-pixel-height)))
821 (progn ; emacs
822 (fset 'ediff-display-pixel-width
823 (if (fboundp 'display-pixel-width)
824 (symbol-function 'display-pixel-width)
825 (symbol-function 'x-display-pixel-width)))
826 (fset 'ediff-display-pixel-height
827 (if (fboundp 'display-pixel-height)
828 (symbol-function 'display-pixel-height)
829 (symbol-function 'x-display-pixel-height))))
832 ;; A-list of current-diff-overlay symbols associated with buf types
833 (defconst ediff-current-diff-overlay-alist
834 '((A . ediff-current-diff-overlay-A)
835 (B . ediff-current-diff-overlay-B)
836 (C . ediff-current-diff-overlay-C)
837 (Ancestor . ediff-current-diff-overlay-Ancestor)))
839 ;; A-list of current-diff-face-* symbols associated with buf types
840 (defconst ediff-current-diff-face-alist
841 '((A . ediff-current-diff-face-A)
842 (B . ediff-current-diff-face-B)
843 (C . ediff-current-diff-face-C)
844 (Ancestor . ediff-current-diff-face-Ancestor)))
847 (defun ediff-set-overlay-face (extent face)
848 (ediff-overlay-put extent 'face face)
849 (ediff-overlay-put extent 'help-echo 'ediff-region-help-echo))
851 (defun ediff-region-help-echo (extent-or-window &optional overlay point)
852 (unless overlay
853 (setq overlay extent-or-window))
854 (let ((is-current (ediff-overlay-get overlay 'ediff))
855 (face (ediff-overlay-get overlay 'face))
856 (diff-num (ediff-overlay-get overlay 'ediff-diff-num))
857 face-help)
859 ;; This happens only for refinement overlays
860 (if (stringp face)
861 (setq face (intern face)))
862 (setq face-help (and face (get face 'ediff-help-echo)))
864 (cond ((and is-current diff-num) ; current diff region
865 (format "Difference region %S -- current" (1+ diff-num)))
866 (face-help) ; refinement of current diff region
867 (diff-num ; non-current
868 (format "Difference region %S -- non-current" (1+ diff-num)))
869 (t "")) ; none
873 (defun ediff-set-face-pixmap (face pixmap)
874 "Set face pixmap on a monochrome display."
875 (if (and (ediff-window-display-p) (not (ediff-color-display-p)))
876 (condition-case nil
877 (set-face-background-pixmap face pixmap)
878 (error
879 (message "Pixmap not found for %S: %s" (face-name face) pixmap)
880 (sit-for 1)))))
882 (defun ediff-hide-face (face)
883 (if (and (ediff-has-face-support-p) ediff-emacs-p)
884 (add-to-list 'facemenu-unlisted-faces face)))
888 (defface ediff-current-diff-face-A
889 '((((class color)) (:foreground "firebrick" :background "pale green"))
890 (t (:inverse-video t)))
891 "Face for highlighting the selected difference in buffer A."
892 :group 'ediff-highlighting)
893 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
894 ;; this variable is set to nil, then again to the appropriate face.
895 (defvar ediff-current-diff-face-A 'ediff-current-diff-face-A
896 "Face for highlighting the selected difference in buffer A.
897 DO NOT CHANGE this variable. Instead, use the customization
898 widget to customize the actual face object `ediff-current-diff-face-A'
899 this variable represents.")
900 (ediff-hide-face 'ediff-current-diff-face-A)
901 ;; Until custom.el for XEmacs starts supporting :inverse-video we do this.
902 ;; This means that some user customization may be trashed.
903 (if (and ediff-xemacs-p
904 (ediff-has-face-support-p)
905 (not (ediff-color-display-p)))
906 (copy-face 'modeline 'ediff-current-diff-face-A))
910 (defface ediff-current-diff-face-B
911 '((((class color)) (:foreground "DarkOrchid" :background "Yellow"))
912 (t (:inverse-video t)))
913 "Face for highlighting the selected difference in buffer B."
914 :group 'ediff-highlighting)
915 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
916 ;; this variable is set to nil, then again to the appropriate face.
917 (defvar ediff-current-diff-face-B 'ediff-current-diff-face-B
918 "Face for highlighting the selected difference in buffer B.
919 this variable. Instead, use the customization
920 widget to customize the actual face `ediff-current-diff-face-B'
921 this variable represents.")
922 (ediff-hide-face 'ediff-current-diff-face-B)
923 ;; Until custom.el for XEmacs starts supporting :inverse-video we do this.
924 ;; This means that some user customization may be trashed.
925 (if (and ediff-xemacs-p
926 (ediff-has-face-support-p)
927 (not (ediff-color-display-p)))
928 (copy-face 'modeline 'ediff-current-diff-face-B))
931 (defface ediff-current-diff-face-C
932 '((((class color)) (:foreground "Navy" :background "Pink"))
933 (t (:inverse-video t)))
934 "Face for highlighting the selected difference in buffer C."
935 :group 'ediff-highlighting)
936 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
937 ;; this variable is set to nil, then again to the appropriate face.
938 (defvar ediff-current-diff-face-C 'ediff-current-diff-face-C
939 "Face for highlighting the selected difference in buffer C.
940 DO NOT CHANGE this variable. Instead, use the customization
941 widget to customize the actual face object `ediff-current-diff-face-C'
942 this variable represents.")
943 (ediff-hide-face 'ediff-current-diff-face-C)
944 ;; Until custom.el for XEmacs starts supporting :inverse-video we do this.
945 ;; This means that some user customization may be trashed.
946 (if (and ediff-xemacs-p
947 (ediff-has-face-support-p)
948 (not (ediff-color-display-p)))
949 (copy-face 'modeline 'ediff-current-diff-face-C))
952 (defface ediff-current-diff-face-Ancestor
953 '((((class color)) (:foreground "Black" :background "VioletRed"))
954 (t (:inverse-video t)))
955 "Face for highlighting the selected difference in buffer Ancestor."
956 :group 'ediff-highlighting)
957 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
958 ;; this variable is set to nil, then again to the appropriate face.
959 (defvar ediff-current-diff-face-Ancestor 'ediff-current-diff-face-Ancestor
960 "Face for highlighting the selected difference in buffer Ancestor.
961 DO NOT CHANGE this variable. Instead, use the customization
962 widget to customize the actual face object `ediff-current-diff-face-Ancestor'
963 this variable represents.")
964 (ediff-hide-face 'ediff-current-diff-face-Ancestor)
965 ;; Until custom.el for XEmacs starts supporting :inverse-video we do this.
966 ;; This means that some user customization may be trashed.
967 (if (and ediff-xemacs-p
968 (ediff-has-face-support-p)
969 (not (ediff-color-display-p)))
970 (copy-face 'modeline 'ediff-current-diff-face-Ancestor))
973 (defface ediff-fine-diff-face-A
974 '((((class color)) (:foreground "Navy" :background "sky blue"))
975 (t (:underline t :stipple "gray3")))
976 "Face for highlighting the refinement of the selected diff in buffer A."
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-fine-diff-face-A 'ediff-fine-diff-face-A
981 "Face for highlighting the fine differences in buffer A.
982 DO NOT CHANGE this variable. Instead, use the customization
983 widget to customize the actual face object `ediff-fine-diff-face-A'
984 this variable represents.")
985 (ediff-hide-face 'ediff-fine-diff-face-A)
987 (defface ediff-fine-diff-face-B
988 '((((class color)) (:foreground "Black" :background "cyan"))
989 (t (:underline t :stipple "gray3")))
990 "Face for highlighting the refinement of the selected diff in buffer B."
991 :group 'ediff-highlighting)
992 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
993 ;; this variable is set to nil, then again to the appropriate face.
994 (defvar ediff-fine-diff-face-B 'ediff-fine-diff-face-B
995 "Face for highlighting the fine differences in buffer B.
996 DO NOT CHANGE this variable. Instead, use the customization
997 widget to customize the actual face object `ediff-fine-diff-face-B'
998 this variable represents.")
999 (ediff-hide-face 'ediff-fine-diff-face-B)
1001 (defface ediff-fine-diff-face-C
1002 '((((class color)) (:foreground "Black" :background "Turquoise"))
1003 (t (:underline t :stipple "gray3")))
1004 "Face for highlighting the refinement of the selected diff in buffer C."
1005 :group 'ediff-highlighting)
1006 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
1007 ;; this variable is set to nil, then again to the appropriate face.
1008 (defvar ediff-fine-diff-face-C 'ediff-fine-diff-face-C
1009 "Face for highlighting the fine differences in buffer C.
1010 DO NOT CHANGE this variable. Instead, use the customization
1011 widget to customize the actual face object `ediff-fine-diff-face-C'
1012 this variable represents.")
1013 (ediff-hide-face 'ediff-fine-diff-face-C)
1015 (defface ediff-fine-diff-face-Ancestor
1016 '((((class color)) (:foreground "Black" :background "Green"))
1017 (t (:underline t :stipple "gray3")))
1018 "Face for highlighting the refinement of the selected diff in the ancestor buffer.
1019 At present, this face is not used and no fine differences are computed for the
1020 ancestor buffer."
1021 :group 'ediff-highlighting)
1022 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
1023 ;; this variable is set to nil, then again to the appropriate face.
1024 (defvar ediff-fine-diff-face-Ancestor 'ediff-fine-diff-face-Ancestor
1025 "Face for highlighting the fine differences in buffer Ancestor.
1026 DO NOT CHANGE this variable. Instead, use the customization
1027 widget to customize the actual face object `ediff-fine-diff-face-Ancestor'
1028 this variable represents.")
1029 (ediff-hide-face 'ediff-fine-diff-face-Ancestor)
1031 ;; Some installs don't have stipple or Stipple. So, try them in turn.
1032 (defvar stipple-pixmap
1033 (cond ((not (ediff-has-face-support-p)) nil)
1034 ((and (boundp 'x-bitmap-file-path)
1035 (locate-library "stipple" t x-bitmap-file-path)) "stipple")
1036 ((and (boundp 'mswindowsx-bitmap-file-path)
1037 (locate-library "stipple" t mswindowsx-bitmap-file-path)) "stipple")
1038 (t "Stipple")))
1040 (defface ediff-even-diff-face-A
1041 `((((class color)) (:foreground "Black" :background "light grey"))
1042 (t (:italic t :stipple ,stipple-pixmap)))
1043 "Face for highlighting even-numbered non-current differences in buffer A."
1044 :group 'ediff-highlighting)
1045 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
1046 ;; this variable is set to nil, then again to the appropriate face.
1047 (defvar ediff-even-diff-face-A 'ediff-even-diff-face-A
1048 "Face for highlighting even-numbered non-current differences in buffer A.
1049 DO NOT CHANGE this variable. Instead, use the customization
1050 widget to customize the actual face object `ediff-even-diff-face-A'
1051 this variable represents.")
1052 (ediff-hide-face 'ediff-even-diff-face-A)
1054 (defface ediff-even-diff-face-B
1055 `((((class color)) (:foreground "White" :background "Grey"))
1056 (t (:italic t :stipple ,stipple-pixmap)))
1057 "Face for highlighting even-numbered non-current differences in buffer B."
1058 :group 'ediff-highlighting)
1059 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
1060 ;; this variable is set to nil, then again to the appropriate face.
1061 (defvar ediff-even-diff-face-B 'ediff-even-diff-face-B
1062 "Face for highlighting even-numbered non-current differences in buffer B.
1063 DO NOT CHANGE this variable. Instead, use the customization
1064 widget to customize the actual face object `ediff-even-diff-face-B'
1065 this variable represents.")
1066 (ediff-hide-face 'ediff-even-diff-face-B)
1068 (defface ediff-even-diff-face-C
1069 `((((class color)) (:foreground "Black" :background "light grey"))
1070 (t (:italic t :stipple ,stipple-pixmap)))
1071 "Face for highlighting even-numbered non-current differences in buffer C."
1072 :group 'ediff-highlighting)
1073 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
1074 ;; this variable is set to nil, then again to the appropriate face.
1075 (defvar ediff-even-diff-face-C 'ediff-even-diff-face-C
1076 "Face for highlighting even-numbered non-current differences in buffer C.
1077 DO NOT CHANGE this variable. Instead, use the customization
1078 widget to customize the actual face object `ediff-even-diff-face-C'
1079 this variable represents.")
1080 (ediff-hide-face 'ediff-even-diff-face-C)
1082 (defface ediff-even-diff-face-Ancestor
1083 `((((class color)) (:foreground "White" :background "Grey"))
1084 (t (:italic t :stipple ,stipple-pixmap)))
1085 "Face for highlighting even-numbered non-current differences in the ancestor buffer."
1086 :group 'ediff-highlighting)
1087 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
1088 ;; this variable is set to nil, then again to the appropriate face.
1089 (defvar ediff-even-diff-face-Ancestor 'ediff-even-diff-face-Ancestor
1090 "Face for highlighting even-numbered non-current differences in buffer Ancestor.
1091 DO NOT CHANGE this variable. Instead, use the customization
1092 widget to customize the actual face object `ediff-even-diff-face-Ancestor'
1093 this variable represents.")
1094 (ediff-hide-face 'ediff-even-diff-face-Ancestor)
1096 ;; Association between buffer types and even-diff-face symbols
1097 (defconst ediff-even-diff-face-alist
1098 '((A . ediff-even-diff-face-A)
1099 (B . ediff-even-diff-face-B)
1100 (C . ediff-even-diff-face-C)
1101 (Ancestor . ediff-even-diff-face-Ancestor)))
1103 (defface ediff-odd-diff-face-A
1104 '((((class color)) (:foreground "White" :background "Grey"))
1105 (t (:italic t :stipple "gray1")))
1106 "Face for highlighting odd-numbered non-current differences in buffer A."
1107 :group 'ediff-highlighting)
1108 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
1109 ;; this variable is set to nil, then again to the appropriate face.
1110 (defvar ediff-odd-diff-face-A 'ediff-odd-diff-face-A
1111 "Face for highlighting odd-numbered non-current differences in buffer A.
1112 DO NOT CHANGE this variable. Instead, use the customization
1113 widget to customize the actual face object `ediff-odd-diff-face-A'
1114 this variable represents.")
1115 (ediff-hide-face 'ediff-odd-diff-face-A)
1118 (defface ediff-odd-diff-face-B
1119 '((((class color)) (:foreground "Black" :background "light grey"))
1120 (t (:italic t :stipple "gray1")))
1121 "Face for highlighting odd-numbered non-current differences in buffer B."
1122 :group 'ediff-highlighting)
1123 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
1124 ;; this variable is set to nil, then again to the appropriate face.
1125 (defvar ediff-odd-diff-face-B 'ediff-odd-diff-face-B
1126 "Face for highlighting odd-numbered non-current differences in buffer B.
1127 DO NOT CHANGE this variable. Instead, use the customization
1128 widget to customize the actual face object `ediff-odd-diff-face-B'
1129 this variable represents.")
1130 (ediff-hide-face 'ediff-odd-diff-face-B)
1132 (defface ediff-odd-diff-face-C
1133 '((((class color)) (:foreground "White" :background "Grey"))
1134 (t (:italic t :stipple "gray1")))
1135 "Face for highlighting odd-numbered non-current differences in buffer C."
1136 :group 'ediff-highlighting)
1137 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
1138 ;; this variable is set to nil, then again to the appropriate face.
1139 (defvar ediff-odd-diff-face-C 'ediff-odd-diff-face-C
1140 "Face for highlighting odd-numbered non-current differences in buffer C.
1141 DO NOT CHANGE this variable. Instead, use the customization
1142 widget to customize the actual face object `ediff-odd-diff-face-C'
1143 this variable represents.")
1144 (ediff-hide-face 'ediff-odd-diff-face-C)
1146 (defface ediff-odd-diff-face-Ancestor
1147 '((((class color)) (:foreground "Black" :background "light grey"))
1148 (t (:italic t :stipple "gray1")))
1149 "Face for highlighting odd-numbered non-current differences in the ancestor buffer."
1150 :group 'ediff-highlighting)
1151 ;; An internal variable. Ediff takes the face from here. When unhighlighting,
1152 ;; this variable is set to nil, then again to the appropriate face.
1153 (defvar ediff-odd-diff-face-Ancestor 'ediff-odd-diff-face-Ancestor
1154 "Face for highlighting odd-numbered non-current differences in buffer Ancestor.
1155 DO NOT CHANGE this variable. Instead, use the customization
1156 widget to customize the actual face object `ediff-odd-diff-face-Ancestor'
1157 this variable represents.")
1158 (ediff-hide-face 'ediff-odd-diff-face-Ancestor)
1160 ;; Association between buffer types and odd-diff-face symbols
1161 (defconst ediff-odd-diff-face-alist
1162 '((A . ediff-odd-diff-face-A)
1163 (B . ediff-odd-diff-face-B)
1164 (C . ediff-odd-diff-face-C)
1165 (Ancestor . ediff-odd-diff-face-Ancestor)))
1167 ;; A-list of fine-diff face symbols associated with buffer types
1168 (defconst ediff-fine-diff-face-alist
1169 '((A . ediff-fine-diff-face-A)
1170 (B . ediff-fine-diff-face-B)
1171 (C . ediff-fine-diff-face-C)
1172 (Ancestor . ediff-fine-diff-face-Ancestor)))
1174 ;; Help echo
1175 (put 'ediff-fine-diff-face-A 'ediff-help-echo
1176 "A `refinement' of the current difference region")
1177 (put 'ediff-fine-diff-face-B 'ediff-help-echo
1178 "A `refinement' of the current difference region")
1179 (put 'ediff-fine-diff-face-C 'ediff-help-echo
1180 "A `refinement' of the current difference region")
1181 (put 'ediff-fine-diff-face-Ancestor 'ediff-help-echo
1182 "A `refinement' of the current difference region")
1184 (add-hook 'ediff-quit-hook 'ediff-cleanup-mess)
1185 (add-hook 'ediff-suspend-hook 'ediff-default-suspend-function)
1188 ;;; Overlays
1190 (ediff-defvar-local ediff-current-diff-overlay-A nil
1191 "Overlay for the current difference region in buffer A.")
1192 (ediff-defvar-local ediff-current-diff-overlay-B nil
1193 "Overlay for the current difference region in buffer B.")
1194 (ediff-defvar-local ediff-current-diff-overlay-C nil
1195 "Overlay for the current difference region in buffer C.")
1196 (ediff-defvar-local ediff-current-diff-overlay-Ancestor nil
1197 "Overlay for the current difference region in the ancestor buffer.")
1199 ;; Compute priority of a current ediff overlay.
1200 (defun ediff-highest-priority (start end buffer)
1201 (let ((pos (max 1 (1- start)))
1202 ovr-list)
1203 (ediff-cond-compile-for-xemacs-or-emacs
1204 (1+ ediff-shadow-overlay-priority) ; xemacs form
1205 ;; emacs form
1206 (ediff-with-current-buffer buffer
1207 (while (< pos (min (point-max) (1+ end)))
1208 (setq ovr-list (append (overlays-at pos) ovr-list))
1209 (setq pos (next-overlay-change pos)))
1210 (+ 1 ediff-shadow-overlay-priority
1211 (apply 'max
1212 (cons
1214 (mapcar
1215 (lambda (ovr)
1216 (if (and ovr
1217 ;; exclude ediff overlays from priority
1218 ;; calculation, or else priority will keep
1219 ;; increasing
1220 (null (ediff-overlay-get ovr 'ediff))
1221 (null (ediff-overlay-get ovr 'ediff-diff-num)))
1222 ;; use the overlay priority or 0
1223 (or (ediff-overlay-get ovr 'priority) 0)
1225 ovr-list)
1228 ) ; ediff-cond-compile-for-xemacs-or-emacs
1232 (defvar ediff-toggle-read-only-function nil
1233 "*Specifies the function to be used to toggle read-only.
1234 If nil, Ediff tries to deduce the function from the binding of C-x C-q.
1235 Normally, this is the `toggle-read-only' function, but, if version
1236 control is used, it could be `vc-toggle-read-only' or `rcs-toggle-read-only'.")
1238 (defcustom ediff-make-buffers-readonly-at-startup nil
1239 "*Make all variant buffers read-only when Ediff starts up.
1240 This property can be toggled interactively."
1241 :type 'boolean
1242 :group 'ediff)
1245 ;;; Misc
1247 ;; if nil, this silences some messages
1248 (defconst ediff-verbose-p t)
1250 (defcustom ediff-autostore-merges 'group-jobs-only
1251 "*Save the results of merge jobs automatically.
1252 nil means don't save automatically. t means always save. Anything else
1253 means save automatically only if the merge job is part of a group of jobs, such
1254 as `ediff-merge-directory' or `ediff-merge-directory-revisions'."
1255 :type '(choice (const nil) (const t) (const group-jobs-only))
1256 :group 'ediff-merge)
1257 (make-variable-buffer-local 'ediff-autostore-merges)
1259 ;; file where the result of the merge is to be saved. used internally
1260 (ediff-defvar-local ediff-merge-store-file nil "")
1262 (defcustom ediff-merge-filename-prefix "merge_"
1263 "*Prefix to be attached to saved merge buffers."
1264 :type 'string
1265 :group 'ediff-merge)
1267 (defcustom ediff-no-emacs-help-in-control-buffer nil
1268 "*Non-nil means C-h should not invoke Emacs help in control buffer.
1269 Instead, C-h would jump to previous difference."
1270 :type 'boolean
1271 :group 'ediff)
1273 ;; This is the same as temporary-file-directory from Emacs 20.3.
1274 ;; Copied over here because XEmacs doesn't have this variable.
1275 (defcustom ediff-temp-file-prefix
1276 (file-name-as-directory
1277 (cond ((boundp 'temporary-file-directory) temporary-file-directory)
1278 ((fboundp 'temp-directory) (temp-directory))
1279 (t "/tmp/")))
1280 ;;; (file-name-as-directory
1281 ;;; (cond ((memq system-type '(ms-dos windows-nt))
1282 ;;; (or (getenv "TEMP") (getenv "TMPDIR") (getenv "TMP") "c:/temp"))
1283 ;;; ((memq system-type '(vax-vms axp-vms))
1284 ;;; (or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP") "SYS$SCRATCH:"))
1285 ;;; (t
1286 ;;; (or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP") "/tmp"))))
1287 "*Prefix to put on Ediff temporary file names.
1288 Do not start with `~/' or `~USERNAME/'."
1289 :type 'string
1290 :group 'ediff)
1292 (defcustom ediff-temp-file-mode 384 ; u=rw only
1293 "*Mode for Ediff temporary files."
1294 :type 'integer
1295 :group 'ediff)
1297 ;; Metacharacters that have to be protected from the shell when executing
1298 ;; a diff/diff3 command.
1299 (defcustom ediff-metachars "[ \t\n!\"#$&'()*;<=>?[\\^`{|~]"
1300 "Regexp that matches characters that must be quoted with `\\' in shell command line.
1301 This default should work without changes."
1302 :type 'string
1303 :group 'ediff)
1305 ;; needed to simulate frame-char-width in XEmacs.
1306 (defvar ediff-H-glyph (if ediff-xemacs-p (make-glyph "H")))
1309 ;; Temporary file used for refining difference regions in buffer A.
1310 (ediff-defvar-local ediff-temp-file-A nil "")
1311 ;; Temporary file used for refining difference regions in buffer B.
1312 (ediff-defvar-local ediff-temp-file-B nil "")
1313 ;; Temporary file used for refining difference regions in buffer C.
1314 (ediff-defvar-local ediff-temp-file-C nil "")
1317 ;; If file-remote-p is defined (as in XEmacs, use it. Otherwise, check
1318 ;; if find-file-name-handler is defined for 'file-local-copy
1319 (defun ediff-file-remote-p (file-name)
1320 (or (and (fboundp 'file-remote-p) (file-remote-p file-name))
1321 (find-file-name-handler file-name 'file-local-copy)))
1323 ;; File for which we can get attributes, such as size or date
1324 (defun ediff-listable-file (file-name)
1325 (let ((handler (find-file-name-handler file-name 'file-local-copy)))
1326 (or (null handler) (eq handler 'dired-handler-fn))))
1329 (defsubst ediff-frame-unsplittable-p (frame)
1330 (cdr (assq 'unsplittable (frame-parameters frame))))
1332 (defsubst ediff-get-next-window (wind prev-wind)
1333 (or (window-live-p wind)
1334 (setq wind (if prev-wind
1335 (next-window wind)
1336 (selected-window)))))
1339 (defsubst ediff-kill-buffer-carefully (buf)
1340 "Kill buffer BUF if it exists."
1341 (if (ediff-buffer-live-p buf)
1342 (kill-buffer (get-buffer buf))))
1344 (defsubst ediff-background-face (buf-type dif-num)
1345 ;; The value of dif-num is always 1- the one that user sees.
1346 ;; This is why even face is used when dif-num is odd.
1347 (ediff-get-symbol-from-alist
1348 buf-type (if (ediff-odd-p dif-num)
1349 ediff-even-diff-face-alist
1350 ediff-odd-diff-face-alist)
1354 ;; activate faces on diff regions in buffer
1355 (defun ediff-paint-background-regions-in-one-buffer (buf-type unhighlight)
1356 (let ((diff-vector
1357 (eval (ediff-get-symbol-from-alist
1358 buf-type ediff-difference-vector-alist)))
1359 overl diff-num)
1360 (mapcar (lambda (rec)
1361 (setq overl (ediff-get-diff-overlay-from-diff-record rec)
1362 diff-num (ediff-overlay-get overl 'ediff-diff-num))
1363 (if (ediff-overlay-buffer overl)
1364 ;; only if overlay is alive
1365 (ediff-set-overlay-face
1366 overl
1367 (if (not unhighlight)
1368 (ediff-background-face buf-type diff-num))))
1370 diff-vector)))
1373 ;; activate faces on diff regions in all buffers
1374 (defun ediff-paint-background-regions (&optional unhighlight)
1375 (ediff-paint-background-regions-in-one-buffer
1376 'A unhighlight)
1377 (ediff-paint-background-regions-in-one-buffer
1378 'B unhighlight)
1379 (ediff-paint-background-regions-in-one-buffer
1380 'C unhighlight)
1381 (ediff-paint-background-regions-in-one-buffer
1382 'Ancestor unhighlight))
1385 ;; arg is a record for a given diff in a difference vector
1386 ;; this record is itself a vector
1387 (defsubst ediff-clear-fine-diff-vector (diff-record)
1388 (if diff-record
1389 (mapcar 'ediff-delete-overlay
1390 (ediff-get-fine-diff-vector-from-diff-record diff-record))))
1392 (defsubst ediff-clear-fine-differences-in-one-buffer (n buf-type)
1393 (ediff-clear-fine-diff-vector (ediff-get-difference n buf-type))
1394 (ediff-set-fine-diff-vector n buf-type nil))
1396 (defsubst ediff-clear-fine-differences (n)
1397 (ediff-clear-fine-differences-in-one-buffer n 'A)
1398 (ediff-clear-fine-differences-in-one-buffer n 'B)
1399 (if ediff-3way-job
1400 (ediff-clear-fine-differences-in-one-buffer n 'C)))
1403 (defsubst ediff-mouse-event-p (event)
1404 (ediff-cond-compile-for-xemacs-or-emacs
1405 (button-event-p event) ; xemacs form
1406 (string-match "mouse" (format "%S" (event-basic-type event))) ; emacs form
1410 (defsubst ediff-key-press-event-p (event)
1411 (ediff-cond-compile-for-xemacs-or-emacs
1412 (key-press-event-p event) ; xemacs form
1413 (or (char-or-string-p event) (symbolp event)) ; emacs form
1416 (defun ediff-event-point (event)
1417 (cond ((ediff-mouse-event-p event)
1418 (ediff-cond-compile-for-xemacs-or-emacs
1419 (event-point event) ; xemacs form
1420 (posn-point (event-start event)) ; emacs form
1423 ((ediff-key-press-event-p event)
1424 (point))
1425 (t (error nil))))
1427 (defun ediff-event-buffer (event)
1428 (cond ((ediff-mouse-event-p event)
1429 (ediff-cond-compile-for-xemacs-or-emacs
1430 (event-buffer event) ; xemacs form
1431 (window-buffer (posn-window (event-start event))) ; emacs form
1434 ((ediff-key-press-event-p event)
1435 (current-buffer))
1436 (t (error nil))))
1438 (defun ediff-event-key (event-or-key)
1439 (ediff-cond-compile-for-xemacs-or-emacs
1440 (if (eventp event-or-key) (event-key event-or-key) event-or-key) ; xemacs
1441 event-or-key ; emacs form
1445 (defsubst ediff-frame-iconified-p (frame)
1446 (if (and (ediff-window-display-p) (frame-live-p frame))
1447 (ediff-cond-compile-for-xemacs-or-emacs
1448 (frame-iconified-p frame) ; xemacs form
1449 (eq (frame-visible-p frame) 'icon) ; emacs form
1453 (defsubst ediff-window-visible-p (wind)
1454 ;; under TTY, window-live-p also means window is visible
1455 (and (window-live-p wind)
1456 (or (not (ediff-window-display-p))
1457 (frame-visible-p (window-frame wind)))))
1460 (defsubst ediff-frame-char-width (frame)
1461 (ediff-cond-compile-for-xemacs-or-emacs
1462 (/ (frame-pixel-width frame) (frame-width frame)) ; xemacs
1463 (frame-char-width frame) ; emacs
1466 (defun ediff-reset-mouse (&optional frame do-not-grab-mouse)
1467 (or frame (setq frame (selected-frame)))
1468 (if (ediff-window-display-p)
1469 (let ((frame-or-wind frame))
1470 (if ediff-xemacs-p
1471 (setq frame-or-wind (frame-selected-window frame)))
1472 (or do-not-grab-mouse
1473 ;; don't set mouse if the user said to never do this
1474 (not ediff-grab-mouse)
1475 ;; Don't grab on quit, if the user doesn't want to.
1476 ;; If ediff-grab-mouse = t, then mouse won't be grabbed for
1477 ;; sessions that are not part of a group (this is done in
1478 ;; ediff-recenter). The condition below affects only terminating
1479 ;; sessions in session groups (in which case mouse is warped into
1480 ;; a meta buffer).
1481 (and (eq ediff-grab-mouse 'maybe)
1482 (memq this-command '(ediff-quit ediff-update-diffs)))
1483 (set-mouse-position frame-or-wind 1 0))
1486 (defsubst ediff-spy-after-mouse ()
1487 (setq ediff-mouse-pixel-position (mouse-pixel-position)))
1489 ;; It is not easy to find out when the user grabs the mouse, since emacs and
1490 ;; xemacs behave differently when mouse is not in any frame. Also, this is
1491 ;; sensitive to when the user grabbed mouse. Not used for now.
1492 (defun ediff-user-grabbed-mouse ()
1493 (if ediff-mouse-pixel-position
1494 (cond ((not (eq (car ediff-mouse-pixel-position)
1495 (car (mouse-pixel-position)))))
1496 ((and (car (cdr ediff-mouse-pixel-position))
1497 (car (cdr (mouse-pixel-position)))
1498 (cdr (cdr ediff-mouse-pixel-position))
1499 (cdr (cdr (mouse-pixel-position))))
1500 (not (and (< (abs (- (car (cdr ediff-mouse-pixel-position))
1501 (car (cdr (mouse-pixel-position)))))
1502 ediff-mouse-pixel-threshold)
1503 (< (abs (- (cdr (cdr ediff-mouse-pixel-position))
1504 (cdr (cdr (mouse-pixel-position)))))
1505 ediff-mouse-pixel-threshold))))
1506 (t nil))))
1508 (defsubst ediff-frame-char-height (frame)
1509 (ediff-cond-compile-for-xemacs-or-emacs
1510 (glyph-height ediff-H-glyph (selected-window frame)) ; xemacs cse
1511 (frame-char-height frame) ; emacs case
1515 ;; Some overlay functions
1517 (defsubst ediff-overlay-start (overl)
1518 (if (ediff-overlayp overl)
1519 (ediff-cond-compile-for-xemacs-or-emacs
1520 (extent-start-position overl) ; xemacs form
1521 (overlay-start overl) ; emacs form
1525 (defsubst ediff-overlay-end (overl)
1526 (if (ediff-overlayp overl)
1527 (ediff-cond-compile-for-xemacs-or-emacs
1528 (extent-end-position overl) ; xemacs form
1529 (overlay-end overl) ; emacs form
1533 (defsubst ediff-empty-overlay-p (overl)
1534 (= (ediff-overlay-start overl) (ediff-overlay-end overl)))
1536 ;; like overlay-buffer in Emacs. In XEmacs, returns nil if the extent is
1537 ;; dead. Otherwise, works like extent-buffer
1538 (defun ediff-overlay-buffer (overl)
1539 (ediff-cond-compile-for-xemacs-or-emacs
1540 (and (extent-live-p overl) (extent-object overl)) ; xemacs form
1541 (overlay-buffer overl) ; emacs form
1544 ;; like overlay-get in Emacs. In XEmacs, returns nil if the extent is
1545 ;; dead. Otherwise, like extent-property
1546 (defun ediff-overlay-get (overl property)
1547 (ediff-cond-compile-for-xemacs-or-emacs
1548 (and (extent-live-p overl) (extent-property overl property)) ; xemacs form
1549 (overlay-get overl property) ; emacs form
1553 ;; These two functions are here because XEmacs refuses to
1554 ;; handle overlays whose buffers were deleted.
1555 (defun ediff-move-overlay (overlay beg end &optional buffer)
1556 "Calls `move-overlay' in Emacs and `set-extent-endpoints' in Lemacs.
1557 Checks if overlay's buffer exists before actually doing the move."
1558 (let ((buf (and overlay (ediff-overlay-buffer overlay))))
1559 (if (ediff-buffer-live-p buf)
1560 (ediff-cond-compile-for-xemacs-or-emacs
1561 (set-extent-endpoints overlay beg end) ; xemacs form
1562 (move-overlay overlay beg end buffer) ; emacs form
1564 ;; buffer's dead
1565 (if overlay
1566 (ediff-delete-overlay overlay)))))
1568 (defun ediff-overlay-put (overlay prop value)
1569 "Calls `overlay-put' or `set-extent-property' depending on Emacs version.
1570 Checks if overlay's buffer exists."
1571 (if (ediff-buffer-live-p (ediff-overlay-buffer overlay))
1572 (ediff-cond-compile-for-xemacs-or-emacs
1573 (set-extent-property overlay prop value) ; xemacs form
1574 (overlay-put overlay prop value) ; emacs form
1576 (ediff-delete-overlay overlay)))
1578 ;; temporarily uses DIR to abbreviate file name
1579 ;; if DIR is nil, use default-directory
1580 (defun ediff-abbreviate-file-name (file &optional dir)
1581 (cond ((stringp dir)
1582 (let ((directory-abbrev-alist (list (cons dir ""))))
1583 (abbreviate-file-name file)))
1585 (ediff-cond-compile-for-xemacs-or-emacs
1586 ;; XEmacs requires addl argument
1587 (abbreviate-file-name file t) ; xemacs form
1588 (abbreviate-file-name file)) ; emacs form
1592 ;; Takes a directory and returns the parent directory.
1593 ;; does nothing to `/'. If the ARG is a regular file,
1594 ;; strip the file AND the last dir.
1595 (defun ediff-strip-last-dir (dir)
1596 (if (not (stringp dir)) (setq dir default-directory))
1597 (setq dir (expand-file-name dir))
1598 (or (file-directory-p dir) (setq dir (file-name-directory dir)))
1599 (let* ((pos (1- (length dir)))
1600 (last-char (aref dir pos)))
1601 (if (and (> pos 0) (= last-char ?/))
1602 (setq dir (substring dir 0 pos)))
1603 (ediff-abbreviate-file-name (file-name-directory dir))))
1605 (defun ediff-truncate-string-left (str newlen)
1606 ;; leave space for ... on the left
1607 (let ((len (length str))
1608 substr)
1609 (if (<= len newlen)
1611 (setq newlen (max 0 (- newlen 3)))
1612 (setq substr (substring str (max 0 (- len 1 newlen))))
1613 (concat "..." substr))))
1615 (defsubst ediff-nonempty-string-p (string)
1616 (and (stringp string) (not (string= string ""))))
1618 (unless (fboundp 'subst-char-in-string)
1619 (defun subst-char-in-string (fromchar tochar string &optional inplace)
1620 "Replace FROMCHAR with TOCHAR in STRING each time it occurs.
1621 Unless optional argument INPLACE is non-nil, return a new string."
1622 (let ((i (length string))
1623 (newstr (if inplace string (copy-sequence string))))
1624 (while (> i 0)
1625 (setq i (1- i))
1626 (if (eq (aref newstr i) fromchar)
1627 (aset newstr i tochar)))
1628 newstr)))
1630 (defun ediff-abbrev-jobname (jobname)
1631 (cond ((eq jobname 'ediff-directories)
1632 "Compare two directories")
1633 ((eq jobname 'ediff-files)
1634 "Compare two files")
1635 ((eq jobname 'ediff-buffers)
1636 "Compare two buffers")
1637 ((eq jobname 'ediff-directories3)
1638 "Compare three directories")
1639 ((eq jobname 'ediff-files3)
1640 "Compare three files")
1641 ((eq jobname 'ediff-buffers3)
1642 "Compare three buffers")
1643 ((eq jobname 'ediff-revision)
1644 "Compare file with a version")
1645 ((eq jobname 'ediff-directory-revisions)
1646 "Compare dir files with versions")
1647 ((eq jobname 'ediff-merge-directory-revisions)
1648 "Merge dir files with versions")
1649 ((eq jobname 'ediff-merge-directory-revisions-with-ancestor)
1650 "Merge dir versions via ancestors")
1652 (capitalize
1653 (subst-char-in-string ?- ?\ (substring (symbol-name jobname) 6))))
1657 ;; If ediff modified mode line, strip the modification
1658 (defsubst ediff-strip-mode-line-format ()
1659 (if (member (car mode-line-format) '(" A: " " B: " " C: " " Ancestor: "))
1660 (setq mode-line-format (nth 2 mode-line-format))))
1662 ;; Verify that we have a difference selected.
1663 (defsubst ediff-valid-difference-p (&optional n)
1664 (or n (setq n ediff-current-difference))
1665 (and (>= n 0) (< n ediff-number-of-differences)))
1667 (defsubst ediff-show-all-diffs (n)
1668 "Don't skip difference regions."
1669 nil)
1671 (defsubst Xor (a b)
1672 (or (and a (not b)) (and (not a) b)))
1674 (defsubst ediff-message-if-verbose (string &rest args)
1675 (if ediff-verbose-p
1676 (apply 'message string args)))
1678 (defun ediff-file-attributes (filename attr-number)
1679 (if (ediff-listable-file filename)
1680 (nth attr-number (file-attributes filename))
1684 (defsubst ediff-file-size (filename)
1685 (ediff-file-attributes filename 7))
1686 (defsubst ediff-file-modtime (filename)
1687 (ediff-file-attributes filename 5))
1690 (defun ediff-convert-standard-filename (fname)
1691 (if (fboundp 'convert-standard-filename)
1692 (convert-standard-filename fname)
1693 fname))
1696 (if (fboundp 'with-syntax-table)
1697 (fset 'ediff-with-syntax-table 'with-syntax-table)
1698 ;; stolen from subr.el in emacs 21
1699 (defmacro ediff-with-syntax-table (table &rest body)
1700 (let ((old-table (make-symbol "table"))
1701 (old-buffer (make-symbol "buffer")))
1702 `(let ((,old-table (syntax-table))
1703 (,old-buffer (current-buffer)))
1704 (unwind-protect
1705 (progn
1706 (set-syntax-table (copy-syntax-table ,table))
1707 ,@body)
1708 (save-current-buffer
1709 (set-buffer ,old-buffer)
1710 (set-syntax-table ,old-table)))))))
1714 ;;; Local Variables:
1715 ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun)
1716 ;;; eval: (put 'ediff-with-current-buffer 'lisp-indent-hook 1)
1717 ;;; eval: (put 'ediff-with-current-buffer 'edebug-form-spec '(form body))
1718 ;;; End:
1720 (provide 'ediff-init)
1722 ;;; ediff-init.el ends here