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