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