annotate lisp/ediff/ediff.el @ 167:85ec50267440 r20-3b10

Import from CVS: tag r20-3b10
author cvs
date Mon, 13 Aug 2007 09:45:46 +0200
parents 318232e2a3f0
children 2d532a89d707
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; ediff.el --- a comprehensive visual interface to diff & patch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
3 ;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Author: Michael Kifer <kifer@cs.sunysb.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Created: February 2, 1994
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Keywords: comparing, merging, patching, version control.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
144
318232e2a3f0 Import from CVS: tag r20-2b6
cvs
parents: 134
diff changeset
9 (defconst ediff-version "2.65" "The current version of Ediff")
318232e2a3f0 Import from CVS: tag r20-2b6
cvs
parents: 134
diff changeset
10 (defconst ediff-date "May 1, 1997" "Date of last update")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; This file is part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; along with GNU Emacs; see the file COPYING. If not, write to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; Boston, MA 02111-1307, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; Never read that diff output again!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; Apply patch interactively!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; Merge with ease!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; This package provides a convenient way of simultaneous browsing through
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; the differences between a pair (or a triple) of files or buffers. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; files being compared, file-A, file-B, and file-C (if applicable) are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; shown in separate windows (side by side, one above the another, or in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; separate frames), and the differences are highlighted as you step
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; through them. You can also copy difference regions from one buffer to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;; another (and recover old differences if you change your mind).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;; Ediff also supports merging operations on files and buffers, including
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; merging using ancestor versions. Both comparison and merging operations can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;; be performed on directories, i.e., by pairwise comparison of files in those
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;; directories.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;; In addition, Ediff can apply a patch to a file and then let you step
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;; though both files, the patched and the original one, simultaneously,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;; difference-by-difference. You can even apply a patch right out of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;; mail buffer, i.e., patches received by mail don't even have to be saved.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;; Since Ediff lets you copy differences between buffers, you can, in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;; effect, apply patches selectively (i.e., you can copy a difference
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;; region from file_orig to file, thereby undoing any particular patch that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;; you don't like).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;; Ediff is aware of version control, which lets the user compare
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;; files with their older versions. Ediff can also work with remote and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;; compressed files. Details are given below.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;; Finally, Ediff supports directory-level comparison, merging and patching.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;; See the on-line manual for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;; This package builds upon the ideas borrowed from emerge.el and several
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;; Ediff's functions are adaptations from emerge.el. Much of the functionality
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;; Ediff provides is also influenced by emerge.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;; The present version of Ediff supersedes Emerge. It provides a superior user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;; interface and has numerous major features not found in Emerge. In
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;; particular, it can do patching, and 2-way and 3-way file comparison,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;; merging, and directory operations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;;; Bugs:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;; 1. The undo command doesn't restore deleted regions well. That is, if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;; you delete all characters in a difference region and then invoke
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;; `undo', the reinstated text will most likely be inserted outside of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;; what Ediff thinks is the current difference region. (This problem
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;; doesn't seem to exist with XEmacs.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;; If at any point you feel that difference regions are no longer correct,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;; you can hit '!' to recompute the differences.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;; 2. On a monochrome display, the repertoire of faces with which to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;; highlight fine differences is limited. By default, Ediff is using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;; underlining. However, if the region is already underlined by some other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;; overlays, there is no simple way to temporarily remove that residual
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;; underlining. This problem occurs when a buffer is highlighted with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;; hilit19.el or font-lock.el packages. If this residual highlighting gets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;; in the way, you can do the following. Both font-lock.el and hilit19.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;; provide commands for unhighlighting buffers. You can either place these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;; commands in `ediff-prepare-buffer-hook' (which will unhighlight every
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;; buffer used by Ediff) or you can execute them interactively, at any time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;; and on any buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;;; Acknowledgements:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ;; Ediff was inspired by Dale R. Worley's <drw@math.mit.edu> emerge.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;; Ediff would not have been possible without the help and encouragement of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;; its many users. See Ediff on-line Info for the full list of those who
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ;; helped. Improved defaults in Ediff file-name reading commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
109 (provide 'ediff)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
111 ;; Compiler pacifier
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
112 (and noninteractive
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
113 (eval-when-compile
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
114 (load-library "dired")
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
115 (load-library "info")
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
116 (load "pcl-cvs" 'noerror)))
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
117 (eval-when-compile
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
118 (let ((load-path (cons (expand-file-name ".") load-path)))
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
119 (or (featurep 'ediff-init)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
120 (load "ediff-init.el" nil nil 'nosuffix))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
121 (or (featurep 'ediff-mult)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
122 (load "ediff-mult.el" nil nil 'nosuffix))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
123 (or (featurep 'ediff-ptch)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
124 (load "ediff-ptch.el" nil nil 'nosuffix))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
125 (or (featurep 'ediff-vers)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
126 (load "ediff-vers.el" nil nil 'nosuffix))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
127 ))
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
128 ;; end pacifier
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
129
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
130 (require 'ediff-init)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
131 (require 'ediff-mult) ; required because of the registry stuff
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 82
diff changeset
133 (defgroup ediff nil
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 82
diff changeset
134 "A comprehensive visual interface to diff & patch"
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 82
diff changeset
135 :group 'tools)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 82
diff changeset
136
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 82
diff changeset
137
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 82
diff changeset
138 (defcustom ediff-use-last-dir nil
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 82
diff changeset
139 "*If t, Ediff uses previous directory as default when reading file name."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 82
diff changeset
140 :type 'boolean
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 82
diff changeset
141 :group 'ediff)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 82
diff changeset
142
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (defvar ediff-last-dir-A nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 "Last directory used by an Ediff command for file-A.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (defvar ediff-last-dir-B nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 "Last directory used by an Ediff command for file-B.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (defvar ediff-last-dir-C nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 "Last directory used by an Ediff command for file-C.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (defvar ediff-last-dir-ancestor nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 "Last directory used by an Ediff command for the ancestor file.")
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
151 (defvar ediff-last-merge-autostore-dir
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
152 "Last directory used by an Ediff command as the output directory for merge.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ;; Some defvars to reduce the number of compiler warnings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (defvar cvs-cookie-handle)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (defvar ediff-last-dir-patch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (defvar ediff-patch-default-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ;; end of compiler pacifier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ;; Used as a startup hook to set `_orig' patch file read-only.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (defun ediff-set-read-only-in-buf-A ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (ediff-eval-in-buffer ediff-buffer-A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (toggle-read-only 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ;; Return a plausible default for ediff's first file:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;; In dired, return the file name under the point, unless it is a directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 ;; If the buffer has a file name, return that file name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (defun ediff-get-default-file-name ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (cond ((eq major-mode 'dired-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (let ((f (dired-get-filename nil 'no-error)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (if (and (stringp f) (not (file-directory-p f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 ((buffer-file-name (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (file-name-nondirectory (buffer-file-name (current-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 ;;; Compare files/buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (defun ediff-files (file-A file-B &optional startup-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 "Run Ediff on a pair of files, FILE-A and FILE-B."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (let ((dir-A (if ediff-use-last-dir
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ediff-last-dir-A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 default-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 dir-B f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (list (setq f (ediff-read-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 "File A to compare" dir-A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (ediff-get-default-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (ediff-read-file-name "File B to compare"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (setq dir-B
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (if ediff-use-last-dir
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 ediff-last-dir-B
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (file-name-directory f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (setq file-name-history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (cons (ediff-abbreviate-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (expand-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (file-name-nondirectory f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 dir-B))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 file-name-history))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (ediff-files-internal file-A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (if (file-directory-p file-B)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (expand-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (file-name-nondirectory file-A) file-B)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 file-B)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 nil ; file-C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 startup-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 'ediff-files))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (defun ediff-files3 (file-A file-B file-C &optional startup-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 "Run Ediff on three files, FILE-A, FILE-B, and FILE-C."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (let ((dir-A (if ediff-use-last-dir
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 ediff-last-dir-A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 default-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 dir-B dir-C f ff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (list (setq f (ediff-read-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 "File A to compare" dir-A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (ediff-get-default-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (setq ff (ediff-read-file-name "File B to compare"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (setq dir-B
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (if ediff-use-last-dir
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 ediff-last-dir-B
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (file-name-directory f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (setq file-name-history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (ediff-abbreviate-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (expand-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (file-name-nondirectory f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 dir-B))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 file-name-history))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (ediff-read-file-name "File C to compare"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (setq dir-C (if ediff-use-last-dir
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 ediff-last-dir-C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (file-name-directory ff)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (setq file-name-history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (cons (ediff-abbreviate-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (expand-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (file-name-nondirectory ff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 dir-C))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 file-name-history))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 ff))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (ediff-files-internal file-A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (if (file-directory-p file-B)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (expand-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (file-name-nondirectory file-A) file-B)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 file-B)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (if (file-directory-p file-C)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (expand-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (file-name-nondirectory file-A) file-C)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 file-C)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 startup-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 'ediff-files3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (defalias 'ediff3 'ediff-files3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 ;; Visit FILE and arrange its buffer to Ediff's liking.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 ;; FILE is actually a variable symbol that must contain a true file name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 ;; BUFFER-NAME is a variable symbol, which will get the buffer object into
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 ;; which FILE is read.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 ;; LAST-DIR is the directory variable symbol where FILE's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 ;; directory name should be returned. HOOKS-VAR is a variable symbol that will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 ;; be assigned the hook to be executed after `ediff-startup' is finished.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 ;; `ediff-find-file' arranges that the temp files it might create will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 ;; deleted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (defun ediff-find-file (file-var buffer-name &optional last-dir hooks-var)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (let* ((file (symbol-value file-var))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (file-magic (find-file-name-handler file 'find-file-noselect))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (temp-file-name-prefix (file-name-nondirectory file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (cond ((not (file-readable-p file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (error "File `%s' does not exist or is not readable" file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 ((file-directory-p file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (error "File `%s' is a directory" file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 ;; some of the commands, below, require full file name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (setq file (expand-file-name file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 ;; Record the directory of the file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (if last-dir
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (set last-dir (expand-file-name (file-name-directory file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 ;; Setup the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (set buffer-name (find-file-noselect file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (ediff-eval-in-buffer (symbol-value buffer-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (widen) ; Make sure the entire file is seen
82
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
298 (cond (file-magic ; file has a handler, such as jka-compr-handler or
6a378aca36af Import from CVS: tag r20-0b91
cvs
parents: 80
diff changeset
299 ;;; ange-ftp-hook-function--arrange for temp file
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (ediff-verify-file-buffer 'magic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (setq file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (ediff-make-temp-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (current-buffer) temp-file-name-prefix))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (set hooks-var (cons (` (lambda () (delete-file (, file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (symbol-value hooks-var))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 ;; file processed via auto-mode-alist, a la uncompress.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 ((not (equal (file-truename file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (file-truename (buffer-file-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (setq file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (ediff-make-temp-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (current-buffer) temp-file-name-prefix))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (set hooks-var (cons (` (lambda () (delete-file (, file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (symbol-value hooks-var))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (t ;; plain file---just check that the file matches the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (ediff-verify-file-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (set file-var file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (defun ediff-files-internal (file-A file-B file-C startup-hooks job-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (let (buf-A buf-B buf-C)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (message "Reading file %s ... " file-A)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 ;;(sit-for 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (ediff-find-file 'file-A 'buf-A 'ediff-last-dir-A 'startup-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (message "Reading file %s ... " file-B)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 ;;(sit-for 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (ediff-find-file 'file-B 'buf-B 'ediff-last-dir-B 'startup-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (if (stringp file-C)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (message "Reading file %s ... " file-C)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 ;;(sit-for 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (ediff-find-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 'file-C 'buf-C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (if (eq job-name 'ediff-merge-files-with-ancestor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 'ediff-last-dir-ancestor 'ediff-last-dir-C)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 'startup-hooks)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (ediff-setup buf-A file-A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 buf-B file-B
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 buf-C file-C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 startup-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (list (cons 'ediff-job-name job-name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (defalias 'ediff 'ediff-files)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (defun ediff-buffers (buffer-A buffer-B &optional startup-hooks job-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 "Run Ediff on a pair of buffers, BUFFER-A and BUFFER-B."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (let (bf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (list (setq bf (read-buffer "Buffer A to compare: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (ediff-other-buffer "") t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (read-buffer "Buffer B to compare: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 ;; realign buffers so that two visible bufs will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 ;; at the top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (save-window-excursion (other-window 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (ediff-other-buffer bf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (or job-name (setq job-name 'ediff-buffers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (ediff-buffers-internal buffer-A buffer-B nil startup-hooks job-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (defalias 'ebuffers 'ediff-buffers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (defun ediff-buffers3 (buffer-A buffer-B buffer-C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 &optional startup-hooks job-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 "Run Ediff on three buffers, BUFFER-A, BUFFER-B, and BUFFER-C."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (let (bf bff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (list (setq bf (read-buffer "Buffer A to compare: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (ediff-other-buffer "") t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (setq bff (read-buffer "Buffer B to compare: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 ;; realign buffers so that two visible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 ;; bufs will be at the top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (save-window-excursion (other-window 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (ediff-other-buffer bf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (read-buffer "Buffer C to compare: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 ;; realign buffers so that three visible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 ;; bufs will be at the top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (save-window-excursion (other-window 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (ediff-other-buffer (list bf bff)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (or job-name (setq job-name 'ediff-buffers3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (ediff-buffers-internal buffer-A buffer-B buffer-C startup-hooks job-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (defalias 'ebuffers3 'ediff-buffers3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (defun ediff-buffers-internal (buf-A buf-B buf-C startup-hooks job-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (let* ((buf-A-file-name (buffer-file-name (get-buffer buf-A)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (buf-B-file-name (buffer-file-name (get-buffer buf-B)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (buf-C-is-alive (ediff-buffer-live-p buf-C))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (buf-C-file-name (if buf-C-is-alive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (buffer-file-name (get-buffer buf-B))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 file-A file-B file-C)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (if (not (ediff-buffer-live-p buf-A))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (error "Buffer %S doesn't exist" buf-A))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (if (not (ediff-buffer-live-p buf-B))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (error "Buffer %S doesn't exist" buf-B))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (let ((ediff-job-name job-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (if (and ediff-3way-comparison-job
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (not buf-C-is-alive))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (error "Buffer %S doesn't exist" buf-C)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (if (stringp buf-A-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (setq buf-A-file-name (file-name-nondirectory buf-A-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (if (stringp buf-B-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (setq buf-B-file-name (file-name-nondirectory buf-B-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (if (stringp buf-C-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (setq buf-C-file-name (file-name-nondirectory buf-C-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (setq file-A (ediff-make-temp-file buf-A buf-A-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 file-B (ediff-make-temp-file buf-B buf-B-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (if buf-C-is-alive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (setq file-C (ediff-make-temp-file buf-C buf-C-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (ediff-setup (get-buffer buf-A) file-A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (get-buffer buf-B) file-B
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (if buf-C-is-alive (get-buffer buf-C))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 file-C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (cons (` (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (delete-file (, file-A))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (delete-file (, file-B))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (if (stringp (, file-C)) (delete-file (, file-C)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 startup-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (list (cons 'ediff-job-name job-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 ;;; Directory and file group operations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 ;; Get appropriate default name for directory:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 ;; If ediff-use-last-dir, use ediff-last-dir-A.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 ;; In dired mode, use the directory that is under the point (if any);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 ;; otherwise, use default-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (defun ediff-get-default-directory-name ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (cond (ediff-use-last-dir ediff-last-dir-A)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 ((eq major-mode 'dired-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (let ((f (dired-get-filename nil 'noerror)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (if (and (stringp f) (file-directory-p f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 f
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 default-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (t default-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (defun ediff-directories (dir1 dir2 regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 "Run Ediff on a pair of directories, DIR1 and DIR2, comparing files that have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 the same name in both. The third argument, REGEXP, is a regular expression that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 can be used to filter out certain file names."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (let ((dir-A (ediff-get-default-directory-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (list (setq f (ediff-read-file-name "Directory A to compare:" dir-A nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (ediff-read-file-name "Directory B to compare:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (if ediff-use-last-dir
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 ediff-last-dir-B
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (ediff-strip-last-dir f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (read-string "Filter through regular expression: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 nil 'ediff-filtering-regexp-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (ediff-directories-internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 dir1 dir2 nil regexp 'ediff-files 'ediff-directories
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (defalias 'edirs 'ediff-directories)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (defun ediff-directory-revisions (dir1 regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 "Run Ediff on a directory, DIR1, comparing its files with their revisions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 The second argument, REGEXP, is a regular expression that filters the file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 names. Only the files that are under revision control are taken into account."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (let ((dir-A (ediff-get-default-directory-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (list (ediff-read-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 "Directory to compare with revision:" dir-A nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (read-string "Filter through regular expression: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 nil 'ediff-filtering-regexp-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (ediff-directory-revisions-internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 dir1 regexp 'ediff-revision 'ediff-directory-revisions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (defalias 'edir-revisions 'ediff-directory-revisions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (defun ediff-directories3 (dir1 dir2 dir3 regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 "Run Ediff on three directories, DIR1, DIR2, and DIR3, comparing files that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 have the same name in all three. The last argument, REGEXP, is a regular
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 expression that can be used to filter out certain file names."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (let ((dir-A (ediff-get-default-directory-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (list (setq f (ediff-read-file-name "Directory A to compare:" dir-A nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (setq f (ediff-read-file-name "Directory B to compare:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (if ediff-use-last-dir
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 ediff-last-dir-B
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (ediff-strip-last-dir f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (ediff-read-file-name "Directory C to compare:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (if ediff-use-last-dir
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 ediff-last-dir-C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (ediff-strip-last-dir f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (read-string "Filter through regular expression: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 nil 'ediff-filtering-regexp-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (ediff-directories-internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 dir1 dir2 dir3 regexp 'ediff-files3 'ediff-directories3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (defalias 'edirs3 'ediff-directories3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (defun ediff-merge-directories (dir1 dir2 regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 "Run Ediff on a pair of directories, DIR1 and DIR2, merging files that have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 the same name in both. The third argument, REGEXP, is a regular expression that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 can be used to filter out certain file names."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (let ((dir-A (ediff-get-default-directory-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (list (setq f (ediff-read-file-name "Directory A to merge:" dir-A nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (ediff-read-file-name "Directory B to merge:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (if ediff-use-last-dir
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 ediff-last-dir-B
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (ediff-strip-last-dir f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (read-string "Filter through regular expression: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 nil 'ediff-filtering-regexp-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (ediff-directories-internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 dir1 dir2 nil regexp 'ediff-merge-files 'ediff-merge-directories
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (defalias 'edirs-merge 'ediff-merge-directories)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (defun ediff-merge-directories-with-ancestor (dir1 dir2 ancestor-dir regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 "Merge files in directories DIR1 and DIR2 using files in ANCESTOR-DIR as ancestors.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 Ediff merges files that have identical names in DIR1, DIR2. If a pair of files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 in DIR1 and DIR2 doesn't have an ancestor in ANCESTOR-DIR, Ediff will merge
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 without ancestor. The fourth argument, REGEXP, is a regular expression that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 can be used to filter out certain file names."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (let ((dir-A (ediff-get-default-directory-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (list (setq f (ediff-read-file-name "Directory A to merge:" dir-A nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (setq f (ediff-read-file-name "Directory B to merge:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (if ediff-use-last-dir
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 ediff-last-dir-B
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (ediff-strip-last-dir f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (ediff-read-file-name "Ancestor directory:"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (if ediff-use-last-dir
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 ediff-last-dir-C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (ediff-strip-last-dir f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (read-string "Filter through regular expression: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 nil 'ediff-filtering-regexp-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (ediff-directories-internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 dir1 dir2 ancestor-dir regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 'ediff-merge-files-with-ancestor 'ediff-merge-directories-with-ancestor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (defun ediff-merge-directory-revisions (dir1 regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 "Run Ediff on a directory, DIR1, merging its files with their revisions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 The second argument, REGEXP, is a regular expression that filters the file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 names. Only the files that are under revision control are taken into account."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (let ((dir-A (ediff-get-default-directory-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (list (ediff-read-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 "Directory to merge with revisions:" dir-A nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (read-string "Filter through regular expression: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 nil 'ediff-filtering-regexp-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (ediff-directory-revisions-internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 dir1 regexp 'ediff-merge-revisions 'ediff-merge-directory-revisions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (defalias 'edir-merge-revisions 'ediff-merge-directory-revisions)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (defun ediff-merge-directory-revisions-with-ancestor (dir1 regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 "Run Ediff on a directory, DIR1, merging its files with their revisions and ancestors.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 The second argument, REGEXP, is a regular expression that filters the file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 names. Only the files that are under revision control are taken into account."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (let ((dir-A (ediff-get-default-directory-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (list (ediff-read-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 "Directory to merge with revisions and ancestors:" dir-A nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (read-string "Filter through regular expression: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 nil 'ediff-filtering-regexp-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (ediff-directory-revisions-internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 dir1 regexp 'ediff-merge-revisions-with-ancestor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 'ediff-merge-directory-revisions-with-ancestor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (defalias
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 'edir-merge-revisions-with-ancestor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 'ediff-merge-directory-revisions-with-ancestor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (defalias 'edirs-merge-with-ancestor 'ediff-merge-directories-with-ancestor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 ;; Run ediff-action (ediff-files, ediff-merge, ediff-merge-with-ancestors)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 ;; on a pair of directories (three directories, in case of ancestor).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 ;; The third argument, REGEXP, is a regular expression that can be used to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 ;; filter out certain file names.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 ;; JOBNAME is the symbol indicating the meta-job to be performed.
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
631 ;; MERGE-DIR is the directory in which to store merged files.
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
632 (defun ediff-directories-internal (dir1 dir2 dir3 regexp action jobname
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 &optional startup-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 ;; ediff-read-file-name is set to attach a previously entered file name if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 ;; the currently entered file is a directory. This code takes care of that.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (setq dir1 (if (file-directory-p dir1) dir1 (file-name-directory dir1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 dir2 (if (file-directory-p dir2) dir2 (file-name-directory dir2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (if (stringp dir3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (setq dir3 (if (file-directory-p dir3) dir3 (file-name-directory dir3))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (cond ((string= dir1 dir2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (error "Directories A and B are the same: %s" dir1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 ((and (eq jobname 'ediff-directories3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (string= dir1 dir3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (error "Directories A and C are the same: %s" dir1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 ((and (eq jobname 'ediff-directories3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (string= dir2 dir3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (error "Directories B and C are the same: %s" dir1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (let (diffs ; var where ediff-intersect-directories returns the diff list
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
652 merge-autostore-dir
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 file-list meta-buf)
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
654 (if (and ediff-autostore-merges (ediff-merge-metajob jobname))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
655 (setq merge-autostore-dir
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
656 (ediff-read-file-name "Directory to save merged files:"
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
657 (if ediff-use-last-dir
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
658 ediff-last-merge-autostore-dir
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
659 (ediff-strip-last-dir dir1))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
660 nil)))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
661 ;; verify we are not merging into an orig directory
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
662 (if (stringp merge-autostore-dir)
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
663 (cond ((and (stringp dir1) (string= merge-autostore-dir dir1))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
664 (or (y-or-n-p "Merge directory same as directory A, sure? ")
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
665 (error "Directory merge aborted")))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
666 ((and (stringp dir2) (string= merge-autostore-dir dir2))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
667 (or (y-or-n-p "Merge directory same as directory B, sure? ")
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
668 (error "Directory merge aborted")))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
669 ((and (stringp dir3) (string= merge-autostore-dir dir3))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
670 (or (y-or-n-p
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
671 "Merge directory same as ancestor directory, sure? ")
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
672 (error "Directory merge aborted")))))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
673
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 (setq file-list (ediff-intersect-directories
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
675 jobname 'diffs
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
676 regexp dir1 dir2 dir3 merge-autostore-dir))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (setq startup-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 ;; this sets various vars in the meta buffer inside
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 ;; ediff-prepare-meta-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (cons (` (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 ;; tell what to do if the user clicks on a session record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (setq ediff-session-action-function (quote (, action)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 ;; set ediff-dir-difference-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 (setq ediff-dir-difference-list (quote (, diffs)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 startup-hooks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 (setq meta-buf (ediff-prepare-meta-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 'ediff-filegroup-action
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 file-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 "*Ediff Session Group Panel"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 'ediff-redraw-directory-group-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 jobname
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 startup-hooks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 (ediff-show-meta-buffer meta-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 (defun ediff-directory-revisions-internal (dir1 regexp action jobname
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 &optional startup-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 (setq dir1 (if (file-directory-p dir1) dir1 (file-name-directory dir1)))
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
699
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
700 (let (file-list meta-buf merge-autostore-dir)
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
701 (if (and ediff-autostore-merges (ediff-merge-metajob jobname))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
702 (setq merge-autostore-dir
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
703 (ediff-read-file-name "Directory to save merged files:"
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
704 (if ediff-use-last-dir
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
705 ediff-last-merge-autostore-dir
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
706 (ediff-strip-last-dir dir1))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
707 nil)))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
708 ;; verify merge-autostore-dir != dir1
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
709 (if (and (stringp merge-autostore-dir)
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
710 (stringp dir1)
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
711 (string= merge-autostore-dir dir1))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
712 (or (y-or-n-p
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
713 "Directory for saving merges is the same as directory A. Sure? ")
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
714 (error "Merge of directory revisions aborted")))
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
715
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (setq file-list
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
717 (ediff-get-directory-files-under-revision
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
718 jobname regexp dir1 merge-autostore-dir))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 (setq startup-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 ;; this sets various vars in the meta buffer inside
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 ;; ediff-prepare-meta-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (cons (` (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 ;; tell what to do if the user clicks on a session record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (setq ediff-session-action-function (quote (, action)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 startup-hooks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (setq meta-buf (ediff-prepare-meta-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 'ediff-filegroup-action
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 file-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 "*Ediff Session Group Panel"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 'ediff-redraw-directory-group-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 jobname
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 startup-hooks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 (ediff-show-meta-buffer meta-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 ;;; Compare regions and windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (defun ediff-windows-wordwise (dumb-mode &optional wind-A wind-B startup-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 "Compare WIND-A and WIND-B, which are selected by clicking, wordwise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 With prefix argument, DUMB-MODE, or on a non-windowing display, works as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 If WIND-A is nil, use selected window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 If WIND-B is nil, use window next to WIND-A."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (ediff-windows dumb-mode wind-A wind-B
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 startup-hooks 'ediff-windows-wordwise 'word-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 (defun ediff-windows-linewise (dumb-mode &optional wind-A wind-B startup-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 "Compare WIND-A and WIND-B, which are selected by clicking, linewise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 With prefix argument, DUMB-MODE, or on a non-windowing display, works as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 If WIND-A is nil, use selected window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 If WIND-B is nil, use window next to WIND-A."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (ediff-windows dumb-mode wind-A wind-B
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 startup-hooks 'ediff-windows-linewise nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 ;; Compare WIND-A and WIND-B, which are selected by clicking.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 ;; With prefix argument, DUMB-MODE, or on a non-windowing display,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 ;; works as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 ;; If WIND-A is nil, use selected window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 ;; If WIND-B is nil, use window next to WIND-A.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (defun ediff-windows (dumb-mode wind-A wind-B startup-hooks job-name word-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 (if (or dumb-mode (not (ediff-window-display-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 (setq wind-A (ediff-get-next-window wind-A nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 wind-B (ediff-get-next-window wind-B wind-A))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 (setq wind-A (ediff-get-window-by-clicking wind-A nil 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 wind-B (ediff-get-window-by-clicking wind-B wind-A 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 (let ((buffer-A (window-buffer wind-A))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 (buffer-B (window-buffer wind-B))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 beg-A end-A beg-B end-B)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 (sit-for 0) ; sync before using window-start/end -- a precaution
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 (select-window wind-A)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (setq beg-A (window-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 end-A (window-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 (select-window wind-B)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 (setq beg-B (window-start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 end-B (window-end))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 (ediff-regions-internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 buffer-A beg-A end-A buffer-B beg-B end-B
144
318232e2a3f0 Import from CVS: tag r20-2b6
cvs
parents: 134
diff changeset
789 startup-hooks job-name word-mode nil)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 (defun ediff-regions-wordwise (buffer-A buffer-B &optional startup-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 "Run Ediff on a pair of regions in two different buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 Regions \(i.e., point and mark\) are assumed to be set in advance.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 This function is effective only for relatively small regions, up to 200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 lines. For large regions, use `ediff-regions-linewise'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 (let (bf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (list (setq bf (read-buffer "Region's A buffer: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 (ediff-other-buffer "") t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (read-buffer "Region's B buffer: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 ;; realign buffers so that two visible bufs will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 ;; at the top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (save-window-excursion (other-window 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 (ediff-other-buffer bf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (if (not (ediff-buffer-live-p buffer-A))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (error "Buffer %S doesn't exist" buffer-A))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 (if (not (ediff-buffer-live-p buffer-B))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 (error "Buffer %S doesn't exist" buffer-B))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 (let (reg-A-beg reg-A-end reg-B-beg reg-B-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 (set-buffer buffer-A)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 (setq reg-A-beg (region-beginning)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 reg-A-end (region-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 (set-buffer buffer-B)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 (setq reg-B-beg (region-beginning)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 reg-B-end (region-end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 (ediff-regions-internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 (get-buffer buffer-A) reg-A-beg reg-A-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 (get-buffer buffer-B) reg-B-beg reg-B-end
144
318232e2a3f0 Import from CVS: tag r20-2b6
cvs
parents: 134
diff changeset
826 startup-hooks 'ediff-regions-wordwise 'word-mode nil)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 (defun ediff-regions-linewise (buffer-A buffer-B &optional startup-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 "Run Ediff on a pair of regions in two different buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 Regions \(i.e., point and mark\) are assumed to be set in advance.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 Each region is enlarged to contain full lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 This function is effective for large regions, over 100-200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 lines. For small regions, use `ediff-regions-wordwise'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (let (bf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 (list (setq bf (read-buffer "Region A's buffer: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (ediff-other-buffer "") t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 (read-buffer "Region B's buffer: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 ;; realign buffers so that two visible bufs will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 ;; at the top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (save-window-excursion (other-window 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (ediff-other-buffer bf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (if (not (ediff-buffer-live-p buffer-A))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (error "Buffer %S doesn't exist" buffer-A))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 (if (not (ediff-buffer-live-p buffer-B))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 (error "Buffer %S doesn't exist" buffer-B))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (let (reg-A-beg reg-A-end reg-B-beg reg-B-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 (set-buffer buffer-A)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (setq reg-A-beg (region-beginning)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 reg-A-end (region-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 ;; enlarge the region to hold full lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (goto-char reg-A-beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (setq reg-A-beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 (goto-char reg-A-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 (or (eobp) (forward-char)) ; include the newline char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 (setq reg-A-end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (set-buffer buffer-B)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 (setq reg-B-beg (region-beginning)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 reg-B-end (region-end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 ;; enlarge the region to hold full lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 (goto-char reg-B-beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 (setq reg-B-beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 (goto-char reg-B-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 (or (eobp) (forward-char)) ; include the newline char
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 (setq reg-B-end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 ) ; save excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 (ediff-regions-internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 (get-buffer buffer-A) reg-A-beg reg-A-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 (get-buffer buffer-B) reg-B-beg reg-B-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 startup-hooks 'ediff-regions-linewise nil))) ; no word mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 ;; compare region beg-A to end-A of buffer-A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 ;; to regions beg-B -- end-B in buffer-B.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 (defun ediff-regions-internal (buffer-A beg-A end-A buffer-B beg-B end-B
144
318232e2a3f0 Import from CVS: tag r20-2b6
cvs
parents: 134
diff changeset
886 startup-hooks job-name word-mode
318232e2a3f0 Import from CVS: tag r20-2b6
cvs
parents: 134
diff changeset
887 setup-parameters)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 (let ((tmp-buffer (get-buffer-create ediff-tmp-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 overl-A overl-B
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 file-A file-B)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 ;; in case beg/end-A/B aren't markers--make them into markers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 (ediff-eval-in-buffer buffer-A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 (setq beg-A (move-marker (make-marker) beg-A)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 end-A (move-marker (make-marker) end-A)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 (ediff-eval-in-buffer buffer-B
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (setq beg-B (move-marker (make-marker) beg-B)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 end-B (move-marker (make-marker) end-B)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 (if (and (eq buffer-A buffer-B)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 (or (and (< beg-A end-B) (<= beg-B beg-A)) ; b-B b-A e-B
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 (and (< beg-B end-A) (<= end-A end-B)))) ; b-B e-A e-B
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 (with-output-to-temp-buffer ediff-msg-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 (princ "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 You have requested to compare overlapping regions of the same buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 In this case, Ediff's highlighting may be confusing---in the same window,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 you may see highlighted regions that belong to different regions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 Continue anyway? (y/n) "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 (if (y-or-n-p "Continue anyway? ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 (error "%S aborted" job-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 ;; make file-A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 (if word-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 (ediff-wordify beg-A end-A buffer-A tmp-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 (ediff-copy-to-buffer beg-A end-A buffer-A tmp-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 (setq file-A (ediff-make-temp-file tmp-buffer "regA"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 ;; make file-B
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 (if word-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 (ediff-wordify beg-B end-B buffer-B tmp-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 (ediff-copy-to-buffer beg-B end-B buffer-B tmp-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 (setq file-B (ediff-make-temp-file tmp-buffer "regB"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 (setq overl-A (ediff-make-bullet-proof-overlay beg-A end-A buffer-A))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 (setq overl-B (ediff-make-bullet-proof-overlay beg-B end-B buffer-B))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 (ediff-setup buffer-A file-A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 buffer-B file-B
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 nil nil ; buffer & file C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 (cons (` (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 (delete-file (, file-A))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 (delete-file (, file-B))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 startup-hooks)
144
318232e2a3f0 Import from CVS: tag r20-2b6
cvs
parents: 134
diff changeset
938 (append
318232e2a3f0 Import from CVS: tag r20-2b6
cvs
parents: 134
diff changeset
939 (list (cons 'ediff-word-mode word-mode)
318232e2a3f0 Import from CVS: tag r20-2b6
cvs
parents: 134
diff changeset
940 (cons 'ediff-narrow-bounds (list overl-A overl-B))
318232e2a3f0 Import from CVS: tag r20-2b6
cvs
parents: 134
diff changeset
941 (cons 'ediff-job-name job-name))
318232e2a3f0 Import from CVS: tag r20-2b6
cvs
parents: 134
diff changeset
942 setup-parameters)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 ;;; Merge files and buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 (defalias 'ediff-merge 'ediff-merge-files)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 (defsubst ediff-merge-on-startup ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 (ediff-do-merge 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 (ediff-eval-in-buffer ediff-buffer-C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 (set-buffer-modified-p nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 (defun ediff-merge-files (file-A file-B &optional startup-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 "Merge two files without ancestor."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 (let ((dir-A (if ediff-use-last-dir
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 ediff-last-dir-A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 default-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 dir-B f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 (list (setq f (ediff-read-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 "File A to merge" dir-A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 (ediff-get-default-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 (ediff-read-file-name "File B to merge"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 (setq dir-B
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 (if ediff-use-last-dir
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 ediff-last-dir-B
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 (file-name-directory f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 (setq file-name-history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 (cons (ediff-abbreviate-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 (expand-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 (file-name-nondirectory f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 dir-B))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 file-name-history))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 (setq startup-hooks (cons 'ediff-merge-on-startup startup-hooks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 (ediff-files-internal file-A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 (if (file-directory-p file-B)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 (expand-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 (file-name-nondirectory file-A) file-B)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 file-B)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 nil ; file-C
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 startup-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 'ediff-merge-files))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 (defun ediff-merge-files-with-ancestor (file-A file-B file-ancestor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 &optional startup-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 "Merge two files with ancestor."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 (let ((dir-A (if ediff-use-last-dir
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 ediff-last-dir-A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 default-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 dir-B dir-ancestor f ff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 (list (setq f (ediff-read-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 "File A to merge" dir-A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 (ediff-get-default-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 (setq ff (ediff-read-file-name "File B to merge"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 (setq dir-B
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 (if ediff-use-last-dir
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 ediff-last-dir-B
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 (file-name-directory f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 (setq file-name-history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 (ediff-abbreviate-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 (expand-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 (file-name-nondirectory f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 dir-B))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 file-name-history))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 (ediff-read-file-name "Ancestor file"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 (setq dir-ancestor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 (if ediff-use-last-dir
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 ediff-last-dir-ancestor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 (file-name-directory ff)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 (setq file-name-history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 (cons (ediff-abbreviate-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 (expand-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 (file-name-nondirectory ff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 dir-ancestor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 file-name-history))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 ff))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 (setq startup-hooks (cons 'ediff-merge-on-startup startup-hooks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 (ediff-files-internal file-A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 (if (file-directory-p file-B)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 (expand-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 (file-name-nondirectory file-A) file-B)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 file-B)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 file-ancestor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 startup-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 'ediff-merge-files-with-ancestor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 (defalias 'ediff-merge-with-ancestor 'ediff-merge-files-with-ancestor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 (defun ediff-merge-buffers (buffer-A buffer-B &optional startup-hooks job-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 "Merge buffers without ancestor."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 (let (bf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 (list (setq bf (read-buffer "Buffer A to merge: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 (ediff-other-buffer "") t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 (read-buffer "Buffer B to merge: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 ;; realign buffers so that two visible bufs will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 ;; at the top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 (save-window-excursion (other-window 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 (ediff-other-buffer bf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 (setq startup-hooks (cons 'ediff-merge-on-startup startup-hooks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 (or job-name (setq job-name 'ediff-merge-buffers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 (ediff-buffers-internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 buffer-A buffer-B nil startup-hooks job-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 (defun ediff-merge-buffers-with-ancestor (buffer-A
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 buffer-B buffer-ancestor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 &optional startup-hooks job-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 "Merge buffers with ancestor."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 (let (bf bff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 (list (setq bf (read-buffer "Buffer A to merge: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 (ediff-other-buffer "") t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 (setq bff (read-buffer "Buffer B to merge: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 ;; realign buffers so that two visible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 ;; bufs will be at the top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 (save-window-excursion (other-window 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 (ediff-other-buffer bf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 (read-buffer "Ancestor buffer: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 ;; realign buffers so that three visible
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 ;; bufs will be at the top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 (save-window-excursion (other-window 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 (ediff-other-buffer (list bf bff)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 (setq startup-hooks (cons 'ediff-merge-on-startup startup-hooks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 (or job-name (setq job-name 'ediff-merge-buffers-with-ancestor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 (ediff-buffers-internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 buffer-A buffer-B buffer-ancestor startup-hooks job-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 (defun ediff-merge-revisions (&optional file startup-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 "Run Ediff by merging two revisions of a file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 The file is the optional FILE argument or the file visited by the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 (if (stringp file) (find-file file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 (let (rev1 rev2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 (setq rev1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 (read-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 "Version 1 to merge (default: %s's latest version): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 (if (stringp file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 (file-name-nondirectory file) "current buffer")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 rev2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 (read-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 "Version 2 to merge (default: %s): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 (if (stringp file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 (file-name-nondirectory file) "current buffer"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 (ediff-load-version-control)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 ;; ancestor-revision=nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 (funcall
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
1119 (intern (format "ediff-%S-merge-internal" ediff-version-control-package))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 rev1 rev2 nil startup-hooks)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 (defun ediff-merge-revisions-with-ancestor (&optional file startup-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 "Run Ediff by merging two revisions of a file with a common ancestor.
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
1126 The file is the the optional FILE argument or the file visited by the current
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 (if (stringp file) (find-file file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 (let (rev1 rev2 ancestor-rev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 (setq rev1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 (read-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 "Version 1 to merge (default: %s's latest version): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 (if (stringp file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 (file-name-nondirectory file) "current buffer")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 rev2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 (read-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 "Version 2 to merge (default: %s): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 (if (stringp file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 (file-name-nondirectory file) "current buffer")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 ancestor-rev
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 (read-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 "Ancestor version (default: %s): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 (if (stringp file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 (file-name-nondirectory file) "current buffer"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 (ediff-load-version-control)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 (funcall
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
1151 (intern (format "ediff-%S-merge-internal" ediff-version-control-package))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 rev1 rev2 ancestor-rev startup-hooks)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 (defun run-ediff-from-cvs-buffer (pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 "Run Ediff-merge on appropriate revisions of the selected file.
144
318232e2a3f0 Import from CVS: tag r20-2b6
cvs
parents: 134
diff changeset
1157 First run after `M-x cvs-update'. Then place the cursor on a line describing a
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 file and then run `run-ediff-from-cvs-buffer'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 (interactive "d")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 (ediff-load-version-control)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 (let ((tin (tin-locate cvs-cookie-handle pos)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 (if tin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 (cvs-run-ediff-on-file-descriptor tin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 (error "There is no file to merge"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 ;;; Apply patch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 (defun ediff-patch-file ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 "Run Ediff by patching SOURCE-FILENAME."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 ;; This now returns the control buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 (let (source-dir source-file patch-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 (require 'ediff-ptch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 (setq patch-buf (ediff-get-patch-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 (setq source-dir (cond (ediff-use-last-dir ediff-last-dir-patch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 ((and (not ediff-patch-default-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 (buffer-file-name patch-buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 (file-name-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 (expand-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 (buffer-file-name patch-buf))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 (t default-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 (setq source-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 ;; the default is the directory, not the visited file name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 (ediff-read-file-name "Which file to patch? " source-dir source-dir))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 (ediff-dispatch-file-patching-job patch-buf source-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 (defun ediff-patch-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 "Run Ediff by patching BUFFER-NAME."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 (let (patch-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 (require 'ediff-ptch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 (setq patch-buf (ediff-get-patch-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 (ediff-patch-buffer-internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 patch-buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 (read-buffer "Which buffer to patch? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 (cond ((eq patch-buf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 (window-buffer (other-window 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 (t (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 'must-match))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 (defalias 'epatch 'ediff-patch-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 (defalias 'epatch-buffer 'ediff-patch-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 ;;; Versions Control functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 (defun ediff-revision (&optional file startup-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 "Run Ediff by comparing versions of a file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 The file is an optional FILE argument or the file visited by the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 buffer. Use `vc.el' or `rcs.el' depending on `ediff-version-control-package'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 ;; if buffer is non-nil, use that buffer instead of the current buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 (if (stringp file) (find-file file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 (let (rev1 rev2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 (setq rev1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 (read-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 (format "Version 1 to compare (default: %s's latest version): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 (if (stringp file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 (file-name-nondirectory file) "current buffer")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 rev2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 (read-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 (format "Version 2 to compare (default: %s): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 (if (stringp file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 (file-name-nondirectory file) "current buffer"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 (ediff-load-version-control)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 (funcall
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
1235 (intern (format "ediff-%S-internal" ediff-version-control-package))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 rev1 rev2 startup-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 ;; Test if version control package is loaded and load if not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 ;; Is SILENT is non-nil, don't report error if package is not found.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 (defun ediff-load-version-control (&optional silent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 (require 'ediff-vers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 (or (featurep ediff-version-control-package)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 (if (locate-library (symbol-name ediff-version-control-package))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 (message "") ; kill the message from `locate-library'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 (require ediff-version-control-package))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 (or silent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 (error "Version control package %S.el not found. Use vc.el instead"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 ediff-version-control-package)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 (defun ediff-version ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 "Return string describing the version of Ediff.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 When called interactively, displays the version."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 (if (interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 (message (ediff-version))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 (format "Ediff %s of %s" ediff-version ediff-date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 ;;;###autoload
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
1265 (defun ediff-documentation (&optional node)
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
1266 "Display Ediff's manual.
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
1267 With optional NODE, goes to that node."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 (let ((ctl-window ediff-control-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 (ctl-buf ediff-control-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 (ediff-skip-unsuitable-frames)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 (pop-to-buffer (get-buffer-create "*info*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 (info (if ediff-xemacs-p "ediff.info" "ediff"))
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
1277 (if node
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
1278 (Info-goto-node node)
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
1279 (message "Type `i' to search for a specific topic"))
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
1280 (raise-frame (selected-frame)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 (error (beep 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 (with-output-to-temp-buffer ediff-msg-buffer
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
1283 (princ ediff-BAD-INFO))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 (if (window-live-p ctl-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 (select-window ctl-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 (set-window-buffer ctl-window ctl-buf)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 ;;; Local Variables:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 ;;; eval: (put 'ediff-eval-in-buffer 'lisp-indent-hook 1)
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
1295 ;;; eval: (put 'ediff-eval-in-buffer 'edebug-form-spec '(form body))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 ;;; End:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 (require 'ediff-util)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 ;;; ediff.el ends here