Mercurial > emacs
annotate lisp/ediff.el @ 8483:19dbc8373bec
(compilation-set-window-height): New function,
broken out from compile-internal.
Don't change window height if it is the frame root window.
(compile-internal): Call it.
(compilation-goto-locus): Call it.
Use any visible frame already showing the compilation buffer.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 08 Aug 1994 09:02:40 +0000 |
parents | cb9d52c38ed7 |
children | 084456e12635 |
rev | line source |
---|---|
7267 | 1 ;;; ediff.el --- a visual interface to diff & patch |
2 ;;; Copyright (C) 1994 Free Software Foundation, Inc. | |
3 | |
4 ;; Author: Michael Kifer <kifer@cs.sunysb.edu> | |
5 ;; Created: February 2, 1994 | |
8441
cb9d52c38ed7
(ediff-version): Function, variable deleted.
Richard M. Stallman <rms@gnu.org>
parents:
8348
diff
changeset
|
6 ;; Version of last Kifer changes: 1.64.2 |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
7 ;; Keywords: comparing, merging, patching, version control. |
7267 | 8 |
9 ;; This file is part of GNU Emacs. | |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;; any later version. | |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
23 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
24 | |
25 | |
26 ;;; Commentary: | |
27 ;; ---------- | |
28 | |
7391 | 29 ;; Never read those diff outputs again! |
30 ;; Apply patch selectively, like a pro! | |
7267 | 31 |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
32 ;; This package provides a convenient way of simultaneous browsing through |
7267 | 33 ;; the differences between a pair of files or buffers. The two files being |
34 ;; compared (file-A and file-B) are shown in separate windows (side by | |
35 ;; side, one above the another, or in separate frames), and the differences | |
36 ;; are highlighted as you step through them. You can also copy difference | |
37 ;; regions from one buffer to another (and recover old differences if you | |
38 ;; change your mind). | |
39 | |
40 ;; 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>
parents:
7709
diff
changeset
|
41 ;; though both files, the patched and the original one, simultaneously, |
7267 | 42 ;; difference-by-difference. You can even apply a patch right out of a |
43 ;; mail buffer, i.e., patches received by mail don't even have to be saved. | |
44 ;; Since Ediff lets you copy differences between buffers, you can, in | |
45 ;; effect, apply patches selectively (i.e., you can copy a difference | |
46 ;; region from file.orig to file, thereby undoing any particular patch that | |
47 ;; you don't like). | |
48 | |
7424 | 49 ;; This package builds upon the ideas borrowed from emerge.el. It is still |
50 ;; using half a dozen of functions defined there. Several other Ediff's | |
51 ;; functions are adaptations from emerge.el. Ediff requires, at least, | |
52 ;; Version 5 of emerge.el. This version comes with standard distributions | |
53 ;; of Emacs and Lemacs. Make sure you don't have some stray old copy of | |
54 ;; Emerge on your load path. | |
55 | |
56 ;; Ediff is complimentary to Emerge. While Emerge is primarily intended | |
57 ;; for merging of files, Ediff is by far superior for browsing through | |
58 ;; files compared via diff and for patching files with patch. | |
59 ;; Furthermore, Ediff is more convenient even for merging, when one of the | |
60 ;; files is a designated output. This situation arises while patching | |
61 ;; files or when comparing an old version of a file with a newer version | |
62 ;; (in such cases, it is often desirable to selectively revert some | |
63 ;; portions of the new file to its old state). | |
64 | |
65 ;; Ediff also supports version control via vc.el (in the standard | |
66 ;; distribution of Emacs 19) and rcs.el. The latter is a package written by | |
67 ;; Sebastian Kremer <sk@thp.Uni-Koeln.DE>, which is available in | |
68 ;; | |
69 ;; ftp.cs.buffalo.edu:pub/Emacs/rcs.tar.Z | |
70 ;; ftp.uni-koeln.de:/pub/gnu/emacs/rcs.tar.Z | |
71 ;; | |
72 | |
7267 | 73 |
74 ;; Window configuration: | |
75 ;; ---------------------- | |
76 | |
77 ;; By default, Ediff sets things up in one frame, splitting it between a | |
78 ;; small control window and the two windows for file-A and file-B. The | |
79 ;; split between these latter windows can be horizontal or vertical, which | |
80 ;; can be changed interactively by hitting 's' while the cursor is in the | |
81 ;; control window. | |
82 ;; | |
83 ;; In a multi-frame situation, Ediff would work as follows. When it starts, | |
84 ;; it will place the control window in the frame that was selected at the | |
85 ;; time of the invocation. If file-A or file-B is seen in one of the | |
86 ;; frames, Ediff will leave it there. If a file (A/B) is not visible in any | |
87 ;; frame, Ediff will arrange that it will share a frame with the control | |
88 ;; window. (If none of the files is visible, then both will share the | |
89 ;; control window frame.) The same algorithm works when you hit 'c' | |
90 ;; (ediff-recenter), 'p' (ediff-previous-difference), 'n', etc. | |
91 ;; | |
92 ;; Thus, you can compare files in one frame or in different frames. | |
93 ;; The former is done by default, while the latter can be achieved by | |
94 ;; arranging files A and B to be seen in different frames. Ediff | |
95 ;; respects these arrangements, automatically adapting itself to | |
96 ;; the multi-frame mode. | |
97 | |
98 | |
7424 | 99 ;; To those who like to go where noone has gone before: |
7267 | 100 |
101 ;; Ediff lets the user run multiple sessions at once, i.e., you can invoke | |
102 ;; Ediff on different functions several times in a row, without exiting | |
103 ;; the previous Ediff sessions. Different sessions may even operate on the | |
104 ;; same pair of files. So, in principle, it is possible to do, say, | |
105 ;; pairwise comparison of three (or more) different files. Each session | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
106 ;; would have its own Ediff Control Panel and all the regarding a |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
107 ;; particular session is local to the associated control panel buffer. |
7267 | 108 ;; You can switch between sessions by suspending one session and then |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
109 ;; switching to another control panel. (Different control panel buffers |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
110 ;; are distinguished by a numerical suffix, e.g., Ediff Control Panel<3>.) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
111 ;; Thus, if you would like to compare three files pairwise, you can do |
7267 | 112 ;; this by preparing three different frames, each with its own control |
113 ;; window. (This would require a very wide screen, and I never claimed | |
114 ;; that such 3-way comparison is very easy to do.) | |
115 ;; | |
116 ;; If you need to conduct multiple Ediff sessions on the same file, one | |
117 ;; thing should be kept in mind: each time you invoke Ediff on a buffer that | |
118 ;; already participates in another Ediff session, that buffer should not | |
119 ;; have any ASCII Ediff flags in it. (Highlighting with faces is OK.) If | |
120 ;; flags are not removed, difference overlays won't be set correctly | |
121 ;; for the second invocation of Ediff. The simplest way to remove ASCII | |
7424 | 122 ;; flags from an Ediff buffer is to hit `h' and thus switch to highlighting |
123 ;; with faces (unhighlighting on a dumb terminal). | |
7267 | 124 |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
125 ;;; Remote and Compressed Files |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
126 ;; --------------------------- |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
127 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
128 ;; Ediff will work with remote files, compressed files, and, probably, |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
129 ;; with encrypted files. (I have only tested it with ange-ftp.el, |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
130 ;; jka-compr.el, and uncompress.el.) This means that you can compare files |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
131 ;; residing on another machine, or you can apply a patch to a file on |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
132 ;; another machine (even the patch itself can be a remote file!). This is |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
133 ;; provided that you access remote files via the usual find-file command |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
134 ;; using the syntax acceptable to ange-ftp (see Emacs Manual). |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
135 ;; |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
136 ;; The files to be compared or patched can be compressed or be both |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
137 ;; compressed and remote. To be able to handle compressed files, you |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
138 ;; should use uncompress.el or jka-compr.el. Ediff is designed so that it |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
139 ;; will interface to these packages. When patching compressed or remote |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
140 ;; files, Ediff doesn't rename the source file into source-file-name.orig |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
141 ;; (unlike what `patch' would usually do). Instead, the source file |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
142 ;; retains its name and the result of applying the patch is placed in a |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
143 ;; temporary file that has the suffix `.patched'. Generally, this applies |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
144 ;; to files that are handled using black magic, such as special file |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
145 ;; handlers (ange-ftp and some compression and encryption packages all |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
146 ;; use this method). |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
147 ;; |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
148 ;; Regular files are treated by `patch' in the usual manner, i.e., the |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
149 ;; original is renamed into source-name.orig and the result of the patch |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
150 ;; is placed into the file source-name. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
151 |
7267 | 152 |
153 ;;; Remarks: | |
154 ;; ------- | |
155 | |
7424 | 156 ;; 1. Ediff is heavily dependent on the new features of Emacs 19. |
157 ;; It won't run under Emacs 18 at all. | |
7267 | 158 ;; 2. If running Lucid Emacs, Ediff requires at least version 19.9. |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
159 ;; 3. The function vc-ediff requires the version of vc.el that comes with |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
160 ;; Emacs 19.22 and later. |
7267 | 161 |
162 | |
163 ;;; Installation and use: | |
164 ;; -------------------- | |
165 | |
166 ;; You can invoke Ediff interactively using the following functions: | |
167 ;; | |
168 ;; ediff-buffers - compare buffers | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
169 ;; ediff - alias for ediff-files) |
7267 | 170 ;; ediff-files - compare files |
171 ;; ediff-patch-file - patch file then compare | |
7424 | 172 ;; epatch - alias for ediff-patch-file |
7267 | 173 ;; ediff-patch-buffer - patch buffer then compare |
7424 | 174 ;; epatch-buffer - alias for ediff-patch-buffer |
7267 | 175 ;; vc-ediff - compare buffer & version |
176 ;; using vc.el package | |
177 ;; (Emacs 19.22 and up). | |
178 ;; rcs-ediff - same using rcs.el; rcs.el | |
179 ;; is not part of the | |
180 ;; standard Emacs distribution. | |
181 ;; | |
182 ;; | |
183 ;; To use Ediff, put this in your .emacs file: | |
184 ;; | |
7391 | 185 ;; (autoload 'ediff-buffers "ediff" "Visual interface to diff" t) |
186 ;; (autoload 'ediff "ediff" "Visual interface to diff" t) | |
187 ;; (autoload 'ediff-files "ediff" "Visual interface to diff" t) | |
188 ;; (autoload 'epatch "ediff" "Visual interface to patch" t) | |
189 ;; (autoload 'ediff-patch-file "ediff" "Visual interface to patch" t) | |
190 ;; (autoload 'ediff-patch-buffer "ediff" "Visual interface to patch" t) | |
7424 | 191 ;; (autoload 'epatch-buffer "ediff" "Visual interface to patch" t) |
7267 | 192 ;; (autoload 'vc-ediff "ediff" |
193 ;; "Interface to diff & version control via vc.el" t) | |
194 ;; (autoload 'rcs-ediff "ediff" | |
195 ;; "Interface to diff & version control via rcs.el" t) | |
196 ;; | |
197 ;; | |
198 ;; If you want Ediff to be loaded from the very beginning, you should have | |
199 ;; | |
200 ;; (require 'ediff) | |
201 ;; | |
202 ;; in your .emacs file. This way it is also easier to figure out changes | |
203 ;; to the default Ediff setting, if such changes become necessary --- see | |
204 ;; Customization. | |
205 ;; | |
206 | |
207 ;;; Compilation | |
208 ;; ----------- | |
209 ;; | |
210 ;; When you byte-compile Ediff, you will get some warnings about functions | |
211 ;; being undefined. These can be safely ignored. | |
7424 | 212 ;; |
213 ;; Important: | |
214 ;; ========= | |
215 ;; | |
216 ;; If you are using advice.el (directly or indirectly, via one of the | |
217 ;; other packages), Ediff may not compile properly. In this case, you | |
218 ;; should do: | |
219 ;; | |
220 ;; M-x ad-deactivate-all RET | |
221 ;; | |
222 ;; M-x byte-compile-file RET ediff.el RET | |
223 ;; | |
224 ;; M-x ad-activate-all RET | |
225 ;; | |
226 ;; This precaution will not be needed starting with GNU Emacs 19.23 and | |
227 ;; Lucid Emacs 19.10, due to fixing a bug in advice.el. | |
7267 | 228 |
229 ;;; Customization: | |
230 ;; ------------- | |
231 | |
7424 | 232 ;; Hooks: |
233 ;; ----- | |
7267 | 234 ;; If you don't like the default setting, you can change it through the |
235 ;; various variables and hooks. In particular, the following hooks are | |
236 ;; available: | |
237 | |
238 ;; ediff-load-hooks | |
239 ;; ediff-before-setup-windows-hooks | |
240 ;; ediff-startup-hooks | |
241 ;; ediff-select-hooks | |
242 ;; ediff-unselect-hooks | |
243 ;; ediff-suspend-hooks | |
244 ;; ediff-quit-hooks | |
245 ;; ediff-prepare-buffer-hooks | |
246 | |
247 ;; The hooks in ediff-load-hooks can be used to change defaults after Ediff | |
248 ;; is loaded. | |
249 ;; The hooks in ediff-before-setup-windows-hooks, ediff-suspend-hooks, and | |
250 ;; ediff-quit-hooks can be used to save and then restore whatever window | |
251 ;; configuration you want. However, make sure you understand what you are | |
252 ;; doing. Many variables that drive Ediff are local to the different | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
253 ;; Ediff Control Panel buffers. Take a look at ediff-default-suspend-hook and |
7267 | 254 ;; ediff-default-quit-hook to see what's involved. |
255 ;; The hooks in ediff-prepare-buffer-hooks are executed for each Ediff buffer | |
256 ;; (A and B) right after these buffers are arranged. | |
257 ;; | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
258 ;; |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
259 ;; Selective browsing: Control over stepping through difference regions |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
260 ;; ----------------------------------------------- |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
261 ;; |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
262 ;; Sometimes it is convenient to be able to step through only some |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
263 ;; difference regions, those that satisfy certain conditions and to ignore |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
264 ;; all others. The commands `#f' and `#h' let the user specify regular |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
265 ;; expressions to control the way Ediff skips to the next or previous |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
266 ;; difference. Typing `#f' lets one specify a pair of regular expressions, |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
267 ;; regexp-A and regexp-B. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
268 ;; Ediff will then start stepping only through those difference regions where |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
269 ;; the region in buffer A matches regexp-A and the region in buffer B |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
270 ;; matches regexp-B. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
271 ;; Similarly, using `#h', one specifies expressions that match difference |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
272 ;; regions to be ignored while stepping through the differences. That is, if |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
273 ;; the buf A part matches regexp-A and the buf B part matches regexp B then |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
274 ;; the region will be ignored by ediff-next-difference and |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
275 ;; ediff-previous-difference commands. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
276 ;; |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
277 ;; Hitting `#f' and `#h' toggles this feature on/off. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
278 ;; |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
279 ;; Note that selective browsing affects only ediff-next-difference and |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
280 ;; ediff-previous-difference, i.e., the commands invoked by typing n/SPC |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
281 ;; and p/DEL. You can still jump directly (using `j' or `ga/gb') to any |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
282 ;; numbered difference. Also, it should be understood, that #f and #h do |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
283 ;; not change the position of the point in the buffers. The effect of these |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
284 ;; commands is seen only when the user types `n' or `p', i.e., when |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
285 ;; Ediff is told to jump to the next or previous difference. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
286 ;; |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
287 ;; Users can supply their own functions that specify how Ediff should do |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
288 ;; selective browsing. To change the default Ediff function, add a function to |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
289 ;; ediff-load-hooks which will do the following assignments: |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
290 ;; |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
291 ;; (fset ediff-hide-regexp-matches 'your-hide-function) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
292 ;; (fset ediff-focus-on-regexp-matches 'your-focus-function) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
293 ;; |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
294 ;; Useful hints: To specify a regexp that matches everything, don't simply |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
295 ;; type RET in response to a prompt. Typing RET tells Ediff to accept the |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
296 ;; default value, which may not be what you want. Instead, one should enter |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
297 ;; something like `^' or `$' --- which would match every line. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
298 ;; |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
299 ;; If the user doesn't remember if selective browsing is in effect and |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
300 ;; which regexps are being used, the status command, `i', will supply |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
301 ;; the requisite information. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
302 ;; |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
303 ;; |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
304 ;; Highlighting difference regions |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
305 ;; ------------------------------- |
7267 | 306 ;; The second group of Ediff variables that could be changed, if you so |
307 ;; wish, is: | |
308 ;; | |
309 ;; ediff-before-flag-eol | |
310 ;; ediff-after-flag-eol | |
311 ;; ediff-before-flag-mol | |
312 ;; ediff-after-flag-mol | |
313 ;; | |
314 ;; ediff-current-diff-face-A | |
315 ;; ediff-current-diff-face-B | |
7424 | 316 ;; ediff-fine-diff-face-A |
317 ;; ediff-fine-diff-face-B | |
7267 | 318 ;; ediff-even-diff-face-A |
319 ;; ediff-even-diff-face-B | |
320 ;; ediff-odd-diff-face-A | |
321 ;; ediff-odd-diff-face-B | |
322 ; | |
323 ;; The first four are ASCII strings that mark the beginning and the end of | |
324 ;; the differences found in file-A and file-B. Ediff uses different flags | |
325 ;; to highlight regions that begin/end at the beginning of a line or in a | |
326 ;; middle of a line. | |
327 | |
328 ;; The rest are the faces used to highlight text on X displays. On X | |
329 ;; displays, Ediff uses ediff-current-diff-face-A and | |
330 ;; ediff-current-diff-face-B to highlight the current difference regions. | |
7424 | 331 ;; The faces ediff-fine-diff-face-A and ediff-fine-diff-face-B |
332 ;; are used to show the fine differences between the current differences | |
333 ;; regions in buffer A and B. | |
7267 | 334 ;; Other (non-current) difference regions are displayed in alternating |
7391 | 335 ;; faces: ediff-even/odd-diff-face-A/B. The odd and the even |
7267 | 336 ;; faces are actually identical on monochrome displays, because it is |
7424 | 337 ;; rather poor in what you can do on such a display. So, I chose to use |
8348
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
338 ;; italics to highlight other differences. Any ideas would be welcome. |
7267 | 339 ;; There are two ways to change the default setting for highlighting faces: |
340 ;; either change the variables, as in | |
341 ;; | |
8348
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
342 ;; (setq ediff-current-diff-face-A 'bold-italic) |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
343 ;; |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
344 ;; or |
7267 | 345 ;; |
8348
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
346 ;; (setq ediff-current-diff-face-A |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
347 ;; (copy-face 'bold-italic 'ediff-current-diff-face-A)) |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
348 ;; |
7267 | 349 ;; or by selectively modifying the defaults: |
350 ;; | |
351 ;; (add-hook 'ediff-load-hooks | |
352 ;; (function (lambda () | |
353 ;; (set-face-foreground ediff-current-diff-face-B "blue") | |
354 ;; (set-face-background ediff-current-diff-face-B "red") | |
355 ;; (make-face-italic ediff-current-diff-face-B)))) | |
356 ;; | |
357 ;; You may also want to take a look at how the above faces are defined in | |
358 ;; Ediff. | |
359 ;; | |
8348
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
360 ;; Note: it is not recommended to use `internal-get-face' (or `get-face' in |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
361 ;; Lucid) when defining faces for Ediff, since this may cause |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
362 ;; problems when there are several frames with different font sizes. |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
363 ;; Instead, use copy-face or set/make-face-* as shown above. |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
364 ;; |
7424 | 365 ;; The last group of variables in this group, |
7267 | 366 ;; |
367 ;; ediff-want-faces | |
7424 | 368 ;; ediff-highlight-all-diffs |
369 ;; ediff-want-default-menus | |
7267 | 370 ;; |
371 ;; indicate whether---on a window system---you want differences to be | |
372 ;; marked using ASCII strings (like on a dumb terminal) or using colors and | |
373 ;; highlighting. If ediff-want-faces is t, then highlighting with faces is | |
374 ;; used. Normally, Ediff highlights all differences, but the selected | |
7424 | 375 ;; difference is highlighted more visibly. You can cycle through various |
376 ;; modes of highlighting by hitting `h'. By default, Ediff starts in the | |
377 ;; mode where all difference regions are highlighted. If you prefer to | |
378 ;; start in the mode where unselected differences are not highlighted, you | |
379 ;; should set ediff-highlight-all-diffs to nil. | |
380 ;; You will still be able to turn on highlighting of all differences by | |
381 ;; hitting `h'. | |
382 ;; The variable `ediff-want-default-menus', if true, will cause Ediff to | |
383 ;; set up a pair of menues in the menu bar, so you can invoke it from there. | |
384 ;; If you don't like the look of the default menus, set this variable to | |
385 ;; nil and design your own menus. | |
7267 | 386 ;; |
387 ;; If you plan on changing these variables, they must be set | |
388 ;; BEFORE ediff.el is loaded. | |
389 ;; | |
390 ;; Note: Ediff lets you switch between the two types of highlighting. That | |
391 ;; is you can switch, interactively, from highlighting using faces to | |
392 ;; highlighting using ASCII flags, and back. Of course, toggling has | |
393 ;; effect only on a window system. On a dumb terminal or in an xterm | |
394 ;; window, the only available option is highlighting with ASCII flags. | |
395 ;; | |
7424 | 396 ;; Refining difference regions |
397 ;; --------------------------- | |
8348
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
398 ;; Ediff has variables that control the way fine differences are |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
399 ;; highlighted. This feature lets the user highlight the exact words that |
7424 | 400 ;; make the difference regions in buffer A and B different. This process |
401 ;; ignores spaces, tabs, and newlines. | |
402 ;; | |
403 ;; ediff-auto-refine | |
404 ;; ediff-auto-refine-limit | |
405 ;; | |
406 ;; By default, `ediff-auto-refine' is `'on', which means that fine differences | |
407 ;; within regions will be highlighted automatically. On a slow system, this | |
408 ;; feature may be undesirable. In any case, the user can always toggle | |
409 ;; auto-refining on/off/nix by hitting `@'. When auto-refining is off, fine | |
410 ;; differences will be shown only for regions for which these differences | |
411 ;; have been computed and saved before. If auto-refining is nixed, fine | |
412 ;; differences will not be shown at all. Hitting `*' will compute and | |
413 ;; display fine differences for the current difference region regardless of | |
414 ;; whether auto-refining is on, off, or nixed. | |
415 ;; If auto-refining is on, the variable `ediff-auto-refine-limit' limits | |
416 ;; the size of the regions to be auto-refined. This variable guards against | |
417 ;; possible slow-down that may be caused by an extraordinary large | |
418 ;; difference region. However, the user can always force refining by | |
419 ;; hitting `*'. | |
420 ;; | |
421 ;; ediff-fine-diff-program | |
422 ;; ediff-fine-diff-options | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
423 ;; ediff-forward-word-function |
7424 | 424 ;; |
425 ;; These variables let the user control how fine differences are computed. | |
426 ;; `ediff-fine-diff-program' is diff, by default. However, you can use | |
427 ;; any function as long as it produces output consistent with diff. | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
428 ;; `ediff-forward-word-function' is a lisp function that determines how the |
7424 | 429 ;; current difference region is split into words. (Fine diferences are |
430 ;; computed by first splitting the current difference region into words and | |
431 ;; then passing this along to `ediff-fine-diff-program'. For the default | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
432 ;; wordify function, `ediff-forward-word', a word is a string consisting of |
7424 | 433 ;; letters, `-', or `_', or a string consisting of symbols that are neither |
434 ;; space, nor a letter.) | |
435 ;; | |
436 ;; Patch and diff programs | |
437 ;; ----------------------- | |
438 ;; The next group of variables determines the programs to be used for | |
439 ;; applying patches and for computing the main difference regions (not the | |
440 ;; fine difference regions): | |
7267 | 441 ;; |
442 ;; ediff-patch-program | |
443 ;; ediff-patch-options | |
444 ;; ediff-diff-program | |
445 ;; ediff-diff-options | |
446 ;; | |
447 ;; These specify the functions that produce differences and do patching. | |
448 ;; The *-options variables specify which options to pass to these programs. | |
449 ;; It is unlikely that you would want to change these. One possible | |
450 ;; exception is when you may want to generate differences with context | |
451 ;; lines in order to send a patch file through email. Then, you might want | |
452 ;; to set ediff-diff-options to '-c'. Sometimes, you may also want to tell | |
7391 | 453 ;; diff to ignore spaces and such. Use the option '-w' for that. Diff |
7267 | 454 ;; has several other useful options (type 'man diff' to find out). |
455 ;; | |
7391 | 456 ;; The output from diff is found in *ediff-diff* buffer. However, this |
7267 | 457 ;; makes sense only if you also intend to use Ediff to browse through the |
458 ;; diff'ed files before sending the patch. This is because diff.el is much | |
7424 | 459 ;; faster in yielding the output of diff (Ediff is a big gun, if used |
7267 | 460 ;; for this simple purpose). |
461 ;; | |
8348
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
462 ;; Mode line |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
463 ;; --------- |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
464 ;; |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
465 ;; When Ediff is running, the mode line of Ediff Control Panel buffer |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
466 ;; displays the current difference being displayed and the total number of |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
467 ;; difference regions in the two files. |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
468 ;; |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
469 ;; The mode line of the buffers being compared displays the type of the |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
470 ;; buffer (`A:' or `B:') and (usually) the file name. Ediff is trying to be |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
471 ;; intelligent in choosing mode line buffer identification. In particular, |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
472 ;; it works well with uniquify.el and mode-line.el packages (which improve |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
473 ;; on the default way in which Emacs displays buffer identification). |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
474 ;; If you don't like the way Ediff identifies its buffers, there is always |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
475 ;; ediff-prepare-buffer-hooks, which can be used to modify the mode line. |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
476 ;; |
7424 | 477 ;; Miscellaneous |
478 ;; ------------- | |
7267 | 479 ;; The last set of variables that can be modified is |
480 ;; | |
481 ;; ediff-split-window-function | |
482 ;; ediff-use-last-dir | |
7424 | 483 ;; ediff-no-help-in-control-buffer |
7267 | 484 ;; |
485 ;; ediff-split-window-function controls the way you want the window be | |
486 ;; split between file-A and file-B. It defaults to vertical split, but you | |
487 ;; can set it to 'split-window-horizontally, if you want. Ediff lets you | |
488 ;; toggle the way windows are split, so you can try different settings | |
489 ;; interactively. Note: if file-A and file-B are in different frames, | |
490 ;; windows are not split, regardless of the value | |
491 ;; ediff-split-window-function. Instead, other windows on these frames are | |
492 ;; deleted and Ediff starts displaying file-A and file-B using these two | |
493 ;; frames, one file per frame. You can then switch to one-frame mode | |
494 ;; simply by hiding the file-A/B buffer that is displayed on a frame other | |
495 ;; than the control-window frame. | |
496 ;; | |
497 ;; Note that if Ediff sees that the two buffers it compares are residing in | |
498 ;; separate frames, it assumes that the user wants them to be so displayed | |
499 ;; and stops splitting windows. Instead, it will arrange each buffer to | |
500 ;; occupy its own frame (possibly shared with Ediff's help window). | |
501 ;; | |
502 ;; The variable ediff-use-last-dir controls the way Ediff presents the | |
503 ;; default directory when it prompts the user for files to compare. If nil, | |
504 ;; Ediff will use the default directory of the current buffer when it | |
505 ;; prompts the user for file names. Otherwise, it will use the | |
506 ;; directories it had previously used for file-A and file-B. | |
507 ;; | |
7424 | 508 ;; The ediff-no-help-in-control-buffer, if set to t, makes C-h behave like |
7267 | 509 ;; the DEL key, i.e., it will move you back to the previous difference |
510 ;; rather than invoking help. This is useful when, in an xterm window or on | |
511 ;; a dumb terminal, the Backspace key is bound to C-h and is positioned | |
512 ;; more conveniently than the DEL key. | |
513 | |
514 | |
515 ;;; Commands | |
516 ;; -------- | |
517 | |
518 ;; All Ediff commands are displayed in a help window, unless you hit '?' to | |
519 ;; shrink it to just one line. You can redisplay the help window by hitting | |
520 ;; '?' again. | |
521 ;; | |
522 ;; Many Ediff commands take numeric prefix arguments. For instance, if you | |
7424 | 523 ;; hit a number, N, and then 'j' (ediff-jump-to-difference), Ediff will |
524 ;; take you to Nth difference. Hitting a number, N, and then 'ab' | |
7419 | 525 ;; (ediff-diff-to-diff) will copy Nth difference from buffer A to buffer B. |
7267 | 526 ;; Hitting 'ba' does copying in the other direction. |
7424 | 527 ;; Likewise, a number, N, followed by 'ra' will restore the Nth difference |
7267 | 528 ;; region in buffer A (if it was previously saved as a result of copying |
529 ;; from B to A). | |
530 ;; | |
531 ;; Without the prefix argument, all commands operate on the current | |
532 ;; difference region. | |
533 ;; | |
534 ;; The total number of differences and the current difference number are | |
535 ;; always displayed in the mode line of the control window. | |
536 | |
537 ;;; Display Modes | |
538 ;; ------------- | |
539 | |
540 ;; Ediff can display files in one frame, stacked side-by-side or one on top | |
541 ;; of another; or it can display the files in different frames. When you | |
542 ;; start Ediff, it assumes a 1-frame mode. You can toggle the side-by-side | |
543 ;; and one-on-top-of-another displays by simply hitting 's'. | |
544 ;; | |
545 ;; Ediff switches to the multi-frame mode when: | |
546 ;; | |
547 ;; 1. file-A and file-B are in different frames (you have to put them into | |
548 ;; different frames manually); or | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
549 ;; 2. Ediff Control Panel is visible in one frame and one other file (A |
7267 | 550 ;; or B) is visible in another frame. If, say, fileA is visible in 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>
parents:
7709
diff
changeset
|
551 ;; different frame than Ediff Control Panel, fileB doesn't have to be |
7267 | 552 ;; visible. If it is, Ediff will continue displaying fileB in the frame |
553 ;; where it was visible before. If it isn't then Ediff will arrange for | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
554 ;; fileB to share a frame with Ediff Control Panel. |
7267 | 555 ;; |
556 ;; If all three buffers are in separate frames, Ediff will switch to a | |
557 ;; 3-frame mode. If Ediff buffers are currently visible only in two | |
558 ;; frames, Ediff will work in a 2-frame mode. In this mode, one of the | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
559 ;; frames will be shared by Ediff Control Panel and file-A or file-B |
7267 | 560 ;; (whichever is appropriate). |
561 | |
562 | |
563 ;;; Bugs: | |
564 ;; ---- | |
565 | |
566 ;; 1. The undo command doesn't restore deleted regions well. That is, if | |
567 ;; you delete all characters in a difference region and then invoke | |
568 ;; `undo', the reinserted text will most likely be reinserted outside of | |
7424 | 569 ;; what Ediff thinks is the current difference region. (This problem |
570 ;; doesn't seem to exist with Lucid Emacs.) | |
571 ;; | |
572 ;; If at any point you feel that difference regions are no longer correct, | |
573 ;; you can hit '!' to recompute the differences. | |
574 | |
575 ;; 2. Emacs 19.xx, where xx < 23, has several bugs related to overlays and | |
576 ;; faces. Somethimes, these may cause highlighting of the refinements or | |
577 ;; of the unselected differences to disappear. Hitting `!' will bring them | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
578 ;; back. In version 19.23 and later, these problems no longer occur. |
7424 | 579 |
580 ;; 3. On a monochrome display, the repertoire of faces with which to | |
581 ;; highlight fine differences is limited. By default, Ediff is using | |
582 ;; underlining. However, if the region is already underlied by some other | |
583 ;; overlays, there is no simple way to temporarily remove that residual | |
584 ;; underlining. This problem occurs when a buffer is highlighted with | |
585 ;; hilit19.el or font-lock.el packages. If this residual highlighting gets | |
586 ;; in the way, you can do the following. Both font-lock.el and hilit19.el | |
587 ;; provide commands for unhighlighting buffers. You can either place these | |
588 ;; commands in `ediff-prepare-buffer-hooks' (which will unhighlight every | |
589 ;; buffer used by Ediff) or you can execute them interactively, at any time | |
590 ;; and on any buffer. | |
591 | |
592 ;; 4. In Lucid Emacs (statically linked with Motif libraries), emerge.el | |
593 ;; and hence ediff.el won't start, unless you set (setq scrollbar-width 0). | |
594 ;; This is a Motif-related bug, I was told. | |
7267 | 595 |
596 | |
597 ;;; Change Log: | |
598 ;; ---------- | |
599 | |
600 ;; Thu Feb 3, 1994 | |
601 | |
602 ;; Added ediff-read-file-name, which is a stub that takes care of Lemacs | |
603 ;; versions of Emerge. (Thanks to Alastair Burt <burt@dfki.uni-kl.de>.) | |
604 ;; | |
605 ;; Fixed a bug in ediff-setup-windows that caused control window to | |
606 ;; appear in a wrong place when split-window-keep-point is nil | |
607 ;; (Thanks to Kevin Broadey <KevinB@bartley.demon.co.uk>.) | |
608 ;; | |
609 ;; Added mechanism for using faces instead of before/after flags. This | |
610 ;; looks much better on an X display, especially on a color one. | |
611 ;; (Thanks to Boris Goldowsky <boris@cs.rochester.edu> for the code | |
612 ;; that led to ediff-highlight-diff. | |
613 ;; Also, thanks to Kevin Esler <esler@ch.hp.com> for suggestions | |
614 ;; regarding highlighting differences on X displays.) | |
615 ;; | |
616 ;; Added functions to apply patches. | |
617 ;; (Thanks to Kevin Broadey <KevinB@bartley.demon.co.uk> for this | |
618 ;; suggestion.) | |
619 | |
620 ;; Fri Feb 4, 1994 | |
621 | |
622 ;; Added mechanism for toggling vertical/horizontal window split. | |
623 ;; (Inspired by a suggestion from Allan Gottlieb | |
624 ;; <gottlieb@allan.ultra.nyu.edu> -- thanks.) | |
625 ;; | |
626 ;; Added mechanism for toggling between highlighting using faces and | |
627 ;; highlighting using ASCII flags. | |
628 ;; | |
629 ;; Fixed a problem with undo. Now, Ediff has smartened up and doesn't | |
630 ;; keep undo info on ASCII flags inserted in buffer-A and buffer-B. | |
631 ;; So, if you edit the files while browsing through them, undo behaves | |
632 ;; as you would expect, i.e., faces/flags don't get in the way. | |
633 | |
634 ;; Sun Feb 6, 1994 | |
635 | |
636 ;; Added horizontal scrolling. Added ediff-position-region to ensure | |
637 ;; that difference regions in buffer-A and buffer-B are aligned with | |
638 ;; each other. Disabled ediff-toggle-split when buffers are displayed | |
639 ;; in different frames. | |
640 | |
641 ;; Mon Feb 7, 1994 | |
642 | |
643 ;; Added toggle-window help (Suggested by Boris Goldowsky | |
644 ;; <boris@cs.rochester.edu>.) | |
645 ;; Added functions to copy differences from one buffer to another and to | |
646 ;; recover old differences. | |
647 ;; Added prefix arguments to ediff-next-difference and | |
648 ;; ediff-previous-difference. | |
649 | |
650 ;; Tue Feb 8, 1994 | |
651 | |
652 ;; Replaced text properties with overlays. Fixed ediff-setup-windows. | |
653 ;; Added ediff-save-buffer to local-write-file-hooks to prevent user | |
654 ;; from saving corrupted states. (Thanks to <boris@cs.rochester.edu> | |
655 ;; for suggestion.) Instead, Ediff now has a pair of functions for | |
656 ;; safe saving of buffers. | |
657 ;; Changed ediff-read-file-name to be more intuitive on ediff-files. | |
658 ;; Added ediff-prepare-buffer-hooks. (Thanks to Kevin Esler | |
659 ;; <esler@ch.hp.com> for the idea.) | |
660 | |
661 ;; Wed Feb 9, 1994 | |
662 | |
663 ;; Cleanups in ediff-patch-file. Protected ediff-copy-diff against | |
664 ;; a bug that Emacs has in kill-region. | |
665 | |
666 ;; Thu Feb 10, 1994 | |
667 | |
668 ;; Added support for Lemacs. (Thanks to Alastair Burt | |
669 ;; <burt@dfki.uni-kl.de> for coercing Ediff into working under Lemacs.) | |
670 ;; Added ediff-kill-buffer-carefully and other suggestions by Boris | |
671 ;; Goldowsky <boris@cs.rochester.edu>. | |
672 ;; Refined the protection against interference with highlighting caused | |
673 ;; by Hilit19. Added the variable ediff-third-party-highlighting. | |
674 ;; Added mechanisn for unhighlighting regions highlighted with Hilit19 | |
675 ;; before hightlighting them with Ediff's overlays. (And for | |
676 ;; rehighlighting them with Hilit19, when the current difference moves on.) | |
677 | |
678 ;; Sun Feb 13, 1994 | |
679 | |
680 ;; Added ediff-place-flags-in-buffer and ediff-remote-exit, which are | |
681 ;; modifications of Emerge's similar functions. The difference is that | |
682 ;; in Ediff they make ediff-before-flag and ediff-after-flag into | |
683 ;; read-only regions, so the user can't change them by mistake. | |
684 ;; | |
685 ;; Adopted a suggestion by Boris Goldowsky <boris@cs.rochester.edu> | |
686 ;; that led to a more elegant treatment of faces. | |
687 ;; | |
688 ;; Added protection against interference with Font-Lock highlighting | |
689 ;; similar to that of Hilit19's protection. | |
690 | |
691 ;; Tue Feb 15, 1994 | |
692 | |
693 ;; Deleted spurious (auto-save-mode 1) in ediff-control-buffer, which | |
694 ;; was causing this buffer to be auto-saved for no good reason. | |
695 ;; Added read-only protection to ediff-before/after-flags in Lemacs. | |
696 ;; (Thanks to Alastair Burt <burt@dfki.uni-kl.de> for help in testing.) | |
697 | |
698 ;; Wed Feb 16, 1994 | |
699 | |
700 ;; Further fixes in the Lemacs part. Changed highlighted region in | |
701 ;; ediff-highlight-diff so that an extra character will be highlighted | |
702 ;; only if a difference is empty (thereby allowing the user to see where an | |
703 ;; insertion or a deletion has taken place). | |
704 ;; | |
705 ;; Simplified interaction with other highlighting packages by giving | |
706 ;; Ediff overlays the highest priority. (Taking a cue from | |
707 ;; ediff-highlight-diff-lemacs written by Alastair Burt | |
708 ;; <burt@dfki.uni-kl.de>.) Zapped ediff-third-party-highlighting | |
709 ;; variable and hooks that were previously used to | |
710 ;; unhighlight/rehighlight buffers when hilit19/font-lock are on. | |
711 | |
712 ;; Fri Feb 18, 1994 | |
713 | |
714 ;; Added a bit more sophistication to ediff-read-file-name. Now, | |
715 ;; ediff-files remembers both, the file-A and the file-B directories. | |
716 ;; They are offered as defaults when ediff-use-last-dir is set to t. | |
717 | |
718 ;; Fri Feb 22, 1994 | |
719 | |
720 ;; Added ediff-before-change-guard to remove ASCII highlighting when | |
721 ;; the user attempts to change buffer-A/B. This is needed because | |
722 ;; otherwise the undo info may become screwed up in those buffers. | |
723 ;; Hitting 'h' (ediff-toggle-hilit) on a dumb terminal will toggle | |
724 ;; between ASCII highlighting and no highlighting. | |
725 | |
726 ;; Fri Feb 24, 1994 | |
727 | |
728 ;; Fixed problems with multiple Ediff sessions running simultaneously. | |
729 | |
730 ;; Tue Mar 1, 1994 | |
731 | |
732 ;; Added vc-ediff, the Ediff interface to vc.el. (Thanks to Eric | |
733 ;; Freudenthal <freudent@jan.ultra.nyu.edu> for contributing this | |
734 ;; function.) | |
735 | |
736 ;; Sun Mar 6, 1994 | |
737 | |
738 ;; Added rcs-ediff, an Ediff interface to RCS via rcs.el. (Thanks to | |
739 ;; Alastair Burt <burt@dfki.uni-kl.de>.) | |
740 ;; Some minor improvements. | |
741 | |
742 ;; Tue March 15, 1994 | |
743 | |
744 ;; Fixed a buglet in defining ediff-current-diff-face-A/B. | |
745 ;; (Thanks to Job Ganzevoort <Job.Ganzevoort@cwi.nl>.) | |
746 | |
747 ;; Tue March 22, 1994 | |
748 | |
749 ;; Fixed a bug with ediffing narrowed buffers, reported by Kevin | |
750 ;; Broadey <KevinB@bartley.demon.co.uk>. | |
751 ;; Made Ediff to work with files that have incomplete last line. | |
7391 | 752 ;; Made Ediff execute diff and patch using Bourne Shell, which |
7267 | 753 ;; should eliminate problems with $prompt that some people had. |
754 | |
755 ;; Thu March 24, 1994 | |
756 | |
757 ;; Achieved quadratic speedup in the size of the file by replacing the | |
758 ;; slow goto-line by forward-line. Ediff is now *much* faster than | |
759 ;; Emerge on large files. Converted demarkation of difference regions | |
760 ;; from markers to overlays. This will later allow us to highlight all | |
761 ;; diffs, not just the current one. | |
762 | |
763 ;; Wed March 30, 1994 | |
764 | |
765 ;; Under X, Ediff now highlights all differences in dim colors and the | |
766 ;; current difference in bright colors. Improved Lucid Emacs support. | |
767 | |
768 ;; Thu March 31, 1994 | |
769 | |
770 ;; Changed toggle hilit to cycle through 3 states: highlighting all | |
771 ;; diffs, highlighting only the current diff, and highlighting using | |
772 ;; ASCII flags. | |
773 ;; Added support for difference regions that are not full lines. | |
774 | |
775 ;; Fri April 1, 1994 | |
776 | |
777 ;; Fixed bugs related to writing buffers A and B. | |
778 ;; Added commands 'ga', 'gb' to jump directly to the closest diff in | |
779 ;; buffer A and B, respectively. | |
780 | |
7424 | 781 ;; Fri April 11, 1994 |
782 | |
783 ;; Added `ediff-recompute-diffs', a function that lets the user recompute | |
784 ;; difference regions after extensive editing done to buffers A and B | |
785 ;; (bound to `!'). | |
786 | |
787 ;; Wed April 13, 1994 | |
788 | |
789 ;; Added the new feature: refining the current difference region. | |
790 ;; This would highlight the precise differences between the regions in | |
791 ;; buffer A and B. (A way to implement this was suggested by Boris | |
792 ;; Goldowsky <boris@cs.rochester.edu>.) | |
793 ;; | |
794 ;; Fixed Ediff to be immune to several different versions of rcs.el | |
795 ;; that are currently in distribution. | |
796 | |
797 ;; Thu April 14, 1994 | |
798 | |
799 ;; Ediff now respects X resources for the faces it uses. It no longer | |
800 ;; barks when the colormap has no colors it is using; or when face | |
801 ;; fonts can't be italicized, etc. | |
802 | |
803 ;; Fri April 15, 1994 | |
804 | |
805 ;; Changed `ediff-setup-windows' to minimize the need to delete and | |
806 ;; create windows. Now jumps faster from diff to diff. | |
807 | |
808 ;; Sat April 16, 1994 | |
809 | |
8348
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
810 ;; Added Ediff to the File menu on the menu bar (FSF's version). |
7424 | 811 |
812 ;; Mon April 18, 1994 | |
813 | |
814 ;; Fixed to work with OS/2's PM-Emacs. | |
815 | |
816 ;; Thu April 21, 1994 | |
817 | |
818 ;; Lemacs' menus added (thanks to Alastair Burt for the help). | |
819 | |
820 ;; Wed April 28, 1994 | |
821 | |
822 ;; Fixed ediff-leave-window-config (thanks to Norbert Kiesel | |
823 ;; <norbert@i3.informatik.rwth-aachen.de>), ediff-shell and | |
824 ;; ediff-protect-metachars (thanks to Richard Stanton | |
825 ;; <stanton@haas.berkeley.edu>). Made access to difference | |
826 ;; overlays structure-independent, making it less bug-prone. | |
827 ;; Patched ediff-read-file-name to work more intuitively with directory | |
828 ;; names (thanks to Kevin Broadey <KevinB@bartley.demon.co.uk>). | |
829 | |
830 ;; Mon May 2, 1994 | |
831 | |
832 ;; Added `ediff-frame-has-menubar' to guard against the possibility that | |
833 ;; the current frame has no menu bar. | |
834 | |
835 ;; Fri May 6, 1994 | |
836 | |
837 ;; Fixed buglet in vc-ediff (thanks to Ray Nickson <nickson@cs.uq.oz.au>). | |
838 | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
839 ;; Wed May 18, 1994 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
840 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
841 ;; Modified ediff-read-file-name to not put long file names in the |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
842 ;; default prompt area, as suggested by KevinB@bartley.demon.co.uk. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
843 ;; Applied patch supplied by burt@dfki.uni-kl.de, fixing a problem with |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
844 ;; ediff-diff-to-diff in Lemacs. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
845 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
846 ;; Tue May 31, 1994 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
847 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
848 ;; Added ediff-forward-word-function (as suggested by Job Ganzevoort |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
849 ;; <Job.Ganzevoort@cwi.nl>). Modified ediff-default-quit-hook so it |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
850 ;; will clean things up in a more satisfactory way. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
851 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
852 ;; Thu Jun 2, 1994 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
853 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
854 ;; Added `ediff-toggle-regexp-match', which allows the user to step |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
855 ;; through only those difference regions that match some regexp; or, |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
856 ;; vice versa, to skip over regions that match a regexp. (This feature |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
857 ;; was suggested by Andy Scott <ascott@pcocd2.intel.com>.) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
858 ;; Added ediff-eval-in-buffer, which is a modified emerge-eval-in-buffer. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
859 ;; The function ediff-status-info, bound to `i', now replaces and extends |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
860 ;; ediff-file-names and ediff-line-numbers, which were bound to `f' |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
861 ;; and `i', respectively. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
862 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
863 ;; Wed Jun 8, 1994 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
864 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
865 ;; Made `ediff-frame-has-menubar' into a function; copied |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
866 ;; `emerge-defvar-local' and turned it into `ediff-defvar-local' |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
867 ;; This is supposed to make the same ediff.elc file work for both Emacs |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
868 ;; and Lucid Emacs, at least, if compiled under Lucid Emacs. (Thanks |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
869 ;; to Eric Eide <eeide@asylum.cs.utah.edu>.) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
870 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
871 ;; Wed Jun 10, 1994 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
872 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
873 ;; Improved `ediff-read-file-name' and `ediff-buffers' so they are now |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
874 ;; providing more intuitive defaults. Modified `ediff-read-file-name' |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
875 ;; so it won't cause problems under OS/2. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
876 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
877 ;; Fri Jun 24, 1994 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
878 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
879 ;; Modified ediff-find-file, ediff-files-internal, and made |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
880 ;; emerge-verify-file-buffer into ediff-verify-file-buffer so that |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
881 ;; Ediff will work correctly with remote and compressed |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
882 ;; files. (Suggested by Sandy Rutherford <sandy@ibm550.sissa.it>.) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
883 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
884 ;; Fri Jun 28, 1994 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
885 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
886 ;; Fixed ediff-patch-files to work with remote and compressed files. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
887 |
8348
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
888 ;; Wed July 20, 1994 |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
889 |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
890 ;; Changed menu bar items per RMS's suggestion. Changed odd/even faces |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
891 ;; in Lemacs to italic. Changed ediff-*-face-* variables so that they |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
892 ;; will contain names of faces instead of the face internal |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
893 ;; representation. (Copy-face works better with face names than with |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
894 ;; face internal representation. With face internal representation, if |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
895 ;; a face vector mentions a font explicitly, copy-face may attempt to |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
896 ;; copy this font, which would cause an error if the font has a wrong |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
897 ;; size for one of the existing frames.) Improved the way |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
898 ;; mode-line-buffer-identification is set in ediff-setup so that Ediff |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
899 ;; will accommodate the way buffers are identified in mode-line.el and |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
900 ;; uniquify.el. |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
901 |
7424 | 902 |
903 ;;; Acknowledgements: | |
904 | |
905 ;; Special thanks to Alastair Burt <burt@dfki.uni-kl.de>, Kevin Esler | |
906 ;; <esler@ch.hp.com>, Kevin Broadey <KevinB@bartley.demon.co.uk>, | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
907 ;; Harald Boegeholz <hwb@machnix.mathematik.uni-stuttgart.de>, |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
908 ;; Robert Estes <estes@ece.ucdavis.edu>, Eric Eide <eeide@asylum.cs.utah.edu>, |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
909 ;; Eric Freudenthal <freudent@jan.ultra.nyu.edu>, Job Ganzevoort |
7424 | 910 ;; <Job.Ganzevoort@cwi.nl>, Boris Goldowsky <boris@cs.rochester.edu>, |
911 ;; Allan Gottlieb <gottlieb@allan.ultra.nyu.edu>, Xiaoli Huang | |
912 ;; <hxl@epic.com>, irvine@lks.csi.com, jaffe@chipmunk.cita.utoronto.ca, | |
913 ;; David Karr, <dkarr@nmo.gtegsc.com>, Norbert Kiesel | |
914 ;; <norbert@i3.informatik.rwth-aachen.de>, Heinz Knutzen | |
915 ;; <hk@informatik.uni-kiel.d400.de>, Martin Maechler | |
916 ;; <maechler@stat.math.ethz.ch>, Richard Mlynarik <mly@adoc.xerox.com>, | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
917 ;; Ray Nickson <nickson@cs.uq.oz.au>, Sandy Rutherford |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
918 ;; <sandy@ibm550.sissa.it>, Andy Scott <ascott@pcocd2.intel.com>, |
8348
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
919 ;; Richard Stallman <rms@gnu.ai.mit.edu>, Richard Stanton |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
920 ;; <stanton@haas.berkeley.edu>, Peter Stout <Peter_Stout@cs.cmu.edu> |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
921 ;; for contributing ideas, patches, and bug reports. |
7424 | 922 ;; |
923 ;; Thanks also to many others who felt obliged to drop a thanks note. | |
924 | |
925 | |
7267 | 926 |
927 ;;; Code: | |
928 | |
7424 | 929 (require 'emerge) ;; Ediff uses some functions defined in emerge.el |
7267 | 930 |
931 | |
932 ;;; Macros | |
933 (defmacro ediff-if-lucid () | |
934 (` (string-match "Lucid" emacs-version))) | |
7424 | 935 |
7267 | 936 (defmacro ediff-odd-p (arg) |
937 (` (eq (logand (, arg) 1) 1))) | |
7424 | 938 |
7267 | 939 (defmacro ediff-buffer-live-p (buf) |
940 (` (and (, buf) (get-buffer (, buf)) (buffer-name (get-buffer (, buf)))))) | |
941 | |
7424 | 942 (defmacro ediff-get-buffer (arg) |
943 (` (cond ((eq (, arg) 'A) ediff-A-buffer) | |
944 ((eq (, arg) 'B) ediff-B-buffer) | |
945 ) | |
946 )) | |
947 | |
948 (defmacro ediff-char-to-buftype (arg) | |
949 (` (cond ((eq (, arg) ?a) 'A) | |
950 ((eq (, arg) ?b) 'B) | |
951 ) | |
952 )) | |
953 | |
954 (defmacro ediff-get-difference (n) | |
955 (` (aref ediff-difference-vector (, n)))) | |
956 | |
957 (defmacro ediff-get-diff-overlay-from-vector (vec buf-type) | |
958 (` (aref (, vec) | |
959 (cond ((eq (, buf-type) 'A) 0) | |
960 ((eq (, buf-type) 'B) 1) | |
961 ) | |
962 ))) | |
963 | |
964 (defmacro ediff-get-diff-overlay (n buf-type) | |
965 (` (ediff-get-diff-overlay-from-vector | |
966 (ediff-get-difference (, n)) | |
967 (, buf-type)))) | |
968 | |
969 (defmacro ediff-get-fine-diff-vector-from-vec (current-diff-vec) | |
970 (` (aref (, current-diff-vec) 2))) | |
971 | |
972 (defmacro ediff-set-fine-diff-vector (n fine-vec) | |
973 (` (aset (ediff-get-difference (, n)) 2 (, fine-vec)))) | |
974 | |
975 (defmacro ediff-get-fine-diff-vector (n) | |
976 (` (ediff-get-fine-diff-vector-from-vec (ediff-get-difference (, n))))) | |
977 | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
978 (defmacro ediff-defvar-local (var value doc) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
979 "Defines SYMBOL as an advertised local variable. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
980 Performs a defvar, then executes `make-variable-buffer-local' on |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
981 the variable. Also sets the `preserved' (Emacs) or `permanent-local' (Lucid) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
982 property, so that `kill-all-local-variables' (called by major-mode setting |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
983 commands) won't destroy Ediff control variables. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
984 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
985 This is a merge of `emerge-defvar-local' for Emacs and Lucid Emacs. It is |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
986 needed to make the same ediff.elc work under both Emacsen." |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
987 (` (progn |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
988 (defvar (, var) (, value) (, doc)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
989 (make-variable-buffer-local '(, var)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
990 (put '(, var) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
991 (if (ediff-if-lucid) 'permanent-local 'preserved) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
992 t)))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
993 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
994 (defmacro ediff-eval-in-buffer (buffer &rest forms) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
995 "Macro to switch to BUFFER, evaluate FORMS, returns to original buffer. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
996 Differs from `save-excursion' in that it doesn't save the point and mark. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
997 This is essentially `emerge-eval-in-buffer' with the test for live buffers." |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
998 (` (let ((StartBuffer (current-buffer))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
999 (if (ediff-buffer-live-p (, buffer)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1000 (unwind-protect |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1001 (progn |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1002 (set-buffer (, buffer)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1003 (,@ forms)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1004 (set-buffer StartBuffer)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1005 (beep 1) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1006 (message "You seem to have killed an essential Ediff buffer---quit!")) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1007 ))) |
7424 | 1008 |
1009 | |
1010 ;;; Functions | |
7267 | 1011 |
1012 (defun ediff-mode () | |
1013 "Ediff mode is used by the Ediff file-difference package. | |
1014 It is entered only through one of the following commands: | |
7419 | 1015 `ediff' |
1016 `ediff-files' | |
1017 `ediff-buffers' | |
1018 `epatch' | |
1019 `ediff-patch-file' | |
1020 `ediff-patch-buffer' | |
7424 | 1021 `epatch-buffer' |
7419 | 1022 `vc-ediff' |
1023 `rcs-ediff' | |
7267 | 1024 |
1025 Commands: | |
1026 \\{ediff-mode-map}" | |
1027 (interactive) | |
1028 (kill-all-local-variables) | |
1029 (setq major-mode 'ediff-mode) | |
1030 (setq mode-name "Ediff")) | |
1031 | |
1032 | |
1033 ;; Hook variables | |
1034 | |
1035 (defvar ediff-before-setup-windows-hooks nil | |
7424 | 1036 "*Hooks to run before Ediff sets its own window config. |
1037 This can be used to save the previous window config, which can be restored | |
1038 on ediff-quit or ediff-suspend.") | |
7267 | 1039 (defvar ediff-startup-hooks nil |
1040 "*Hooks to run in the control buffer after Ediff has been set up.") | |
1041 (defvar ediff-select-hooks nil | |
1042 "*Hooks to run after a difference has been selected.") | |
1043 (defvar ediff-unselect-hooks nil | |
1044 "*Hooks to run after a difference has been unselected.") | |
1045 (defvar ediff-prepare-buffer-hooks nil | |
1046 "*Hooks called after buffers A and B are set up.") | |
1047 (defvar ediff-load-hooks nil | |
7419 | 1048 "*Hook run after Ediff is loaded. Can be used to change defaults.") |
7267 | 1049 |
7424 | 1050 (defvar ediff-suspend-hooks (list 'ediff-default-suspend-hook) |
7419 | 1051 "*Hooks to run in the Ediff control buffer when Ediff is suspended.") |
7424 | 1052 (defvar ediff-quit-hooks (list 'ediff-default-quit-hook) |
7419 | 1053 "*Hooks to run in the Ediff control buffer after finishing Ediff.") |
7267 | 1054 |
1055 (make-variable-buffer-local 'local-write-file-hooks) | |
1056 (make-variable-buffer-local 'before-change-function) | |
1057 | |
1058 ;; Help messages | |
1059 | |
1060 (defconst ediff-help-message-long | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1061 "p,DEL - prev diff v/V - scroll up/dn ab - diff A to B * - refine diff |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1062 n,SPC - next diff </> - scroll lt/rt ba - diff B to A ! - recomp diffs |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1063 j - jump to diff s - toggle split ra - restore A i - status info |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1064 ga/gb - goto pt in A/B h - toggle hilit rb - restore B z - suspend Ediff |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1065 c - recenter @ - toggle refine q - quit Ediff |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1066 #f/#h - toggle focus/hide diff regions |
7424 | 1067 wa/wb - save buf A/B A/B - toggle read-only in buffers A/B ? - toggle help") |
7267 | 1068 |
1069 (defconst ediff-help-message-short | |
7424 | 1070 " ? - toggle help window") |
7267 | 1071 |
1072 (defvar ediff-help-message ediff-help-message-long | |
7419 | 1073 "*The actual help message.") |
7267 | 1074 |
7424 | 1075 ;; diff stuff. |
7267 | 1076 (defvar ediff-diff-program "diff" |
7419 | 1077 "*Name of the program that compares two files.") |
7267 | 1078 (defvar ediff-diff-options "" |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1079 "*Options to pass to `ediff-diff-program'. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1080 If diff\(1\) is used as `ediff-diff-program', then the most useful options are |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1081 `-w', to ignore space, and `-i', to ignore case of letters.") |
7267 | 1082 |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1083 ;; Fine differences |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1084 (defvar ediff-forward-word-function 'ediff-forward-word |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1085 "*Function to call to move to the next word. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1086 Used for splitting difference regions into individual words.") |
7424 | 1087 |
1088 (defvar ediff-fine-diff-program "diff" | |
1089 "*Name of the program that compares the current diff regions for fine differences. | |
1090 | |
1091 This program should produce output in the format of diff. One could | |
1092 possibly use `spiff' here if appropriate options are set.") | |
1093 | |
1094 (defvar ediff-fine-diff-options "" | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1095 "*Options to pass to `ediff-fine-diff-program'. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1096 If diff\(1\) is used as `ediff-diff-program', then the most useful options are |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1097 `-w', to ignore space, and `-i', to ignore case of letters.") |
7424 | 1098 |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1099 (defvar ediff-whitespace " \n\t\C-j" |
7424 | 1100 "*White space. Used to split strings into words.") |
1101 | |
1102 (defvar ediff-word-1 "a-zA-Z---_`'.?!:" | |
1103 "*Characters constituting type 1 words. | |
1104 | |
1105 Ediff is using a very simple schema for splitting text into words, which is | |
1106 used to determine fine differences between regions. There are two types of | |
1107 words. One consists entirely out of characters in `ediff-word-1' and | |
1108 another out of characters matching `ediff-word-1'.") | |
1109 | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1110 (defvar ediff-word-2 "^a-zA-Z---_`'.?!: \t\n\C-j" |
7424 | 1111 "*Characters matching this regexp constitute words of type 2. |
1112 See `ediff-word-1' for more details.") | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1113 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1114 ;; Selective browsing |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1115 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1116 (defconst ediff-skip-diff-region-function 'ediff-show-all-diffs |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1117 "Function that determines the next/previous diff region to show.") |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1118 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1119 (defconst ediff-regexp-focus-A "" |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1120 "Regexp that determines buf A regions to focus on when skipping to diff.") |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1121 (defconst ediff-regexp-focus-B "" |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1122 "Regexp that determines buf B regions to focus on when skipping to diff.") |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1123 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1124 (defconst ediff-regexp-hide-A "" |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1125 "Regexp that determines buf A regions to ignore when skipping to diff.") |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1126 (defconst ediff-regexp-hide-B "" |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1127 "Regexp that determines buf B regions to ignore when skipping to diff.") |
7424 | 1128 |
7267 | 1129 |
1130 ;; Support for patches | |
1131 | |
1132 (defvar ediff-patch-program "patch" | |
7419 | 1133 "*Name of the program that applies patches.") |
7267 | 1134 (defvar ediff-patch-options "" |
7419 | 1135 "*Options to pass to ediff-patch-program.") |
7267 | 1136 |
7424 | 1137 (defvar ediff-shell (cond ((eq system-type 'emx) "cmd") ;; OS/2 |
1138 (t "sh")) ;; unix | |
1139 "*The shell used to run diff and patch. If user's .profile or | |
1140 .cshrc files are set up correctly, any shell will do. However, some people | |
1141 set $prompt or other things incorrectly, which leads to undesirable output | |
1142 messages. These may cause Ediff to fail. In such a case, set ediff-shell | |
1143 to a shell that you are not using or, better, fix your shell's startup file.") | |
1144 | |
7267 | 1145 (defvar ediff-diff-ok-lines-regexp |
1146 "^\\([0-9,]+[acd][0-9,]+$\\|[<>] \\|---\\|Warning:\\)" | |
7419 | 1147 "*Regexp that matches normal output lines from `ediff-diff-program'. |
7267 | 1148 This is mostly lifted from Emerge, except that Ediff also considers the |
1149 'Missing newline' message to be 'normal output.' | |
1150 Lines that do not match are assumed to be error messages.") | |
1151 | |
7424 | 1152 (defvar ediff-fine-diff-ok-lines-regexp |
1153 "^\\([0-9,]+[acd][0-9,]+$\\|[<>] \\|---\\|Warning:\\)" | |
1154 "*Regexp that matches normal output lines from `ediff-fine-diff-program'. | |
1155 This is mostly lifted from Emerge, except that Ediff also considers the | |
1156 'Missing newline' message to be 'normal output.' | |
1157 Lines that do not match are assumed to be error messages.") | |
1158 | |
7267 | 1159 (defvar ediff-match-diff-line (let ((x "\\([0-9]+\\)\\(\\|,\\([0-9]+\\)\\)")) |
1160 (concat "^" x "\\([acd]\\)" x "$")) | |
1161 "*Pattern to match lines produced by diff that describe differences.") | |
1162 | |
1163 (defvar ediff-patch-buf nil | |
1164 "The buffer of the patch file.") | |
1165 (defvar ediff-patch-diagnostics nil | |
7391 | 1166 "The buffer where patch would display its diagnostics.") |
7267 | 1167 |
1168 | |
1169 ;; Copying diffs betw buffers. | |
1170 | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1171 (ediff-defvar-local ediff-killed-diffs-alist nil |
7424 | 1172 "A list of killed diffs. |
7419 | 1173 A diff is saved here if it is replaced by a diff |
7267 | 1174 from another buffer. This alist has the form: |
7639 | 1175 \((num (A . diff) (B . diff)) ...), |
7419 | 1176 where A or B parts may be missing.") |
7267 | 1177 |
1178 | |
1179 ;; Highlighting | |
1180 (defvar ediff-before-flag-bol | |
1181 ;"vvvvvvvvvvvvvvvv---- ediff ----vvvvvvvvvvvvvvv\n" | |
1182 ">>--->>>\n" | |
7424 | 1183 "*Flag placed above the highlighted block of differences. |
1184 Must end with newline. Must be set before Ediff is loaded.") | |
7267 | 1185 (defvar ediff-after-flag-bol |
1186 ;"^^^^^^^^^^^^^^^^---- ediff ----^^^^^^^^^^^^^^^\n" | |
1187 "<<<---<<\n" | |
7419 | 1188 "*Flag placed below the highlighted block of differences. |
7424 | 1189 Must end with newline. Must be set before Ediff is loaded.") |
7267 | 1190 |
1191 (defvar ediff-before-flag-mol ">>--->>>" | |
7419 | 1192 "*Like ediff-before-flag, used when a difference starts in mid-line.") |
7267 | 1193 (defvar ediff-after-flag-mol "<<<---<<" |
7419 | 1194 "*Like ediff-after-flag, used when a difference starts in mid-line.") |
7267 | 1195 |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1196 (ediff-defvar-local ediff-before-flag-A nil |
7267 | 1197 "This is the actual ASCII before-flag in effect in buffer A. |
1198 It is either `ediff-before-flag-mol' or `ediff-before-flag-bol' depending | |
1199 on whether the selected difference region starts in the middle of a line | |
1200 or at the beginning of a line.") | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1201 (ediff-defvar-local ediff-after-flag-A nil |
7267 | 1202 "This is the actual ASCII after-flag in effect in buffer A. |
1203 It is either `ediff-before-flag-mol' or `ediff-before-flag-bol' depending | |
1204 on whether the selected difference region starts in the middle of a line | |
1205 or at the beginning of a line.") | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1206 (ediff-defvar-local ediff-before-flag-B nil |
7267 | 1207 "This is the actual ASCII before-flag in effect in buffer B. |
1208 It is either `ediff-before-flag-mol' or `ediff-before-flag-bol' depending | |
1209 on whether the selected difference region starts in the middle of a line | |
1210 or at the beginning of a line.") | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1211 (ediff-defvar-local ediff-after-flag-B nil |
7267 | 1212 "This is the actual ASCII after-flag in effect in buffer B. |
1213 It is either `ediff-before-flag-mol' or `ediff-before-flag-bol' depending | |
1214 on whether the selected difference region starts in the middle of a line | |
1215 or at the beginning of a line.") | |
1216 | |
1217 | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1218 (ediff-defvar-local ediff-want-faces t |
7419 | 1219 "If t, differences are highlighted using faces on a window system. |
1220 If nil, they are highlighted using ASCII flags, ediff-before-flag | |
7267 | 1221 and ediff-after-flag. On a non-window system, differences are always |
1222 highlighted using ASCII flags. | |
1223 | |
7424 | 1224 This variable can be set either in .emacs or toggled interactively, using |
1225 ediff-toggle-hilit.") | |
1226 | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1227 (ediff-defvar-local ediff-want-default-menus t |
7424 | 1228 "If t, Ediff will set up menus in the menu bar. |
1229 This variable must be set before Ediff is loaded. If you don't like the | |
1230 look of the default menus, set this variable to nil and make your own | |
1231 menus.") | |
1232 | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1233 (ediff-defvar-local ediff-auto-refine 'on |
7424 | 1234 "If `'on', Ediff auto-highlights fine diffs for the current diff region. |
1235 If `off', auto-highlighting is not used. If `'nix', no fine diffs are shown | |
1236 at all, unless the user force-refines the region by hitting `*'. | |
1237 | |
1238 This variable can be set either in .emacs or toggled interactively, using | |
1239 ediff-toggle-hilit.") | |
1240 | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1241 (ediff-defvar-local ediff-auto-refine-limit 700 |
7424 | 1242 "Auto-refine only those regions that are smaller than this number of bytes.") |
1243 | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1244 (ediff-defvar-local ediff-highlight-all-diffs t |
7424 | 1245 "If nil, only the selected differences are highlighted. |
1246 This variable can be set either in .emacs or toggled interactively, using | |
1247 ediff-toggle-hilit.") | |
7267 | 1248 |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1249 (ediff-defvar-local ediff-highlighting-style nil |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1250 "A var local to each control panel buffer. |
7419 | 1251 Indicates highlighting style in effect for this buffer: `face', `ascii', |
1252 nil -- temporarily unhighlighted, `off' -- turned off \(on a dumb | |
1253 terminal only\).") | |
7267 | 1254 |
1255 | |
1256 | |
1257 ;; Variables that control each Ediff session. They are local to the | |
1258 ;; control buffer. | |
1259 | |
1260 ;; Mode variables | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1261 (ediff-defvar-local ediff-A-buffer nil |
7267 | 1262 "The buffer in which the A variant is stored.") |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1263 (ediff-defvar-local ediff-B-buffer nil |
7267 | 1264 "The buffer in which the B variant is stored.") |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1265 (ediff-defvar-local ediff-control-buffer nil |
7267 | 1266 "The control buffer of ediff. ") |
1267 | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1268 ;(ediff-defvar-local ediff-control-buffer-suffix nil |
7424 | 1269 ; "The suffix of the control buffer name. ") |
7267 | 1270 |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1271 (ediff-defvar-local ediff-control-window nil |
7267 | 1272 "The control window.") |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1273 (ediff-defvar-local ediff-window-config-saved "" |
7424 | 1274 "Ediff's window configuration. |
1275 Used to minimize the need to rearrange windows.") | |
7267 | 1276 |
1277 | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1278 (ediff-defvar-local ediff-A-buffer-values nil |
7267 | 1279 "Keeps working values of ediff-saved-variables for ediff-A-buffer.") |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1280 (ediff-defvar-local ediff-B-buffer-values nil |
7267 | 1281 "Keeps working values of ediff-saved-variables for ediff-B-buffer.") |
1282 | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1283 (ediff-defvar-local ediff-A-buffer-values-setup nil |
7267 | 1284 "Remembers ediff-saved-variables for ediff-A-buffer as they were at setup.") |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1285 (ediff-defvar-local ediff-B-buffer-values-setup nil |
7267 | 1286 "Remembers ediff-saved-variables for ediff-B-buffer as they were at setup.") |
1287 | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1288 (ediff-defvar-local ediff-difference-vector nil |
7424 | 1289 "Vector of differences between the variants. |
7419 | 1290 Each difference is represented by a vector of two overlays. The first |
7424 | 1291 overlays the difference section in the A buffer and the second overlays the |
1292 diff in the B buffer. If a difference section is empty, the corresponding | |
1293 overlay's endpoints coincide. ") | |
7267 | 1294 |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1295 (ediff-defvar-local ediff-current-difference -1 |
7267 | 1296 "The difference that is currently selected.") |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1297 (ediff-defvar-local ediff-number-of-differences nil |
7267 | 1298 "Number of differences found.") |
1299 | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1300 (ediff-defvar-local ediff-diff-buffer nil |
7424 | 1301 "Buffer containing the output of diff, which is used by Ediff to step |
1302 through files.") | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1303 (ediff-defvar-local ediff-tmp-buffer nil |
7424 | 1304 "Temporary buffer used for computing fine differences.") |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1305 (ediff-defvar-local ediff-error-buffer nil |
7424 | 1306 "Buffer containing the output of diff when diff returns errors.") |
1307 | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1308 (ediff-defvar-local ediff-this-buffer-control-sessions nil |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1309 "List of ediff control panels associated with each buffer A/B.") |
7267 | 1310 |
1311 (defvar ediff-disturbed-overlays nil | |
7419 | 1312 "List of difference overlays disturbed by working with the current diff.") |
7267 | 1313 |
8348
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1314 (defvar ediff-shaded-overlay-priority 100 |
7267 | 1315 "Priority of non-selected overlays.") |
1316 | |
1317 | |
1318 (if (ediff-if-lucid) | |
1319 (progn | |
1320 (fset 'ediff-overlayp (symbol-function 'extentp)) | |
1321 (fset 'ediff-make-overlay (symbol-function 'make-extent)) | |
1322 (fset 'ediff-delete-overlay (symbol-function 'delete-extent)) | |
1323 (fset 'ediff-overlay-put (symbol-function 'set-extent-property)) | |
1324 (fset 'ediff-move-overlay (symbol-function 'set-extent-endpoints)) | |
1325 (fset 'ediff-overlay-start (symbol-function 'extent-start-position)) | |
1326 (fset 'ediff-overlay-end (symbol-function 'extent-end-position)) | |
1327 (fset 'ediff-overlay-get (symbol-function 'extent-property))) | |
1328 (fset 'ediff-overlayp (symbol-function 'overlayp)) | |
1329 (fset 'ediff-make-overlay (symbol-function 'make-overlay)) | |
1330 (fset 'ediff-delete-overlay (symbol-function 'delete-overlay)) | |
1331 (fset 'ediff-overlay-put (symbol-function 'overlay-put)) | |
1332 (fset 'ediff-move-overlay (symbol-function 'move-overlay)) | |
1333 (fset 'ediff-overlay-start (symbol-function 'overlay-start)) | |
1334 (fset 'ediff-overlay-end (symbol-function 'overlay-end)) | |
1335 (fset 'ediff-overlay-get (symbol-function 'overlay-get))) | |
1336 | |
1337 (if window-system | |
1338 (if (ediff-if-lucid) | |
1339 (progn | |
1340 (fset 'ediff-select-frame (symbol-function 'select-screen)) | |
1341 (fset 'ediff-window-frame (symbol-function 'window-screen)) | |
1342 (fset 'ediff-display-color-p (symbol-function 'x-color-display-p)) | |
7424 | 1343 (fset 'ediff-valid-color-p (symbol-function 'x-valid-color-name-p)) |
7267 | 1344 (fset 'ediff-get-face (symbol-function 'get-face))) |
1345 (fset 'ediff-window-frame (symbol-function 'window-frame)) | |
1346 (fset 'ediff-select-frame (symbol-function 'select-frame)) | |
1347 (fset 'ediff-display-color-p (symbol-function 'x-display-color-p)) | |
7424 | 1348 |
1349 ;; This is a temporary fix for OS/2 users | |
1350 ;; pm-win.el in PM-Emacs should be fixed. | |
1351 (if (eq window-system 'pm) | |
1352 (fset 'ediff-valid-color-p | |
1353 (function (lambda (color) (assoc color pm-color-alist)))) | |
1354 (fset 'ediff-valid-color-p (symbol-function 'x-color-defined-p)) | |
1355 ) | |
1356 | |
7267 | 1357 (fset 'ediff-get-face (symbol-function 'internal-get-face))) |
1358 ;; not a window system | |
1359 (fset 'ediff-window-frame (function (lambda (wind) (if wind 1 nil)) )) | |
1360 (fset 'ediff-select-frame (symbol-function 'identity)) | |
1361 (fset 'ediff-make-current-diff-overlay (function (lambda (type) nil))) | |
1362 (fset 'ediff-unhighlight-diffs-totally (function (lambda () nil)))) | |
1363 | |
1364 | |
1365 (if (not window-system) | |
1366 () | |
7424 | 1367 (defun ediff-set-face (ground face color) |
8348
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1368 "Sets face foreground/background." |
7424 | 1369 (if (ediff-valid-color-p color) |
1370 (if (eq ground 'foreground) | |
1371 (set-face-foreground face color) | |
1372 (set-face-background face color)) | |
1373 (cond ((memq face | |
1374 '(ediff-current-diff-face-A ediff-current-diff-face-B)) | |
1375 (copy-face 'highlight face)) | |
1376 ((memq face | |
1377 '(ediff-fine-diff-face-A ediff-fine-diff-face-B)) | |
1378 (copy-face 'secondary-selection face) | |
1379 (set-face-underline-p face t)) | |
1380 ((memq face | |
1381 '(ediff-odd-diff-face-A ediff-odd-diff-face-B | |
1382 ediff-even-diff-face-A ediff-even-diff-face-B)) | |
1383 (copy-face 'secondary-selection face))))) | |
1384 | |
7267 | 1385 (defvar ediff-current-diff-face-A |
1386 (progn | |
1387 (make-face 'ediff-current-diff-face-A) | |
7424 | 1388 (or (face-differs-from-default-p 'ediff-current-diff-face-A) |
1389 (cond ((ediff-display-color-p) | |
1390 (ediff-set-face | |
1391 'foreground 'ediff-current-diff-face-A "firebrick") | |
1392 (ediff-set-face | |
1393 'background 'ediff-current-diff-face-A "pale green")) | |
1394 (t | |
1395 (if (ediff-if-lucid) | |
1396 (copy-face 'modeline 'ediff-current-diff-face-A) | |
1397 (copy-face 'highlight 'ediff-current-diff-face-A)) | |
1398 ))) | |
8348
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1399 'ediff-current-diff-face-A) |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1400 ;;(ediff-get-face 'ediff-current-diff-face-A)) |
7424 | 1401 "Face for highlighting the selected difference in buffer A.") |
7267 | 1402 |
1403 (defvar ediff-current-diff-face-B | |
1404 (progn | |
1405 (make-face 'ediff-current-diff-face-B) | |
7424 | 1406 (or (face-differs-from-default-p 'ediff-current-diff-face-B) |
1407 (cond ((ediff-display-color-p) | |
1408 (ediff-set-face | |
1409 'foreground 'ediff-current-diff-face-B "DarkOrchid") | |
1410 (ediff-set-face | |
1411 'background 'ediff-current-diff-face-B "Yellow")) | |
1412 (t | |
1413 (if (ediff-if-lucid) | |
1414 (copy-face 'modeline 'ediff-current-diff-face-B) | |
1415 (copy-face 'highlight 'ediff-current-diff-face-B)) | |
1416 ))) | |
8348
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1417 'ediff-current-diff-face-B) |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1418 ;;(ediff-get-face 'ediff-current-diff-face-B)) |
7424 | 1419 "Face for highlighting the selected difference in buffer B.") |
1420 | |
1421 (defvar ediff-fine-diff-face-A | |
1422 (progn | |
1423 (make-face 'ediff-fine-diff-face-A) | |
1424 (or (face-differs-from-default-p 'ediff-fine-diff-face-A) | |
1425 (cond ((ediff-display-color-p) | |
1426 (ediff-set-face 'foreground 'ediff-fine-diff-face-A | |
1427 "Navy") | |
1428 (ediff-set-face 'background 'ediff-fine-diff-face-A | |
1429 "sky blue")) | |
1430 (t (set-face-underline-p 'ediff-fine-diff-face-A t)))) | |
8348
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1431 'ediff-fine-diff-face-A) |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1432 ;;(ediff-get-face 'ediff-fine-diff-face-A)) |
7424 | 1433 "Face for highlighting the refinement of the selected diff in buffer A.") |
1434 | |
1435 (defvar ediff-fine-diff-face-B | |
1436 (progn | |
1437 (make-face 'ediff-fine-diff-face-B) | |
1438 (or (face-differs-from-default-p 'ediff-fine-diff-face-B) | |
1439 (cond ((ediff-display-color-p) | |
1440 (ediff-set-face 'foreground 'ediff-fine-diff-face-B "Black") | |
1441 (ediff-set-face 'background 'ediff-fine-diff-face-B "cyan")) | |
1442 (t (set-face-underline-p 'ediff-fine-diff-face-B t)))) | |
8348
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1443 'ediff-fine-diff-face-B) |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1444 ;;(ediff-get-face 'ediff-fine-diff-face-B)) |
7424 | 1445 "Face for highlighting the refinement of the selected diff in buffer B.") |
1446 | |
7267 | 1447 |
1448 (defvar ediff-even-diff-face-A | |
1449 (progn | |
1450 (make-face 'ediff-even-diff-face-A) | |
7424 | 1451 (or (face-differs-from-default-p 'ediff-even-diff-face-A) |
1452 (cond ((ediff-display-color-p) | |
1453 (ediff-set-face | |
1454 'foreground 'ediff-even-diff-face-A "black") | |
1455 (ediff-set-face | |
1456 'background 'ediff-even-diff-face-A "light grey")) | |
1457 (t | |
8348
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1458 (copy-face 'italic 'ediff-even-diff-face-A)))) |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1459 'ediff-even-diff-face-A) |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1460 ;;(ediff-get-face 'ediff-even-diff-face-A)) |
7267 | 1461 "Face used to highlight even-numbered differences in buffer A.") |
1462 | |
1463 (defvar ediff-even-diff-face-B | |
1464 (progn | |
1465 (make-face 'ediff-even-diff-face-B) | |
7424 | 1466 (or (face-differs-from-default-p 'ediff-even-diff-face-B) |
1467 (cond ((ediff-display-color-p) | |
1468 (ediff-set-face | |
1469 'foreground 'ediff-even-diff-face-B "White") | |
1470 (ediff-set-face | |
1471 'background 'ediff-even-diff-face-B "Gray")) | |
1472 (t | |
8348
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1473 (copy-face 'italic 'ediff-even-diff-face-B)))) |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1474 'ediff-even-diff-face-B) |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1475 ;;(ediff-get-face 'ediff-even-diff-face-B)) |
7267 | 1476 "Face used to highlight even-numbered differences in buffer B.") |
7424 | 1477 |
7267 | 1478 (defvar ediff-odd-diff-face-A |
1479 (progn | |
1480 (make-face 'ediff-odd-diff-face-A) | |
7424 | 1481 (or (face-differs-from-default-p 'ediff-odd-diff-face-A) |
1482 (cond ((ediff-display-color-p) | |
1483 (ediff-set-face | |
1484 'foreground 'ediff-odd-diff-face-A "White") | |
1485 (ediff-set-face | |
1486 'background 'ediff-odd-diff-face-A "Gray")) | |
1487 (t | |
8348
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1488 (copy-face 'italic 'ediff-odd-diff-face-A)))) |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1489 'ediff-odd-diff-face-A) |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1490 ;;(ediff-get-face 'ediff-odd-diff-face-A)) |
7267 | 1491 "Face used to highlight odd-numbered differences in buffer A.") |
1492 | |
1493 (defvar ediff-odd-diff-face-B | |
1494 (progn | |
1495 (make-face 'ediff-odd-diff-face-B) | |
7424 | 1496 (or (face-differs-from-default-p 'ediff-odd-diff-face-B) |
1497 (cond ((ediff-display-color-p) | |
1498 (ediff-set-face | |
1499 'foreground 'ediff-odd-diff-face-B "Black") | |
1500 (ediff-set-face | |
1501 'background 'ediff-odd-diff-face-B "light grey")) | |
1502 (t | |
8348
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1503 (copy-face 'italic 'ediff-odd-diff-face-B)))) |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1504 'ediff-odd-diff-face-B) |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1505 ;;(ediff-get-face 'ediff-odd-diff-face-B)) |
7267 | 1506 "Face used to highlight odd-numbered differences in buffer B.") |
7424 | 1507 |
7267 | 1508 ;; Create *-var faces. These are the actual faces used to highlight |
1509 ;; odd-numbered difference regions. | |
1510 ;; They are used as follows: when highlighting is turned on, | |
1511 ;; ediff-odd/even-diff-face-A/B are copied | |
1512 ;; into ediff-odd/even-diff-face-A/B-var, and all odd/even overlays become | |
1513 ;; highlighted. When highlighting is turned off, then the face 'default is | |
1514 ;; copied into ediff-odd/even-diff-face-A/B-var, thereby unhighlighting all | |
1515 ;; difference regions. | |
1516 (make-face 'ediff-even-diff-face-A-var) | |
1517 (make-face 'ediff-even-diff-face-B-var) | |
1518 (make-face 'ediff-odd-diff-face-A-var) | |
1519 (make-face 'ediff-odd-diff-face-B-var) | |
1520 | |
1521 ;; initialize *-var faces | |
1522 (defun ediff-init-var-faces () | |
7424 | 1523 (copy-face (if (and ediff-want-faces ediff-highlight-all-diffs) |
7267 | 1524 ediff-even-diff-face-A 'default) |
1525 'ediff-even-diff-face-A-var) | |
7424 | 1526 (copy-face (if (and ediff-want-faces ediff-highlight-all-diffs) |
7267 | 1527 ediff-even-diff-face-B 'default) |
1528 'ediff-even-diff-face-B-var) | |
7424 | 1529 (copy-face (if (and ediff-want-faces ediff-highlight-all-diffs) |
7267 | 1530 ediff-odd-diff-face-A 'default) |
1531 'ediff-odd-diff-face-A-var) | |
7424 | 1532 (copy-face (if (and ediff-want-faces ediff-highlight-all-diffs) |
7267 | 1533 ediff-odd-diff-face-B 'default) |
1534 'ediff-odd-diff-face-B-var)) | |
1535 | |
1536 | |
1537 ;;; Overlays | |
1538 | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1539 (ediff-defvar-local ediff-current-diff-overlay-A nil |
7267 | 1540 "Overlay in 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>
parents:
7709
diff
changeset
|
1541 (ediff-defvar-local ediff-current-diff-overlay-B nil |
7267 | 1542 "Overlay in buffer B.") |
1543 | |
1544 (defun ediff-make-current-diff-overlay (type) | |
1545 (let ((overlay (if (eq type 'A) | |
1546 'ediff-current-diff-overlay-A | |
1547 'ediff-current-diff-overlay-B)) | |
7424 | 1548 (buffer (ediff-get-buffer type)) |
7267 | 1549 (face (if (eq type 'A) |
1550 (face-name ediff-current-diff-face-A) | |
1551 (face-name ediff-current-diff-face-B)))) | |
1552 (set overlay (ediff-make-overlay (point-max) (point-max) buffer)) | |
1553 (ediff-overlay-put (eval overlay) 'face face) | |
1554 (ediff-overlay-put (eval overlay) 'ediff ediff-control-buffer) | |
1555 )) | |
1556 | |
8348
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1557 ;; Compute priority of ediff overlay. |
7267 | 1558 (defun ediff-highest-priority (start end buffer) |
1559 (let ((pos (max 1 (1- start))) | |
1560 ovr-list) | |
1561 (if (ediff-if-lucid) | |
8348
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1562 (1+ ediff-shaded-overlay-priority) |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1563 (ediff-eval-in-buffer |
7267 | 1564 buffer |
1565 (while (< pos (min (point-max) (1+ end))) | |
1566 (setq ovr-list (append (overlays-at pos) ovr-list)) | |
1567 (setq pos (next-overlay-change pos))) | |
1568 (1+ (eval | |
1569 (cons '+ | |
1570 (mapcar (function | |
1571 (lambda (ovr) | |
1572 (if ovr | |
1573 (or (ediff-overlay-get ovr 'priority) 0) | |
1574 0))) | |
1575 ovr-list) | |
1576 ))) | |
1577 )))) | |
1578 | |
1579 ) ; end of window-system-only code. | |
1580 | |
1581 | |
1582 | |
1583 ;;; Misc | |
1584 | |
1585 (defvar ediff-split-window-function 'split-window-vertically | |
7419 | 1586 "*The function to split the main window between buffer-A and buffer-B. |
1587 You can set it to be split horizontally instead of the | |
7424 | 1588 default vertical split by setting this variable to |
7267 | 1589 'split-window-horizontally. You can also have your own function for fancy |
1590 splits. This variable has no effect when buffer-A and buffer-B are shown in | |
1591 different frames. In this case, Ediff will use those frames to display | |
1592 these buffers.") | |
1593 | |
1594 (defconst ediff-saved-variables | |
1595 '(buffer-read-only | |
1596 buffer-auto-save-file-name) | |
7419 | 1597 "Buffer-local variables saved and restored during an Ediff session.") |
7267 | 1598 |
1599 (defconst ediff-working-values '(nil nil) | |
7419 | 1600 "Values to be assigned to `ediff-saved-variables' during diff.") |
7267 | 1601 |
1602 (defvar ediff-use-last-dir nil | |
7419 | 1603 "*If t, Ediff uses previous directory as default when reading file name.") |
7267 | 1604 |
7457
315fb6386b54
(ediff-no-help-in-control-buffer): Renamed from
Karl Heuer <kwzh@gnu.org>
parents:
7424
diff
changeset
|
1605 (defvar ediff-no-help-in-control-buffer nil |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1606 "*Non-nil means C-h should not invoke Emacs help in control buffer. |
7419 | 1607 Instead, C-h jumps to previous difference.") |
7267 | 1608 |
1609 (defvar ediff-temp-file-prefix | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1610 (let ((env (or (getenv "TMPDIR") |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1611 (getenv "TMP") |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1612 (getenv "TEMP"))) |
7267 | 1613 d) |
1614 (setq d (if (and env (> (length env) 0)) | |
1615 env | |
1616 "/tmp")) | |
1617 (if (= (aref d (1- (length d))) ?/) | |
1618 (setq d (substring d 0 -1))) | |
1619 (concat d "/ediff")) | |
1620 "*Prefix to put on Ediff temporary file names. | |
1621 Do not start with `~/' or `~user-name/'.") | |
1622 | |
1623 (defvar ediff-temp-file-mode 384 ; u=rw only | |
1624 "*Mode for Ediff temporary files.") | |
1625 | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1626 (ediff-defvar-local ediff-temp-file-A nil |
7424 | 1627 "Temporary file used for refining difference regions in 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>
parents:
7709
diff
changeset
|
1628 (ediff-defvar-local ediff-temp-file-B nil |
7424 | 1629 "Temporary file used for refining difference regions in buffer B.") |
1630 | |
7267 | 1631 (defvar ediff-last-dir-A nil |
1632 "Last directory used by an Ediff command for file-A.") | |
1633 (defvar ediff-last-dir-B nil | |
1634 "Last directory used by an Ediff command for file-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>
parents:
7709
diff
changeset
|
1635 (defvar ediff-last-dir-patch nil |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1636 "Last directory used by an Ediff command for file to patch.") |
7267 | 1637 |
1638 ;; Build keymaps | |
1639 | |
1640 (defvar ediff-mode-map nil | |
1641 "Local keymap used in Ediff mode.") | |
7424 | 1642 |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1643 (defun ediff-frame-has-menubar () |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1644 (if (ediff-if-lucid) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1645 current-menubar |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1646 (< 0 (cdr (assq 'menu-bar-lines (frame-parameters (selected-frame))))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1647 )) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1648 |
7495
266bf374a7bf
Move menu bar defines to top level
Richard M. Stallman <rms@gnu.org>
parents:
7457
diff
changeset
|
1649 ;;; This is split in three parts to avoid |
266bf374a7bf
Move menu bar defines to top level
Richard M. Stallman <rms@gnu.org>
parents:
7457
diff
changeset
|
1650 ;;; making a line in loaddefs.el that is too long for patch. |
266bf374a7bf
Move menu bar defines to top level
Richard M. Stallman <rms@gnu.org>
parents:
7457
diff
changeset
|
1651 ;;; Note that autoload.el currently looks for cookies |
266bf374a7bf
Move menu bar defines to top level
Richard M. Stallman <rms@gnu.org>
parents:
7457
diff
changeset
|
1652 ;;; only at top level in the file. |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1653 ;;; So I moved these to top level. But the conditionals on |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1654 ;;; purify-flag make these no-ops when you load ediff. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1655 ;;; They only do something in loaddefs.el. |
7495
266bf374a7bf
Move menu bar defines to top level
Richard M. Stallman <rms@gnu.org>
parents:
7457
diff
changeset
|
1656 ;;;###autoload |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1657 (if purify-flag |
8348
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1658 (progn |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1659 (defvar menu-bar-epatch-menu (make-sparse-keymap "Epatch")) |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1660 (fset 'menu-bar-epatch-menu (symbol-value 'menu-bar-epatch-menu)) |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1661 (defvar menu-bar-ediff-menu (make-sparse-keymap "Ediff")) |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1662 (fset 'menu-bar-ediff-menu (symbol-value 'menu-bar-ediff-menu)))) |
7495
266bf374a7bf
Move menu bar defines to top level
Richard M. Stallman <rms@gnu.org>
parents:
7457
diff
changeset
|
1663 |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1664 |
7495
266bf374a7bf
Move menu bar defines to top level
Richard M. Stallman <rms@gnu.org>
parents:
7457
diff
changeset
|
1665 ;;;###autoload |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1666 (if purify-flag |
8348
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1667 (progn |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1668 (define-key menu-bar-ediff-menu [rcs-ediff] |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1669 '("Compare with a version via RCS ..." . rcs-ediff)) |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1670 (define-key menu-bar-ediff-menu [vc-ediff] |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1671 '("Compare with a version via VC ..." . vc-ediff)) |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1672 (define-key menu-bar-ediff-menu [ediff-buffers] |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1673 '("Compare buffers ..." . ediff-buffers)) |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1674 (define-key menu-bar-ediff-menu [ediff-files] |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1675 '("Compare files ..." . ediff-files)))) |
7495
266bf374a7bf
Move menu bar defines to top level
Richard M. Stallman <rms@gnu.org>
parents:
7457
diff
changeset
|
1676 |
266bf374a7bf
Move menu bar defines to top level
Richard M. Stallman <rms@gnu.org>
parents:
7457
diff
changeset
|
1677 ;;;###autoload |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1678 (if purify-flag |
8348
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1679 (progn |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1680 (define-key menu-bar-epatch-menu [ediff-patch-buffer] |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1681 '("To a Buffer ..." . ediff-patch-buffer)) |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1682 (define-key menu-bar-epatch-menu [ediff-patch-file] |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1683 '("To a File ..." . ediff-patch-file)))) |
7495
266bf374a7bf
Move menu bar defines to top level
Richard M. Stallman <rms@gnu.org>
parents:
7457
diff
changeset
|
1684 |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1685 (if (and window-system ediff-want-default-menus (ediff-frame-has-menubar) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1686 (ediff-if-lucid)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1687 (progn ;; Lucid menu bars |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1688 (defvar ediff-menu |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1689 '("" |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1690 ["Compare files ..." ediff-files t] |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1691 ["Compare buffers ..." ediff-buffers t] |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1692 ["Compare with a version via VC ..." vc-ediff t] |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1693 ["Compare with a version via RCS ..." rcs-ediff t])) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1694 (defvar epatch-menu |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1695 '("" |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1696 ["To a file ..." ediff-patch-file t] |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1697 ["To a buffer ..." ediff-patch-buffer t])) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1698 (add-menu '("File") "Compare files" |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1699 ediff-menu |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1700 "New Screen") |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1701 (add-menu '("File") "Apply Patch" |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1702 epatch-menu |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1703 "New Screen") |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1704 ;; Displays as a solid horizontal line |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1705 (add-menu-item '("File") "---" nil nil "New Screen"))) |
7267 | 1706 |
1707 | |
8348
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1708 |
7267 | 1709 (defun ediff-setup-keymap () |
1710 "Set up the keymap used in the control buffer of Ediff." | |
1711 (setq ediff-mode-map (make-sparse-keymap)) | |
1712 (suppress-keymap ediff-mode-map) | |
1713 | |
1714 (define-key ediff-mode-map "p" 'ediff-previous-difference) | |
1715 (define-key ediff-mode-map "\C-?" 'ediff-previous-difference) | |
7424 | 1716 (define-key ediff-mode-map "\C-h" (if ediff-no-help-in-control-buffer |
7267 | 1717 'ediff-previous-difference nil)) |
1718 (define-key ediff-mode-map "n" 'ediff-next-difference) | |
1719 (define-key ediff-mode-map " " 'ediff-next-difference) | |
1720 (define-key ediff-mode-map "j" 'ediff-jump-to-difference) | |
1721 (define-key ediff-mode-map "g" nil) | |
1722 (define-key ediff-mode-map "ga" 'ediff-jump-to-difference-at-point) | |
1723 (define-key ediff-mode-map "gb" 'ediff-jump-to-difference-at-point) | |
1724 (define-key ediff-mode-map "q" 'ediff-quit) | |
1725 (define-key ediff-mode-map "z" 'ediff-suspend) | |
1726 (define-key ediff-mode-map "c" 'ediff-recenter) | |
1727 (define-key ediff-mode-map "s" 'ediff-toggle-split) | |
1728 (define-key ediff-mode-map "h" 'ediff-toggle-hilit) | |
7424 | 1729 (define-key ediff-mode-map "@" 'ediff-toggle-autorefine) |
7267 | 1730 (define-key ediff-mode-map "v" 'ediff-scroll-up) |
1731 (define-key ediff-mode-map "\C-v" 'ediff-scroll-up) | |
1732 (define-key ediff-mode-map "^" 'ediff-scroll-down) | |
1733 (define-key ediff-mode-map "\M-v" 'ediff-scroll-down) | |
1734 (define-key ediff-mode-map "V" 'ediff-scroll-down) | |
1735 (define-key ediff-mode-map "<" 'ediff-scroll-left) | |
1736 (define-key ediff-mode-map ">" 'ediff-scroll-right) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1737 (define-key ediff-mode-map "i" 'ediff-status-info) |
7267 | 1738 (define-key ediff-mode-map "?" 'ediff-toggle-help) |
7424 | 1739 (define-key ediff-mode-map "!" 'ediff-recompute-diffs) |
1740 (define-key ediff-mode-map "*" 'ediff-make-fine-diffs) | |
7267 | 1741 (define-key ediff-mode-map "a" nil) |
1742 (define-key ediff-mode-map "ab" 'ediff-diff-to-diff) | |
1743 (define-key ediff-mode-map "b" nil) | |
1744 (define-key ediff-mode-map "ba" 'ediff-diff-to-diff) | |
1745 (define-key ediff-mode-map "r" nil) | |
1746 (define-key ediff-mode-map "ra" 'ediff-restore-diff) | |
1747 (define-key ediff-mode-map "rb" 'ediff-restore-diff) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1748 (define-key ediff-mode-map "#" nil) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1749 (define-key ediff-mode-map "#h" 'ediff-toggle-regexp-match) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1750 (define-key ediff-mode-map "#f" 'ediff-toggle-regexp-match) |
7267 | 1751 (define-key ediff-mode-map "o" nil) |
1752 (define-key ediff-mode-map "A" 'ediff-toggle-read-only) | |
1753 (define-key ediff-mode-map "B" 'ediff-toggle-read-only) | |
1754 (define-key ediff-mode-map "w" nil) | |
1755 (define-key ediff-mode-map "wa" 'ediff-save-buffer) | |
1756 (define-key ediff-mode-map "wb" 'ediff-save-buffer) | |
1757 (define-key ediff-mode-map "k" nil) | |
1758 (define-key ediff-mode-map "kkk" 'ediff-reload-keymap) ;; for debug | |
1759 ;; Allow ediff-mode-map to be referenced indirectly | |
1760 (fset 'ediff-mode-map ediff-mode-map)) | |
1761 | |
1762 | |
1763 ;;; Setup functions | |
1764 | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1765 (defun ediff-find-file (file-var buffer &optional last-dir hooks-var) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1766 "Visit FILE and arrange its buffer to Ediff's liking. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1767 FILE is actually a variables symbol that must contain a true file name. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1768 BUFFER is a variable symbol, which will get the buffer object into which |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1769 FILE is read. LAST-DIR is the directory variable symbol where FILE's |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1770 directory name should be returned. HOOKS is a variable symbol that will be |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1771 assigned the hook to be executed after `ediff-strartup' is finished. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1772 `ediff-find-file' arranges that the temp files it might create will be |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1773 deleted. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1774 Arguments: (file buffer &optional last-dir hooks)" |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1775 (let* ((file (eval file-var)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1776 (file-magic (find-file-name-handler file 'find-file-noselect))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1777 (if (not (file-readable-p file)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1778 (error "File `%s' does not exist or is not readable" file)) |
7267 | 1779 |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1780 ;; Record the directory of the file |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1781 (if last-dir |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1782 (set last-dir (expand-file-name (file-name-directory file)))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1783 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1784 ;; Setup the buffer |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1785 (set buffer (find-file-noselect file)) |
7267 | 1786 |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1787 (ediff-eval-in-buffer |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1788 (eval buffer) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1789 (widen) ;; Make sure the entire file is seen |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1790 (cond (file-magic ;; file has handler, such as jka-compr-handler or |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1791 ;; ange-ftp-hook-function--arrange for temp file |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1792 (ediff-verify-file-buffer 'magic) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1793 (setq file (ediff-make-temp-file)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1794 (set hooks-var (cons (` (lambda () (delete-file (, file)))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1795 (eval hooks-var)))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1796 ;; file processed via auto-mode-alist, a la uncompress.el |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1797 ((not (equal (expand-file-name file) (buffer-file-name))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1798 (setq file (ediff-make-temp-file)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1799 (set hooks-var (cons (` (lambda () (delete-file (, file)))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1800 (eval hooks-var)))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1801 (t ;; plain file---just check that the file matches the buffer |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1802 (ediff-verify-file-buffer)))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1803 (set file-var file))) |
7267 | 1804 |
1805 (defun ediff-files-internal (file-A file-B &optional startup-hooks) | |
1806 (let (buffer-A buffer-B) | |
7424 | 1807 (message "Reading file %s ... " file-A)(sit-for .5) |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1808 (ediff-find-file 'file-A 'buffer-A 'ediff-last-dir-A 'startup-hooks) |
7424 | 1809 (message "Reading file %s ... " file-B)(sit-for .5) |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1810 (ediff-find-file 'file-B 'buffer-B 'ediff-last-dir-B 'startup-hooks) |
7267 | 1811 (ediff-setup buffer-A file-A buffer-B file-B startup-hooks))) |
1812 | |
1813 (defun ediff-get-patch-buffer (dir) | |
1814 "Obtain patch buffer. If patch is already in a buffer---use it. | |
1815 Else, read patch file into a new buffer." | |
1816 (if (y-or-n-p "Is the patch file already in a buffer? ") | |
1817 (setq ediff-patch-buf | |
1818 (get-buffer (read-buffer "Patch buffer name: " nil t))) ;must match | |
1819 (setq ediff-patch-buf | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1820 (find-file-noselect (read-file-name "Patch file name: " dir)))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1821 (ediff-eval-in-buffer |
7267 | 1822 ediff-patch-buf |
1823 (toggle-read-only 1)) | |
1824 (setq ediff-patch-diagnostics | |
1825 (get-buffer-create "*ediff patch diagnostics*")) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1826 (ediff-eval-in-buffer |
7267 | 1827 ediff-patch-diagnostics |
1828 (insert-buffer ediff-patch-buf)) | |
1829 ) | |
1830 | |
1831 ;; Start up Ediff on two files | |
1832 (defun ediff-setup (buffer-A file-A buffer-B file-B startup-hooks) | |
1833 (setq file-A (expand-file-name file-A)) | |
1834 (setq file-B (expand-file-name file-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>
parents:
7709
diff
changeset
|
1835 (let* ((control-buffer-name |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1836 (emerge-unique-buffer-name "Ediff Control Panel" "")) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1837 (control-buffer (ediff-eval-in-buffer |
7267 | 1838 buffer-A |
1839 (get-buffer-create control-buffer-name)))) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1840 (ediff-eval-in-buffer |
7267 | 1841 control-buffer |
1842 (ediff-mode) ;; in control buffer only | |
1843 (setq buffer-read-only nil) | |
1844 (setq ediff-A-buffer buffer-A) | |
1845 (setq ediff-B-buffer buffer-B) | |
1846 (setq ediff-control-buffer control-buffer) | |
7424 | 1847 ; (setq ediff-control-buffer-suffix |
1848 ; (if (string-match "<[0-9]*>" control-buffer-name) | |
1849 ; (substring control-buffer-name | |
1850 ; (match-beginning 0) (match-end 0)) | |
1851 ; "<1>")) | |
1852 (setq ediff-error-buffer (get-buffer-create (emerge-unique-buffer-name | |
1853 "*ediff-errors" "*"))) | |
7267 | 1854 (ediff-remember-buffer-characteristics t) ;; remember at setup |
1855 | |
1856 (ediff-set-keys) | |
7424 | 1857 (setq ediff-difference-vector (ediff-setup-diff-regions file-A file-B)) |
7267 | 1858 (setq ediff-number-of-differences (length ediff-difference-vector)) |
1859 (setq ediff-current-difference -1) | |
1860 (ediff-make-current-diff-overlay 'A) | |
1861 (ediff-make-current-diff-overlay 'B) | |
1862 (if window-system | |
1863 (ediff-init-var-faces)) | |
1864 (run-hooks 'ediff-before-setup-windows-hooks) | |
1865 (ediff-setup-windows buffer-A buffer-B control-buffer t) | |
1866 | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1867 ;; all these must be inside ediff-eval-in-buffer control-buffer, |
7267 | 1868 ;; since these vars are local to control-buffer |
1869 ;; These won't run if there are errors in diff | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1870 (ediff-eval-in-buffer |
7267 | 1871 ediff-A-buffer |
1872 (add-hook 'local-write-file-hooks 'ediff-block-write-file) | |
1873 (setq before-change-function 'ediff-before-change-guard) | |
1874 ;; add control-buffer to the list of sessions | |
1875 (or (memq control-buffer ediff-this-buffer-control-sessions) | |
1876 (setq ediff-this-buffer-control-sessions | |
1877 (cons control-buffer ediff-this-buffer-control-sessions))) | |
8348
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1878 (setq mode-line-buffer-identification |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1879 (cons "A: " |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1880 (if (string-match "\\(^ \\|^[^ \t]*: \\)" |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1881 (car mode-line-buffer-identification)) |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1882 (cons (substring (car mode-line-buffer-identification) |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1883 (match-end 0)) |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1884 (cdr mode-line-buffer-identification)) |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1885 mode-line-buffer-identification))) |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1886 (run-hooks 'ediff-prepare-buffer-hooks)) |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1887 (ediff-eval-in-buffer |
7267 | 1888 ediff-B-buffer |
1889 (add-hook 'local-write-file-hooks 'ediff-block-write-file) | |
1890 (setq before-change-function 'ediff-before-change-guard) | |
1891 ;; add control-buffer to the list of sessions | |
1892 (or (memq control-buffer ediff-this-buffer-control-sessions) | |
1893 (setq ediff-this-buffer-control-sessions | |
1894 (cons control-buffer ediff-this-buffer-control-sessions))) | |
8348
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1895 (setq mode-line-buffer-identification |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1896 (cons "B: " |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1897 (if (string-match "\\(^ \\|^[^ \t]*: \\)" |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1898 (car mode-line-buffer-identification)) |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1899 (cons (substring (car mode-line-buffer-identification) |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1900 (match-end 0)) |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1901 (cdr mode-line-buffer-identification)) |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1902 mode-line-buffer-identification))) |
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
1903 (run-hooks 'ediff-prepare-buffer-hooks)) |
7267 | 1904 |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1905 (ediff-eval-in-buffer control-buffer |
7267 | 1906 (run-hooks 'startup-hooks 'ediff-startup-hooks) |
1907 (setq buffer-read-only t))))) | |
1908 | |
7424 | 1909 ;; Generate the difference vector and overlays for the two files |
1910 ;; With optional arg `refine', create refining difference regions | |
1911 (defun ediff-setup-diff-regions (file-A file-B | |
1912 &optional use-old refine-region | |
1913 diff-program diff-options | |
1914 diff-ok-lines-regexp) | |
1915 | |
1916 (setq diff-program (or diff-program ediff-diff-program) | |
1917 diff-options (or diff-options ediff-diff-options) | |
1918 diff-ok-lines-regexp | |
1919 (or diff-ok-lines-regexp ediff-diff-ok-lines-regexp)) | |
1920 | |
1921 (or use-old (setq ediff-diff-buffer | |
1922 (get-buffer-create | |
1923 (emerge-unique-buffer-name "*ediff-diff" "*")))) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1924 (ediff-eval-in-buffer |
7267 | 1925 ediff-diff-buffer |
1926 (erase-buffer) | |
1927 ;; shell-command tends to display old shell command buffers even when it | |
1928 ;; puts output in another buffer---probably an Emacs bug. | |
1929 (ediff-kill-buffer-carefully "*Shell Command Output*") | |
1930 (let ((shell-file-name ediff-shell)) | |
7424 | 1931 (if refine-region |
1932 (message "Refining difference region %d ..." (1+ refine-region)) | |
1933 (message "Computing differences ...")(sit-for .5)) | |
7267 | 1934 (shell-command |
1935 (format "%s %s %s %s" | |
7424 | 1936 diff-program diff-options |
1937 (ediff-protect-metachars file-A) | |
1938 (ediff-protect-metachars file-B)) | |
7267 | 1939 t) |
1940 )) | |
7424 | 1941 (ediff-prepare-error-list diff-ok-lines-regexp) |
1942 (if refine-region | |
1943 (message "Refining difference region %d ... Done." (1+ refine-region)) | |
1944 (message "Computing differences ... Done.")(sit-for .5)) | |
1945 (if refine-region | |
1946 (ediff-convert-diffs-to-overlays-refine | |
1947 ediff-A-buffer ediff-B-buffer | |
1948 (ediff-extract-diffs ediff-diff-buffer) | |
1949 refine-region) | |
1950 (ediff-convert-diffs-to-overlays | |
1951 ediff-A-buffer ediff-B-buffer | |
1952 (ediff-extract-diffs ediff-diff-buffer ediff-A-buffer ediff-B-buffer))) | |
1953 ) | |
1954 | |
7267 | 1955 |
1956 (defun ediff-prepare-error-list (ok-regexp) | |
1957 (let ((diff-buff ediff-diff-buffer)) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1958 (ediff-eval-in-buffer |
7424 | 1959 ediff-error-buffer |
7267 | 1960 (erase-buffer) |
1961 (insert-buffer diff-buff) | |
1962 (delete-matching-lines ok-regexp)))) | |
1963 | |
1964 ;;; Function to start Ediff by patching a file | |
1965 | |
1966 ;;;###autoload | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1967 (defun ediff-patch-file (source-filename &optional startup-hooks) |
7424 | 1968 "Run Ediff by patching FILE-TP-PATCH." |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1969 (interactive |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1970 (list (ediff-read-file-name "File to patch" |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1971 (if ediff-use-last-dir |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1972 ediff-last-dir-patch |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1973 default-directory) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1974 nil))) |
7267 | 1975 |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1976 (ediff-get-patch-buffer (file-name-directory source-filename)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1977 (let* ((backup-extension |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1978 ;; if the user specified a -b option, extract the backup |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1979 ;; extension from there; else use `.orig' |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1980 (substring ediff-patch-options |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1981 (if (string-match "-b[ \t]+" ediff-patch-options) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1982 (match-end 0) 0) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1983 (if (string-match "-b[ \t]+[^ \t]+" ediff-patch-options) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1984 (match-end 0) 0))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1985 (backup-extension (if (string= backup-extension "") |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1986 "orig" backup-extension)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1987 (shell-file-name ediff-shell) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1988 ;; ediff-find-file may use a temp file to do the patch |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1989 ;; so, we save source-filename and true-source-filename as a var |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1990 ;; that initially is source-filename but may be changed to a temp |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1991 ;; file for the purpose of patching. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1992 (true-source-filename source-filename) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1993 (target-filename source-filename) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1994 target-buf buf-to-patch file-name-magic-p) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1995 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1996 ;; Make a temp file, if source-filename has a magic file handler (or if |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1997 ;; it is handled via auto-mode-alist and similar magic). |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1998 ;; Check if there is a buffer visiting source-filename and if they are in |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
1999 ;; synch; arrange for the deletion of temp file. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2000 (ediff-find-file 'true-source-filename 'buf-to-patch |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2001 'ediff-last-dir-patch 'startup-hooks) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2002 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2003 ;; Check if source file name has triggered black magic, such as file name |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2004 ;; handlers or auto mode alist, and make a note of it. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2005 (setq file-name-magic-p (not (equal (expand-file-name true-source-filename) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2006 (expand-file-name source-filename)))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2007 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2008 (ediff-eval-in-buffer |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2009 ediff-patch-diagnostics |
7424 | 2010 (message "Applying patch ... ")(sit-for .5) |
2011 ;; always pass patch the -f option, so it won't ask any questions | |
7267 | 2012 (shell-command-on-region |
2013 (point-min) (point-max) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2014 (format "%s -f %s %s" |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2015 ediff-patch-program ediff-patch-options |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2016 (expand-file-name true-source-filename)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2017 t)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2018 (message "Applying patch ... Done.")(sit-for .5) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2019 (switch-to-buffer ediff-patch-diagnostics) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2020 (sit-for 0) ;; synchronize |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2021 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2022 (or (file-exists-p (concat true-source-filename "." backup-extension)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2023 (error "Patch failed or didn't modify the original file.")) |
7267 | 2024 |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2025 ;; If black magic is involved, apply patch to a temp copy of the |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2026 ;; file. Otherwise, apply patch to the orig copy. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2027 ;; If patch is applied to temp copy, we name the result |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2028 ;; ***.patched. The orig file name isn't changed, and the temp copy of |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2029 ;; the original is later deleted. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2030 ;; Without magic, the original file is renamed (usually into |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2031 ;; old-name.orig) and the result of patching will have the |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2032 ;; same name as the original. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2033 (if (not file-name-magic-p) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2034 (ediff-eval-in-buffer |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2035 buf-to-patch |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2036 (set-visited-file-name (concat source-filename "." backup-extension)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2037 (set-buffer-modified-p nil)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2038 (setq target-filename (concat true-source-filename ".patched")) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2039 (rename-file true-source-filename target-filename t) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2040 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2041 ;; arrange that the temp copy of orig will be deleted |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2042 (rename-file (concat true-source-filename "." backup-extension) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2043 true-source-filename t)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2044 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2045 ;; make orig buffer read-only |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2046 (setq startup-hooks (cons 'ediff-toggle-read-only-A startup-hooks)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2047 ;; set up a buf for the patched file |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2048 (setq target-buf (find-file-noselect target-filename)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2049 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2050 (ediff-buffers buf-to-patch target-buf startup-hooks) |
7267 | 2051 |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2052 (bury-buffer ediff-patch-diagnostics) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2053 (message "Patch diagnostics available in buffer %s." |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2054 (buffer-name ediff-patch-diagnostics)))) |
7267 | 2055 |
2056 (defalias 'epatch 'ediff-patch-file) | |
7424 | 2057 (defalias 'epatch-buffer 'ediff-patch-buffer) |
7267 | 2058 |
2059 ;;; Function to start Ediff on files | |
2060 | |
2061 ;;;###autoload | |
2062 (defun ediff-files (file-A file-B &optional startup-hooks) | |
2063 "Run Ediff on a pair files, FILE-A and FILE-B." | |
2064 (interactive | |
2065 (let (f) | |
2066 (list (setq f (ediff-read-file-name "File A to compare" | |
2067 (if ediff-use-last-dir | |
2068 ediff-last-dir-A | |
2069 default-directory) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2070 nil)) |
7267 | 2071 (ediff-read-file-name "File B to compare" |
2072 (if ediff-use-last-dir | |
2073 ediff-last-dir-B nil) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2074 f) |
7267 | 2075 ))) |
7424 | 2076 (ediff-files-internal file-A |
2077 (if (file-directory-p file-B) | |
2078 (expand-file-name | |
2079 (file-name-nondirectory file-A) file-B) | |
2080 file-B) | |
2081 startup-hooks)) | |
7267 | 2082 |
2083 | |
2084 (defalias 'ediff 'ediff-files) | |
2085 | |
2086 | |
2087 ;;; Function to start Ediff on buffers | |
2088 | |
2089 ;;;###autoload | |
2090 (defun ediff-buffers (buffer-A buffer-B &optional startup-hooks) | |
2091 "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>
parents:
7709
diff
changeset
|
2092 (interactive |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2093 (list (read-buffer "Buffer A to compare: " (current-buffer) t) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2094 (read-buffer "Buffer B to compare: " |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2095 (progn |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2096 ;; realign buffers so that two visible bufs will be |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2097 ;; at the top |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2098 (save-window-excursion (other-window 1)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2099 (other-buffer (current-buffer) t)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2100 t))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2101 (if (not (ediff-buffer-live-p buffer-A)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2102 (error "Buffer %S doesn't exist." buffer-A)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2103 (if (not (ediff-buffer-live-p buffer-B)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2104 (error "Buffer %S doesn't exist." buffer-B)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2105 |
7424 | 2106 (let (file-A file-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>
parents:
7709
diff
changeset
|
2107 (ediff-eval-in-buffer |
7267 | 2108 buffer-A |
7424 | 2109 (setq file-A (ediff-make-temp-file))) |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2110 (ediff-eval-in-buffer |
7267 | 2111 buffer-B |
7424 | 2112 (setq file-B (ediff-make-temp-file))) |
2113 (ediff-setup (get-buffer buffer-A) file-A | |
2114 (get-buffer buffer-B) file-B | |
7267 | 2115 (cons (` (lambda () |
7424 | 2116 (delete-file (, file-A)) |
2117 (delete-file (, file-B)))) | |
7267 | 2118 startup-hooks) |
2119 ))) | |
2120 | |
7709
d88d94461e5d
(ediff-patch-buffer): Fix autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
7639
diff
changeset
|
2121 ;;;###autoload |
7267 | 2122 (defun ediff-patch-buffer (buffer-name &optional startup-hooks) |
2123 "Run Ediff by patching BUFFER-NAME." | |
2124 (interactive "bBuffer to patch: ") | |
2125 | |
2126 (let* ((file-buffer (get-buffer buffer-name)) | |
2127 (file-name (if file-buffer (buffer-file-name file-buffer)))) | |
2128 (if (not file-name) | |
2129 (error "Buffer %s doesn't exist or doesn't visit any file. Why patch?" | |
2130 file-name)) | |
2131 | |
2132 (ediff-patch-file file-name startup-hooks))) | |
2133 | |
2134 | |
2135 ;;; Versions Control functions | |
2136 | |
2137 ;;;###autoload | |
2138 (defun vc-ediff (rev) | |
7424 | 2139 ;; Note: this function will work only with Emacs 19.22 and higher. |
7267 | 2140 "Run ediff on version REV of the current buffer in another window. |
2141 If the current buffer is named `F', the version is named `F.~REV~'. | |
7391 | 2142 If `F.~REV~' already exists, it is used instead of being re-created." |
7267 | 2143 (interactive "sVersion to ediff with (default is the latest version): ") |
2144 (or (featurep 'vc) | |
2145 (if (locate-library "vc") ;; if vc.el is available | |
2146 (progn | |
2147 (require 'vc-hooks) | |
2148 (define-key vc-prefix-map "=" 'vc-ediff)) | |
2149 (error "The VC package is apparently not installed."))) | |
2150 (let ((newvers (current-buffer)) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2151 ) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2152 (vc-version-other-window rev) |
7424 | 2153 ;; current-buffer is supposed to contain the old version in another |
2154 ;; window | |
2155 (ediff-buffers newvers (current-buffer)) | |
7267 | 2156 )) |
2157 | |
2158 (defun rcs-ediff-view-revision (&optional rev) | |
7424 | 2159 "View previous RCS revision of current file. |
7267 | 2160 With prefix argument, prompts for a revision name." |
2161 (interactive (list (if current-prefix-arg | |
2162 (read-string "Revision: ")))) | |
2163 (let* ((filename (buffer-file-name (current-buffer))) | |
2164 (switches (append '("-p") | |
2165 (if rev (list (concat "-r" rev)) nil))) | |
2166 (buff (concat (file-name-nondirectory filename) ".~" rev "~"))) | |
2167 (message "Working...") | |
2168 (setq filename (expand-file-name filename)) | |
2169 (with-output-to-temp-buffer | |
2170 buff | |
7424 | 2171 (let ((output-buffer (ediff-rcs-get-output-buffer filename buff))) |
7267 | 2172 (delete-windows-on output-buffer) |
2173 (save-excursion | |
2174 (set-buffer output-buffer) | |
2175 (apply 'call-process "co" nil t nil | |
2176 ;; -q: quiet (no diagnostics) | |
2177 (append switches rcs-default-co-switches | |
2178 (list "-q" filename))))) | |
2179 (message "") | |
2180 buff))) | |
7424 | 2181 |
2182 (defun ediff-rcs-get-output-buffer (file name) | |
2183 ;; Get a buffer for RCS output for FILE, make it writable and clean it up. | |
2184 ;; Optional NAME is name to use instead of `*RCS-output*'. | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2185 ;; This is a modified version from rcs.el v1.1. I use it here to make |
7424 | 2186 ;; Ediff immune to changes in rcs.el |
2187 (let* ((default-major-mode 'fundamental-mode);; no frills! | |
2188 (buf (get-buffer-create name))) | |
2189 (save-excursion | |
2190 (set-buffer buf) | |
2191 (setq buffer-read-only nil | |
2192 default-directory (file-name-directory (expand-file-name file))) | |
2193 (erase-buffer)) | |
2194 buf)) | |
7267 | 2195 |
2196 ;;;###autoload | |
2197 (defun rcs-ediff (&optional rev) | |
7424 | 2198 "Run Ediff on the current buffer, comparing it with previous RCS revision. |
7267 | 2199 With prefix argument, prompts for revision name." |
2200 (interactive (list (if current-prefix-arg | |
2201 (read-string "Revision: ")))) | |
2202 (or (featurep 'rcs) | |
2203 (if (locate-library "rcs") | |
2204 (progn | |
2205 (require 'rcs) | |
2206 (global-set-key "\C-cD" 'rcs-ediff)) | |
2207 (error "The RCS package is apparently not installed."))) | |
2208 (let ((newvers (current-buffer)) | |
2209 (oldvers (rcs-ediff-view-revision rev))) | |
2210 (ediff-buffers newvers oldvers) | |
2211 )) | |
2212 | |
2213 | |
2214 | |
2215 | |
2216 ;; Select the lowest window on the frame. | |
2217 (defun ediff-select-lowest-window () | |
2218 (let* ((lowest-window (selected-window)) | |
2219 (bottom-edge (car (cdr (cdr (cdr (window-edges)))))) | |
2220 (last-window (previous-window)) | |
2221 (window-search t)) | |
2222 (while window-search | |
2223 (let* ((this-window (next-window)) | |
2224 (next-bottom-edge (car (cdr (cdr (cdr | |
2225 (window-edges this-window))))))) | |
2226 (if (< bottom-edge next-bottom-edge) | |
2227 (progn | |
2228 (setq bottom-edge next-bottom-edge) | |
2229 (setq lowest-window this-window))) | |
2230 | |
2231 (select-window this-window) | |
2232 (if (eq last-window this-window) | |
2233 (progn | |
2234 (select-window lowest-window) | |
2235 (setq window-search nil))))))) | |
2236 | |
2237 ;;; Common setup routines | |
2238 | |
2239 ;; Set up the window configuration. If POS is given, set the points to | |
2240 ;; the beginnings of the buffers. | |
2241 (defun ediff-setup-windows (buffer-A buffer-B control-buffer &optional pos) | |
2242 ;; Make sure we are not in the minibuffer window when we try to delete | |
2243 ;; all other windows. | |
2244 (if (eq (selected-window) (minibuffer-window)) | |
2245 (other-window 1)) | |
7424 | 2246 (or (ediff-leave-window-config control-buffer) |
2247 (progn | |
2248 (delete-other-windows) | |
2249 (switch-to-buffer control-buffer) | |
2250 (ediff-refresh-mode-line) | |
7267 | 2251 |
7424 | 2252 (ediff-arrange-buffer buffer-A buffer-B (current-buffer) pos) |
2253 (ediff-arrange-buffer buffer-B buffer-A (current-buffer) pos) | |
2254 ;; ediff-arrange-buffer always leaves in ctl buffer | |
2255 ;; setup ctl wind if it is not set. | |
2256 (ediff-setup-control-window) | |
7267 | 2257 |
7424 | 2258 ;; If diff reports errors, show them then quit. |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2259 (if (/= 0 (ediff-eval-in-buffer ediff-error-buffer (buffer-size))) |
7424 | 2260 (let ((diff-output-buf ediff-diff-buffer)) |
2261 (switch-to-buffer ediff-error-buffer) | |
2262 (ediff-kill-buffer-carefully control-buffer) | |
2263 (error "Errors found in diff output. Diff output buffer is %s" | |
2264 diff-output-buf)))))) | |
7267 | 2265 |
2266 | |
2267 ;; Arranges goal-buf on the screen. | |
2268 (defun ediff-arrange-buffer (goal-buf other-buf ctl-buf &optional pos) | |
2269 (let* ((ctl-wind (get-buffer-window ctl-buf t)) | |
2270 (goal-wind (get-buffer-window goal-buf t)) | |
2271 (other-wind (get-buffer-window other-buf t)) | |
2272 (ctl-frame (ediff-window-frame ctl-wind)) | |
2273 (goal-frame (if goal-wind (ediff-window-frame goal-wind))) | |
2274 (other-frame (if other-wind (ediff-window-frame other-wind))) | |
2275 (ctl-frame-shared (or (eq ctl-frame goal-frame) | |
2276 (eq ctl-frame other-frame)))) | |
2277 | |
2278 (cond ((and goal-frame (not (eq goal-wind other-wind))) | |
2279 ;; goal buffer is visible and we are not comparing file | |
2280 ;; against itself (by mistake). | |
2281 ;; Note: goal-frame != ctl-frame, as we deleted other | |
2282 ;; windows on ctl-frame. | |
2283 (ediff-select-frame goal-frame) | |
2284 (select-window goal-wind) | |
2285 (delete-other-windows)) | |
2286 | |
2287 ;; goal-buf invisible, ctl-frame has only ctl-buf | |
2288 ;; then put goal-buf on ctl-frame | |
2289 ((null ctl-frame-shared) | |
2290 (ediff-select-frame ctl-frame) | |
2291 (split-window-vertically) | |
2292 (ediff-select-lowest-window) | |
2293 (setq ctl-wind (selected-window)) | |
2294 (switch-to-buffer ctl-buf) | |
2295 (ediff-setup-control-window) | |
2296 (other-window 1) | |
2297 (switch-to-buffer goal-buf)) ; goal-buf set | |
2298 ;; goal-buf invisible, ctl-frame has ctl-buf and other-buf | |
2299 ;; So, put everything in one frame | |
2300 (other-frame ;; share with the other buf | |
2301 (ediff-select-frame ctl-frame) | |
2302 (select-window other-wind) | |
2303 (funcall ediff-split-window-function) | |
2304 (other-window 1) | |
2305 (switch-to-buffer goal-buf)) | |
2306 (t ;; debug | |
2307 (error "Funny window combination (Ediff bug?)"))) | |
2308 | |
2309 (if pos | |
2310 (goto-char (point-min))) | |
2311 | |
2312 (ediff-select-frame ctl-frame) | |
2313 (select-window ctl-wind) | |
2314 (switch-to-buffer ctl-buf))) | |
2315 | |
2316 ;; This function assumes that we are in the window where control buffer is | |
2317 ;; to reside. | |
2318 (defun ediff-setup-control-window () | |
2319 "Set up window for control buffer." | |
2320 (erase-buffer) | |
2321 (insert ediff-help-message) | |
2322 (shrink-window-if-larger-than-buffer) | |
2323 (setq ediff-control-window (selected-window)) | |
7424 | 2324 (setq ediff-window-config-saved |
2325 (format "%S%S%S%S" | |
2326 ediff-control-window | |
2327 (get-buffer-window ediff-A-buffer t) | |
2328 (get-buffer-window ediff-B-buffer t) | |
2329 ediff-split-window-function)) | |
7267 | 2330 (goto-char (point-min)) |
7424 | 2331 (skip-chars-forward ediff-whitespace)) |
2332 | |
2333 (defun ediff-leave-window-config (control-buf) | |
2334 (and (eq control-buf (current-buffer)) | |
2335 (/= (buffer-size) 0) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2336 (ediff-eval-in-buffer |
7424 | 2337 control-buf |
2338 (string= ediff-window-config-saved | |
2339 (format "%S%S%S%S" | |
2340 (get-buffer-window ediff-control-buffer t) | |
2341 (get-buffer-window ediff-A-buffer t) | |
2342 (get-buffer-window ediff-B-buffer t) | |
2343 ediff-split-window-function))))) | |
7267 | 2344 |
2345 | |
2346 ;; Set up the keymap in the control buffer | |
2347 (defun ediff-set-keys () | |
2348 "Set up Ediff keymap, if necessary." | |
2349 (if (null ediff-mode-map) | |
2350 (ediff-setup-keymap)) | |
2351 (use-local-map ediff-mode-map)) | |
2352 | |
2353 ;; Reload Ediff keymap. For debugging only. | |
2354 (defun ediff-reload-keymap () | |
2355 (interactive) | |
2356 (setq ediff-mode-map nil) | |
2357 (ediff-set-keys)) | |
2358 | |
2359 (defun ediff-before-change-guard (start end) | |
7419 | 2360 "If buffer is highlighted with ASCII flags, remove highlighting. |
2361 Arguments, START and END are not used, but are provided | |
2362 because this is required by `before-change-function'." | |
7424 | 2363 (let (rehighlight-key) |
7267 | 2364 (save-window-excursion |
2365 (mapcar | |
2366 (function | |
2367 (lambda (buf) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2368 (ediff-eval-in-buffer |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2369 buf |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2370 (if (eq ediff-highlighting-style 'ascii) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2371 (progn |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2372 (ediff-unselect-and-select-difference |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2373 ediff-current-difference |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2374 'unselect-only 'no-recenter) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2375 (setq rehighlight-key |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2376 (substitute-command-keys "\\[ediff-recenter]")) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2377 ))))) |
7267 | 2378 ediff-this-buffer-control-sessions) |
7424 | 2379 (if rehighlight-key |
2380 (error | |
2381 "ASCII flags removed. You can edit now. Hit %S to rehighlight." | |
2382 rehighlight-key)) | |
7267 | 2383 ))) |
7424 | 2384 |
2385 (defun ediff-recompute-diffs () | |
2386 "Recompute difference regions in buffers A and B." | |
2387 (interactive) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2388 (let ((point-A (ediff-eval-in-buffer ediff-A-buffer (point))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2389 (point-B (ediff-eval-in-buffer ediff-B-buffer (point))) |
7424 | 2390 file-A file-B) |
2391 (ediff-unselect-and-select-difference -1) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2392 (ediff-eval-in-buffer |
7424 | 2393 ediff-A-buffer |
2394 (setq file-A (ediff-make-temp-file))) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2395 (ediff-eval-in-buffer |
7424 | 2396 ediff-B-buffer |
2397 (setq file-B (ediff-make-temp-file))) | |
2398 (ediff-clear-diff-vector ediff-difference-vector 'fine-diffs-also) | |
2399 (setq ediff-killed-diffs-alist nil) ; saved kills will no longer be valid | |
2400 ; after recompute | |
2401 (setq ediff-difference-vector | |
2402 (ediff-setup-diff-regions file-A file-B 'use-old)) | |
2403 (setq ediff-number-of-differences (length ediff-difference-vector)) | |
2404 (delete-file file-A) | |
2405 (delete-file file-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>
parents:
7709
diff
changeset
|
2406 (ediff-eval-in-buffer ediff-A-buffer (goto-char point-A)) |
7424 | 2407 (ediff-jump-to-difference (ediff-diff-at-point 'A)) |
2408 (beep 1) | |
2409 (if (y-or-n-p | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2410 "Ediff is at last posn in buff A. Stay (or goto last posn in B)? ") |
7424 | 2411 () |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2412 (ediff-eval-in-buffer ediff-B-buffer (goto-char point-B)) |
7424 | 2413 (ediff-jump-to-difference (ediff-diff-at-point 'B))) |
2414 (message "") | |
2415 )) | |
7267 | 2416 |
2417 (defun ediff-remember-buffer-characteristics (&optional arg) | |
2418 "Record certain properties of the buffers being compared. | |
7419 | 2419 Must be called in the control buffer. Saves `read-only', `modified', |
2420 and `auto-save' properties in buffer local variables. Turns off | |
2421 `auto-save-mode'. These properties are restored via a call to | |
2422 `ediff-restore-buffer-characteristics'." | |
7267 | 2423 |
2424 ;; remember and alter buffer characteristics | |
2425 (set (if arg 'ediff-A-buffer-values-setup 'ediff-A-buffer-values) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2426 (ediff-eval-in-buffer |
7267 | 2427 ediff-A-buffer |
2428 (prog1 | |
2429 (emerge-save-variables ediff-saved-variables) | |
2430 (emerge-restore-variables ediff-saved-variables | |
2431 ediff-working-values)))) | |
2432 (set (if arg 'ediff-B-buffer-values-setup 'ediff-B-buffer-values) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2433 (ediff-eval-in-buffer |
7267 | 2434 ediff-B-buffer |
2435 (prog1 | |
2436 (emerge-save-variables ediff-saved-variables) | |
2437 (emerge-restore-variables ediff-saved-variables | |
2438 ediff-working-values))))) | |
2439 | |
2440 (defun ediff-restore-buffer-characteristics (&optional arg) | |
7419 | 2441 "Restores properties saved by `ediff-remember-buffer-characteristics'." |
7267 | 2442 (let ((A-values (if arg ediff-A-buffer-values-setup ediff-A-buffer-values)) |
2443 (B-values (if arg ediff-B-buffer-values-setup ediff-B-buffer-values))) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2444 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2445 (ediff-eval-in-buffer ediff-A-buffer |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2446 (emerge-restore-variables ediff-saved-variables |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2447 A-values)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2448 (ediff-eval-in-buffer ediff-B-buffer |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2449 (emerge-restore-variables ediff-saved-variables |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2450 B-values)))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2451 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2452 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2453 ;; If optional A-buffer and B-buffer are given, then construct a vector of |
7424 | 2454 ;; diff using point values. Otherwise, use line offsets. |
2455 (defun ediff-extract-diffs (diff-buffer &optional A-buffer B-buffer) | |
7267 | 2456 (let (diff-list |
2457 (a-prev 1) ;; this is needed to set the first diff line correctly | |
2458 (b-prev 1)) | |
7424 | 2459 |
2460 (if (and A-buffer B-buffer) | |
2461 (progn ;; reset point in buffers A and 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>
parents:
7709
diff
changeset
|
2462 (ediff-eval-in-buffer |
7424 | 2463 A-buffer |
2464 (goto-char (point-min))) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2465 (ediff-eval-in-buffer |
7424 | 2466 B-buffer |
2467 (goto-char (point-min))))) | |
2468 | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2469 (ediff-eval-in-buffer |
7267 | 2470 diff-buffer |
2471 (goto-char (point-min)) | |
2472 (while (re-search-forward ediff-match-diff-line nil t) | |
2473 (let* ((a-begin (string-to-int (buffer-substring (match-beginning 1) | |
2474 (match-end 1)))) | |
2475 (a-end (let ((b (match-beginning 3)) | |
2476 (e (match-end 3))) | |
2477 (if b | |
2478 (string-to-int (buffer-substring b e)) | |
2479 a-begin))) | |
2480 (diff-type (buffer-substring (match-beginning 4) (match-end 4))) | |
2481 (b-begin (string-to-int (buffer-substring (match-beginning 5) | |
2482 (match-end 5)))) | |
2483 (b-end (let ((b (match-beginning 7)) | |
2484 (e (match-end 7))) | |
2485 (if b | |
2486 (string-to-int (buffer-substring b e)) | |
2487 b-begin))) | |
2488 a-begin-pt a-end-pt b-begin-pt b-end-pt) | |
2489 ;; fix the beginning and end numbers, because diff is somewhat | |
2490 ;; strange about how it numbers lines | |
2491 (if (string-equal diff-type "a") | |
2492 (setq b-end (1+ b-end) | |
2493 a-begin (1+ a-begin) | |
2494 a-end a-begin) | |
2495 (if (string-equal diff-type "d") | |
2496 (setq a-end (1+ a-end) | |
2497 b-begin (1+ b-begin) | |
2498 b-end b-begin) | |
2499 ;; (string-equal diff-type "c") | |
2500 (setq a-end (1+ a-end) | |
2501 b-end (1+ b-end)))) | |
7424 | 2502 (if (and A-buffer B-buffer) |
2503 (progn ;; computing main diff vector | |
2504 ;; convert to relative line numbers | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2505 (ediff-eval-in-buffer |
7424 | 2506 A-buffer |
2507 (forward-line (- a-begin a-prev)) | |
2508 (setq a-begin-pt (point)) | |
2509 (forward-line (- a-end a-begin)) | |
2510 (setq a-end-pt (point) | |
2511 a-prev a-end)) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2512 (ediff-eval-in-buffer |
7424 | 2513 B-buffer |
2514 (forward-line (- b-begin b-prev)) | |
2515 (setq b-begin-pt (point)) | |
2516 (forward-line (- b-end b-begin)) | |
2517 (setq b-end-pt (point) | |
2518 b-prev b-end)) | |
2519 (setq diff-list | |
2520 (nconc diff-list (list (vector a-begin-pt a-end-pt | |
2521 b-begin-pt b-end-pt))))) | |
2522 ;; computing refinement vector | |
2523 (setq diff-list | |
2524 (nconc diff-list (list (vector (- a-begin a-prev) | |
2525 (- a-end a-begin) | |
2526 (- b-begin b-prev) | |
2527 (- b-end b-begin)))) | |
2528 a-prev a-end | |
2529 b-prev b-end)) | |
2530 | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2531 ))) ;; end ediff-eval-in-buffer |
7267 | 2532 diff-list |
2533 )) | |
2534 | |
2535 (defun ediff-convert-diffs-to-overlays (A-buffer B-buffer diff-list) | |
2536 (let* ((current-diff -1) | |
2537 (total-diffs (length diff-list)) | |
7424 | 2538 ; (control-buffer-suffix ediff-control-buffer-suffix) |
7267 | 2539 diff-overlay-list list-element |
2540 a-begin a-end b-begin b-end | |
2541 a-overlay b-overlay) | |
2542 | |
2543 (while diff-list | |
2544 (setq current-diff (1+ current-diff) | |
2545 list-element (car diff-list) | |
2546 a-begin (aref list-element 0) | |
2547 a-end (aref list-element 1) | |
2548 b-begin (aref list-element 2) | |
2549 b-end (aref list-element 3)) | |
2550 | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2551 ;; Put overlays at the appropriate places in the buffers |
7267 | 2552 (setq a-overlay (ediff-make-overlay a-begin a-end A-buffer)) |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2553 ;; Priorities of overlays should be equal in all ediff control |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2554 ;; panels buffers. Otherwise it won't work due to Emacs |
7424 | 2555 ;; bug---insert-in-front-hooks will be called |
7267 | 2556 ;; only on behalf of the buffer with higher priority. |
2557 (ediff-overlay-put a-overlay 'priority ediff-shaded-overlay-priority) | |
2558 (ediff-overlay-put a-overlay 'ediff-diff-num current-diff) | |
2559 (ediff-overlay-put a-overlay | |
2560 'insert-in-front-hooks '(ediff-insert-in-front)) | |
7424 | 2561 ; (ediff-overlay-put a-overlay |
2562 ; 'ediff-control-buffer control-buffer-suffix) | |
7267 | 2563 (ediff-overlay-put a-overlay |
2564 'face (if (ediff-odd-p current-diff) ;; odd diff | |
2565 'ediff-odd-diff-face-A-var | |
2566 'ediff-even-diff-face-A-var)) | |
2567 | |
2568 (setq b-overlay (ediff-make-overlay b-begin b-end B-buffer)) | |
2569 (ediff-overlay-put b-overlay 'priority ediff-shaded-overlay-priority) | |
2570 (ediff-overlay-put b-overlay 'ediff-diff-num current-diff) | |
2571 (ediff-overlay-put b-overlay | |
2572 'insert-in-front-hooks '(ediff-insert-in-front)) | |
7424 | 2573 ; (ediff-overlay-put b-overlay |
2574 ; 'ediff-control-buffer control-buffer-suffix) | |
7267 | 2575 (ediff-overlay-put b-overlay |
2576 'face (if (ediff-odd-p current-diff) ;; odd diff | |
2577 'ediff-odd-diff-face-B-var | |
2578 'ediff-even-diff-face-B-var)) | |
2579 | |
2580 (if (ediff-if-lucid) ;; chars inserted at end will be inside extent | |
2581 (progn | |
2582 (ediff-overlay-put a-overlay | |
2583 'ediff-marker | |
2584 (move-marker (make-marker) a-begin A-buffer)) | |
2585 (ediff-overlay-put b-overlay | |
2586 'ediff-marker | |
2587 (move-marker (make-marker) b-begin B-buffer)) | |
2588 (ediff-overlay-put a-overlay 'end-open nil) | |
2589 (ediff-overlay-put b-overlay 'end-open nil))) | |
2590 | |
2591 ;; record all overlays for this difference | |
2592 (setq diff-overlay-list | |
7424 | 2593 (nconc diff-overlay-list (list (vector a-overlay b-overlay nil))) |
7267 | 2594 diff-list (cdr diff-list)) |
7424 | 2595 (message "Processing diff region %d of %d" |
7267 | 2596 current-diff total-diffs) |
2597 ) ;; while | |
2598 ;; this is just to avoid confusing the user with diff num < total-diffs | |
7424 | 2599 (message "Processing diff region %d of %d" |
7267 | 2600 (1+ current-diff) total-diffs) |
2601 ;; convert the list of difference information into a vector for | |
2602 ;; fast access | |
7424 | 2603 (apply 'vector diff-overlay-list))) |
7267 | 2604 |
2605 | |
2606 | |
2607 ;;; Commands | |
2608 | |
2609 (defun ediff-recenter (&optional no-rehighlight) | |
2610 "Bring the highlighted region of all buffers A and B into view. | |
2611 Reestablish the default three-window display." | |
2612 (interactive) | |
2613 (setq ediff-disturbed-overlays nil) ;; clear after use | |
2614 (let (buffer-read-only) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2615 (if (and (ediff-buffer-live-p ediff-A-buffer) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2616 (ediff-buffer-live-p ediff-B-buffer)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2617 (ediff-setup-windows |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2618 ediff-A-buffer ediff-B-buffer ediff-control-buffer))) |
7267 | 2619 ;; Redisplay whatever buffers are showing, if there is a selected difference |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2620 (if (and (ediff-buffer-live-p ediff-A-buffer) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2621 (ediff-buffer-live-p ediff-B-buffer) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2622 (>= ediff-current-difference 0) |
7267 | 2623 (< ediff-current-difference ediff-number-of-differences)) |
2624 (let* ( ;; context must be saved before switching to windows A/B | |
2625 (buffer-A ediff-A-buffer) | |
2626 (buffer-B ediff-B-buffer) | |
2627 (wind (selected-window)) | |
2628 (control-buf ediff-control-buffer) | |
2629 (before-flag-shift-A (if (eq ediff-highlighting-style 'ascii) | |
2630 (1- (length ediff-before-flag-A)) | |
2631 0)) | |
2632 (after-flag-shift-A (if (eq ediff-highlighting-style 'ascii) | |
2633 (1- (length ediff-after-flag-A)) | |
2634 0)) | |
2635 (before-flag-shift-B (if (eq ediff-highlighting-style 'ascii) | |
2636 (1- (length ediff-before-flag-B)) | |
2637 0)) | |
2638 (after-flag-shift-B (if (eq ediff-highlighting-style 'ascii) | |
2639 (1- (length ediff-after-flag-B)) | |
2640 0)) | |
2641 (window-A (get-buffer-window buffer-A t)) | |
2642 (window-B (get-buffer-window buffer-B t))) | |
2643 | |
2644 (or no-rehighlight | |
2645 (ediff-operate-on-flags 'insert)) | |
2646 | |
2647 (if window-A (progn | |
2648 (select-window window-A) | |
2649 (ediff-position-region | |
2650 (- (ediff-get-diff-posn 'A 'beg nil control-buf) | |
2651 before-flag-shift-A) | |
2652 (+ (ediff-get-diff-posn 'A 'end nil control-buf) | |
2653 after-flag-shift-A) | |
2654 (ediff-get-diff-posn 'A 'beg nil control-buf)))) | |
2655 (if window-B (progn | |
2656 (select-window window-B) | |
2657 (ediff-position-region | |
2658 (- (ediff-get-diff-posn 'B 'beg nil control-buf) | |
2659 before-flag-shift-B) | |
2660 (+ (ediff-get-diff-posn 'B 'end nil control-buf) | |
2661 after-flag-shift-B) | |
2662 (ediff-get-diff-posn 'B 'beg nil control-buf)))) | |
2663 (select-window wind)))) | |
2664 | |
2665 (defun ediff-toggle-split () | |
2666 "Toggle vertical/horizontal window split. | |
2667 Does nothing if file-A and file-B are in different frames." | |
2668 (interactive) | |
2669 (let* ((wind-A (get-buffer-window ediff-A-buffer t)) | |
2670 (wind-B (get-buffer-window ediff-B-buffer t)) | |
2671 (frame-A (if wind-A (ediff-window-frame wind-A))) | |
2672 (frame-B (if wind-B (ediff-window-frame wind-B)))) | |
2673 (if (eq frame-A frame-B) | |
2674 (setq ediff-split-window-function | |
2675 (if (eq ediff-split-window-function 'split-window-vertically) | |
2676 'split-window-horizontally | |
2677 'split-window-vertically)) | |
7424 | 2678 (message "No splitting: Buffers A and B are in different frames.")) |
7267 | 2679 (ediff-recenter 'no-rehighlight))) |
2680 | |
2681 (defun ediff-toggle-hilit () | |
2682 "Switch between highlighting using ASCII flags and highlighting using faces. | |
2683 On a dumb terminal, switches between ASCII highlighting and no highlighting." | |
2684 (interactive) | |
2685 (if (not window-system) | |
2686 (if (eq ediff-highlighting-style 'ascii) | |
2687 (progn | |
2688 (message "ASCII highlighting flags removed.") | |
2689 (ediff-unselect-and-select-difference ediff-current-difference | |
2690 'unselect-only) | |
2691 (setq ediff-highlighting-style 'off)) | |
2692 (ediff-unselect-and-select-difference ediff-current-difference | |
2693 'select-only)) | |
2694 (ediff-unselect-and-select-difference ediff-current-difference | |
2695 'unselect-only) | |
2696 ;; cycle through highlighting | |
7424 | 2697 (cond ((and ediff-want-faces ediff-highlight-all-diffs) |
2698 (message "Unhighlighting unselected difference regions.") | |
2699 (setq ediff-highlight-all-diffs nil)) | |
7267 | 2700 (ediff-want-faces |
7424 | 2701 (message "Highlighting with ASCII flags.") |
7267 | 2702 (setq ediff-want-faces nil)) |
2703 (t | |
7424 | 2704 (message "Re-highlighting all difference regions.") |
7267 | 2705 (setq ediff-want-faces t |
7424 | 2706 ediff-highlight-all-diffs t))) |
7267 | 2707 |
7424 | 2708 (if (and ediff-want-faces ediff-highlight-all-diffs) |
7267 | 2709 (if (not (face-differs-from-default-p 'ediff-odd-diff-face-A-var)) |
2710 (progn | |
2711 (copy-face ediff-odd-diff-face-A 'ediff-odd-diff-face-A-var) | |
2712 (copy-face ediff-odd-diff-face-B 'ediff-odd-diff-face-B-var) | |
2713 (copy-face ediff-even-diff-face-A 'ediff-even-diff-face-A-var) | |
2714 (copy-face ediff-even-diff-face-B 'ediff-even-diff-face-B-var))) | |
2715 (copy-face 'default 'ediff-odd-diff-face-A-var) | |
2716 (copy-face 'default 'ediff-odd-diff-face-B-var) | |
2717 (copy-face 'default 'ediff-even-diff-face-A-var) | |
2718 (copy-face 'default 'ediff-even-diff-face-B-var)) | |
2719 | |
2720 (ediff-unselect-and-select-difference | |
2721 ediff-current-difference 'select-only)) | |
2722 (ediff-operate-on-flags 'insert) | |
2723 ) | |
2724 | |
7424 | 2725 (defun ediff-toggle-autorefine () |
2726 "Toggle auto-refine mode." | |
2727 (interactive) | |
2728 (if window-system | |
2729 (cond ((eq ediff-auto-refine 'nix) | |
2730 (setq ediff-auto-refine 'on) | |
2731 (ediff-make-fine-diffs ediff-current-difference 'noforce) | |
2732 (message "Auto-refining is ON.")) | |
2733 ((eq ediff-auto-refine 'on) | |
2734 (message "Auto-refining is OFF.") | |
2735 (setq ediff-auto-refine 'off)) | |
2736 (t | |
2737 (ediff-set-fine-diff-properties ediff-current-difference 'default) | |
2738 (message "Refinements are HIDDEN.") | |
2739 (setq ediff-auto-refine 'nix)) | |
2740 ))) | |
2741 | |
7267 | 2742 (defun ediff-toggle-help () |
2743 "Toggle short/long help message." | |
2744 (interactive) | |
2745 (let (buffer-read-only) | |
2746 (erase-buffer) | |
2747 (if (string= ediff-help-message ediff-help-message-long) | |
2748 (setq ediff-help-message ediff-help-message-short) | |
2749 (setq ediff-help-message ediff-help-message-long))) | |
7424 | 2750 (setq ediff-window-config-saved "") ;; force redisplay |
7267 | 2751 (ediff-recenter 'no-rehighlight)) |
2752 | |
2753 | |
2754 (defun ediff-toggle-read-only-A () | |
2755 "Used as a startup hook to set `.orig' patch file read-only." | |
2756 (let ((last-command-char ?A)) | |
2757 (ediff-toggle-read-only))) | |
2758 | |
2759 (defun ediff-toggle-read-only () | |
2760 "Toggles buffer-read-only for buffer buffers A and B." | |
2761 (interactive) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2762 (ediff-eval-in-buffer |
7267 | 2763 (if (eq last-command-char ?A) ediff-A-buffer ediff-B-buffer) |
2764 (setq buffer-read-only (null buffer-read-only)))) | |
2765 | |
2766 ;;; Window scrolling operations | |
2767 ;; These operations are designed to scroll all three windows the same amount, | |
2768 ;; so as to keep the text in them aligned. | |
2769 | |
7424 | 2770 ;; Perform some operation on the two file windows (if they are showing). |
7267 | 2771 ;; Catches all errors on the operation in the A and B windows. |
2772 ;; Usually, errors come from scrolling off the | |
2773 ;; beginning or end of the buffer, and this gives nice nice error messages. | |
2774 (defun ediff-operate-on-windows (operation arg) | |
2775 (let* ((buffer-A ediff-A-buffer) | |
2776 (buffer-B ediff-B-buffer) | |
2777 (wind (selected-window)) | |
2778 (window-A (get-buffer-window buffer-A t)) | |
2779 (window-B (get-buffer-window buffer-B t))) | |
2780 (if window-A (progn | |
2781 (select-window window-A) | |
2782 (condition-case nil | |
2783 (funcall operation arg) | |
2784 (error)))) | |
2785 (if window-B (progn | |
2786 (select-window window-B) | |
2787 (condition-case nil | |
2788 (funcall operation arg) | |
2789 (error)))) | |
2790 (select-window wind) | |
2791 )) | |
2792 | |
2793 (defun ediff-scroll-up (&optional arg) | |
2794 "Scroll up buffers A and B, if they are in windows. | |
2795 With optional argument ARG, scroll ARG lines; otherwise scroll by nearly | |
2796 the height of window-A." | |
2797 (interactive "P") | |
2798 (ediff-operate-on-windows | |
2799 'scroll-up | |
2800 ;; calculate argument to scroll-up | |
2801 ;; if there is an explicit argument | |
2802 (if (and arg (not (equal arg '-))) | |
2803 ;; use it | |
2804 (prefix-numeric-value arg) | |
2805 ;; if not, see if we can determine a default amount (the window height) | |
2806 (let* ((window-A (get-buffer-window ediff-A-buffer t)) | |
2807 (window-B (get-buffer-window ediff-B-buffer t)) | |
2808 default-amount) | |
2809 (if (or (null window-A) (null window-B)) | |
2810 (setq default-amount 0) | |
2811 (setq default-amount | |
2812 (- (min (window-height window-A) (window-height window-B)) | |
2813 1 next-screen-context-lines))) | |
2814 ;; the window was found | |
2815 (if arg | |
2816 ;; C-u as argument means half of default amount | |
2817 (/ default-amount 2) | |
2818 ;; no argument means default amount | |
2819 default-amount))))) | |
2820 | |
2821 (defun ediff-scroll-down (&optional arg) | |
2822 "Scroll down buffers A and B, if they are in windows. | |
2823 With optional argument ARG, scroll ARG lines; otherwise scroll by nearly | |
2824 the height of window-A." | |
2825 (interactive "P") | |
2826 (ediff-operate-on-windows | |
2827 'scroll-down | |
2828 ;; calculate argument to scroll-down | |
2829 ;; if there is an explicit argument | |
2830 (if (and arg (not (equal arg '-))) | |
2831 ;; use it | |
2832 (prefix-numeric-value arg) | |
2833 ;; if not, see if we can determine a default amount (the window height) | |
2834 (let* ((window-A (get-buffer-window ediff-A-buffer t)) | |
2835 (window-B (get-buffer-window ediff-B-buffer t)) | |
2836 default-amount) | |
2837 (if (or (null window-A) (null window-B)) | |
2838 (setq default-amount 0) | |
2839 (setq default-amount | |
2840 (- (min (window-height window-A) (window-height window-B)) | |
2841 1 next-screen-context-lines))) | |
2842 ;; the window was found | |
2843 (if arg | |
2844 ;; C-u as argument means half of default amount | |
2845 (/ default-amount 2) | |
2846 ;; no argument means default amount | |
2847 default-amount))))) | |
2848 | |
2849 (defun ediff-scroll-left (&optional arg) | |
2850 "Scroll left buffer-A and buffer-B, if they are in windows. | |
2851 If an argument is given, that is how many columns are scrolled, else nearly | |
2852 the width of the A and B windows." | |
2853 (interactive "P") | |
2854 (ediff-operate-on-windows | |
2855 'scroll-left | |
2856 ;; calculate argument to scroll-left | |
2857 ;; if there is an explicit argument | |
2858 (if (and arg (not (equal arg '-))) | |
2859 ;; use it | |
2860 (prefix-numeric-value arg) | |
2861 ;; if not, see if we can determine a default amount | |
2862 ;; (half the window width) | |
2863 (if (null ediff-control-window) | |
2864 ;; no control window, use nil | |
2865 nil | |
2866 (let ((default-amount | |
2867 (- (/ (window-width ediff-control-window) 2) 3))) | |
2868 ;; the window was found | |
2869 (if arg | |
2870 ;; C-u as argument means half of default amount | |
2871 (/ default-amount 2) | |
2872 ;; no argument means default amount | |
2873 default-amount)))))) | |
2874 | |
2875 (defun ediff-scroll-right (&optional arg) | |
2876 "Scroll right buffer-A and buffer-B, if they are in windows. | |
2877 If an argument is given, that is how many columns are scrolled, else nearly | |
2878 the width of the A and B windows." | |
2879 (interactive "P") | |
2880 (ediff-operate-on-windows | |
2881 'scroll-right | |
2882 ;; calculate argument to scroll-right | |
2883 ;; if there is an explicit argument | |
2884 (if (and arg (not (equal arg '-))) | |
2885 ;; use it | |
2886 (prefix-numeric-value arg) | |
2887 ;; if not, see if we can determine a default amount | |
2888 ;; (half the window width) | |
2889 (if (null ediff-control-window) | |
2890 ;; no control window, use nil | |
2891 nil | |
2892 (let ((default-amount | |
2893 (- (/ (window-width ediff-control-window) 2) 3))) | |
2894 ;; the window was found | |
2895 (if arg | |
2896 ;; C-u as argument means half of default amount | |
2897 (/ default-amount 2) | |
2898 ;; no argument means default amount | |
2899 default-amount)))))) | |
2900 | |
2901 (defun ediff-position-region (beg end pos) | |
7424 | 2902 "This is a variation on `emerge-position-region'. |
7267 | 2903 The difference is that it always tries to align difference regions in |
2904 buffer-A and buffer-B, so that it will be easier to compare them." | |
2905 (set-window-start (selected-window) beg) | |
2906 (if (pos-visible-in-window-p end) | |
2907 ;; Determine the number of lines that the region occupies | |
2908 (let ((lines 0)) | |
2909 (while (> end (progn | |
2910 (move-to-window-line lines) | |
2911 (point))) | |
2912 (setq lines (1+ lines))) | |
2913 ;; And position the beginning on the right line | |
2914 (goto-char beg) | |
2915 (recenter (/ (1+ (max (- (1- (window-height (selected-window))) | |
2916 lines) | |
2917 1) | |
2918 ) | |
2919 2)))) | |
2920 (goto-char pos) | |
2921 ) | |
2922 | |
2923 | |
7424 | 2924 (defun ediff-next-difference (&optional arg) |
7267 | 2925 "Advance to the next difference. |
2926 With a prefix argument, go back that many differences." | |
2927 (interactive "P") | |
2928 (if (< ediff-current-difference ediff-number-of-differences) | |
2929 (let ((n (min ediff-number-of-differences | |
2930 (+ ediff-current-difference (if arg arg 1)))) | |
2931 (buffer-read-only nil)) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2932 (while (funcall ediff-skip-diff-region-function n) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2933 (setq n (1+ n))) |
7267 | 2934 (ediff-unselect-and-select-difference n)) |
2935 (error "At end of the difference list."))) | |
2936 | |
7424 | 2937 (defun ediff-previous-difference (&optional arg) |
7267 | 2938 "Go to the previous difference. |
2939 With a prefix argument, go back that many differences." | |
2940 (interactive "P") | |
2941 (if (> ediff-current-difference -1) | |
2942 (let ((n (max -1 (- ediff-current-difference (if arg arg 1)))) | |
2943 (buffer-read-only nil)) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2944 (while (funcall ediff-skip-diff-region-function n) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2945 (setq n (1- n))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2946 (ediff-unselect-and-select-difference n)) |
7267 | 2947 (error "At beginning of the difference list."))) |
2948 | |
2949 (defun ediff-jump-to-difference (difference-number) | |
2950 "Go to the difference specified as a prefix argument." | |
2951 (interactive "p") | |
2952 (let ((buffer-read-only nil)) | |
2953 (setq difference-number (1- difference-number)) | |
2954 (if (and (>= difference-number -1) | |
2955 (< difference-number (1+ ediff-number-of-differences))) | |
2956 (ediff-unselect-and-select-difference difference-number) | |
2957 (error "Bad difference number")))) | |
2958 | |
2959 (defun ediff-jump-to-difference-at-point () | |
2960 "Go to the difference closest to the point in buffer A or 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>
parents:
7709
diff
changeset
|
2961 If this command is invoked via `\\[ediff-jump-to-difference-at-point]' |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2962 then the point in buffer B is used. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2963 Otherwise, buffer A's point is used." |
7267 | 2964 (interactive) |
2965 (let ((buffer-read-only nil) | |
7424 | 2966 (buf-type (ediff-char-to-buftype last-command-char))) |
7267 | 2967 (ediff-jump-to-difference (ediff-diff-at-point buf-type)))) |
2968 | |
2969 | |
2970 ;; find region "most related to the current point position | |
2971 | |
2972 (defun ediff-diff-at-point (buf-type) | |
7424 | 2973 (let ((buffer (ediff-get-buffer buf-type)) |
7267 | 2974 (ctl-buffer ediff-control-buffer) |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2975 (max-dif-num (1- ediff-number-of-differences)) |
7267 | 2976 (diff-no -1) |
2977 (prev-beg 0) | |
7424 | 2978 (prev-end 0) |
2979 (beg 0) | |
2980 (end 0)) | |
7267 | 2981 |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2982 (ediff-eval-in-buffer |
7267 | 2983 buffer |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2984 (while (and (or (< (point) prev-beg) (> (point) beg)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
2985 (< diff-no max-dif-num)) |
7267 | 2986 (setq diff-no (1+ diff-no)) |
7424 | 2987 (setq prev-beg beg |
2988 prev-end end) | |
2989 (setq beg (ediff-get-diff-posn buf-type 'beg diff-no ctl-buffer) | |
2990 end (ediff-get-diff-posn buf-type 'end diff-no ctl-buffer)) | |
2991 ) | |
7267 | 2992 |
7424 | 2993 (if (< (abs (- (point) prev-end)) |
7267 | 2994 (abs (- (point) beg))) |
2995 diff-no | |
2996 (1+ diff-no)) ;; jump-to-diff works with diff nums higher by 1 | |
2997 ))) | |
2998 | |
2999 ;;; Copying diffs. | |
3000 | |
3001 (defun ediff-diff-to-diff (arg) | |
3002 "Copy buffer-A'th diff to buffer B. | |
3003 If numerical prefix argument, copy this diff specified in the arg. | |
7419 | 3004 Otherwise, copy the difference given by `ediff-current-difference'." |
7267 | 3005 (interactive "P") |
3006 (if arg | |
3007 (ediff-jump-to-difference arg)) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3008 (let* ((key1 (aref (this-command-keys) 0)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3009 (key2 (aref (this-command-keys) 1)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3010 (char1 (if (ediff-if-lucid) (event-key key1) key1)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3011 (char2 (if (ediff-if-lucid) (event-key key2) key2))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3012 (ediff-copy-diff ediff-current-difference |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3013 (ediff-char-to-buftype char1) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3014 (ediff-char-to-buftype char2)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3015 (ediff-recenter 'no-rehighlight))) |
7267 | 3016 |
3017 | |
7424 | 3018 (defun ediff-copy-diff (n from-buf-type to-buf-type) |
3019 "Copy diff N from FROM-BUF-TYPE \(given as 'A or 'B\) to TO-BUF-TYPE." | |
3020 (let* ((to-buf (ediff-get-buffer to-buf-type)) | |
3021 (from-buf (ediff-get-buffer from-buf-type)) | |
7267 | 3022 (ctrl-buf ediff-control-buffer) |
3023 reg-to-copy reg-to-delete | |
3024 reg-to-delete-beg reg-to-delete-end) | |
3025 | |
3026 (ediff-operate-on-flags 'remove) | |
3027 (setq reg-to-delete-beg | |
7424 | 3028 (ediff-get-diff-posn to-buf-type 'beg n ctrl-buf)) |
7267 | 3029 (setq reg-to-delete-end |
7424 | 3030 (ediff-get-diff-posn to-buf-type 'end n ctrl-buf)) |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3031 (setq reg-to-copy (ediff-eval-in-buffer |
7424 | 3032 from-buf |
7267 | 3033 (buffer-substring (ediff-get-diff-posn |
7424 | 3034 from-buf-type 'beg n ctrl-buf) |
7267 | 3035 (ediff-get-diff-posn |
7424 | 3036 from-buf-type 'end n ctrl-buf)))) |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3037 (setq reg-to-delete (ediff-eval-in-buffer |
7424 | 3038 to-buf |
7267 | 3039 (buffer-substring reg-to-delete-beg |
3040 reg-to-delete-end))) | |
3041 (setq ediff-disturbed-overlays nil) ;; clear before use | |
3042 | |
3043 (if (string= reg-to-delete reg-to-copy) | |
3044 (progn | |
3045 (ding) | |
3046 (message | |
7424 | 3047 "Diff regions %d are identical in buffers %S and %S. Nothing copied." |
3048 (1+ n) from-buf-type to-buf-type)) | |
7267 | 3049 |
3050 ;; seems ok to copy | |
7424 | 3051 (if (ediff-test-save-region n to-buf-type) |
7267 | 3052 (condition-case conds |
3053 (let (inhibit-read-only) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3054 (ediff-eval-in-buffer |
7424 | 3055 to-buf |
7267 | 3056 ;; to prevent flags from interfering if buffer is writable |
3057 (setq inhibit-read-only (null buffer-read-only)) | |
3058 (let ((before-change-function nil)) | |
3059 (goto-char reg-to-delete-end) | |
3060 (insert-before-markers reg-to-copy) | |
3061 (if (ediff-if-lucid) | |
3062 (progn | |
3063 (ediff-collect-extents-lucid reg-to-delete-beg) | |
3064 (if (> reg-to-delete-end reg-to-delete-beg) | |
3065 (progn | |
3066 (kill-region reg-to-delete-beg | |
3067 reg-to-delete-end) | |
3068 (if (string= reg-to-copy "") | |
3069 (ediff-adjust-disturbed-extents-lucid | |
3070 reg-to-delete-beg))))) | |
3071 (if (> reg-to-delete-end reg-to-delete-beg) | |
3072 (kill-region reg-to-delete-beg reg-to-delete-end) | |
3073 (ediff-move-disturbed-overlays reg-to-delete-beg))) | |
3074 )) | |
7424 | 3075 (ediff-save-diff-region n to-buf-type reg-to-delete)) |
7267 | 3076 (error (message "%s %s" |
3077 (car conds) | |
3078 (mapconcat 'prin1-to-string (cdr conds) " ")) | |
3079 (beep 1)))) | |
3080 ) | |
3081 (ediff-operate-on-flags 'insert) | |
3082 )) | |
3083 | |
3084 (defun ediff-save-diff-region (n buf-type reg) | |
7419 | 3085 "Save Nth diff of buffer BUF-TYPE \(`A' or `B'\). |
3086 That is to say, the Nth diff on the `ediff-killed-diffs-alist'. REG | |
7424 | 3087 is the region to save. It is redundant here, but is passed anyway, for |
7419 | 3088 convenience." |
7267 | 3089 |
3090 (let* ((n-th-diff-saved (assoc n ediff-killed-diffs-alist)) | |
3091 (this-buf-n-th-diff-saved (assoc buf-type (cdr n-th-diff-saved)))) | |
3092 | |
3093 (if this-buf-n-th-diff-saved | |
3094 ;; either nothing saved for n-th diff and buffer or we OK'ed | |
3095 ;; overriding | |
3096 (setcdr this-buf-n-th-diff-saved reg) | |
3097 (if n-th-diff-saved ;; n-th diff saved, but for another buffer | |
3098 (nconc n-th-diff-saved (list (cons buf-type reg))) | |
3099 (setq ediff-killed-diffs-alist ;; create record for n-th diff | |
3100 (cons (list n (cons buf-type reg)) | |
3101 ediff-killed-diffs-alist)))) | |
7424 | 3102 (message "Saved diff region #%d for buffer %S. To recover hit 'r%s'." |
3103 (1+ n) buf-type | |
3104 (downcase (symbol-name buf-type))))) | |
7267 | 3105 |
3106 (defun ediff-test-save-region (n buf-type) | |
7419 | 3107 "Test if saving Nth difference region of buffer BUF-TYPE is possible." |
7267 | 3108 (let* ((n-th-diff-saved (assoc n ediff-killed-diffs-alist)) |
3109 (this-buf-n-th-diff-saved (assoc buf-type (cdr n-th-diff-saved)))) | |
3110 | |
3111 (if this-buf-n-th-diff-saved | |
3112 (if (yes-or-no-p | |
3113 (format | |
7424 | 3114 "You've previously copied diff region %d to buffer %S. Confirm." |
3115 (1+ n) buf-type)) | |
7267 | 3116 t |
3117 (error "Quit.")) | |
3118 t))) | |
3119 | |
3120 (defun ediff-pop-diff (n buf-type) | |
7419 | 3121 "Pop last killed Nth diff region from buffer BUF-TYPE." |
7267 | 3122 (let* ((n-th-record (assoc n ediff-killed-diffs-alist)) |
3123 (saved-rec (assoc buf-type (cdr n-th-record))) | |
7424 | 3124 (buf (ediff-get-buffer buf-type)) |
7267 | 3125 saved-diff reg-beg reg-end recovered) |
3126 | |
3127 (if (cdr saved-rec) | |
3128 (setq saved-diff (cdr saved-rec)) | |
7424 | 3129 (if (> ediff-number-of-differences 0) |
3130 (error "Nothing saved for diff %d in buffer %S." (1+ n) buf-type) | |
3131 (error "No differences found."))) | |
7267 | 3132 |
3133 (ediff-operate-on-flags 'remove) | |
3134 | |
3135 (setq reg-beg (ediff-get-diff-posn buf-type 'beg n ediff-control-buffer)) | |
3136 (setq reg-end (ediff-get-diff-posn buf-type 'end n ediff-control-buffer)) | |
3137 (setq ediff-disturbed-overlays nil) ;; clear before use | |
3138 | |
3139 (condition-case conds | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3140 (ediff-eval-in-buffer |
7267 | 3141 buf |
3142 (let ((inhibit-read-only (null buffer-read-only)) | |
3143 (before-change-function nil)) | |
3144 (goto-char reg-end) | |
3145 (insert-before-markers saved-diff) | |
3146 | |
3147 (if (ediff-if-lucid) | |
3148 (progn | |
3149 (ediff-collect-extents-lucid reg-beg) | |
3150 (if (> reg-end reg-beg) | |
3151 (progn | |
3152 (kill-region reg-beg reg-end) | |
3153 (if (string= saved-diff "") | |
3154 (ediff-adjust-disturbed-extents-lucid reg-beg))))) | |
3155 (if (> reg-end reg-beg) | |
3156 (kill-region reg-beg reg-end) | |
3157 (ediff-move-disturbed-overlays reg-beg))) | |
3158 | |
3159 (setq recovered t) | |
3160 )) | |
3161 (error (message "%s %s" | |
3162 (car conds) | |
3163 (mapconcat 'prin1-to-string (cdr conds) " ")) | |
3164 (beep 1))) | |
3165 | |
3166 (ediff-operate-on-flags 'insert) | |
3167 (if recovered | |
3168 (progn | |
3169 (setq n-th-record (delq saved-rec n-th-record)) | |
7424 | 3170 (message "Restored diff region %d in buffer %S." (1+ n) buf-type))) |
7267 | 3171 )) |
3172 | |
3173 (defun ediff-restore-diff (arg) | |
7419 | 3174 "Restore ARGth diff from `ediff-killed-diffs-alist'. |
3175 ARG is a prefix argument. If ARG is nil, restore current-difference." | |
7267 | 3176 (interactive "P") |
3177 (if arg | |
3178 (ediff-jump-to-difference arg)) | |
3179 (ediff-pop-diff ediff-current-difference | |
7424 | 3180 (ediff-char-to-buftype last-command-char)) |
7267 | 3181 (ediff-recenter 'no-rehighlight)) |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3182 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3183 (defun ediff-toggle-regexp-match () |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3184 "Focus on difference regions that match a regexp or hide those diffs." |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3185 (interactive) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3186 (let (regexp-A regexp-B) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3187 (cond |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3188 ((or (and (eq ediff-skip-diff-region-function 'ediff-focus-on-regexp-matches) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3189 (eq last-command-char ?f)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3190 (and (eq ediff-skip-diff-region-function 'ediff-hide-regexp-matches) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3191 (eq last-command-char ?h))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3192 (message "Show all difference regions.") |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3193 (setq ediff-skip-diff-region-function 'ediff-show-all-diffs)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3194 ((eq last-command-char ?h) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3195 (setq ediff-skip-diff-region-function 'ediff-hide-regexp-matches |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3196 regexp-A |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3197 (read-string |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3198 (format |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3199 "Ignore A-regions matching this regexp (default \"%s\"): " |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3200 (regexp-quote ediff-regexp-hide-A))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3201 regexp-B |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3202 (read-string |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3203 (format |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3204 "Ignore B-regions matching this regexp (default \"%s\"): " |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3205 (regexp-quote ediff-regexp-hide-B)))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3206 (message "Hide difference regions matching regexp.") |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3207 (or (string= regexp-A "") (setq ediff-regexp-hide-A regexp-A)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3208 (or (string= regexp-B "") (setq ediff-regexp-hide-B regexp-B))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3209 ((eq last-command-char ?f) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3210 (setq ediff-skip-diff-region-function 'ediff-focus-on-regexp-matches |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3211 regexp-A |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3212 (read-string |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3213 (format |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3214 "Focus on A-regions matching this regexp (default \"%s\"): " |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3215 (regexp-quote ediff-regexp-focus-A))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3216 regexp-B |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3217 (read-string |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3218 (format |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3219 "Focus on B-regions matching this regexp (default \"%s\"): " |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3220 (regexp-quote ediff-regexp-focus-B)))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3221 (message "Focus on difference regions matching regexp.") |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3222 (or (string= regexp-A "") (setq ediff-regexp-focus-A regexp-A)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3223 (or (string= regexp-B "") (setq ediff-regexp-focus-B regexp-B)))))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3224 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3225 (defun ediff-show-all-diffs (n) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3226 "Don't skip difference regions." |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3227 nil) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3228 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3229 (defun ediff-focus-on-regexp-matches (n) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3230 "Focus on diffs that match regexp `ediff-regexp-focus-A/B'. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3231 Regions to be ignored according to this function are those where |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3232 buf A region doesn't match `ediff-regexp-focus-A' and buf B region |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3233 doesn't match `ediff-regexp-focus-B'. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3234 This function should return nil for regions not to be ignored and t for |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3235 regions to be ignored." |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3236 (if (and (>= n 0) (< n ediff-number-of-differences)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3237 (let* ((ctl-buf ediff-control-buffer) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3238 (reg-A-match (ediff-eval-in-buffer |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3239 ediff-A-buffer |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3240 (goto-char (ediff-get-diff-posn 'A 'beg n ctl-buf)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3241 (re-search-forward |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3242 ediff-regexp-focus-A |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3243 (ediff-get-diff-posn 'A 'end n ctl-buf) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3244 t))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3245 (reg-B-match (ediff-eval-in-buffer |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3246 ediff-B-buffer |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3247 (goto-char (ediff-get-diff-posn 'B 'beg n ctl-buf)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3248 (re-search-forward |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3249 ediff-regexp-focus-B |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3250 (ediff-get-diff-posn 'B 'end n ctl-buf) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3251 t)))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3252 (not (and reg-A-match reg-B-match))))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3253 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3254 (defun ediff-hide-regexp-matches (n) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3255 "Hide diffs that match regexp `ediff-regexp-hide-A/B'. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3256 Regions to be ignored are those where buf A region matches |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3257 `ediff-regexp-hide-A' and buf B region matches `ediff-regexp-hide-B'. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3258 This function returns nil for regions not to be ignored and t for regions |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3259 to be ignored." |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3260 (if (and (>= n 0) (< n ediff-number-of-differences)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3261 (let* ((ctl-buf ediff-control-buffer) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3262 (reg-A-match (ediff-eval-in-buffer |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3263 ediff-A-buffer |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3264 (goto-char (ediff-get-diff-posn 'A 'beg n ctl-buf)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3265 (re-search-forward |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3266 ediff-regexp-hide-A |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3267 (ediff-get-diff-posn 'A 'end n ctl-buf) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3268 t))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3269 (reg-B-match (ediff-eval-in-buffer |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3270 ediff-B-buffer |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3271 (goto-char (ediff-get-diff-posn 'B 'beg n ctl-buf)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3272 (re-search-forward |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3273 ediff-regexp-hide-B |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3274 (ediff-get-diff-posn 'B 'end n ctl-buf) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3275 t)))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3276 (and reg-A-match reg-B-match)))) |
7267 | 3277 |
3278 | |
3279 ;;; Quitting, suspending, etc. | |
3280 (defun ediff-quit () | |
3281 "Finish an Ediff session and exit Ediff. | |
3282 Unselects the selected difference, if any, restores the read-only and modified | |
3283 flags of the compared file buffers, kills Ediff buffers for this session | |
3284 \(but not file-A and file-B\)." | |
3285 (interactive) | |
3286 (if (prog1 | |
3287 (y-or-n-p "Do you really want to exit Ediff? ") | |
3288 (message "")) | |
3289 (ediff-really-quit))) | |
3290 | |
7424 | 3291 |
7267 | 3292 ;; Perform the quit operations. |
3293 (defun ediff-really-quit () | |
3294 (setq ediff-help-message ediff-help-message-long) | |
3295 (ediff-restore-buffer-characteristics t) ;; restore as they were at setup | |
3296 (ediff-unhighlight-diffs-totally) | |
7424 | 3297 (ediff-clear-diff-vector ediff-difference-vector 'fine-diffs-also) |
3298 (if ediff-temp-file-A (delete-file ediff-temp-file-A)) | |
3299 (if ediff-temp-file-B (delete-file ediff-temp-file-B)) | |
7267 | 3300 |
3301 ;; restore buffer mode line id's in buffer-A/B | |
3302 (let ((control-buffer ediff-control-buffer)) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3303 (condition-case nil |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3304 (ediff-eval-in-buffer |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3305 ediff-A-buffer |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3306 (setq before-change-function nil) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3307 (setq ediff-this-buffer-control-sessions |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3308 (delq control-buffer ediff-this-buffer-control-sessions)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3309 (if (null ediff-this-buffer-control-sessions) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3310 (setq local-write-file-hooks |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3311 (delq 'ediff-block-write-file local-write-file-hooks))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3312 (kill-local-variable 'mode-line-buffer-identification)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3313 (error)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3314 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3315 (condition-case nil |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3316 (ediff-eval-in-buffer |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3317 ediff-B-buffer |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3318 (setq ediff-this-buffer-control-sessions |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3319 (delq control-buffer ediff-this-buffer-control-sessions)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3320 (if (null ediff-this-buffer-control-sessions) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3321 (setq local-write-file-hooks |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3322 (delq 'ediff-block-write-file local-write-file-hooks))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3323 (setq before-change-function nil) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3324 (kill-local-variable 'mode-line-buffer-identification)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3325 (error))) |
7267 | 3326 |
3327 (run-hooks 'ediff-quit-hooks)) | |
3328 | |
3329 (defun ediff-kill-buffer-carefully (buf) | |
3330 "Kill buffer BUF if it exists." | |
3331 (if (ediff-buffer-live-p buf) | |
3332 (kill-buffer (get-buffer buf)))) | |
3333 | |
3334 ;; The default way of quitting Ediff. | |
3335 ;; Kills control buffers and leaves the | |
3336 ;; frame split between the two diff'ed files. | |
3337 (defun ediff-default-quit-hook () | |
3338 (let ((buff-A ediff-A-buffer) | |
3339 (buff-B ediff-B-buffer)) | |
3340 (ediff-kill-buffer-carefully ediff-diff-buffer) | |
7424 | 3341 (ediff-kill-buffer-carefully ediff-tmp-buffer) |
3342 (ediff-kill-buffer-carefully ediff-error-buffer) | |
7267 | 3343 (ediff-kill-buffer-carefully ediff-control-buffer) |
3344 (ediff-kill-buffer-carefully ediff-patch-diagnostics) | |
3345 (delete-other-windows) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3346 ;; display only if not visible |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3347 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3348 (condition-case nil |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3349 (or (get-buffer-window buff-B t) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3350 (switch-to-buffer buff-B)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3351 (error)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3352 (condition-case nil |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3353 (or (get-buffer-window buff-A t) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3354 (progn |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3355 (if (get-buffer-window buff-B) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3356 (split-window-vertically)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3357 (switch-to-buffer buff-A))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3358 (error)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3359 (message "") |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3360 )) |
7267 | 3361 |
3362 ;; The default way of suspending Ediff. | |
3363 ;; Buries Ediff buffers, kills all windows. | |
3364 (defun ediff-default-suspend-hook () | |
3365 (let ((buf-A ediff-A-buffer) | |
3366 (buf-B ediff-B-buffer) | |
3367 (buf-patch ediff-patch-buf) | |
3368 (buf-patch-diag ediff-patch-diagnostics) | |
7424 | 3369 (buf-err ediff-error-buffer) |
7267 | 3370 (buf-diff ediff-diff-buffer)) |
3371 (bury-buffer) ;; ediff-control-buffer | |
3372 (delete-other-windows) | |
3373 (bury-buffer buf-err) | |
3374 (bury-buffer buf-diff) | |
3375 (bury-buffer buf-patch) | |
3376 (bury-buffer buf-patch-diag) | |
3377 (bury-buffer buf-A) | |
3378 (bury-buffer buf-B))) | |
3379 | |
3380 | |
3381 (defun ediff-suspend () | |
7419 | 3382 "Suspend Ediff. |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3383 To resume, switch to the appropriate `Ediff Control Panel' |
7419 | 3384 buffer and then type \\[ediff-recenter]. Ediff will automatically set |
7267 | 3385 up an appropriate window config." |
3386 (interactive) | |
7424 | 3387 (let ((key (substitute-command-keys "\\[ediff-recenter]"))) |
7267 | 3388 (run-hooks 'ediff-suspend-hooks) |
3389 (message | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3390 "To resume Ediff, switch to Ediff Control Panel and hit '%S'" key))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3391 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3392 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3393 (defun ediff-status-info () |
7267 | 3394 "Show the names of the buffers or files being operated on by Ediff. |
7419 | 3395 Hit \\[ediff-recenter] to reset the windows afterward." |
7267 | 3396 (interactive) |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3397 (with-output-to-temp-buffer " *ediff-info*" |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3398 (ediff-eval-in-buffer ediff-A-buffer |
7267 | 3399 (if buffer-file-name |
7424 | 3400 (princ |
3401 (format "File A is: %s\n" buffer-file-name)) | |
3402 (princ | |
3403 (format "Buffer A is: %s\n" (buffer-name))))) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3404 (ediff-eval-in-buffer ediff-B-buffer |
7267 | 3405 (if buffer-file-name |
7424 | 3406 (princ |
3407 (format "File B is: %s\n" buffer-file-name)) | |
3408 (princ | |
3409 (format "Buffer B is: %s\n" (buffer-name))))) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3410 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3411 (let* ((A-line (ediff-eval-in-buffer ediff-A-buffer |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3412 (count-lines (point-min) (point)))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3413 (B-line (ediff-eval-in-buffer ediff-B-buffer |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3414 (count-lines (point-min) (point))))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3415 (princ (format "\nPoint position in buffer A = %d\n" A-line)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3416 (princ (format "Point position in buffer B = %d\n" B-line))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3417 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3418 (princ (format "\nCurrent difference number = %d\n" |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3419 (1+ ediff-current-difference))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3420 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3421 (cond ((eq ediff-skip-diff-region-function 'ediff-show-all-diffs) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3422 (princ "\nSelective browsing is not in effect.\n")) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3423 ((eq ediff-skip-diff-region-function 'ediff-hide-regexp-matches) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3424 (princ |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3425 "\nSelective browsing is in effect. Ignoring diff regions that:") |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3426 (princ |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3427 (format "\n match `%s' in buffer A and `%s' in buffer B\n" |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3428 ediff-regexp-hide-A ediff-regexp-hide-B))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3429 ((eq ediff-skip-diff-region-function 'ediff-focus-on-regexp-matches) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3430 (princ |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3431 "\nSelective browsing is in effect. Focus on diff regions that:") |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3432 (princ |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3433 (format "\n match `%s' in buffer A and `%s' in buffer B\n" |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3434 ediff-regexp-focus-A ediff-regexp-focus-B)))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3435 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3436 (princ "\nBug fixes to: Michael Kifer <kifer@cs.sunysb.edu>\n") |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3437 (princ "Gripes to: /dev/null <dev@null.gov>\n") |
7267 | 3438 )) |
3439 | |
3440 | |
3441 | |
3442 ;;; Support routines | |
3443 | |
3444 ;; Select a difference by placing the ASCII flags around the appropriate | |
3445 ;; group of lines in the A, B buffers | |
3446 (defun ediff-select-difference (n) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3447 (if (and (ediff-buffer-live-p ediff-A-buffer) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3448 (ediff-buffer-live-p ediff-B-buffer) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3449 (>= n 0) (< n ediff-number-of-differences)) |
7267 | 3450 (progn |
3451 (ediff-remember-buffer-characteristics) | |
3452 (if (and window-system ediff-want-faces) | |
3453 (progn | |
3454 (ediff-highlight-diff n) | |
3455 (setq ediff-highlighting-style 'face)) | |
3456 (setq ediff-highlighting-style 'ascii) | |
3457 (ediff-place-flags-in-buffer 'A ediff-A-buffer | |
3458 ediff-control-buffer n) | |
3459 (ediff-place-flags-in-buffer 'B ediff-B-buffer | |
3460 ediff-control-buffer n)) | |
3461 | |
7424 | 3462 (if window-system |
3463 (cond ((eq ediff-auto-refine 'on) | |
3464 (if (and | |
3465 (> ediff-auto-refine-limit | |
3466 (- (ediff-get-diff-posn 'A 'end n) | |
3467 (ediff-get-diff-posn 'A 'beg n))) | |
3468 (> ediff-auto-refine-limit | |
3469 (- (ediff-get-diff-posn 'B 'end n) | |
3470 (ediff-get-diff-posn 'B 'beg n)))) | |
3471 (ediff-make-fine-diffs n 'noforce) | |
3472 (ediff-make-fine-diffs n 'skip))) | |
3473 | |
3474 ((eq ediff-auto-refine 'off) ; highlight iff fine diffs | |
3475 (ediff-make-fine-diffs n 'skip)))) ; already exist | |
3476 | |
7267 | 3477 (ediff-restore-buffer-characteristics) |
3478 (run-hooks 'ediff-select-hooks)))) | |
3479 | |
3480 | |
3481 ;; Unselect a difference by removing the ASCII flags in the buffers. | |
3482 (defun ediff-unselect-difference (n) | |
3483 (if (and (>= n 0) (< n ediff-number-of-differences)) | |
3484 (progn | |
3485 (ediff-remember-buffer-characteristics) | |
3486 | |
3487 (cond ((and window-system ediff-want-faces) | |
3488 (ediff-unhighlight-diff)) | |
3489 ((eq ediff-highlighting-style 'ascii) | |
3490 (ediff-remove-flags-from-buffer | |
3491 ediff-A-buffer | |
3492 (ediff-get-diff-posn 'A 'beg n) | |
3493 (ediff-get-diff-posn 'A 'end n) | |
3494 ediff-before-flag-A ediff-after-flag-A) | |
3495 (ediff-remove-flags-from-buffer | |
3496 ediff-B-buffer | |
3497 (ediff-get-diff-posn 'B 'beg n) | |
3498 (ediff-get-diff-posn 'B 'end n) | |
3499 ediff-before-flag-B ediff-after-flag-B))) | |
3500 | |
3501 (ediff-restore-buffer-characteristics) | |
3502 (setq ediff-highlighting-style nil) | |
7424 | 3503 |
3504 ;; unhighlight fine diffs | |
3505 (if window-system | |
3506 (ediff-set-fine-diff-properties | |
3507 ediff-current-difference 'default)) | |
3508 | |
7267 | 3509 (run-hooks 'ediff-unselect-hooks)))) |
3510 | |
3511 | |
3512 ;; Unselects prev diff and selects a new one, if FLAG has value other than | |
3513 ;; 'select-only or 'unselect-only. If FLAG is 'select-only, the | |
3514 ;; next difference is selected, but the current selection is not | |
3515 ;; unselected. If FLAG is 'unselect-only then the current selection is | |
3516 ;; unselected, but the next one is not selected. If NO-RECENTER is non-nil, | |
3517 ;; don't recenter buffers after selecting/unselecting. | |
3518 ;; | |
7419 | 3519 ;; Don't use `ediff-select-difference' and `ediff-unselect-difference' |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3520 ;; directly, since this will screw up the undo info in the presence of |
7267 | 3521 ;; ASCII flags. |
7419 | 3522 ;; Instead, use `ediff-unselect-and-select-difference' with appropriate |
7267 | 3523 ;; flags. |
3524 | |
3525 (defun ediff-unselect-and-select-difference (n &optional flag no-recenter) | |
7424 | 3526 (let (;; save buf modified info |
3527 (control-buf ediff-control-buffer) | |
7267 | 3528 (buf-A-modified (buffer-modified-p ediff-A-buffer)) |
3529 (buf-B-modified (buffer-modified-p ediff-B-buffer)) | |
3530 ;; temporarily disable undo so highlighting won't confuse the user | |
3531 buf-A-undo buf-B-undo) | |
3532 | |
7424 | 3533 (let ((ediff-current-difference n)) |
3534 (or no-recenter | |
3535 (ediff-recenter 'no-rehighlight))) | |
3536 | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3537 (if (and (ediff-buffer-live-p ediff-A-buffer) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3538 (ediff-buffer-live-p ediff-B-buffer)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3539 (progn |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3540 (ediff-eval-in-buffer |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3541 ediff-A-buffer |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3542 (setq buf-A-undo buffer-undo-list)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3543 (ediff-eval-in-buffer |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3544 ediff-B-buffer |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3545 (setq buf-B-undo buffer-undo-list)) |
7424 | 3546 |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3547 (buffer-disable-undo ediff-A-buffer) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3548 (buffer-disable-undo ediff-B-buffer))) |
7424 | 3549 |
3550 (unwind-protect ;; we don't want to lose undo info due to error | |
3551 (progn | |
3552 (or (eq flag 'select-only) | |
3553 (ediff-unselect-difference ediff-current-difference)) | |
3554 | |
3555 ;; Auto-save buffers while Ediff flags are temporarily removed. | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3556 (ediff-eval-in-buffer |
7424 | 3557 ediff-A-buffer |
3558 (if buf-A-modified | |
3559 (do-auto-save))) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3560 (ediff-eval-in-buffer |
7424 | 3561 ediff-B-buffer |
3562 (if buf-B-modified | |
3563 (do-auto-save))) | |
3564 | |
3565 (or (eq flag 'unselect-only) | |
3566 (ediff-select-difference n)) | |
3567 (setq ediff-current-difference n) | |
3568 ) ;; end protected section | |
3569 | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3570 (ediff-eval-in-buffer |
7424 | 3571 control-buf |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3572 (ediff-refresh-mode-line) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3573 ;; restore undo and buffer-modified info |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3574 (ediff-eval-in-buffer |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3575 ediff-A-buffer |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3576 (set-buffer-modified-p buf-A-modified) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3577 (setq buffer-undo-list buf-A-undo))) |
7424 | 3578 |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3579 (ediff-eval-in-buffer |
7424 | 3580 control-buf |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3581 (ediff-eval-in-buffer |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3582 ediff-B-buffer |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3583 (set-buffer-modified-p buf-B-modified) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3584 (setq buffer-undo-list buf-B-undo))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3585 ))) |
7267 | 3586 |
3587 ;; Revise the mode line to display which difference we have selected | |
3588 | |
3589 (defun ediff-refresh-mode-line () | |
3590 (setq mode-line-buffer-identification | |
7424 | 3591 (cond ((< ediff-current-difference 0) |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3592 (list (format "%%b: At start of %d diffs" |
7424 | 3593 ediff-number-of-differences))) |
3594 ((>= ediff-current-difference ediff-number-of-differences) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3595 (list (format "%%b: At end of %d diffs" |
7424 | 3596 ediff-number-of-differences))) |
3597 (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>
parents:
7709
diff
changeset
|
3598 (list (format "%%b: diff %d of %d" |
7424 | 3599 (1+ ediff-current-difference) |
3600 ediff-number-of-differences))))) | |
7267 | 3601 ;; Force mode-line redisplay |
8348
bf950cbd542c
Made menu bar's autoloaded stuff conditional on
Richard M. Stallman <rms@gnu.org>
parents:
8303
diff
changeset
|
3602 (force-mode-line-update)) |
7267 | 3603 |
3604 | |
3605 | |
3606 ;; Verify that we have a difference selected. | |
3607 (defun ediff-validate-difference () | |
3608 (if (not (and (>= ediff-current-difference 0) | |
3609 (< ediff-current-difference ediff-number-of-differences))) | |
3610 (error "No difference selected"))) | |
3611 | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3612 (defun ediff-read-file-name (prompt default-dir default-file) |
7419 | 3613 ; This is a modified version of a similar function in `emerge.el'. |
7267 | 3614 ; PROMPT should not have trailing ': ', so that it can be modified |
3615 ; according to context. | |
3616 ; If default-file is set, it should be used as the default value. | |
3617 ; If default-dir is non-nil, use it as the default directory. | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3618 ; Otherwise, use the value of Emacs' variable `default-directory.' |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3619 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3620 ;; hack default-dir if it is not set |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3621 (setq default-dir |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3622 (file-name-as-directory |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3623 (abbreviate-file-name |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3624 (expand-file-name (or default-dir |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3625 (and default-file |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3626 (file-name-directory default-file)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3627 default-directory))))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3628 |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3629 ;; strip the directory from default-file |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3630 (if default-file |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3631 (setq default-file (file-name-nondirectory default-file))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3632 |
7424 | 3633 (let (f) |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3634 (setq f (expand-file-name |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3635 (read-file-name |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3636 (format "%s%s: " |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3637 prompt |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3638 (if default-file |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3639 (concat " (default " default-file ")") |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3640 "")) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3641 default-dir |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3642 default-file |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3643 'confirm |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3644 default-file |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3645 ) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3646 default-dir |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3647 )) |
7424 | 3648 ;; If user enters a directory name, expand the default file in that |
3649 ;; directory. This allows the user to enter a directory name for the | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3650 ;; B-file and diff against the default-file in that directory instead |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3651 ;; of a DIRED listing! |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3652 (if (and (file-directory-p f) default-file) |
7424 | 3653 (setq f (expand-file-name |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3654 (file-name-nondirectory default-file) f))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3655 f)) |
7267 | 3656 |
7424 | 3657 ;; If `prefix' is given, then it is used as a prefix for the temp file |
3658 ;; name. Otherwise, `.buffer-name' is used. If `file' is given, use this | |
3659 ;; file and don't create a new one. | |
3660 (defun ediff-make-temp-file (&optional prefix given-file) | |
3661 (let ((f (or given-file | |
3662 (make-temp-name (concat | |
3663 ediff-temp-file-prefix | |
3664 (or prefix | |
3665 (format | |
3666 ".%s" | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3667 "buf"))))))) |
7267 | 3668 ;; create the file |
7424 | 3669 (write-region (point-min) (point-max) f nil 'no-message) |
7267 | 3670 (set-file-modes f ediff-temp-file-mode) |
3671 f)) | |
7424 | 3672 |
3673 ;; Quote metacharacters (using \) when executing diff in Unix, but not in | |
3674 ;; EMX OS/2 | |
3675 (defun ediff-protect-metachars (str) | |
3676 (or (eq system-type 'emx) | |
3677 (let ((limit 0)) | |
3678 (while (string-match emerge-metachars str limit) | |
3679 (setq str (concat (substring str 0 (match-beginning 0)) | |
3680 "\\" | |
3681 (substring str (match-beginning 0)))) | |
3682 (setq limit (1+ (match-end 0)))))) | |
3683 str) | |
3684 | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3685 ;; Make sure the current buffer (for a file) has the same contents as the |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3686 ;; file on disk, and attempt to remedy the situation if not. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3687 ;; Signal an error if we can't make them the same, or the user doesn't want |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3688 ;; to do what is necessary to make them the same. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3689 ;; If file has file handlers (indicated by the optional arg), then we |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3690 ;; offer to instead of saving. This is one difference with Emerge. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3691 ;; Another is that we always offer to revert obsolete files, whether they |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3692 ;; are modified or not. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3693 (defun ediff-verify-file-buffer (&optional file-magic) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3694 ;; First check if the file has been modified since the buffer visited it. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3695 (if (verify-visited-file-modtime (current-buffer)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3696 (if (buffer-modified-p) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3697 ;; If buffer is not obsolete and is modified, offer to save |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3698 (if (yes-or-no-p |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3699 (format "Buffer out of sync with visited file. %s file %s? " |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3700 (if file-magic "Revert" "Save") |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3701 buffer-file-name)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3702 (if (not file-magic) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3703 (save-buffer) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3704 ;; for some reason, file-name-handlers append instead of |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3705 ;; replacing, so we have to erase first. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3706 (erase-buffer) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3707 (revert-buffer t t)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3708 (error "Buffer out of sync for file %s" buffer-file-name)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3709 ;; If buffer is not obsolete and is not modified, do nothing |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3710 nil) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3711 ;; If buffer is obsolete, offer to revert |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3712 (if (yes-or-no-p |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3713 (format "Buffer out of sync with visited file. Revert file %s? " |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3714 buffer-file-name)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3715 (progn |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3716 (if file-magic |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3717 (erase-buffer)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3718 (revert-buffer t t)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3719 (error "Buffer out of sync for file %s" buffer-file-name)))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3720 |
7424 | 3721 |
7267 | 3722 (defun ediff-block-write-file () |
3723 "Prevent writing files A and B directly." | |
3724 (if (ediff-check-for-ascii-flags) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3725 (error "Type 'wa' and 'wb' in Ediff Control Panel to save buffs A/B."))) |
7267 | 3726 |
3727 (defun ediff-check-for-ascii-flags () | |
3728 (eval | |
3729 (cons 'or | |
3730 (mapcar (function (lambda (buf) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3731 (if (ediff-buffer-live-p buf) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3732 (ediff-eval-in-buffer |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3733 buf |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3734 (eq ediff-highlighting-style 'ascii))))) |
7267 | 3735 ediff-this-buffer-control-sessions)))) |
3736 | |
3737 (defun ediff-insert-in-front (overl beg end) | |
3738 "Capture overlays that had insertions in the front. | |
3739 Called when overlay OVERL gets insertion in front." | |
3740 (if (ediff-overlay-get overl 'ediff-diff-num) | |
3741 (setq ediff-disturbed-overlays | |
3742 (cons overl ediff-disturbed-overlays))) | |
3743 ) | |
3744 | |
3745 (defun ediff-collect-extents-lucid (pos) | |
3746 "Collects all extents at POS having property `ediff-diff-num'. | |
3747 Lucid Emacs causes headache by detaching empty extents, so I have to save | |
3748 them before they disappear." | |
3749 (let (lis elt) | |
3750 (while (setq elt (extent-at pos nil 'ediff-diff-num elt)) | |
3751 (setq lis (cons elt lis))) | |
3752 (setq ediff-disturbed-overlays lis))) | |
3753 | |
3754 (defun ediff-move-disturbed-overlays (posn) | |
3755 (mapcar (function (lambda (overl) | |
3756 (ediff-move-overlay overl | |
3757 posn | |
3758 (ediff-overlay-end overl)) | |
3759 )) | |
3760 ediff-disturbed-overlays) | |
3761 (setq ediff-disturbed-overlays nil)) | |
3762 | |
3763 (defun ediff-adjust-disturbed-extents-lucid (posn &optional posn-type) | |
3764 ;; POSN-TYPE tells if POSN should become a new start of the extents | |
3765 ;; (if 'new-start) or a new end (if 'new-end). If POSN-TYPE is nil, then | |
3766 ;; POSN is both the new start and the new end. | |
3767 (mapcar (function (lambda (overl) | |
3768 (cond ((and (null posn-type) | |
3769 (equal (ediff-overlay-start overl) | |
3770 (ediff-overlay-end overl))) | |
3771 (ediff-move-overlay overl posn posn)) | |
3772 | |
3773 (posn-type | |
3774 (ediff-move-overlay | |
3775 overl | |
3776 (if (eq posn-type 'new-start) | |
3777 posn | |
3778 (ediff-overlay-start overl)) | |
3779 (if (eq posn-type 'new-end) | |
3780 posn | |
3781 (ediff-overlay-end overl))))))) | |
3782 ediff-disturbed-overlays) | |
3783 (setq ediff-disturbed-overlays nil)) | |
3784 | |
3785 (defun ediff-save-buffer () | |
3786 "Safe way of saving buffers A and B." | |
3787 (interactive) | |
3788 (let ((hooks local-write-file-hooks)) | |
3789 (ediff-unselect-and-select-difference ediff-current-difference | |
3790 'unselect-only) | |
3791 (unwind-protect | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3792 (ediff-eval-in-buffer |
7267 | 3793 (if (eq last-command-char ?a) ediff-A-buffer ediff-B-buffer) |
3794 ;; temporarily remove writing block | |
3795 (setq hooks (delq 'ediff-block-write-file hooks)) | |
3796 (let ((local-write-file-hooks hooks)) | |
3797 (save-buffer))) | |
3798 (ediff-unselect-and-select-difference ediff-current-difference | |
3799 'select-only) | |
3800 ))) | |
3801 | |
3802 | |
3803 | |
7419 | 3804 ;; Essentially `emerge-remove-flags-in-buffer', modified to allow deletion |
3805 ;; of read-only flags. | |
7267 | 3806 (defun ediff-remove-flags-from-buffer (buffer before-posn after-posn |
3807 before-flag after-flag) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3808 (ediff-eval-in-buffer |
7267 | 3809 buffer |
3810 (let ((buffer-read-only nil) | |
3811 (before-change-function nil) | |
3812 (inhibit-read-only t) | |
3813 (before-flag-length (length before-flag)) | |
3814 (after-flag-length (length after-flag)) | |
3815 ) | |
3816 (goto-char after-posn) | |
3817 (setq after-posn (point-marker)) ;; after-posn is now a marker | |
3818 ;; remove the flags, if they're there | |
3819 (goto-char (- before-posn before-flag-length)) | |
3820 (if (ediff-if-lucid) | |
3821 (ediff-collect-extents-lucid (+ (point) before-flag-length))) | |
3822 (if (looking-at (regexp-quote before-flag)) | |
3823 (delete-region (point) (+ (point) before-flag-length)) | |
3824 ;; the flag isn't there | |
3825 (ding) | |
3826 (message "Trouble removing ASCII flag")) | |
3827 (if (ediff-if-lucid) | |
3828 (ediff-adjust-disturbed-extents-lucid (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>
parents:
7709
diff
changeset
|
3829 |
7267 | 3830 (if (ediff-if-lucid) |
3831 (ediff-collect-extents-lucid (point))) | |
3832 (goto-char after-posn) | |
3833 (if (looking-at (regexp-quote after-flag)) | |
3834 (delete-region (point) (+ (point) after-flag-length)) | |
3835 ;; the flag isn't there | |
3836 (ding) | |
3837 (message "Trouble removing ASCII flag")) | |
3838 (if (ediff-if-lucid) | |
3839 (ediff-adjust-disturbed-extents-lucid (point))) | |
3840 (setq after-posn nil) ;; after has become a marker--garbage-collect | |
3841 ))) | |
3842 | |
3843 | |
7419 | 3844 ;; This is a modified `emerge-place-flags-in-buffer'. |
7267 | 3845 (defun ediff-place-flags-in-buffer (buf-type buffer ctl-buffer difference) |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3846 (ediff-eval-in-buffer |
7267 | 3847 buffer |
3848 (ediff-place-flags-in-buffer1 buf-type ctl-buffer difference))) | |
3849 | |
7419 | 3850 ;; Modified `emerge-place-flags-in-buffer1'. |
7267 | 3851 (defun ediff-place-flags-in-buffer1 (buf-type ctl-buffer difference) |
3852 (let ((buffer-read-only nil) | |
3853 (inhibit-read-only t) | |
3854 (before-change-function nil) | |
3855 (before-flag-name (if (eq buf-type 'A) | |
3856 'ediff-before-flag-A | |
3857 'ediff-before-flag-B)) | |
3858 (after-flag-name (if (eq buf-type 'A) | |
3859 'ediff-after-flag-A | |
3860 'ediff-after-flag-B)) | |
3861 beg-of-line flag) | |
3862 | |
3863 ;; insert the flag before the difference | |
3864 (let ((before (ediff-get-diff-posn buf-type 'beg difference ctl-buffer))) | |
3865 (goto-char before) | |
3866 (setq beg-of-line (bolp)) | |
3867 | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3868 (setq flag (ediff-eval-in-buffer |
7267 | 3869 ctl-buffer |
3870 (if beg-of-line | |
3871 (set before-flag-name ediff-before-flag-bol) | |
3872 (set before-flag-name ediff-before-flag-mol)))) | |
3873 | |
3874 ;; insert the flag itself | |
3875 (if (ediff-if-lucid) | |
3876 (ediff-collect-extents-lucid (point))) | |
3877 (insert-before-markers flag) | |
3878 (if (ediff-if-lucid) | |
3879 ;; Lucid's extent end-points behave strangely; they won't | |
3880 ;; respect insert-before-markers | |
3881 (ediff-adjust-disturbed-extents-lucid (point) 'new-start)) | |
3882 ) | |
3883 ;; insert the flag after the difference | |
3884 (let* ((after (ediff-get-diff-posn buf-type 'end difference ctl-buffer))) | |
3885 (goto-char after) | |
3886 (setq beg-of-line (bolp)) | |
3887 | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3888 (setq flag (ediff-eval-in-buffer |
7267 | 3889 ctl-buffer |
3890 (if beg-of-line | |
3891 (set after-flag-name ediff-after-flag-bol) | |
3892 (set after-flag-name ediff-after-flag-mol)))) | |
3893 | |
3894 ;; insert the flag itself | |
3895 (if (ediff-if-lucid) | |
3896 (ediff-collect-extents-lucid (point))) | |
3897 (insert flag) | |
3898 (if (ediff-if-lucid) | |
3899 (ediff-adjust-disturbed-extents-lucid after 'new-end)) | |
3900 ))) | |
3901 | |
3902 | |
3903 (defun ediff-get-diff-posn (buf-type pos &optional n control-buf) | |
7419 | 3904 "Returns positions of difference sectors in the BUF-TYPE buffer. |
3905 BUF-TYPE should be a symbol--either `A' or `B'. | |
3906 POS is either `beg' or `end'--it specifies whether you want the position at the | |
7424 | 3907 beginning of a difference or at the end. |
7267 | 3908 |
7419 | 3909 The optional argument N says which difference \(default: |
3910 `ediff-current-difference'\). The optional argument CONTROL-BUF says | |
3911 which control buffer is in effect in case it is not the current | |
3912 buffer." | |
7267 | 3913 (let (diff-overlay) |
3914 (or control-buf | |
3915 (setq control-buf (current-buffer))) | |
3916 | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3917 (ediff-eval-in-buffer |
7267 | 3918 control-buf |
3919 (or n (setq n ediff-current-difference)) | |
3920 (if (or (< n 0) (>= n ediff-number-of-differences)) | |
7424 | 3921 (if (> ediff-number-of-differences 0) |
3922 (error "There is no diff %d. Valid diffs are 1 to %d." | |
3923 (1+ n) ediff-number-of-differences) | |
3924 (error "No differences found."))) | |
3925 (setq diff-overlay (ediff-get-diff-overlay n buf-type))) | |
3926 | |
7267 | 3927 (if (ediff-overlay-get diff-overlay 'detached) |
3928 (ediff-move-overlay diff-overlay | |
3929 (ediff-overlay-get diff-overlay 'ediff-marker) | |
3930 (ediff-overlay-get diff-overlay 'ediff-marker))) | |
3931 (if (eq pos 'beg) | |
3932 (ediff-overlay-start diff-overlay) | |
3933 (ediff-overlay-end diff-overlay)) | |
3934 )) | |
3935 | |
3936 | |
3937 | |
3938 ;; These would highlight differences under X | |
3939 (defun ediff-highlight-diff (n) | |
3940 "Put face on diff N. Invoked for X displays only." | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3941 (let* ((last-A (ediff-eval-in-buffer ediff-A-buffer (point-max))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
3942 (last-B (ediff-eval-in-buffer ediff-B-buffer (point-max))) |
7267 | 3943 (begin-A (ediff-get-diff-posn 'A 'beg n)) |
3944 (end-A (ediff-get-diff-posn 'A 'end n)) | |
3945 (xtraA (if (equal begin-A end-A) 1 0)) | |
3946 (end-A-hilit (min last-A (+ end-A xtraA))) | |
3947 | |
3948 (begin-B (ediff-get-diff-posn 'B 'beg n)) | |
3949 (end-B (ediff-get-diff-posn 'B 'end n)) | |
3950 (xtraB (if (equal begin-B end-B) 1 0)) | |
3951 (end-B-hilit (min last-B (+ end-B xtraB)))) | |
3952 | |
3953 (if (ediff-if-lucid) | |
3954 (progn | |
3955 (ediff-move-overlay | |
3956 ediff-current-diff-overlay-A begin-A end-A-hilit) | |
3957 (ediff-move-overlay | |
3958 ediff-current-diff-overlay-B begin-B end-B-hilit)) | |
7391 | 3959 ;; Emacs 19.22 has a bug, which requires that ediff-move-overlay will |
3960 ;; have the buffer as a parameter. Believed fixed in 19.23. | |
7267 | 3961 (ediff-move-overlay ediff-current-diff-overlay-A |
3962 begin-A end-A-hilit ediff-A-buffer) | |
3963 (ediff-move-overlay ediff-current-diff-overlay-B | |
3964 begin-B end-B-hilit ediff-B-buffer)) | |
3965 ;; giving priority of 0 and then changing it may look funny, but | |
3966 ;; this is intended to overcome an Emacs bug. | |
3967 (ediff-overlay-put ediff-current-diff-overlay-A 'priority 0) | |
3968 (ediff-overlay-put ediff-current-diff-overlay-B 'priority 0) | |
3969 (ediff-overlay-put ediff-current-diff-overlay-A 'priority | |
3970 (ediff-highest-priority begin-A end-A-hilit ediff-A-buffer)) | |
3971 (ediff-overlay-put ediff-current-diff-overlay-B 'priority | |
3972 (ediff-highest-priority begin-B end-B-hilit ediff-B-buffer)) | |
3973 | |
7424 | 3974 (or (face-differs-from-default-p 'ediff-odd-diff-face-A-var) |
3975 (not ediff-highlight-all-diffs) | |
7267 | 3976 (progn |
3977 (copy-face ediff-odd-diff-face-A 'ediff-odd-diff-face-A-var) | |
3978 (copy-face ediff-odd-diff-face-B 'ediff-odd-diff-face-B-var) | |
3979 (copy-face ediff-even-diff-face-A 'ediff-even-diff-face-A-var) | |
3980 (copy-face ediff-even-diff-face-B 'ediff-even-diff-face-B-var))) | |
3981 | |
3982 ;; unhighlight the background overlay for the diff n so they won't | |
3983 ;; interfere with the current diff overlay | |
7424 | 3984 (ediff-overlay-put (ediff-get-diff-overlay n 'A) 'face nil) |
3985 (ediff-overlay-put (ediff-get-diff-overlay n 'B) 'face nil) | |
7267 | 3986 |
3987 (sit-for 0) ;; needs to synch for some reason | |
3988 )) | |
3989 | |
3990 | |
3991 (defun ediff-unhighlight-diff () | |
3992 "Remove overlays from buffers A and B." | |
3993 | |
3994 (ediff-move-overlay ediff-current-diff-overlay-A 1 1) | |
3995 (ediff-move-overlay ediff-current-diff-overlay-B 1 1) | |
3996 | |
3997 ;; rehighlight the overlay in the background of the | |
3998 ;; current difference region | |
7424 | 3999 (ediff-overlay-put (ediff-get-diff-overlay ediff-current-difference 'A) |
7267 | 4000 'face (if (ediff-odd-p ediff-current-difference) |
4001 'ediff-odd-diff-face-A-var | |
4002 'ediff-even-diff-face-A-var)) | |
7424 | 4003 (ediff-overlay-put (ediff-get-diff-overlay ediff-current-difference 'B) |
7267 | 4004 'face (if (ediff-odd-p ediff-current-difference) |
4005 'ediff-odd-diff-face-B-var | |
4006 'ediff-even-diff-face-B-var)) | |
4007 ) | |
4008 | |
4009 | |
7424 | 4010 ;; delete highlighting overlays, restore faces to their original form |
7267 | 4011 (defun ediff-unhighlight-diffs-totally () |
7424 | 4012 (setq buffer-read-only nil) |
4013 (ediff-unselect-and-select-difference -1) | |
4014 | |
7267 | 4015 (if (and window-system ediff-want-faces) |
4016 (let ((inhibit-quit t)) | |
4017 (if (face-differs-from-default-p 'ediff-odd-diff-face-A-var) | |
4018 (progn | |
4019 (copy-face 'default 'ediff-odd-diff-face-A-var) | |
4020 (copy-face 'default 'ediff-odd-diff-face-B-var) | |
4021 (copy-face 'default 'ediff-even-diff-face-A-var) | |
4022 (copy-face 'default 'ediff-even-diff-face-B-var))) | |
4023 (if (ediff-overlayp ediff-current-diff-overlay-A) | |
4024 (ediff-delete-overlay ediff-current-diff-overlay-A)) | |
4025 (setq ediff-current-diff-overlay-A nil) | |
4026 (if (ediff-overlayp ediff-current-diff-overlay-B) | |
4027 (ediff-delete-overlay ediff-current-diff-overlay-B)) | |
7424 | 4028 (setq ediff-current-diff-overlay-B nil))) |
4029 ) | |
4030 | |
4031 (defun ediff-clear-diff-vector (vec &optional fin-diffs-also) | |
4032 ;; null out the difference overlays so they won't slow down future | |
4033 ;; editing operations | |
4034 (mapcar (function | |
4035 (lambda (elt) | |
4036 (ediff-delete-overlay (ediff-get-diff-overlay-from-vector elt 'A)) | |
4037 (ediff-delete-overlay (ediff-get-diff-overlay-from-vector elt 'B)) | |
4038 (if fin-diffs-also | |
4039 (ediff-clear-diff-vector | |
4040 (ediff-get-fine-diff-vector-from-vec elt))) | |
4041 )) | |
4042 vec) | |
4043 ;; allow them to be garbage collected | |
4044 (setq vec nil)) | |
7267 | 4045 |
4046 (defun ediff-operate-on-flags (action) | |
7419 | 4047 "Re/unhighlights buffers A and B with all flags from all Ediff sessions. |
4048 This is usually needed only when a | |
7267 | 4049 buffer is involved in multiple Ediff sessions." |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4050 (let* ((A-sessions (ediff-eval-in-buffer |
7267 | 4051 ediff-A-buffer |
4052 ediff-this-buffer-control-sessions)) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4053 (B-sessions (ediff-eval-in-buffer |
7267 | 4054 ediff-B-buffer |
4055 ediff-this-buffer-control-sessions)) | |
4056 (sessions (ediff-union A-sessions B-sessions)) | |
4057 (flag (if (eq action 'remove) 'unselect-only 'select-only))) | |
4058 | |
4059 (mapcar (function (lambda (buf) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4060 (ediff-eval-in-buffer |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4061 buf |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4062 (or (if (eq action 'insert) |
7267 | 4063 (memq ediff-highlighting-style '(ascii off)) |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4064 (not (eq ediff-highlighting-style 'ascii))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4065 (ediff-unselect-and-select-difference |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4066 ediff-current-difference |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4067 flag 'no-recenter)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4068 ))) |
7267 | 4069 sessions))) |
7424 | 4070 |
4071 | |
4072 | |
4073 ;;; Refinement of current diff | |
4074 ;; Split region along word boundaries. Each word will be on its own line. | |
4075 ;; Output to buffer out-buffer. | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4076 (defun ediff-forward-word () |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4077 "Move point one word forward. Used for splitting diff regions into words. |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4078 This is the default for `ediff-forward-word-function'." |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4079 (or (> (skip-chars-forward ediff-word-1) 0) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4080 (> (skip-chars-forward ediff-word-2) 0))) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4081 |
7424 | 4082 (defun ediff-wordify (beg end in-buffer out-buffer) |
4083 (let (sv-point string) | |
4084 (save-excursion | |
4085 (set-buffer in-buffer) | |
4086 (setq string (buffer-substring beg end)) | |
4087 | |
4088 (set-buffer out-buffer) | |
4089 (erase-buffer) | |
4090 (insert string) | |
4091 (goto-char (point-min)) | |
4092 (skip-chars-forward ediff-whitespace) | |
4093 (delete-region (point-min) (point)) | |
7267 | 4094 |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4095 (while (not (eobp)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4096 (funcall ediff-forward-word-function) |
7424 | 4097 (setq sv-point (point)) |
4098 (skip-chars-forward ediff-whitespace) | |
4099 (delete-region sv-point (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>
parents:
7709
diff
changeset
|
4100 (insert "\n"))))) |
7424 | 4101 |
4102 ;; `n' is the diff region to work on. | |
4103 ;; if `flag' is 'noforce then make fine-diffs only if this region's fine | |
4104 ;; diffs have not been computed before. | |
4105 ;; if `flag' is 'skip then don't compute fine diffs for this region. | |
4106 (defun ediff-make-fine-diffs (&optional n flag) | |
4107 (interactive) | |
4108 (if (not window-system) | |
4109 (error "Non-window system.")) | |
4110 (or n (setq n ediff-current-difference)) | |
4111 | |
4112 (if (< ediff-number-of-differences 1) | |
4113 (error "No differences found.")) | |
4114 | |
4115 (let ((file-A ediff-temp-file-A) | |
4116 (file-B ediff-temp-file-B)) | |
4117 | |
4118 (cond ((and (eq flag 'noforce) (ediff-get-fine-diff-vector n)) | |
4119 nil) | |
4120 ((eq flag 'skip) | |
4121 (or (ediff-get-fine-diff-vector n) | |
4122 (eq ediff-auto-refine 'off) | |
4123 (message "Region %d is larger than auto-refine limit. Hit %S to force-refine." | |
4124 (1+ n) | |
4125 (substitute-command-keys "\\[ediff-make-fine-diffs]") | |
4126 ))) | |
4127 (t | |
4128 ;; delete old fine diffs | |
4129 (ediff-clear-diff-vector (ediff-get-fine-diff-vector n)) | |
4130 ;; recompute fine diffs | |
4131 (setq ediff-tmp-buffer (get-buffer-create "*ediff-tmp*")) | |
4132 | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4133 (ediff-wordify |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4134 (ediff-get-diff-posn 'A 'beg n) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4135 (ediff-get-diff-posn 'A 'end n) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4136 ediff-A-buffer |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4137 ediff-tmp-buffer) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4138 (ediff-eval-in-buffer |
7424 | 4139 ediff-tmp-buffer |
4140 (setq file-A (ediff-make-temp-file ".fine-diffs-A" file-A))) | |
4141 | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4142 (ediff-wordify |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4143 (ediff-get-diff-posn 'B 'beg n) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4144 (ediff-get-diff-posn 'B 'end n) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4145 ediff-B-buffer |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4146 ediff-tmp-buffer) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4147 (ediff-eval-in-buffer |
7424 | 4148 ediff-tmp-buffer |
4149 (setq file-B (ediff-make-temp-file ".fine-diffs-B" file-B))) | |
4150 | |
4151 ;; save temp file names. | |
4152 (setq ediff-temp-file-A file-A | |
4153 ediff-temp-file-B file-B) | |
4154 | |
4155 ;; set the new vector of fine diffs, if none exists | |
4156 (ediff-set-fine-diff-vector | |
4157 n | |
4158 (ediff-setup-diff-regions file-A file-B 'use-old-diff-buf n | |
4159 ediff-fine-diff-program | |
4160 ediff-fine-diff-options | |
4161 ediff-fine-diff-ok-lines-regexp)) | |
4162 (if (eq (length (ediff-get-fine-diff-vector n)) 0) | |
4163 (message "No differences found in region %d, except for white space and line breaks." | |
4164 (1+ n)))) | |
4165 ) ;; end cond | |
4166 (ediff-set-fine-diff-properties n) | |
4167 )) | |
4168 | |
4169 | |
4170 (defun ediff-set-fine-diff-properties (n &optional default) | |
4171 (let ((fine-diff-vector (ediff-get-fine-diff-vector n)) | |
4172 (face-A (if default 'default (face-name ediff-fine-diff-face-A))) | |
4173 (face-B (if default 'default (face-name ediff-fine-diff-face-B))) | |
4174 (priority-A (if default | |
4175 0 | |
4176 (1+ (ediff-overlay-get ediff-current-diff-overlay-A | |
4177 'priority)))) | |
4178 (priority-B (if default | |
4179 0 | |
4180 (1+ (ediff-overlay-get ediff-current-diff-overlay-B | |
4181 'priority))))) | |
4182 (mapcar | |
4183 (function (lambda (vec) | |
4184 (ediff-overlay-put | |
4185 (ediff-get-diff-overlay-from-vector vec 'A) | |
4186 'face face-A) | |
4187 (ediff-overlay-put | |
4188 (ediff-get-diff-overlay-from-vector vec 'A) | |
4189 'priority priority-A) | |
4190 | |
4191 (ediff-overlay-put | |
4192 (ediff-get-diff-overlay-from-vector vec 'B) | |
4193 'face face-B) | |
4194 (ediff-overlay-put | |
4195 (ediff-get-diff-overlay-from-vector vec 'B) | |
4196 'priority priority-B) | |
4197 )) | |
4198 fine-diff-vector) | |
4199 )) | |
4200 | |
4201 (defun ediff-convert-diffs-to-overlays-refine (A-buffer B-buffer | |
4202 diff-list refine-region) | |
4203 (let* ((current-diff -1) | |
4204 (reg-A-start (ediff-get-diff-posn 'A 'beg refine-region)) | |
4205 (reg-B-start (ediff-get-diff-posn 'B 'beg refine-region)) | |
4206 diff-overlay-list list-element | |
4207 a-begin a-end b-begin b-end | |
4208 a-overlay b-overlay) | |
4209 | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4210 (ediff-eval-in-buffer A-buffer (goto-char reg-A-start)) |
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4211 (ediff-eval-in-buffer B-buffer (goto-char reg-B-start)) |
7424 | 4212 |
4213 (while diff-list | |
4214 (setq current-diff (1+ current-diff) | |
4215 list-element (car diff-list) | |
4216 a-begin (aref list-element 0) | |
4217 a-end (aref list-element 1) | |
4218 b-begin (aref list-element 2) | |
4219 b-end (aref list-element 3)) | |
4220 | |
4221 ;; place overlays at the appropriate places in the buffers | |
4222 (setq a-overlay (ediff-make-overlay | |
4223 (ediff-goto-word (1+ a-begin) A-buffer) | |
4224 (ediff-goto-word a-end A-buffer 'end) | |
4225 A-buffer)) | |
4226 | |
4227 (setq b-overlay (ediff-make-overlay | |
4228 (ediff-goto-word (1+ b-begin) B-buffer) | |
4229 (ediff-goto-word b-end B-buffer 'end) | |
4230 B-buffer)) | |
4231 | |
4232 ;; record all overlays for this difference | |
4233 (setq diff-overlay-list (nconc diff-overlay-list | |
4234 (list (vector a-overlay b-overlay))) | |
4235 diff-list (cdr diff-list)) | |
4236 ) ;; while | |
4237 ;; convert the list of difference information into a vector for | |
4238 ;; fast access | |
4239 (apply 'vector diff-overlay-list))) | |
4240 | |
4241 ;; goto word #n starting at current position in buffer `buf' | |
4242 ;; For ediff, a word is either a string of a-z,A-Z, incl `-' and `_'; | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4243 ;; or a string of other non-blanks. A blank is a \n\t\C-j |
7424 | 4244 ;; If `flag' is non-nil, goto the end of the n-th word. |
4245 (defun ediff-goto-word (n buf &optional flag) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4246 (ediff-eval-in-buffer |
7424 | 4247 buf |
4248 (skip-chars-forward ediff-whitespace) | |
4249 (while (> n 1) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4250 (funcall ediff-forward-word-function) |
7424 | 4251 (skip-chars-forward ediff-whitespace) |
4252 (setq n (1- n))) | |
4253 ;(if flag | |
4254 (if (and flag (> n 0)) | |
8303
33ef3e3234dd
(Emacs 19 menu setup): Move back to top level and do it only if purify-flag.
Richard M. Stallman <rms@gnu.org>
parents:
7709
diff
changeset
|
4255 (funcall ediff-forward-word-function)) |
7424 | 4256 (point))) |
4257 | |
4258 | |
4259 | |
4260 | |
4261 | |
4262 ;;; Misc | |
4263 | |
7267 | 4264 (defun ediff-union (list1 list2) |
4265 "Combine LIST1 and LIST2 using a set-union operation. | |
4266 The result list contains all items that appear in either LIST1 or LIST2. | |
4267 This is a non-destructive function; it makes a copy of the data if necessary | |
4268 to avoid corrupting the original LIST1 and LIST2. | |
7419 | 4269 This is a slightly simplified version from `cl-seq.el'. Added here to |
7267 | 4270 avoid loading cl-*." |
4271 (cond ((null list1) list2) ((null list2) list1) | |
4272 ((equal list1 list2) list1) | |
4273 (t | |
4274 (or (>= (length list1) (length list2)) | |
4275 (setq list1 (prog1 list2 (setq list2 list1)))) | |
4276 (while list2 | |
4277 (or (memq (car list2) list1) | |
4278 (setq list1 (cons (car list2) list1))) | |
4279 (setq list2 (cdr list2))) | |
4280 list1))) | |
7424 | 4281 |
4282 ;(defun ediff-debug () | |
4283 ; (interactive) | |
4284 ; (with-output-to-temp-buffer "*ediff-debug*" | |
4285 ; (princ | |
4286 ; (format "Ctl buffer: %S\n\nediff-difference-vector:\n" | |
4287 ; ediff-control-buffer)) | |
4288 ; (mapcar (function | |
4289 ; (lambda (overl-vec) | |
4290 ; (princ (format "Diff %d: %S %S %S\n\t %S %S %S\n" | |
4291 ; (1+ (ediff-overlay-get (aref overl-vec 0) | |
4292 ; 'ediff-diff-num)) | |
4293 ; (ediff-overlay-get (aref overl-vec 0) | |
4294 ; 'ediff-control-buffer) | |
4295 ; (ediff-overlay-get (aref overl-vec 0) | |
4296 ; 'insert-in-front-hooks) | |
4297 ; (aref overl-vec 0) | |
4298 ; (ediff-overlay-get (aref overl-vec 1) | |
4299 ; 'ediff-control-buffer) | |
4300 ; (ediff-overlay-get (aref overl-vec 0) | |
4301 ; 'insert-in-front-hooks) | |
4302 ; (aref overl-vec 1) | |
4303 ; )))) | |
4304 ; ediff-difference-vector) | |
4305 ; (princ "\nediff-disturbed-overlays:\n") | |
4306 ; (mapcar (function | |
4307 ; (lambda (overl) | |
4308 ; (princ (format "%S %S\n" | |
4309 ; (ediff-overlay-get overl 'ediff-control-buffer) | |
4310 ; overl | |
4311 ; )))) | |
4312 ; ediff-disturbed-overlays))) | |
7267 | 4313 |
4314 | |
4315 (run-hooks 'ediff-load-hooks) | |
4316 | |
4317 | |
4318 (provide 'ediff) | |
4319 | |
4320 ;;; ediff.el ends here |