Mercurial > emacs
annotate lisp/ediff-util.el @ 12410:1c02a5b45ae7
(echo_area_display): Don't set FRAME_CURSOR_... here.
(redisplay): In the "point hasn't moved" shortcut,
make sure that the cursor is in the right window already.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 28 Jun 1995 09:39:00 +0000 |
parents | 589a32fa67a9 |
children | 3999c7e35227 |
rev | line source |
---|---|
11042 | 1 ;;; ediff-util.el --- the core commands and utilities of ediff |
11234 | 2 ;;; Copyright (C) 1994, 1995 Free Software Foundation, Inc. |
11042 | 3 |
4 ;; Author: Michael Kifer <kifer@cs.sunysb.edu> | |
5 | |
6 ;; This file is part of GNU Emacs. | |
7 | |
8 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
9 ;; it under the terms of the GNU General Public License as published by | |
10 ;; the Free Software Foundation; either version 2, or (at your option) | |
11 ;; any later version. | |
12 | |
13 ;; GNU Emacs is distributed in the hope that it will be useful, | |
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 ;; GNU General Public License for more details. | |
17 | |
18 ;; You should have received a copy of the GNU General Public License | |
19 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
20 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
21 | |
22 | |
23 ;;; Code: | |
24 | |
25 (require 'ediff-init) | |
26 | |
27 | |
28 ;;; Functions | |
29 | |
30 (defun ediff-mode () | |
31 "Ediff mode is used by the Ediff file-difference package. | |
32 It is entered only through one of the following commands: | |
33 `ediff' | |
34 `ediff-files' | |
35 `ediff-buffers' | |
36 `ediff3' | |
37 `ediff-files3' | |
38 `ediff-buffers3' | |
39 `ediff-merge' | |
40 `ediff-merge-files' | |
41 `ediff-merge-files-with-ancestor' | |
42 `ediff-merge-buffers' | |
43 `ediff-merge-buffers-with-ancestor' | |
44 `ediff-merge-revisions' | |
45 `ediff-merge-revisions-with-ancestor' | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
46 `ediff-windows-wordwise' |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
47 `ediff-windows-linewise' |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
48 `ediff-regions-wordwise' |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
49 `ediff-regions-linewise' |
11042 | 50 `epatch' |
51 `ediff-patch-file' | |
52 `ediff-patch-buffer' | |
53 `epatch-buffer' | |
54 `ediff-revision' | |
55 | |
56 Commands: | |
57 \\{ediff-mode-map}" | |
58 (kill-all-local-variables) | |
59 (setq major-mode 'ediff-mode) | |
60 (setq mode-name "Ediff") | |
61 (run-hooks 'ediff-mode-hooks)) | |
62 | |
63 (defun ediff-version () | |
64 "Return string describing the version of Ediff. | |
65 When called interactively, displays the version." | |
66 (interactive) | |
67 (if (interactive-p) | |
68 (message (ediff-version)) | |
69 (format "Ediff %s of %s" ediff-version ediff-date))) | |
70 | |
71 | |
72 (require 'ediff-diff) | |
73 (require 'ediff-merg) | |
74 | |
75 | |
76 ;;; Build keymaps | |
77 | |
78 (ediff-defvar-local ediff-mode-map nil | |
79 "Local keymap used in Ediff mode. | |
80 This is local to each Ediff Control Panel, so they may vary from invocation | |
81 to invocation.") | |
82 | |
83 ;; Set up the keymap in the control buffer | |
84 (defun ediff-set-keys () | |
85 "Set up Ediff keymap, if necessary." | |
86 (if (null ediff-mode-map) | |
87 (ediff-setup-keymap)) | |
88 (use-local-map ediff-mode-map)) | |
89 | |
90 ;; Reload Ediff keymap. For debugging only. | |
91 (defun ediff-reload-keymap () | |
92 (interactive) | |
93 (setq ediff-mode-map nil) | |
94 (ediff-set-keys)) | |
95 | |
96 | |
97 (defun ediff-setup-keymap () | |
98 "Set up the keymap used in the control buffer of Ediff." | |
99 (setq ediff-mode-map (make-sparse-keymap)) | |
100 (suppress-keymap ediff-mode-map) | |
101 | |
102 (define-key ediff-mode-map "p" 'ediff-previous-difference) | |
103 (define-key ediff-mode-map "\C-?" 'ediff-previous-difference) | |
104 (define-key ediff-mode-map [backspace] 'ediff-previous-difference) | |
105 (define-key ediff-mode-map [delete] 'ediff-previous-difference) | |
106 (define-key ediff-mode-map "\C-h" (if ediff-no-emacs-help-in-control-buffer | |
107 'ediff-previous-difference nil)) | |
108 (define-key ediff-mode-map "n" 'ediff-next-difference) | |
109 (define-key ediff-mode-map " " 'ediff-next-difference) | |
110 (define-key ediff-mode-map "j" 'ediff-jump-to-difference) | |
111 (define-key ediff-mode-map "g" nil) | |
112 (define-key ediff-mode-map "ga" 'ediff-jump-to-difference-at-point) | |
113 (define-key ediff-mode-map "gb" 'ediff-jump-to-difference-at-point) | |
114 (define-key ediff-mode-map "q" 'ediff-quit) | |
115 (define-key ediff-mode-map "z" 'ediff-suspend) | |
116 (define-key ediff-mode-map "\C-l" 'ediff-recenter) | |
117 (define-key ediff-mode-map "|" 'ediff-toggle-split) | |
118 (define-key ediff-mode-map "h" 'ediff-toggle-hilit) | |
119 (or ediff-word-mode | |
120 (define-key ediff-mode-map "@" 'ediff-toggle-autorefine)) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
121 (if ediff-narrow-job |
11042 | 122 (define-key ediff-mode-map "%" 'ediff-toggle-narrow-region)) |
123 (define-key ediff-mode-map "~" 'ediff-swap-buffers) | |
124 (define-key ediff-mode-map "v" 'ediff-scroll-vertically) | |
125 (define-key ediff-mode-map "\C-v" 'ediff-scroll-vertically) | |
126 (define-key ediff-mode-map "^" 'ediff-scroll-vertically) | |
127 (define-key ediff-mode-map "\M-v" 'ediff-scroll-vertically) | |
128 (define-key ediff-mode-map "V" 'ediff-scroll-vertically) | |
129 (define-key ediff-mode-map "<" 'ediff-scroll-horizontally) | |
130 (define-key ediff-mode-map ">" 'ediff-scroll-horizontally) | |
131 (define-key ediff-mode-map "i" 'ediff-status-info) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
132 (define-key ediff-mode-map "D" 'ediff-documentation) |
11042 | 133 (define-key ediff-mode-map "?" 'ediff-toggle-help) |
134 (define-key ediff-mode-map "!" 'ediff-update-diffs) | |
135 (or ediff-word-mode | |
136 (define-key ediff-mode-map "*" 'ediff-make-or-kill-fine-diffs)) | |
137 (define-key ediff-mode-map "a" nil) | |
138 (define-key ediff-mode-map "b" nil) | |
139 (define-key ediff-mode-map "r" nil) | |
140 (cond (ediff-merge-job | |
141 ;; In merging, we allow only A->C and B->C copying. | |
142 (define-key ediff-mode-map "a" (function | |
143 (lambda (arg) | |
144 (interactive "P") | |
145 (ediff-diff-to-diff arg "ac")))) | |
146 (define-key ediff-mode-map "b" (function | |
147 (lambda (arg) | |
148 (interactive "P") | |
149 (ediff-diff-to-diff arg "bc")))) | |
150 (define-key ediff-mode-map "r" (function | |
151 (lambda (arg) | |
152 (interactive "P") | |
153 (ediff-restore-diff arg ?c)))) | |
154 (define-key ediff-mode-map "s" 'ediff-shrink-window-C) | |
155 (define-key ediff-mode-map "+" 'ediff-combine-diffs) | |
156 (define-key ediff-mode-map "$" 'ediff-toggle-show-clashes-only) | |
157 (define-key ediff-mode-map "&" 'ediff-re-merge)) | |
158 (ediff-3way-comparison-job | |
159 (define-key ediff-mode-map "ab" 'ediff-diff-to-diff) | |
160 (define-key ediff-mode-map "ba" 'ediff-diff-to-diff) | |
161 (define-key ediff-mode-map "ac" 'ediff-diff-to-diff) | |
162 (define-key ediff-mode-map "bc" 'ediff-diff-to-diff) | |
163 (define-key ediff-mode-map "c" nil) | |
164 (define-key ediff-mode-map "ca" 'ediff-diff-to-diff) | |
165 (define-key ediff-mode-map "cb" 'ediff-diff-to-diff) | |
166 (define-key ediff-mode-map "ra" 'ediff-restore-diff) | |
167 (define-key ediff-mode-map "rb" 'ediff-restore-diff) | |
168 (define-key ediff-mode-map "rc" 'ediff-restore-diff) | |
169 (define-key ediff-mode-map "C" 'ediff-toggle-read-only)) | |
170 (t ; 2-way comparison | |
171 (define-key ediff-mode-map "a" (function | |
172 (lambda (arg) | |
173 (interactive "P") | |
174 (ediff-diff-to-diff arg "ab")))) | |
175 (define-key ediff-mode-map "b" (function | |
176 (lambda (arg) | |
177 (interactive "P") | |
178 (ediff-diff-to-diff arg "ba")))) | |
179 (define-key ediff-mode-map "ra" 'ediff-restore-diff) | |
180 (define-key ediff-mode-map "rb" 'ediff-restore-diff)) | |
181 ) ; cond | |
182 (define-key ediff-mode-map "G" 'ediff-submit-report) | |
183 (define-key ediff-mode-map "#" nil) | |
184 (define-key ediff-mode-map "#h" 'ediff-toggle-regexp-match) | |
185 (define-key ediff-mode-map "#f" 'ediff-toggle-regexp-match) | |
186 (or ediff-word-mode | |
187 (define-key ediff-mode-map "##" 'ediff-toggle-skip-similar)) | |
188 (define-key ediff-mode-map "o" nil) | |
189 (define-key ediff-mode-map "A" 'ediff-toggle-read-only) | |
190 (define-key ediff-mode-map "B" 'ediff-toggle-read-only) | |
191 (define-key ediff-mode-map "w" nil) | |
192 (define-key ediff-mode-map "wa" 'ediff-save-buffer) | |
193 (define-key ediff-mode-map "wb" 'ediff-save-buffer) | |
194 (define-key ediff-mode-map "wd" 'ediff-save-buffer) | |
195 (if ediff-3way-job | |
196 (progn | |
197 (define-key ediff-mode-map "wc" 'ediff-save-buffer) | |
198 (define-key ediff-mode-map "gc" 'ediff-jump-to-difference-at-point) | |
199 )) | |
200 | |
201 (define-key ediff-mode-map "m" 'ediff-toggle-wide-display) | |
202 | |
203 (define-key ediff-mode-map "k" nil) | |
204 (define-key ediff-mode-map "kkk" 'ediff-reload-keymap) ; for debugging | |
205 | |
206 ;; Allow ediff-mode-map to be referenced indirectly | |
207 (fset 'ediff-mode-map ediff-mode-map) | |
208 (run-hooks 'ediff-keymap-setup-hooks)) | |
209 | |
210 | |
211 ;;; Setup functions | |
212 | |
213 (require 'ediff-wind) | |
214 | |
215 ;; Common startup entry for all Ediff functions | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
216 ;; It now returns control buffer so other functions can do post-processing |
11042 | 217 (defun ediff-setup (buffer-A file-A buffer-B file-B buffer-C file-C |
218 startup-hooks setup-parameters) | |
219 (setq file-A (expand-file-name file-A)) | |
220 (setq file-B (expand-file-name file-B)) | |
221 (if (stringp file-C) | |
222 (setq file-C (expand-file-name file-C))) | |
223 (let* ((control-buffer-name | |
224 (ediff-unique-buffer-name "*Ediff Control Panel" "*")) | |
225 (control-buffer (ediff-eval-in-buffer buffer-A | |
226 (get-buffer-create control-buffer-name)))) | |
227 (ediff-eval-in-buffer control-buffer | |
228 (ediff-mode) | |
229 | |
230 ;; unwrap set up parameters passed as argument | |
231 (while setup-parameters | |
232 (set (car (car setup-parameters)) (cdr (car setup-parameters))) | |
233 (setq setup-parameters (cdr setup-parameters))) | |
234 | |
235 ;; set variables classifying the current ediff job | |
236 (setq ediff-3way-comparison-job (ediff-3way-comparison-job) | |
237 ediff-merge-job (ediff-merge-job) | |
238 ediff-merge-with-ancestor-job (ediff-merge-with-ancestor-job) | |
239 ediff-3way-job (ediff-3way-job) | |
240 ediff-diff3-job (ediff-diff3-job) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
241 ediff-narrow-job (ediff-narrow-job) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
242 ediff-windows-job (ediff-windows-job) |
11042 | 243 ediff-word-mode-job (ediff-word-mode-job)) |
244 | |
245 (make-local-variable 'ediff-prefer-long-help-message) | |
246 (make-local-variable 'ediff-prefer-iconified-control-frame) | |
247 (make-local-variable 'ediff-split-window-function) | |
248 (make-local-variable 'ediff-default-variant) | |
249 (make-local-variable 'ediff-merge-window-share) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
250 (make-local-variable 'ediff-window-setup-function) |
11042 | 251 |
252 ;; adjust for merge jobs | |
253 (if ediff-merge-job | |
254 (let ((buf | |
255 ;; Use buf A even if `combined'. The right stuff is | |
256 ;; inserted by ediff-do-merge | |
257 (if (eq ediff-default-variant 'default-B) buffer-B buffer-A))) | |
258 | |
259 (setq ediff-split-window-function | |
260 ediff-merge-split-window-function) | |
261 | |
262 ;; remember the ancestor buffer, if any | |
263 (setq ediff-ancestor-buffer buffer-C) | |
264 | |
265 (setq buffer-C | |
266 (get-buffer-create | |
267 (ediff-unique-buffer-name "*ediff-merge" "*"))) | |
268 (save-excursion | |
269 (set-buffer buffer-C) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
270 (insert-buffer buf) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
271 (funcall (ediff-eval-in-buffer buf major-mode)) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
272 ;; after Stig@hackvan.com |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
273 (add-hook 'local-write-file-hooks 'ediff-set-merge-mode) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
274 ))) |
11042 | 275 (setq buffer-read-only nil |
276 ediff-buffer-A buffer-A | |
277 ediff-buffer-B buffer-B | |
278 ediff-buffer-C buffer-C | |
279 ediff-control-buffer control-buffer) | |
280 | |
281 (setq ediff-control-buffer-suffix | |
282 (if (string-match "<[0-9]*>" control-buffer-name) | |
283 (substring control-buffer-name | |
284 (match-beginning 0) (match-end 0)) | |
285 "") | |
286 ediff-control-buffer-number | |
287 (max | |
288 0 | |
289 (1- | |
290 (string-to-number | |
291 (substring | |
292 ediff-control-buffer-suffix | |
293 (or | |
294 (string-match "[0-9]+" ediff-control-buffer-suffix) | |
295 0)))))) | |
296 | |
297 (setq ediff-error-buffer (get-buffer-create (ediff-unique-buffer-name | |
298 "*ediff-errors" "*"))) | |
299 | |
300 (ediff-eval-in-buffer buffer-A (ediff-strip-mode-line-format)) | |
301 (ediff-eval-in-buffer buffer-B (ediff-strip-mode-line-format)) | |
302 (if ediff-3way-job | |
303 (ediff-eval-in-buffer buffer-C (ediff-strip-mode-line-format))) | |
304 | |
305 (ediff-save-protected-variables) ; save variables to be restored on exit | |
306 | |
307 ;; ediff-setup-diff-regions-function must be set after setup | |
308 ;; parameters are processed. | |
309 (setq ediff-setup-diff-regions-function | |
310 (if ediff-diff3-job | |
311 'ediff-setup-diff-regions3 | |
312 'ediff-setup-diff-regions)) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
313 |
11042 | 314 (setq ediff-wide-bounds |
315 (list (ediff-make-bullet-proof-overlay | |
316 '(point-min) '(point-max) ediff-buffer-A) | |
317 (ediff-make-bullet-proof-overlay | |
318 '(point-min) '(point-max) ediff-buffer-B) | |
319 (ediff-make-bullet-proof-overlay | |
320 '(point-min) '(point-max) ediff-buffer-C))) | |
321 | |
322 ;; This has effect only on ediff-windows/regions | |
323 ;; In all other cases, ediff-visible-region sets visibility bounds to | |
324 ;; ediff-wide-bounds, and ediff-narrow-bounds are ignored. | |
325 (if ediff-start-narrowed | |
326 (setq ediff-visible-bounds ediff-narrow-bounds) | |
327 (setq ediff-visible-bounds ediff-wide-bounds)) | |
328 | |
329 (ediff-set-keys) ; comes after parameter setup | |
330 | |
331 ;; set up ediff-narrow-bounds, if not set | |
332 (or ediff-narrow-bounds | |
333 (setq ediff-narrow-bounds ediff-wide-bounds)) | |
334 | |
335 ;; All these must be inside ediff-eval-in-buffer control-buffer, | |
336 ;; since these vars are local to control-buffer | |
337 ;; These won't run if there are errors in diff | |
338 (ediff-eval-in-buffer ediff-buffer-A | |
339 (ediff-nuke-selective-display) | |
340 (run-hooks 'ediff-prepare-buffer-hooks) | |
341 (if (ediff-eval-in-buffer control-buffer ediff-merge-job) | |
342 (setq buffer-read-only t)) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
343 ;; add control-buffer to the list of sessions--no longer used, but may |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
344 ;; be used again in the future |
11042 | 345 (or (memq control-buffer ediff-this-buffer-control-sessions) |
346 (setq ediff-this-buffer-control-sessions | |
347 (cons control-buffer ediff-this-buffer-control-sessions))) | |
348 ) | |
349 (ediff-eval-in-buffer ediff-buffer-B | |
350 (ediff-nuke-selective-display) | |
351 (run-hooks 'ediff-prepare-buffer-hooks) | |
352 (if (ediff-eval-in-buffer control-buffer ediff-merge-job) | |
353 (setq buffer-read-only t)) | |
354 ;; add control-buffer to the list of sessions | |
355 (or (memq control-buffer ediff-this-buffer-control-sessions) | |
356 (setq ediff-this-buffer-control-sessions | |
357 (cons control-buffer ediff-this-buffer-control-sessions))) | |
358 ) | |
359 (if ediff-3way-job | |
360 (ediff-eval-in-buffer ediff-buffer-C | |
361 (ediff-nuke-selective-display) | |
362 (run-hooks 'ediff-prepare-buffer-hooks) | |
363 ;; add control-buffer to the list of sessions | |
364 (or (memq control-buffer ediff-this-buffer-control-sessions) | |
365 (setq ediff-this-buffer-control-sessions | |
366 (cons control-buffer | |
367 ediff-this-buffer-control-sessions))) | |
368 )) | |
369 | |
370 ;; must come after setting up ediff-narrow-bounds AND after | |
371 ;; nuking selective display | |
372 (funcall ediff-setup-diff-regions-function file-A file-B file-C) | |
373 (setq ediff-number-of-differences (length ediff-difference-vector-A)) | |
374 (setq ediff-current-difference -1) | |
375 | |
376 (ediff-make-current-diff-overlay 'A) | |
377 (ediff-make-current-diff-overlay 'B) | |
378 (if ediff-3way-job | |
379 (ediff-make-current-diff-overlay 'C)) | |
380 | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
381 (if (ediff-window-display-p) |
11042 | 382 (ediff-init-var-faces)) |
383 | |
384 (ediff-setup-windows buffer-A buffer-B buffer-C control-buffer) | |
385 | |
386 (let ((shift-A (ediff-overlay-start | |
387 (ediff-get-value-according-to-buffer-type | |
388 'A ediff-narrow-bounds))) | |
389 (shift-B (ediff-overlay-start | |
390 (ediff-get-value-according-to-buffer-type | |
391 'B ediff-narrow-bounds))) | |
392 (shift-C (ediff-overlay-start | |
393 (ediff-get-value-according-to-buffer-type | |
394 'C ediff-narrow-bounds)))) | |
395 ;; position point in buf A | |
396 (save-excursion | |
397 (select-window ediff-window-A) | |
398 (goto-char shift-A)) | |
399 ;; position point in buf B | |
400 (save-excursion | |
401 (select-window ediff-window-B) | |
402 (goto-char shift-B)) | |
403 (if ediff-3way-job | |
404 (save-excursion | |
405 (select-window ediff-window-C) | |
406 (goto-char shift-C))) | |
407 ) | |
408 | |
409 (select-window ediff-control-window) | |
410 (ediff-visible-region) | |
411 | |
412 ;; The following is a hack to placate OS/2 | |
413 ;; The problem is that OS/2 doesn't let us delete files used by other | |
414 ;; processes. Thus, in ediff-buffers and other functions, we can't | |
415 ;; delete temp files because they might be used by the asynchronous | |
416 ;; process that computes custom diffs. So, under OS/1 we have to wait | |
417 ;; for some time until custom diffs are done. | |
418 (if (eq system-type 'emx) | |
419 (ediff-eval-in-buffer ediff-custom-diff-buffer | |
420 (let ((proc (get-buffer-process (current-buffer)))) | |
421 (while (and (processp proc) | |
422 (eq (process-status proc) 'run)) | |
423 (message "Waiting for the diff program to quit") | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
424 (sleep-for 1)) |
11042 | 425 (message "") |
426 ))) | |
427 | |
428 (run-hooks 'startup-hooks 'ediff-startup-hooks) | |
429 (ediff-refresh-mode-lines) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
430 (setq buffer-read-only t)) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
431 control-buffer)) |
11042 | 432 |
433 | |
434 ;; This function assumes that we are in the window where control buffer is | |
435 ;; to reside. | |
436 (defun ediff-setup-control-buffer (ctl-buf) | |
437 "Set up window for control buffer." | |
438 (if (window-dedicated-p (selected-window)) | |
439 (set-buffer ctl-buf) ; we are in control frame but just in case | |
440 (switch-to-buffer ctl-buf)) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
441 (let ((window-min-height 2)) |
11042 | 442 (erase-buffer) |
443 (ediff-set-help-message) | |
444 (insert ediff-help-message) | |
445 (shrink-window-if-larger-than-buffer) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
446 (or (ediff-multiframe-setup-p) |
11042 | 447 (ediff-indent-help-message)) |
448 (set-buffer-modified-p nil) | |
449 (ediff-refresh-mode-lines) | |
450 (setq ediff-control-window (selected-window)) | |
451 (setq ediff-window-config-saved | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
452 (format "%S%S%S%S%S%S%S" |
11042 | 453 ediff-control-window |
454 ediff-window-A | |
455 ediff-window-B | |
456 ediff-window-C | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
457 ediff-split-window-function |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
458 (ediff-multiframe-setup-p) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
459 ediff-wide-display-p)) |
11042 | 460 (goto-char (point-min)) |
461 (skip-chars-forward ediff-whitespace))) | |
462 | |
463 ;; assuming we are in control window, calculate length of the first line in | |
464 ;; help message | |
465 (defun ediff-help-message-line-length () | |
466 (save-excursion | |
467 (goto-char (point-min)) | |
468 (if ediff-prefer-long-help-message | |
469 (next-line 1)) | |
470 (end-of-line) | |
471 (current-column))) | |
472 | |
473 | |
474 (defun ediff-indent-help-message () | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
475 (let* ((shift (/ (max 0 (- (window-width (selected-window)) |
11042 | 476 (ediff-help-message-line-length))) |
477 2)) | |
478 (str (make-string shift ?\ ))) | |
479 (save-excursion | |
480 (goto-char (point-min)) | |
481 (while (< (point) (point-max)) | |
482 (insert str) | |
483 (beginning-of-line) | |
484 (forward-line 1))))) | |
485 | |
486 | |
487 (defun ediff-set-help-message () | |
488 (setq ediff-long-help-message | |
489 (cond ((and ediff-long-help-message-custom | |
490 (or (symbolp ediff-long-help-message-custom) | |
491 (consp ediff-long-help-message-custom))) | |
492 (funcall ediff-long-help-message-custom)) | |
493 (ediff-word-mode | |
494 (concat ediff-long-help-message-head | |
495 ediff-long-help-message-word-mode | |
496 ediff-long-help-message-tail)) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
497 (ediff-narrow-job |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
498 (concat ediff-long-help-message-head |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
499 ediff-long-help-message-narrow2 |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
500 ediff-long-help-message-tail)) |
11042 | 501 (ediff-merge-job |
502 (concat ediff-long-help-message-head | |
503 ediff-long-help-message-merge | |
504 ediff-long-help-message-tail)) | |
505 (ediff-diff3-job | |
506 (concat ediff-long-help-message-head | |
507 ediff-long-help-message-compare3 | |
508 ediff-long-help-message-tail)) | |
509 (t | |
510 (concat ediff-long-help-message-head | |
511 ediff-long-help-message-compare2 | |
512 ediff-long-help-message-tail)))) | |
513 (setq ediff-brief-help-message | |
514 (cond ((and ediff-brief-help-message-custom | |
515 (or (symbolp ediff-brief-help-message-custom) | |
516 (consp ediff-brief-help-message-custom))) | |
517 (funcall ediff-brief-help-message-custom)) | |
518 ((stringp ediff-brief-help-message-custom) | |
519 ediff-brief-help-message-custom) | |
520 ((ediff-multiframe-setup-p) ediff-brief-message-string) | |
521 (t ; long brief msg, not multiframe --- put in the middle | |
522 ediff-brief-message-string) | |
523 )) | |
524 (setq ediff-help-message (if ediff-prefer-long-help-message | |
525 ediff-long-help-message | |
526 ediff-brief-help-message)) | |
527 (run-hooks 'ediff-display-help-hooks) | |
528 ) | |
529 | |
530 | |
531 | |
532 | |
533 ;;; Commands for working with Ediff | |
534 | |
535 (defun ediff-update-diffs () | |
536 "Recompute difference regions in buffers A, B, and C. | |
537 Buffers are not synchronized with their respective files, so changes done | |
538 to these buffers are not saved at this point---the user can do this later, | |
539 if necessary." | |
540 (interactive) | |
541 (let ((point-A (ediff-eval-in-buffer ediff-buffer-A (point))) | |
542 ;;(point-B (ediff-eval-in-buffer ediff-buffer-B (point))) | |
543 (tmp-buffer (get-buffer-create ediff-tmp-buffer)) | |
544 (buf-A-file-name | |
545 (file-name-nondirectory (or (buffer-file-name ediff-buffer-A) | |
546 (buffer-name ediff-buffer-A) | |
547 ))) | |
548 (buf-B-file-name | |
549 (file-name-nondirectory (or (buffer-file-name ediff-buffer-B) | |
550 (buffer-name ediff-buffer-B) | |
551 ))) | |
552 (buf-C-file-name | |
553 (file-name-nondirectory (or (buffer-file-name ediff-buffer-C) | |
554 ;; if (null ediff-buffer-C), there is | |
555 ;; no danger, since we later check if | |
556 ;; ediff-buffer-C is alive | |
557 (buffer-name ediff-buffer-C) | |
558 ))) | |
559 (overl-A (ediff-get-value-according-to-buffer-type | |
560 'A ediff-narrow-bounds)) | |
561 (overl-B (ediff-get-value-according-to-buffer-type | |
562 'B ediff-narrow-bounds)) | |
563 (overl-C (ediff-get-value-according-to-buffer-type | |
564 'C ediff-narrow-bounds)) | |
565 beg-A end-A beg-B end-B beg-C end-C | |
566 file-A file-B file-C) | |
567 (ediff-unselect-and-select-difference -1) | |
568 | |
569 (setq beg-A (ediff-overlay-start overl-A) | |
570 beg-B (ediff-overlay-start overl-B) | |
571 beg-C (ediff-overlay-start overl-C) | |
572 end-A (ediff-overlay-end overl-A) | |
573 end-B (ediff-overlay-end overl-B) | |
574 end-C (ediff-overlay-end overl-C)) | |
575 | |
576 (if ediff-word-mode | |
577 (progn | |
578 (ediff-wordify beg-A end-A ediff-buffer-A tmp-buffer) | |
579 (ediff-eval-in-buffer tmp-buffer | |
580 (setq file-A (ediff-make-temp-file "regA"))) | |
581 (ediff-wordify beg-B end-B ediff-buffer-B tmp-buffer) | |
582 (ediff-eval-in-buffer tmp-buffer | |
583 (setq file-B (ediff-make-temp-file "regB"))) | |
584 (if ediff-3way-job | |
585 (progn | |
586 (ediff-wordify beg-C end-C ediff-buffer-C tmp-buffer) | |
587 (ediff-eval-in-buffer tmp-buffer | |
588 (setq file-C (ediff-make-temp-file "regC"))))) | |
589 ) | |
590 ;; not word-mode | |
591 (ediff-eval-in-buffer ediff-buffer-A | |
592 (setq file-A (ediff-make-temp-file buf-A-file-name))) | |
593 (ediff-eval-in-buffer ediff-buffer-B | |
594 (setq file-B (ediff-make-temp-file buf-B-file-name))) | |
595 (if ediff-3way-job | |
596 (ediff-eval-in-buffer ediff-buffer-C | |
597 (setq file-C (ediff-make-temp-file buf-C-file-name)))) | |
598 ) | |
599 | |
600 (ediff-clear-diff-vector 'ediff-difference-vector-A 'fine-diffs-also) | |
601 (ediff-clear-diff-vector 'ediff-difference-vector-B 'fine-diffs-also) | |
602 (ediff-clear-diff-vector 'ediff-difference-vector-C 'fine-diffs-also) | |
603 (setq ediff-killed-diffs-alist nil) ; invalidate saved killed diff regions | |
604 | |
605 ;; In case of merge job, full it into thinking that it is just doing | |
606 ;; comparison | |
607 (let ((ediff-setup-diff-regions-function ediff-setup-diff-regions-function) | |
608 (ediff-job-name ediff-job-name)) | |
609 (if ediff-merge-job | |
610 (setq ediff-setup-diff-regions-function 'ediff-setup-diff-regions3 | |
611 ediff-job-name 'ediff-files3)) | |
612 (funcall ediff-setup-diff-regions-function file-A file-B file-C)) | |
613 | |
614 (setq ediff-number-of-differences (length ediff-difference-vector-A)) | |
615 (delete-file file-A) | |
616 (delete-file file-B) | |
617 (if file-C | |
618 (delete-file file-C)) | |
619 | |
620 (if ediff-3way-job | |
621 (ediff-set-state-of-all-diffs-in-all-buffers ediff-control-buffer)) | |
622 | |
623 (ediff-jump-to-difference (ediff-diff-at-point 'A point-A)) | |
624 (message "") | |
625 )) | |
626 | |
627 ;; Not bound to any key---to dangerous. A user can do it if necessary. | |
628 (defun ediff-revert-buffers-then-recompute-diffs (noconfirm) | |
629 "Revert buffers A, B and C. Then rerun Ediff on file A and file B." | |
630 (interactive "P") | |
631 (let ((bufA ediff-buffer-A) | |
632 (bufB ediff-buffer-B) | |
633 (bufC ediff-buffer-C) | |
634 (ctl-buf ediff-control-buffer) | |
635 (ancestor-buf ediff-ancestor-buffer) | |
636 (ancestor-job ediff-merge-with-ancestor-job) | |
637 (merge ediff-merge-job) | |
638 (comparison ediff-3way-comparison-job)) | |
639 (ediff-eval-in-buffer bufA | |
640 (revert-buffer t noconfirm)) | |
641 (ediff-eval-in-buffer bufB | |
642 (revert-buffer t noconfirm)) | |
643 ;; this should only be executed in a 3way comparison, not in merge | |
644 (if comparison | |
645 (ediff-eval-in-buffer bufC | |
646 (revert-buffer t noconfirm))) | |
647 (if merge | |
648 (progn | |
649 (set-buffer ctl-buf) | |
650 (ediff-really-quit) | |
651 (kill-buffer bufC) | |
652 (if ancestor-job | |
653 (ediff-merge-buffers-with-ancestor bufA bufB ancestor-buf) | |
654 (ediff-merge-buffers bufA bufB))) | |
655 (ediff-update-diffs)))) | |
656 | |
657 | |
658 ;; optional NO-REHIGHLIGHT says to not rehighlight buffers | |
659 (defun ediff-recenter (&optional no-rehighlight) | |
660 "Bring the highlighted region of all buffers being compared into view. | |
661 Reestablish the default three-window display." | |
662 (interactive) | |
663 | |
664 ;; force all minibuffer to display ediff's messages. | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
665 ;; when xemacs implements minibufferless frames, this won't be necessary |
11042 | 666 (if ediff-xemacs-p (setq synchronize-minibuffers t)) |
667 | |
668 (setq ediff-disturbed-overlays nil) ; clear after use | |
669 (let (buffer-read-only) | |
670 (if (and (ediff-buffer-live-p ediff-buffer-A) | |
671 (ediff-buffer-live-p ediff-buffer-B) | |
672 (or (not ediff-3way-job) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
673 (ediff-buffer-live-p ediff-buffer-C))) |
11042 | 674 (ediff-setup-windows |
675 ediff-buffer-A ediff-buffer-B ediff-buffer-C ediff-control-buffer) | |
676 (or (eq this-command 'ediff-quit) | |
677 (message | |
678 "You've killed an essential Ediff buffer---Please quit Ediff" | |
679 (beep 1))) | |
680 )) | |
681 | |
682 ;; set visibility range appropriate to this invocation of Ediff. | |
683 (ediff-visible-region) | |
684 | |
685 ;; raise | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
686 (if (and (ediff-window-display-p) |
11042 | 687 (symbolp this-command) |
688 (symbolp last-command) | |
689 ;; Either one of the display-changing commands | |
690 (or (memq this-command | |
691 '(ediff-recenter | |
692 ediff-toggle-wide-display ediff-toggle-multiframe)) | |
693 ;; Or one of the movement cmds and prev cmd was an Ediff cmd | |
694 ;; This avoids rasing frames unnecessarily. | |
695 (and (memq this-command | |
696 '(ediff-next-difference | |
697 ediff-previous-difference | |
698 ediff-jump-to-difference | |
699 ediff-jump-to-difference-at-point)) | |
700 (not (string-match "^ediff-" (symbol-name last-command))) | |
701 ))) | |
702 (progn | |
703 (if (window-live-p ediff-window-A) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
704 (raise-frame (window-frame ediff-window-A))) |
11042 | 705 (if (window-live-p ediff-window-B) |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
706 (raise-frame (window-frame ediff-window-B))) |
11042 | 707 (if (window-live-p ediff-window-C) |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
708 (raise-frame (window-frame ediff-window-C))))) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
709 (if (and (ediff-window-display-p) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
710 (frame-live-p ediff-control-frame) |
11042 | 711 (not (ediff-frame-iconified-p ediff-control-frame))) |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
712 (raise-frame ediff-control-frame)) |
11042 | 713 |
714 ;; Redisplay whatever buffers are showing, if there is a selected difference | |
715 (let* ((control-frame ediff-control-frame) | |
716 (control-buf ediff-control-buffer)) | |
717 (if (and (ediff-buffer-live-p ediff-buffer-A) | |
718 (ediff-buffer-live-p ediff-buffer-B) | |
719 (or (not ediff-3way-job) | |
720 (ediff-buffer-live-p ediff-buffer-C)) | |
721 (ediff-valid-difference-p)) | |
722 (progn | |
723 (or no-rehighlight | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
724 (ediff-select-difference ediff-current-difference)) |
11042 | 725 |
726 (ediff-recenter-one-window 'A) | |
727 (ediff-recenter-one-window 'B) | |
728 (if ediff-3way-job | |
729 (ediff-recenter-one-window 'C)) | |
730 | |
731 (if (and (ediff-multiframe-setup-p) | |
732 (not (ediff-frame-iconified-p ediff-control-frame))) | |
733 (progn | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
734 (ediff-reset-mouse control-frame) |
11042 | 735 (or ediff-xemacs-p |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
736 (cond ((eq (ediff-device-type) 'ns) |
11042 | 737 (unfocus-frame (selected-frame))) |
738 (t (unfocus-frame)))) | |
739 )) | |
740 )) | |
741 (ediff-eval-in-buffer control-buf | |
742 (ediff-refresh-mode-lines)) | |
743 )) | |
744 | |
745 ;; this function returns to the window it was called from | |
746 ;; (which was the control window) | |
747 (defun ediff-recenter-one-window (buf-type) | |
748 (let* (;; context must be saved before switching to windows A/B/C | |
749 (ctl-wind (selected-window)) | |
750 (shift (ediff-overlay-start | |
751 (ediff-get-value-according-to-buffer-type | |
752 buf-type ediff-narrow-bounds))) | |
753 (job-name ediff-job-name) | |
754 (control-buf ediff-control-buffer) | |
755 (window-name (intern (format "ediff-window-%S" buf-type))) | |
756 (window (if (window-live-p (symbol-value window-name)) | |
757 (symbol-value window-name)))) | |
758 | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
759 (if (and window ediff-windows-job) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
760 (set-window-start window shift)) |
11042 | 761 (if window |
762 (progn | |
763 (select-window window) | |
764 (ediff-deactivate-mark) | |
765 (ediff-position-region | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
766 (ediff-get-diff-posn buf-type 'beg nil control-buf) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
767 (ediff-get-diff-posn buf-type 'end nil control-buf) |
11042 | 768 (ediff-get-diff-posn buf-type 'beg nil control-buf) |
769 job-name | |
770 ))) | |
771 (select-window ctl-wind) | |
772 )) | |
773 | |
774 | |
775 ;; This will have to be refined for 3way jobs | |
776 (defun ediff-toggle-split () | |
777 "Toggle vertical/horizontal window split. | |
778 Does nothing if file-A and file-B are in different frames." | |
779 (interactive) | |
780 (let* ((wind-A (if (window-live-p ediff-window-A) ediff-window-A)) | |
781 (wind-B (if (window-live-p ediff-window-B) ediff-window-B)) | |
782 (wind-C (if (window-live-p ediff-window-C) ediff-window-C)) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
783 (frame-A (if wind-A (window-frame wind-A))) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
784 (frame-B (if wind-B (window-frame wind-B))) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
785 (frame-C (if wind-C (window-frame wind-C)))) |
11042 | 786 (if (or (eq frame-A frame-B) |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
787 (not (frame-live-p frame-A)) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
788 (not (frame-live-p frame-B)) |
11042 | 789 (if ediff-3way-comparison-job |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
790 (or (not (frame-live-p frame-C)) |
11042 | 791 (eq frame-A frame-C) (eq frame-B frame-C)))) |
792 (setq ediff-split-window-function | |
793 (if (eq ediff-split-window-function 'split-window-vertically) | |
794 'split-window-horizontally | |
795 'split-window-vertically)) | |
796 (message "Buffers being compared are in different frames")) | |
797 (ediff-recenter 'no-rehighlight))) | |
798 | |
799 (defun ediff-toggle-hilit () | |
800 "Switch between highlighting using ASCII flags and highlighting using faces. | |
801 On a dumb terminal, switches between ASCII highlighting and no highlighting." | |
802 (interactive) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
803 (if (not (ediff-window-display-p)) |
11042 | 804 (if (eq ediff-highlighting-style 'ascii) |
805 (progn | |
806 (message "ASCII highlighting flags removed") | |
807 (ediff-unselect-and-select-difference ediff-current-difference | |
808 'unselect-only) | |
809 (setq ediff-highlighting-style 'off)) | |
810 (ediff-unselect-and-select-difference ediff-current-difference | |
811 'select-only)) | |
812 (ediff-unselect-and-select-difference ediff-current-difference | |
813 'unselect-only) | |
814 ;; cycle through highlighting | |
815 (cond ((and ediff-use-faces ediff-highlight-all-diffs) | |
816 (message "Unhighlighting unselected difference regions") | |
817 (setq ediff-highlight-all-diffs nil)) | |
818 (ediff-use-faces | |
819 (message "Highlighting with ASCII flags") | |
820 (setq ediff-use-faces nil)) | |
821 (t | |
822 (message "Re-highlighting all difference regions") | |
823 (setq ediff-use-faces t | |
824 ediff-highlight-all-diffs t))) | |
825 | |
826 (if (and ediff-use-faces ediff-highlight-all-diffs) | |
827 (if (not (face-differs-from-default-p 'ediff-odd-diff-face-A-var)) | |
828 (progn | |
829 (copy-face ediff-odd-diff-face-A 'ediff-odd-diff-face-A-var) | |
830 (copy-face ediff-odd-diff-face-B 'ediff-odd-diff-face-B-var) | |
831 (copy-face ediff-odd-diff-face-C 'ediff-odd-diff-face-C-var) | |
832 (copy-face ediff-even-diff-face-A 'ediff-even-diff-face-A-var) | |
833 (copy-face ediff-even-diff-face-B 'ediff-even-diff-face-B-var) | |
834 (copy-face ediff-even-diff-face-C 'ediff-even-diff-face-C-var) | |
835 )) | |
836 (copy-face 'default 'ediff-odd-diff-face-A-var) | |
837 (copy-face 'default 'ediff-odd-diff-face-B-var) | |
838 (copy-face 'default 'ediff-odd-diff-face-C-var) | |
839 (copy-face 'default 'ediff-even-diff-face-A-var) | |
840 (copy-face 'default 'ediff-even-diff-face-B-var) | |
841 (copy-face 'default 'ediff-even-diff-face-C-var)) | |
842 | |
843 (ediff-unselect-and-select-difference | |
844 ediff-current-difference 'select-only)) | |
845 ) | |
846 | |
847 (defun ediff-toggle-autorefine () | |
848 "Toggle auto-refine mode." | |
849 (interactive) | |
850 (if ediff-word-mode | |
851 (error "No fine differences in this mode")) | |
852 (cond ((eq ediff-auto-refine 'nix) | |
853 (setq ediff-auto-refine 'on) | |
854 (ediff-make-fine-diffs ediff-current-difference 'noforce) | |
855 (message "Auto-refining is ON")) | |
856 ((eq ediff-auto-refine 'on) | |
857 (message "Auto-refining is OFF") | |
858 (setq ediff-auto-refine 'off)) | |
859 (t ;; nix 'em | |
860 (ediff-set-fine-diff-properties ediff-current-difference 'default) | |
861 (message "Refinements are HIDDEN") | |
862 (setq ediff-auto-refine 'nix)) | |
863 )) | |
864 | |
865 (defun ediff-make-or-kill-fine-diffs (arg) | |
866 "Compute fine diffs. With negative prefix arg, kill fine diffs. | |
867 In both cases, operates on the currrent difference region." | |
868 (interactive "P") | |
869 (cond ((eq arg '-) | |
870 (ediff-clear-fine-differences ediff-current-difference)) | |
871 ((and (numberp arg) (< arg 0)) | |
872 (ediff-clear-fine-differences ediff-current-difference)) | |
873 (t (ediff-make-fine-diffs)))) | |
874 | |
875 | |
876 (defun ediff-toggle-help () | |
877 "Toggle short/long help message." | |
878 (interactive) | |
879 (let (buffer-read-only) | |
880 (erase-buffer) | |
881 (setq ediff-prefer-long-help-message (not ediff-prefer-long-help-message)) | |
882 (ediff-set-help-message)) | |
883 ;; remember the icon status of the control frame when the user requested | |
884 ;; full control message | |
885 (if (and ediff-prefer-long-help-message (ediff-multiframe-setup-p)) | |
886 (setq ediff-prefer-iconified-control-frame | |
887 (ediff-frame-iconified-p ediff-control-frame))) | |
888 | |
889 (setq ediff-window-config-saved "") ; force redisplay | |
890 (ediff-recenter 'no-rehighlight)) | |
891 | |
892 | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
893 ;; If BUF, this is the buffer to toggle, not current buffer. |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
894 (defun ediff-toggle-read-only (&optional buf) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
895 "Toggle read-only in current buffer. |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
896 If buffer is under version control and locked, check it out first. |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
897 If optional argument BUF is specified, toggle read-only in that buffer instead |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
898 of the current buffer." |
11042 | 899 (interactive) |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
900 (let ((ctl-buf (if (null buf) (current-buffer)))) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
901 (or buf (ediff-recenter)) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
902 (or buf |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
903 (setq buf |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
904 (ediff-get-buffer (ediff-char-to-buftype last-command-char)))) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
905 |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
906 (ediff-eval-in-buffer buf ; eval in buf A/B/C |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
907 (let* ((file (buffer-file-name buf)) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
908 (file-writable (and file |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
909 (file-exists-p file) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
910 (file-writable-p file))) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
911 (toggle-ro-cmd (cond (ediff-toggle-read-only-function) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
912 ((ediff-file-checked-out-p file) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
913 'toggle-read-only) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
914 (file-writable 'toggle-read-only) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
915 (t (key-binding "\C-x\C-q"))))) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
916 ;; If the file is checked in, make sure we don't make buffer modifiable |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
917 ;; without warning the user. The user can fool our checks by making the |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
918 ;; buffer non-RO without checking the file out. We regard this as a |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
919 ;; user problem. |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
920 (if (and (ediff-file-checked-in-p file) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
921 ;; If ctl-buf is null, this means we called this |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
922 ;; non-interactively, in which case don't ask questions |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
923 ctl-buf) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
924 (cond ((not buffer-read-only) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
925 (setq toggle-ro-cmd 'toggle-read-only)) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
926 ((and (or (beep 1) t) ; always beep |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
927 (y-or-n-p |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
928 (format |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
929 "File %s is under version control. Check it out? " |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
930 (abbreviate-file-name file)))) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
931 ;; if we checked the file out, we should also change the |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
932 ;; original state of buffer-read-only to nil. If we don't |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
933 ;; do this, the mode line will show %%, since the file was |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
934 ;; RO before ediff started, so the user will think the file |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
935 ;; is checked in. |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
936 (ediff-eval-in-buffer ctl-buf |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
937 (ediff-change-saved-variable |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
938 'buffer-read-only nil |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
939 (ediff-char-to-buftype last-command-char)))) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
940 (t |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
941 (setq toggle-ro-cmd 'toggle-read-only) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
942 (beep 1) (beep 1) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
943 (message |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
944 "Boy, this is risky! Better don't change this file...") |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
945 (sit-for 3)))) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
946 (if (and toggle-ro-cmd |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
947 (string-match "toggle-read-only" (symbol-name toggle-ro-cmd))) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
948 (save-excursion |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
949 (save-window-excursion |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
950 (command-execute toggle-ro-cmd))) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
951 (error "Don't know how to toggle read-only in buffer %S" buf)) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
952 |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
953 ;; Check if we made the current buffer updatable, but its file is RO. |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
954 ;; Signal a warning in this case. |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
955 (if (and file (not buffer-read-only) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
956 (eq this-command 'ediff-toggle-read-only) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
957 (file-exists-p file) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
958 (not (file-writable-p file))) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
959 (message "Warning: file %s is read-only" |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
960 (abbreviate-file-name file) (beep 1))) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
961 )))) |
11042 | 962 |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
963 |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
964 ;; This is a simple-minded check for whether a file is under version control |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
965 ;; and is checked out. |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
966 ;; If file,v exists but file doesn't, this file is considered to be not checked |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
967 ;; in and not checked out for the purpose of patching (since patch won't be |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
968 ;; able to read such a file anyway). |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
969 ;; FILE is a string representing file name |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
970 (defsubst ediff-file-checked-out-p (file) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
971 (and (stringp file) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
972 (file-exists-p file) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
973 (file-writable-p file) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
974 (file-exists-p (concat file ",v")))) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
975 (defsubst ediff-file-checked-in-p (file) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
976 (and (stringp file) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
977 (file-exists-p file) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
978 (not (file-writable-p file)) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
979 (file-exists-p (concat file ",v")))) |
11042 | 980 |
981 (defun ediff-swap-buffers () | |
982 "Rotate the display of buffers A, B, and C." | |
983 (interactive) | |
984 (if (and (window-live-p ediff-window-A) (window-live-p ediff-window-B)) | |
985 (let ((buf ediff-buffer-A) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
986 (values ediff-buffer-values-orig-A) |
11042 | 987 (diff-vec ediff-difference-vector-A) |
988 (hide-regexp ediff-regexp-hide-A) | |
989 (focus-regexp ediff-regexp-focus-A) | |
990 (wide-visibility-p (eq ediff-visible-bounds ediff-wide-bounds)) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
991 (overlay (if (ediff-window-display-p) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
992 ediff-current-diff-overlay-A))) |
11042 | 993 (if ediff-3way-comparison-job |
994 (progn | |
995 (set-window-buffer ediff-window-A ediff-buffer-C) | |
996 (set-window-buffer ediff-window-B ediff-buffer-A) | |
997 (set-window-buffer ediff-window-C ediff-buffer-B) | |
998 ) | |
999 (set-window-buffer ediff-window-A ediff-buffer-B) | |
1000 (set-window-buffer ediff-window-B ediff-buffer-A)) | |
1001 ;; swap diff buffers | |
1002 (if ediff-3way-comparison-job | |
1003 (setq ediff-buffer-A ediff-buffer-C | |
1004 ediff-buffer-C ediff-buffer-B | |
1005 ediff-buffer-B buf) | |
1006 (setq ediff-buffer-A ediff-buffer-B | |
1007 ediff-buffer-B buf)) | |
1008 | |
1009 ;; swap saved buffer characteristics | |
1010 (if ediff-3way-comparison-job | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1011 (setq ediff-buffer-values-orig-A ediff-buffer-values-orig-C |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1012 ediff-buffer-values-orig-C ediff-buffer-values-orig-B |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1013 ediff-buffer-values-orig-B values) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1014 (setq ediff-buffer-values-orig-A ediff-buffer-values-orig-B |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1015 ediff-buffer-values-orig-B values)) |
11042 | 1016 |
1017 ;; swap diff vectors | |
1018 (if ediff-3way-comparison-job | |
1019 (setq ediff-difference-vector-A ediff-difference-vector-C | |
1020 ediff-difference-vector-C ediff-difference-vector-B | |
1021 ediff-difference-vector-B diff-vec) | |
1022 (setq ediff-difference-vector-A ediff-difference-vector-B | |
1023 ediff-difference-vector-B diff-vec)) | |
1024 | |
1025 ;; swap hide/focus regexp | |
1026 (if ediff-3way-comparison-job | |
1027 (setq ediff-regexp-hide-A ediff-regexp-hide-C | |
1028 ediff-regexp-hide-C ediff-regexp-hide-B | |
1029 ediff-regexp-hide-B hide-regexp | |
1030 ediff-regexp-focus-A ediff-regexp-focus-C | |
1031 ediff-regexp-focus-C ediff-regexp-focus-B | |
1032 ediff-regexp-focus-B focus-regexp) | |
1033 (setq ediff-regexp-hide-A ediff-regexp-hide-B | |
1034 ediff-regexp-hide-B hide-regexp | |
1035 ediff-regexp-focus-A ediff-regexp-focus-B | |
1036 ediff-regexp-focus-B focus-regexp)) | |
1037 | |
1038 ;; The following is needed for XEmacs, since there one can't move | |
1039 ;; overlay to another buffer. In Emacs, this swap is redundant. | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1040 (if (ediff-window-display-p) |
11042 | 1041 (if ediff-3way-comparison-job |
1042 (setq ediff-current-diff-overlay-A ediff-current-diff-overlay-C | |
1043 ediff-current-diff-overlay-C ediff-current-diff-overlay-B | |
1044 ediff-current-diff-overlay-B overlay) | |
1045 (setq ediff-current-diff-overlay-A ediff-current-diff-overlay-B | |
1046 ediff-current-diff-overlay-B overlay))) | |
1047 | |
1048 ;; swap wide bounds | |
1049 (setq ediff-wide-bounds | |
1050 (cond (ediff-3way-comparison-job | |
1051 (list (nth 2 ediff-wide-bounds) | |
1052 (nth 0 ediff-wide-bounds) | |
1053 (nth 1 ediff-wide-bounds))) | |
1054 (ediff-3way-job | |
1055 (list (nth 1 ediff-wide-bounds) | |
1056 (nth 0 ediff-wide-bounds) | |
1057 (nth 2 ediff-wide-bounds))) | |
1058 (t | |
1059 (list (nth 1 ediff-wide-bounds) | |
1060 (nth 0 ediff-wide-bounds))))) | |
1061 ;; swap narrow bounds | |
1062 (setq ediff-narrow-bounds | |
1063 (cond (ediff-3way-comparison-job | |
1064 (list (nth 2 ediff-narrow-bounds) | |
1065 (nth 0 ediff-narrow-bounds) | |
1066 (nth 1 ediff-narrow-bounds))) | |
1067 (ediff-3way-job | |
1068 (list (nth 1 ediff-narrow-bounds) | |
1069 (nth 0 ediff-narrow-bounds) | |
1070 (nth 2 ediff-narrow-bounds))) | |
1071 (t | |
1072 (list (nth 1 ediff-narrow-bounds) | |
1073 (nth 0 ediff-narrow-bounds))))) | |
1074 (if wide-visibility-p | |
1075 (setq ediff-visible-bounds ediff-wide-bounds) | |
1076 (setq ediff-visible-bounds ediff-narrow-bounds)) | |
1077 )) | |
1078 (if ediff-3way-job | |
1079 (ediff-set-state-of-all-diffs-in-all-buffers ediff-control-buffer)) | |
1080 (ediff-recenter 'no-rehighlight) | |
1081 ) | |
1082 | |
1083 | |
1084 (defun ediff-toggle-wide-display () | |
1085 "Toggle wide/regular display. | |
1086 This is especially useful when comparing buffers side-by-side." | |
1087 (interactive) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1088 (or (ediff-window-display-p) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1089 (error "%sEmacs is not running as a window application" |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1090 (if ediff-emacs-p "" "X"))) |
11042 | 1091 (ediff-recenter 'no-rehighlight) ; make sure buffs are displayed in windows |
1092 (let ((ctl-buf ediff-control-buffer)) | |
1093 (setq ediff-wide-display-p (not ediff-wide-display-p)) | |
1094 (if (not ediff-wide-display-p) | |
1095 (ediff-eval-in-buffer ctl-buf | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1096 (modify-frame-parameters |
11042 | 1097 ediff-wide-display-frame ediff-wide-display-orig-parameters) |
1098 (sit-for (if ediff-xemacs-p 0.4 0)) | |
1099 ;; restore control buf, since ctl window may have been deleted | |
1100 ;; during resizing | |
1101 (set-buffer ctl-buf) | |
1102 (setq ediff-wide-display-orig-parameters nil | |
1103 ediff-window-B nil) ; force update of window config | |
1104 (ediff-recenter 'no-rehighlight)) | |
1105 (funcall ediff-make-wide-display-function) | |
1106 (sit-for (if ediff-xemacs-p 0.4 0)) | |
1107 (ediff-eval-in-buffer ctl-buf | |
1108 (setq ediff-window-B nil) ; force update of window config | |
1109 (ediff-recenter 'no-rehighlight))))) | |
1110 | |
1111 (defun ediff-toggle-multiframe () | |
1112 "Switch from the multiframe display to single-frame display and back. | |
1113 This is primarily for debugging, but one can use it for fun, too." | |
1114 (interactive) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1115 (or (ediff-window-display-p) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1116 (error "%sEmacs is not running as a window application" |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1117 (if ediff-emacs-p "" "X"))) |
11042 | 1118 (cond ((eq ediff-window-setup-function 'ediff-setup-windows-multiframe) |
1119 (setq ediff-window-setup-function 'ediff-setup-windows-plain)) | |
1120 ((eq ediff-window-setup-function 'ediff-setup-windows-plain) | |
1121 (setq ediff-window-setup-function 'ediff-setup-windows-multiframe))) | |
1122 (setq ediff-window-B nil) | |
1123 (ediff-recenter 'no-rehighlight)) | |
1124 | |
1125 ;; Merging | |
1126 | |
1127 (defun ediff-toggle-show-clashes-only () | |
1128 "Toggle the mode where only the regions where both buffers differ with the ancestor are shown." | |
1129 (interactive) | |
1130 (if (not ediff-merge-with-ancestor-job) | |
1131 (error "This command makes sense only when merging with an ancestor")) | |
1132 (setq ediff-show-clashes-only (not ediff-show-clashes-only)) | |
1133 (if ediff-show-clashes-only | |
1134 (message "Focus on regions where both buffers differ from the ancestor") | |
1135 (message "Canceling focus on regions where changes clash"))) | |
1136 | |
1137 ;; Widening/narrowing | |
1138 | |
1139 (defun ediff-toggle-narrow-region () | |
1140 "Toggle narrowing in buffers A, B, and C. | |
1141 Used in ediff-windows/regions only." | |
1142 (interactive) | |
1143 (if (eq ediff-buffer-A ediff-buffer-B) | |
1144 (error | |
1145 "Buffers A and B are the same. Can't narrow to two different regions")) | |
1146 (if (eq ediff-visible-bounds ediff-wide-bounds) | |
1147 (setq ediff-visible-bounds ediff-narrow-bounds) | |
1148 (setq ediff-visible-bounds ediff-wide-bounds)) | |
1149 (ediff-recenter 'no-rehighlight)) | |
1150 | |
1151 ;; Narrow bufs A/B/C to ediff-visible-bounds. If this is currently set to | |
1152 ;; ediff-wide-bounds, then this actually widens. | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1153 ;; This function does nothing if job-name is not |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1154 ;; ediff-regions-wordwise/linewise or ediff-windows-wordwise/linewise. |
11042 | 1155 ;; Does nothing if buffer-A = buffer-B since we can't narrow |
1156 ;; to two different regions in one buffer. | |
1157 (defun ediff-visible-region () | |
1158 (if (or (eq ediff-buffer-A ediff-buffer-B) | |
1159 (eq ediff-buffer-A ediff-buffer-C) | |
1160 (eq ediff-buffer-C ediff-buffer-B)) | |
1161 () | |
1162 ;; If ediff-*-regions/windows, ediff-visible-bounds is already set | |
1163 ;; Otherwise, always use full range. | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1164 (if (not ediff-narrow-job) |
11042 | 1165 (setq ediff-visible-bounds ediff-wide-bounds)) |
1166 (let ((overl-A (ediff-get-value-according-to-buffer-type | |
1167 'A ediff-visible-bounds)) | |
1168 (overl-B (ediff-get-value-according-to-buffer-type | |
1169 'B ediff-visible-bounds)) | |
1170 (overl-C (ediff-get-value-according-to-buffer-type | |
1171 'C ediff-visible-bounds)) | |
1172 ) | |
1173 (ediff-eval-in-buffer ediff-buffer-A | |
1174 (narrow-to-region | |
1175 (ediff-overlay-start overl-A) (ediff-overlay-end overl-A))) | |
1176 (ediff-eval-in-buffer ediff-buffer-B | |
1177 (narrow-to-region | |
1178 (ediff-overlay-start overl-B) (ediff-overlay-end overl-B))) | |
1179 | |
1180 (if ediff-3way-job | |
1181 (ediff-eval-in-buffer ediff-buffer-C | |
1182 (narrow-to-region | |
1183 (ediff-overlay-start overl-C) (ediff-overlay-end overl-C)))) | |
1184 ))) | |
1185 | |
1186 | |
1187 ;; Window scrolling operations | |
1188 | |
1189 ;; Performs some operation on the two file windows (if they are showing). | |
1190 ;; Traps all errors on the operation in windows A/B/C. | |
1191 ;; Usually, errors come from scrolling off the | |
1192 ;; beginning or end of the buffer, and this gives error messages. | |
1193 (defun ediff-operate-on-windows (operation arg) | |
1194 | |
1195 ;; make sure windows aren't dead | |
1196 (if (not (and (window-live-p ediff-window-A) (window-live-p ediff-window-B))) | |
1197 (ediff-recenter 'no-rehighlight)) | |
1198 (if (not (and (ediff-buffer-live-p ediff-buffer-A) | |
1199 (ediff-buffer-live-p ediff-buffer-B) | |
1200 (or (not ediff-3way-job) ediff-buffer-C) | |
1201 )) | |
1202 (error "You've killed an essential Ediff buffer---Please quit Ediff")) | |
1203 | |
1204 (let* ((wind (selected-window)) | |
1205 (wind-A ediff-window-A) | |
1206 (wind-B ediff-window-B) | |
1207 (wind-C ediff-window-C) | |
1208 (three-way ediff-3way-job)) | |
1209 | |
1210 (select-window wind-A) | |
1211 (condition-case nil | |
1212 (funcall operation arg) | |
1213 (error)) | |
1214 (select-window wind-B) | |
1215 (condition-case nil | |
1216 (funcall operation arg) | |
1217 (error)) | |
1218 (if three-way | |
1219 (progn | |
1220 (select-window wind-C) | |
1221 (condition-case nil | |
1222 (funcall operation arg) | |
1223 (error)))) | |
1224 | |
1225 (select-window wind))) | |
1226 | |
1227 (defun ediff-scroll-vertically (&optional arg) | |
1228 "Vertically scroll buffers A, B \(and C if appropriate\). | |
1229 With optional argument ARG, scroll ARG lines; otherwise scroll by nearly | |
1230 the height of window-A." | |
1231 (interactive "P") | |
1232 | |
1233 ;; make sure windows aren't dead | |
1234 (if (not (and (window-live-p ediff-window-A) (window-live-p ediff-window-B))) | |
1235 (ediff-recenter 'no-rehighlight)) | |
1236 (if (not (and (ediff-buffer-live-p ediff-buffer-A) | |
1237 (ediff-buffer-live-p ediff-buffer-B) | |
1238 (or (not ediff-3way-job) | |
1239 (ediff-buffer-live-p ediff-buffer-C)) | |
1240 )) | |
1241 (error "You've killed an essential Ediff buffer---Please quit Ediff")) | |
1242 | |
1243 (ediff-operate-on-windows | |
1244 (if (memq last-command-char '(?v ?\C-v)) | |
1245 'scroll-up | |
1246 'scroll-down) | |
1247 ;; calculate argument to scroll-up/down | |
1248 ;; if there is an explicit argument | |
1249 (if (and arg (not (equal arg '-))) | |
1250 ;; use it | |
1251 (prefix-numeric-value arg) | |
1252 ;; if not, see if we can determine a default amount (the window height) | |
1253 (let* (default-amount) | |
1254 (setq default-amount | |
1255 (- (min (window-height ediff-window-A) | |
1256 (window-height ediff-window-B) | |
1257 (if ediff-3way-job | |
1258 (window-height ediff-window-C) | |
1259 123) ; some large number | |
1260 ) | |
1261 1 next-screen-context-lines)) | |
1262 ;; window found | |
1263 (if arg | |
1264 ;; C-u as argument means half of default amount | |
1265 (/ default-amount 2) | |
1266 ;; no argument means default amount | |
1267 default-amount))))) | |
1268 | |
1269 | |
1270 (defun ediff-scroll-horizontally (&optional arg) | |
1271 "Horizontally scroll buffers A, B \(and C if appropriate\). | |
1272 If an argument is given, that is how many columns are scrolled, else nearly | |
1273 the width of the A/B/C windows." | |
1274 (interactive "P") | |
1275 | |
1276 ;; make sure windows aren't dead | |
1277 (if (not (and (window-live-p ediff-window-A) (window-live-p ediff-window-B))) | |
1278 (ediff-recenter 'no-rehighlight)) | |
1279 (if (not (and (ediff-buffer-live-p ediff-buffer-A) | |
1280 (ediff-buffer-live-p ediff-buffer-B) | |
1281 (or (not ediff-3way-job) | |
1282 (ediff-buffer-live-p ediff-buffer-C)) | |
1283 )) | |
1284 (error "You've killed an essential Ediff buffer---Please quit Ediff")) | |
1285 | |
1286 (ediff-operate-on-windows | |
1287 (if (= last-command-char ?<) | |
1288 'scroll-left | |
1289 'scroll-right) | |
1290 ;; calculate argument to scroll-left/right | |
1291 ;; if there is an explicit argument | |
1292 (if (and arg (not (equal arg '-))) | |
1293 ;; use it | |
1294 (prefix-numeric-value arg) | |
1295 ;; if not, see if we can determine a default amount | |
1296 ;; (half the window width) | |
1297 (if (null ediff-control-window) | |
1298 ;; no control window, use nil | |
1299 nil | |
1300 (let ((default-amount | |
1301 (- (/ (min (window-width ediff-window-A) | |
1302 (window-width ediff-window-B) | |
1303 (if ediff-3way-comparison-job | |
1304 (window-width ediff-window-C) | |
1305 500) ; some large number | |
1306 ) | |
1307 2) | |
1308 3))) | |
1309 ;; window found | |
1310 (if arg | |
1311 ;; C-u as argument means half of default amount | |
1312 (/ default-amount 2) | |
1313 ;; no argument means default amount | |
1314 default-amount)))))) | |
1315 | |
1316 | |
1317 ;;BEG, END show the region to be positioned. | |
1318 ;;JOB-NAME holds ediff-job-name. Ediff-windows job positions regions | |
1319 ;;differently. | |
1320 (defun ediff-position-region (beg end pos job-name) | |
1321 (if (> end (point-max)) | |
1322 (setq end (point-max))) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1323 (if ediff-windows-job |
11042 | 1324 (if (pos-visible-in-window-p end) |
1325 () ; do nothing, wind is already positioned | |
1326 ;; at this point, windows are positioned at the beginning of the | |
1327 ;; file regions (not diff-regions) being compared. | |
1328 (save-excursion | |
1329 (move-to-window-line (- (window-height) 2)) | |
1330 (let ((amount (+ 2 (count-lines (point) end)))) | |
1331 (scroll-up amount)))) | |
1332 (set-window-start (selected-window) beg) | |
1333 (if (pos-visible-in-window-p end) | |
1334 ;; Determine the number of lines that the region occupies | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1335 (let ((lines 0) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1336 (prev-point 0)) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1337 (while ( and (> end (progn |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1338 (move-to-window-line lines) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1339 (point))) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1340 ;; `end' may be beyond the window bottom, so check |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1341 ;; that we are making progres |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1342 (< prev-point (point))) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1343 (setq prev-point (point)) |
11042 | 1344 (setq lines (1+ lines))) |
1345 ;; And position the beginning on the right line | |
1346 (goto-char beg) | |
1347 (recenter (/ (1+ (max (- (1- (window-height (selected-window))) | |
1348 lines) | |
1349 1) | |
1350 ) | |
1351 2)))) | |
1352 (goto-char pos) | |
1353 )) | |
1354 | |
1355 | |
1356 (defun ediff-next-difference (&optional arg) | |
1357 "Advance to the next difference. | |
1358 With a prefix argument, go back that many differences." | |
1359 (interactive "P") | |
1360 (if (< ediff-current-difference ediff-number-of-differences) | |
1361 (let ((n (min ediff-number-of-differences | |
1362 (+ ediff-current-difference (if arg arg 1)))) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1363 regexp-skip) |
11042 | 1364 |
1365 (or (>= n ediff-number-of-differences) | |
1366 (setq regexp-skip (funcall ediff-skip-diff-region-function n)) | |
1367 (ediff-install-fine-diff-if-necessary n)) | |
1368 (while (and (< n ediff-number-of-differences) | |
1369 (or | |
1370 ;; regexp skip | |
1371 regexp-skip | |
1372 ;; skip clashes, if necessary | |
1373 (and ediff-show-clashes-only | |
1374 (string-match "prefer" | |
1375 (or (ediff-get-state-of-merge n) ""))) | |
1376 ;; skip difference regions that differ in white space | |
1377 (and ediff-ignore-similar-regions | |
1378 (ediff-no-fine-diffs-p n)))) | |
1379 (setq n (1+ n)) | |
1380 (if (= 0 (mod n 20)) | |
1381 (message "Skipped over region %d and counting ..." n)) | |
1382 (or (>= n ediff-number-of-differences) | |
1383 (setq regexp-skip (funcall ediff-skip-diff-region-function n)) | |
1384 (ediff-install-fine-diff-if-necessary n)) | |
1385 ) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1386 (message "") |
11042 | 1387 (ediff-unselect-and-select-difference n) |
1388 ) ; let | |
1389 (ediff-visible-region) | |
1390 (error "At end of the difference list"))) | |
1391 | |
1392 (defun ediff-previous-difference (&optional arg) | |
1393 "Go to the previous difference. | |
1394 With a prefix argument, go back that many differences." | |
1395 (interactive "P") | |
1396 (if (> ediff-current-difference -1) | |
1397 (let ((n (max -1 (- ediff-current-difference (if arg arg 1)))) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1398 regexp-skip) |
11042 | 1399 |
1400 (or (< n 0) | |
1401 (setq regexp-skip (funcall ediff-skip-diff-region-function n)) | |
1402 (ediff-install-fine-diff-if-necessary n)) | |
1403 (while (and (> n -1) | |
1404 (or | |
1405 ;; regexp skip | |
1406 regexp-skip | |
1407 ;; skip clashes, if necessary | |
1408 (and ediff-show-clashes-only | |
1409 (string-match "prefer" | |
1410 (or (ediff-get-state-of-merge n) ""))) | |
1411 ;; skip difference regions that differ in white space | |
1412 (and ediff-ignore-similar-regions | |
1413 (ediff-no-fine-diffs-p n)))) | |
1414 (if (= 0 (mod (1+ n) 20)) | |
1415 (message "Skipped over region %d and counting ..." (1+ n))) | |
1416 (setq n (1- n)) | |
1417 (or (< n 0) | |
1418 (setq regexp-skip (funcall ediff-skip-diff-region-function n)) | |
1419 (ediff-install-fine-diff-if-necessary n)) | |
1420 ) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1421 (message "") |
11042 | 1422 (ediff-unselect-and-select-difference n) |
1423 ) ; let | |
1424 (ediff-visible-region) | |
1425 (error "At beginning of the difference list"))) | |
1426 | |
1427 (defun ediff-jump-to-difference (difference-number) | |
1428 "Go to the difference specified as a prefix argument." | |
1429 (interactive "p") | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1430 (setq difference-number (1- difference-number)) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1431 (if (and (>= difference-number -1) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1432 (< difference-number (1+ ediff-number-of-differences))) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1433 (ediff-unselect-and-select-difference difference-number) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1434 (error "Bad difference number, %d" difference-number))) |
11042 | 1435 |
1436 (defun ediff-jump-to-difference-at-point () | |
1437 "Go to difference closest to the point in buffer A, B, or C. | |
1438 The type of buffer depends on last command character \(a, b, or c\) that | |
1439 invoked this command." | |
1440 (interactive) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1441 (let ((buf-type (ediff-char-to-buftype last-command-char))) |
11042 | 1442 (ediff-jump-to-difference (ediff-diff-at-point buf-type)))) |
1443 | |
1444 | |
1445 ;; find region most related to the current point position (or POS, if given) | |
1446 (defun ediff-diff-at-point (buf-type &optional pos) | |
1447 (let ((buffer (ediff-get-buffer buf-type)) | |
1448 (ctl-buffer ediff-control-buffer) | |
1449 (max-dif-num (1- ediff-number-of-differences)) | |
1450 (diff-no -1) | |
1451 (prev-beg 0) | |
1452 (prev-end 0) | |
1453 (beg 0) | |
1454 (end 0)) | |
1455 | |
1456 (ediff-eval-in-buffer buffer | |
1457 (setq pos (or pos (point))) | |
1458 (while (and (or (< pos prev-beg) (> pos beg)) | |
1459 (< diff-no max-dif-num)) | |
1460 (setq diff-no (1+ diff-no)) | |
1461 (setq prev-beg beg | |
1462 prev-end end) | |
1463 (setq beg (ediff-get-diff-posn buf-type 'beg diff-no ctl-buffer) | |
1464 end (ediff-get-diff-posn buf-type 'end diff-no ctl-buffer)) | |
1465 ) | |
1466 | |
1467 (if (< (abs (- pos prev-end)) | |
1468 (abs (- pos beg))) | |
1469 diff-no | |
1470 (1+ diff-no)) ; jump-to-diff works with diff nums higher by 1 | |
1471 ))) | |
1472 | |
1473 | |
1474 ;;; Copying diffs. | |
1475 | |
1476 (defun ediff-diff-to-diff (arg &optional keys) | |
1477 "Copy buffer-X'th diff to buffer Y \(X,Y are A, B, or C\). | |
1478 If numerical prefix argument, copy this diff specified in the arg. | |
1479 Otherwise, copy the difference given by `ediff-current-difference'. | |
1480 This command assumes it is bound to a 2-character key sequence, `ab', `ba', | |
1481 `ac', etc., which is used to determine the types of buffers to be used for | |
1482 copying difference regions. The first character in the sequence specifies | |
1483 the source buffer and the second specifies the target. | |
1484 | |
1485 If the second optional argument, a 2-character string, is given, use it to | |
1486 determine the source and the target buffers instead of the command keys." | |
1487 (interactive "P") | |
1488 (or keys (setq keys (this-command-keys))) | |
1489 (if arg | |
1490 (ediff-jump-to-difference arg)) | |
1491 (let* ((key1 (aref keys 0)) | |
1492 (key2 (aref keys 1)) | |
1493 (char1 (if (and ediff-xemacs-p (eventp key1)) (event-key key1) key1)) | |
1494 (char2 (if (and ediff-xemacs-p (eventp key1)) (event-key key2) key2))) | |
1495 (ediff-copy-diff ediff-current-difference | |
1496 (ediff-char-to-buftype char1) | |
1497 (ediff-char-to-buftype char2)) | |
1498 (ediff-recenter 'no-rehighlight))) | |
1499 | |
1500 | |
1501 ;; Copy diff N from FROM-BUF-TYPE \(given as A, B or C\) to TO-BUF-TYPE. | |
1502 ;; If optional DO-NOT-SAVE is non-nil, do not save the old value of the | |
1503 ;; target diff. This is used in merging, when constructing the merged | |
1504 ;; version. | |
1505 (defun ediff-copy-diff (n from-buf-type to-buf-type | |
1506 &optional batch-invocation reg-to-copy) | |
1507 (let* ((to-buf (ediff-get-buffer to-buf-type)) | |
1508 ;;(from-buf (if (not reg-to-copy) (ediff-get-buffer from-buf-type))) | |
1509 (ctrl-buf ediff-control-buffer) | |
1510 (saved-p t) | |
1511 (three-way ediff-3way-job) | |
1512 messg | |
1513 ediff-verbose-p | |
1514 reg-to-delete reg-to-delete-beg reg-to-delete-end) | |
1515 | |
1516 (setq reg-to-delete-beg | |
1517 (ediff-get-diff-posn to-buf-type 'beg n ctrl-buf)) | |
1518 (setq reg-to-delete-end | |
1519 (ediff-get-diff-posn to-buf-type 'end n ctrl-buf)) | |
1520 | |
1521 (if reg-to-copy | |
1522 (setq from-buf-type nil) | |
1523 (setq reg-to-copy (ediff-get-region-contents n from-buf-type ctrl-buf))) | |
1524 | |
1525 (setq reg-to-delete (ediff-get-region-contents | |
1526 n to-buf-type ctrl-buf | |
1527 reg-to-delete-beg reg-to-delete-end)) | |
1528 | |
1529 (setq ediff-disturbed-overlays nil) ; clear before use | |
1530 | |
1531 (if (string= reg-to-delete reg-to-copy) | |
1532 (setq saved-p nil) ; refuse to copy identical buffers | |
1533 ;; seems ok to copy | |
1534 (if (or batch-invocation (ediff-test-save-region n to-buf-type)) | |
1535 (condition-case conds | |
1536 (progn | |
1537 (ediff-eval-in-buffer to-buf | |
1538 ;; to prevent flags from interfering if buffer is writable | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1539 (let ((inhibit-read-only (null buffer-read-only))) |
11042 | 1540 ;; these two insert a dummy char to overcome a bug in |
1541 ;; XEmacs, which sometimes prevents 0-length extents | |
1542 ;; from sensing insertion at its end-points. | |
1543 (if ediff-xemacs-p | |
1544 (progn | |
1545 (goto-char reg-to-delete-end) | |
1546 (insert-before-markers "@"))) | |
1547 | |
1548 (goto-char reg-to-delete-end) | |
1549 (insert-before-markers reg-to-copy) | |
1550 | |
1551 ;; delete the dummy char "@" | |
1552 (if ediff-xemacs-p | |
1553 (delete-char 1)) | |
1554 | |
1555 (if ediff-xemacs-p | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1556 (if (> reg-to-delete-end reg-to-delete-beg) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1557 (kill-region reg-to-delete-beg |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1558 reg-to-delete-end)) |
11042 | 1559 (if (> reg-to-delete-end reg-to-delete-beg) |
1560 (kill-region reg-to-delete-beg reg-to-delete-end) | |
1561 (ediff-move-disturbed-overlays reg-to-delete-beg) | |
1562 )) | |
1563 )) | |
1564 (or batch-invocation | |
1565 (setq | |
1566 messg | |
1567 (ediff-save-diff-region n to-buf-type reg-to-delete)))) | |
1568 (error (message "ediff-copy-diff: %s %s" | |
1569 (car conds) | |
1570 (mapconcat 'prin1-to-string (cdr conds) " ")) | |
1571 (beep 1) | |
1572 (sit-for 2) | |
1573 (setq saved-p nil) | |
1574 ))) | |
1575 ) | |
1576 | |
1577 ;; adjust state of difference in case 3-way and diff was copied ok | |
1578 (if (and saved-p three-way) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1579 (ediff-set-state-of-diff-in-all-buffers n ctrl-buf)) |
11042 | 1580 |
1581 (if batch-invocation | |
1582 (ediff-clear-fine-differences n) | |
1583 ;; If diff3 job, we should recompute fine diffs so we clear them | |
1584 ;; before reinserting flags (and thus before ediff-recenter). | |
1585 (if (and saved-p three-way) | |
1586 (ediff-clear-fine-differences n)) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1587 |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1588 (ediff-refresh-mode-lines) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1589 |
11042 | 1590 ;; For diff2 jobs, don't recompute fine diffs, since we know there |
1591 ;; aren't any. So we clear diffs after ediff-recenter. | |
1592 (if (and saved-p (not three-way)) | |
1593 (ediff-clear-fine-differences n)) | |
1594 ;; Make sure that the message about saving and how to restore is seen | |
1595 ;; by the user | |
1596 (message messg)) | |
1597 )) | |
1598 | |
1599 ;; Save Nth diff of buffer BUF-TYPE \(A, B, or C\). | |
1600 ;; That is to say, the Nth diff on the `ediff-killed-diffs-alist'. REG | |
1601 ;; is the region to save. It is redundant here, but is passed anyway, for | |
1602 ;; convenience. | |
1603 (defun ediff-save-diff-region (n buf-type reg) | |
1604 (let* ((n-th-diff-saved (assoc n ediff-killed-diffs-alist)) | |
1605 (buf (ediff-get-buffer buf-type)) | |
1606 (this-buf-n-th-diff-saved (assoc buf (cdr n-th-diff-saved)))) | |
1607 | |
1608 (if this-buf-n-th-diff-saved | |
1609 ;; either nothing saved for n-th diff and buffer or we OK'ed | |
1610 ;; overriding | |
1611 (setcdr this-buf-n-th-diff-saved reg) | |
1612 (if n-th-diff-saved ;; n-th diff saved, but for another buffer | |
1613 (nconc n-th-diff-saved (list (cons buf reg))) | |
1614 (setq ediff-killed-diffs-alist ;; create record for n-th diff | |
1615 (cons (list n (cons buf reg)) | |
1616 ediff-killed-diffs-alist)))) | |
1617 (message "Saving old diff region #%d of buffer %S. To recover, type `r%s'" | |
1618 (1+ n) buf-type | |
1619 (if ediff-merge-job | |
1620 "" (downcase (symbol-name buf-type)))) | |
1621 )) | |
1622 | |
1623 ;; Test if saving Nth difference region of buffer BUF-TYPE is possible. | |
1624 (defun ediff-test-save-region (n buf-type) | |
1625 (let* ((n-th-diff-saved (assoc n ediff-killed-diffs-alist)) | |
1626 (buf (ediff-get-buffer buf-type)) | |
1627 (this-buf-n-th-diff-saved (assoc buf (cdr n-th-diff-saved)))) | |
1628 | |
1629 (if this-buf-n-th-diff-saved | |
1630 (if (yes-or-no-p | |
1631 (format | |
1632 "You've previously copied diff region %d to buffer %S. Confirm " | |
1633 (1+ n) buf-type)) | |
1634 t | |
1635 (error "Quit")) | |
1636 t))) | |
1637 | |
1638 (defun ediff-pop-diff (n buf-type) | |
1639 "Pop last killed Nth diff region from buffer BUF-TYPE." | |
1640 (let* ((n-th-record (assoc n ediff-killed-diffs-alist)) | |
1641 (buf (ediff-get-buffer buf-type)) | |
1642 (saved-rec (assoc buf (cdr n-th-record))) | |
1643 (three-way ediff-3way-job) | |
1644 (ctl-buf ediff-control-buffer) | |
1645 ediff-verbose-p | |
1646 saved-diff reg-beg reg-end recovered) | |
1647 | |
1648 (if (cdr saved-rec) | |
1649 (setq saved-diff (cdr saved-rec)) | |
1650 (if (> ediff-number-of-differences 0) | |
1651 (error "Nothing saved for diff %d in buffer %S" (1+ n) buf-type) | |
1652 (error "No differences found"))) | |
1653 | |
1654 (setq reg-beg (ediff-get-diff-posn buf-type 'beg n ediff-control-buffer)) | |
1655 (setq reg-end (ediff-get-diff-posn buf-type 'end n ediff-control-buffer)) | |
1656 (setq ediff-disturbed-overlays nil) ; clear before use | |
1657 | |
1658 (condition-case conds | |
1659 (ediff-eval-in-buffer buf | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1660 (let ((inhibit-read-only (null buffer-read-only))) |
11042 | 1661 ;; these two insert a dummy char to overcome a bug in XEmacs, |
1662 ;; which sometimes prevents 0-length extents from sensing | |
1663 ;; insertion at its end-points. | |
1664 (if ediff-xemacs-p | |
1665 (progn | |
1666 (goto-char reg-end) | |
1667 (insert-before-markers "@"))) | |
1668 | |
1669 (goto-char reg-end) | |
1670 (insert-before-markers saved-diff) | |
1671 | |
1672 ;; delete dummy char | |
1673 (if ediff-xemacs-p | |
1674 (delete-char 1)) | |
1675 | |
1676 (if ediff-xemacs-p | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1677 (if (> reg-end reg-beg) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1678 (kill-region reg-beg reg-end)) |
11042 | 1679 (if (> reg-end reg-beg) |
1680 (kill-region reg-beg reg-end) | |
1681 (ediff-move-disturbed-overlays reg-beg) | |
1682 )) | |
1683 | |
1684 (setq recovered t) | |
1685 )) | |
1686 (error (message "ediff-pop-diff: %s %s" | |
1687 (car conds) | |
1688 (mapconcat 'prin1-to-string (cdr conds) " ")) | |
1689 (beep 1))) | |
1690 | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1691 ;; Clearing fine diffs is necessary for |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1692 ;; ediff-unselect-and-select-difference to properly recompute them. We |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1693 ;; can't rely on ediff-copy-diff to clear this vector, as the user might |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1694 ;; have modified diff regions after copying and, thus, may have recomputed |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1695 ;; fine diffs. |
11042 | 1696 (if recovered |
1697 (ediff-clear-fine-differences n)) | |
1698 | |
1699 ;; adjust state of difference | |
1700 (if (and three-way recovered) | |
1701 (ediff-set-state-of-diff-in-all-buffers n ctl-buf)) | |
1702 | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1703 (ediff-refresh-mode-lines) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1704 |
11042 | 1705 (if recovered |
1706 (progn | |
1707 (setq n-th-record (delq saved-rec n-th-record)) | |
1708 (message "Diff region %d in buffer %S restored" (1+ n) buf-type) | |
1709 )) | |
1710 )) | |
1711 | |
1712 (defun ediff-restore-diff (arg &optional key) | |
1713 "Restore ARGth diff from `ediff-killed-diffs-alist'. | |
1714 ARG is a prefix argument. If ARG is nil, restore current-difference. | |
1715 | |
1716 If the second optional argument, a character, is given, use it to | |
1717 determine the target buffer instead of last-command-char" | |
1718 (interactive "P") | |
1719 (if arg | |
1720 (ediff-jump-to-difference arg)) | |
1721 (ediff-pop-diff ediff-current-difference | |
1722 (ediff-char-to-buftype (or key last-command-char))) | |
1723 (ediff-recenter 'no-rehighlight)) | |
1724 | |
1725 (defun ediff-toggle-regexp-match () | |
1726 "Toggle between focusing and hiding of difference regions that match | |
1727 a regular expression typed in by the user." | |
1728 (interactive) | |
1729 (let ((regexp-A "") | |
1730 (regexp-B "") | |
1731 (regexp-C "") | |
1732 msg-connective alt-msg-connective alt-connective) | |
1733 (cond | |
1734 ((or (and (eq ediff-skip-diff-region-function | |
1735 'ediff-focus-on-regexp-matches) | |
1736 (eq last-command-char ?f)) | |
1737 (and (eq ediff-skip-diff-region-function 'ediff-hide-regexp-matches) | |
1738 (eq last-command-char ?h))) | |
1739 (message "Selective browsing by regexp turned off") | |
1740 (setq ediff-skip-diff-region-function 'ediff-show-all-diffs)) | |
1741 ((eq last-command-char ?h) | |
1742 (setq ediff-skip-diff-region-function 'ediff-hide-regexp-matches | |
1743 regexp-A | |
1744 (read-string | |
1745 (format | |
1746 "Ignore A-regions matching this regexp (default \"%s\"): " | |
1747 ediff-regexp-hide-A)) | |
1748 regexp-B | |
1749 (read-string | |
1750 (format | |
1751 "Ignore B-regions matching this regexp (default \"%s\"): " | |
1752 ediff-regexp-hide-B))) | |
1753 (if ediff-3way-comparison-job | |
1754 (setq regexp-C | |
1755 (read-string | |
1756 (format | |
1757 "Ignore C-regions matching this regexp (default \"%s\"): " | |
1758 ediff-regexp-hide-C)))) | |
1759 (if (eq ediff-hide-regexp-connective 'and) | |
1760 (setq msg-connective "BOTH" | |
1761 alt-msg-connective "ONE OF" | |
1762 alt-connective 'or) | |
1763 (setq msg-connective "ONE OF" | |
1764 alt-msg-connective "BOTH" | |
1765 alt-connective 'and)) | |
1766 (if (y-or-n-p | |
1767 (format | |
1768 "Hiding diff regions that match %s regexps. Use %s instead? " | |
1769 msg-connective alt-msg-connective)) | |
1770 (progn | |
1771 (setq ediff-hide-regexp-connective alt-connective) | |
1772 (message "Hiding diff regions that match %s regexps" | |
1773 alt-msg-connective)) | |
1774 (message "Hiding diff regions that match %s regexps" msg-connective)) | |
1775 (or (string= regexp-A "") (setq ediff-regexp-hide-A regexp-A)) | |
1776 (or (string= regexp-B "") (setq ediff-regexp-hide-B regexp-B)) | |
1777 (or (string= regexp-C "") (setq ediff-regexp-hide-C regexp-C))) | |
1778 ((eq last-command-char ?f) | |
1779 (setq ediff-skip-diff-region-function 'ediff-focus-on-regexp-matches | |
1780 regexp-A | |
1781 (read-string | |
1782 (format | |
1783 "Focus on A-regions matching this regexp (default \"%s\"): " | |
1784 ediff-regexp-focus-A)) | |
1785 regexp-B | |
1786 (read-string | |
1787 (format | |
1788 "Focus on B-regions matching this regexp (default \"%s\"): " | |
1789 ediff-regexp-focus-B))) | |
1790 (if ediff-3way-comparison-job | |
1791 (setq regexp-C | |
1792 (read-string | |
1793 (format | |
1794 "Focus on C-regions matching this regexp (default \"%s\"): " | |
1795 ediff-regexp-focus-C)))) | |
1796 (if (eq ediff-focus-regexp-connective 'and) | |
1797 (setq msg-connective "BOTH" | |
1798 alt-msg-connective "ONE OF" | |
1799 alt-connective 'or) | |
1800 (setq msg-connective "ONE OF" | |
1801 alt-msg-connective "BOTH" | |
1802 alt-connective 'and)) | |
1803 (if (y-or-n-p | |
1804 (format | |
1805 "Focusing on diff regions that match %s regexps. Use %s instead? " | |
1806 msg-connective alt-msg-connective)) | |
1807 (progn | |
1808 (setq ediff-focus-regexp-connective alt-connective) | |
1809 (message "Focusing on diff regions that match %s regexps" | |
1810 alt-msg-connective)) | |
1811 (message "Focusing on diff regions that match %s regexps" | |
1812 msg-connective)) | |
1813 (or (string= regexp-A "") (setq ediff-regexp-focus-A regexp-A)) | |
1814 (or (string= regexp-B "") (setq ediff-regexp-focus-B regexp-B)) | |
1815 (or (string= regexp-C "") (setq ediff-regexp-focus-C regexp-C)))))) | |
1816 | |
1817 (defun ediff-toggle-skip-similar () | |
1818 (interactive) | |
1819 (if (not (eq ediff-auto-refine 'on)) | |
1820 (error | |
1821 "Can't skip over whitespace regions: first turn auto-refining on")) | |
1822 (setq ediff-ignore-similar-regions (not ediff-ignore-similar-regions)) | |
1823 (if ediff-ignore-similar-regions | |
1824 (message | |
1825 "Skipping regions that differ only in white space & line breaks") | |
1826 (message "Skipping over white-space differences turned off"))) | |
1827 | |
1828 (defun ediff-focus-on-regexp-matches (n) | |
1829 "Focus on diffs that match regexp `ediff-regexp-focus-A/B'. | |
1830 Regions to be ignored according to this function are those where | |
1831 buf A region doesn't match `ediff-regexp-focus-A' and buf B region | |
1832 doesn't match `ediff-regexp-focus-B'. | |
1833 This function returns nil if the region number N (specified as | |
1834 an argument) is not to be ignored and t if region N is to be ignored. | |
1835 | |
1836 N is a region number used by Ediff internally. It is 1 less | |
1837 the number seen by the user." | |
1838 (if (ediff-valid-difference-p n) | |
1839 (let* ((ctl-buf ediff-control-buffer) | |
1840 (regex-A ediff-regexp-focus-A) | |
1841 (regex-B ediff-regexp-focus-B) | |
1842 (regex-C ediff-regexp-focus-C) | |
1843 (reg-A-match (ediff-eval-in-buffer ediff-buffer-A | |
1844 (goto-char (ediff-get-diff-posn 'A 'beg n ctl-buf)) | |
1845 (re-search-forward | |
1846 regex-A | |
1847 (ediff-get-diff-posn 'A 'end n ctl-buf) | |
1848 t))) | |
1849 (reg-B-match (ediff-eval-in-buffer ediff-buffer-B | |
1850 (goto-char (ediff-get-diff-posn 'B 'beg n ctl-buf)) | |
1851 (re-search-forward | |
1852 regex-B | |
1853 (ediff-get-diff-posn 'B 'end n ctl-buf) | |
1854 t))) | |
1855 (reg-C-match (if ediff-3way-comparison-job | |
1856 (ediff-eval-in-buffer ediff-buffer-C | |
1857 (goto-char | |
1858 (ediff-get-diff-posn 'C 'beg n ctl-buf)) | |
1859 (re-search-forward | |
1860 regex-C | |
1861 (ediff-get-diff-posn 'C 'end n ctl-buf) | |
1862 t))))) | |
1863 (not (eval (if ediff-3way-comparison-job | |
1864 (list ediff-focus-regexp-connective | |
1865 reg-A-match reg-B-match reg-C-match) | |
1866 (list ediff-focus-regexp-connective | |
1867 reg-A-match reg-B-match)))) | |
1868 ))) | |
1869 | |
1870 (defun ediff-hide-regexp-matches (n) | |
1871 "Hide diffs that match regexp `ediff-regexp-hide-A/B/C'. | |
1872 Regions to be ignored are those where buf A region matches | |
1873 `ediff-regexp-hide-A' and buf B region matches `ediff-regexp-hide-B'. | |
1874 This function returns nil if the region number N (specified as | |
1875 an argument) is not to be ignored and t if region N is to be ignored. | |
1876 | |
1877 N is a region number used by Ediff internally. It is 1 less | |
1878 the number seen by the user." | |
1879 (if (ediff-valid-difference-p n) | |
1880 (let* ((ctl-buf ediff-control-buffer) | |
1881 (regex-A ediff-regexp-hide-A) | |
1882 (regex-B ediff-regexp-hide-B) | |
1883 (regex-C ediff-regexp-hide-C) | |
1884 (reg-A-match (ediff-eval-in-buffer ediff-buffer-A | |
1885 (goto-char (ediff-get-diff-posn 'A 'beg n ctl-buf)) | |
1886 (re-search-forward | |
1887 regex-A | |
1888 (ediff-get-diff-posn 'A 'end n ctl-buf) | |
1889 t))) | |
1890 (reg-B-match (ediff-eval-in-buffer ediff-buffer-B | |
1891 (goto-char (ediff-get-diff-posn 'B 'beg n ctl-buf)) | |
1892 (re-search-forward | |
1893 regex-B | |
1894 (ediff-get-diff-posn 'B 'end n ctl-buf) | |
1895 t))) | |
1896 (reg-C-match (if ediff-3way-comparison-job | |
1897 (ediff-eval-in-buffer ediff-buffer-C | |
1898 (goto-char | |
1899 (ediff-get-diff-posn 'C 'beg n ctl-buf)) | |
1900 (re-search-forward | |
1901 regex-C | |
1902 (ediff-get-diff-posn 'C 'end n ctl-buf) | |
1903 t))))) | |
1904 (eval (if ediff-3way-comparison-job | |
1905 (list ediff-hide-regexp-connective | |
1906 reg-A-match reg-B-match reg-C-match) | |
1907 (list ediff-hide-regexp-connective reg-A-match reg-B-match))) | |
1908 ))) | |
1909 | |
1910 | |
1911 | |
1912 ;;; Quitting, suspending, etc. | |
1913 | |
1914 (defun ediff-quit () | |
1915 "Finish an Ediff session and exit Ediff. | |
1916 Unselects the selected difference, if any, restores the read-only and modified | |
1917 flags of the compared file buffers, kills Ediff buffers for this session | |
1918 \(but not buffers A, B, C\)." | |
1919 (interactive) | |
1920 (if (prog1 | |
1921 (y-or-n-p "Do you really want to exit Ediff? ") | |
1922 (message "")) | |
1923 (ediff-really-quit))) | |
1924 | |
1925 | |
1926 ;; Perform the quit operations. | |
1927 (defun ediff-really-quit () | |
1928 (ediff-unhighlight-diffs-totally) | |
1929 (ediff-clear-diff-vector 'ediff-difference-vector-A 'fine-diffs-also) | |
1930 (ediff-clear-diff-vector 'ediff-difference-vector-B 'fine-diffs-also) | |
1931 (ediff-clear-diff-vector 'ediff-difference-vector-C 'fine-diffs-also) | |
1932 | |
1933 (ediff-delete-temp-files) | |
1934 | |
1935 ;; Restore visibility range. This affects only ediff-*-regions/windows. | |
1936 ;; Since for other job names ediff-visible-region sets | |
1937 ;; ediff-visible-bounds to ediff-wide-bounds, the settings below are | |
1938 ;; ignored for such jobs. | |
1939 (if ediff-quit-widened | |
1940 (setq ediff-visible-bounds ediff-wide-bounds) | |
1941 (setq ediff-visible-bounds ediff-narrow-bounds)) | |
1942 | |
1943 ;; Apply selective display to narrow or widen | |
1944 (ediff-visible-region) | |
1945 (mapcar (function (lambda (overl) | |
1946 (if (ediff-overlayp overl) | |
1947 (ediff-delete-overlay overl)))) | |
1948 ediff-wide-bounds) | |
1949 (mapcar (function (lambda (overl) | |
1950 (if (ediff-overlayp overl) | |
1951 (ediff-delete-overlay overl)))) | |
1952 ediff-narrow-bounds) | |
1953 | |
1954 ;; restore buffer mode line id's in buffer-A/B/C | |
1955 (let ((control-buffer ediff-control-buffer)) | |
1956 (condition-case nil | |
1957 (ediff-eval-in-buffer ediff-buffer-A | |
1958 (setq ediff-this-buffer-control-sessions | |
1959 (delq control-buffer ediff-this-buffer-control-sessions)) | |
1960 (kill-local-variable 'mode-line-buffer-identification) | |
1961 (kill-local-variable 'mode-line-format) | |
1962 ) | |
1963 (error)) | |
1964 | |
1965 (condition-case nil | |
1966 (ediff-eval-in-buffer ediff-buffer-B | |
1967 (setq ediff-this-buffer-control-sessions | |
1968 (delq control-buffer ediff-this-buffer-control-sessions)) | |
1969 (kill-local-variable 'mode-line-buffer-identification) | |
1970 (kill-local-variable 'mode-line-format) | |
1971 ) | |
1972 (error)) | |
1973 | |
1974 (condition-case nil | |
1975 (ediff-eval-in-buffer ediff-buffer-C | |
1976 (kill-local-variable 'mode-line-buffer-identification) | |
1977 (kill-local-variable 'mode-line-format) | |
1978 ) | |
1979 (error)) | |
1980 ) | |
1981 ;; restore state of buffers to what it was before ediff | |
1982 (ediff-restore-protected-variables) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1983 ;; good place to kill buffers A/B/C |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
1984 (run-hooks 'ediff-cleanup-hooks) |
11042 | 1985 (run-hooks 'ediff-quit-hooks)) |
1986 | |
1987 | |
1988 (defun ediff-delete-temp-files () | |
1989 (if (stringp ediff-temp-file-A) | |
1990 (delete-file ediff-temp-file-A)) | |
1991 (if (stringp ediff-temp-file-B) | |
1992 (delete-file ediff-temp-file-B)) | |
1993 (if (stringp ediff-temp-file-C) | |
1994 (delete-file ediff-temp-file-C))) | |
1995 | |
1996 | |
1997 ;; Kill control buffer, other auxiliary Ediff buffers. | |
1998 ;; Leave one of the frames split between buffers A/B/C | |
1999 (defun ediff-cleanup-mess () | |
2000 (let ((buff-A ediff-buffer-A) | |
2001 (buff-B ediff-buffer-B) | |
2002 (buff-C ediff-buffer-C) | |
2003 (ctl-buf ediff-control-buffer) | |
2004 (ctl-frame ediff-control-frame) | |
2005 (three-way-job ediff-3way-job)) | |
2006 | |
2007 (ediff-kill-buffer-carefully ediff-diff-buffer) | |
2008 (ediff-kill-buffer-carefully ediff-custom-diff-buffer) | |
2009 (ediff-kill-buffer-carefully ediff-fine-diff-buffer) | |
2010 (ediff-kill-buffer-carefully ediff-tmp-buffer) | |
2011 (ediff-kill-buffer-carefully ediff-error-buffer) | |
2012 (ediff-kill-buffer-carefully ediff-patch-diagnostics) | |
2013 (ediff-kill-buffer-carefully ediff-msg-buffer) | |
2014 (ediff-kill-buffer-carefully ediff-debug-buffer) | |
2015 | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2016 ;;(redraw-display) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2017 (if (and (ediff-window-display-p) (frame-live-p ctl-frame)) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2018 (delete-frame ctl-frame)) |
11042 | 2019 (ediff-kill-buffer-carefully ctl-buf) |
2020 | |
2021 (delete-other-windows) | |
2022 | |
2023 ;; display only if not visible | |
2024 (condition-case nil | |
2025 (or (ediff-get-visible-buffer-window buff-B) | |
2026 (switch-to-buffer buff-B)) | |
2027 (error)) | |
2028 (condition-case nil | |
2029 (or (ediff-get-visible-buffer-window buff-A) | |
2030 (progn | |
2031 (if (ediff-get-visible-buffer-window buff-B) | |
2032 (split-window-vertically)) | |
2033 (switch-to-buffer buff-A))) | |
2034 (error)) | |
2035 (if three-way-job | |
2036 (condition-case nil | |
2037 (or (ediff-get-visible-buffer-window buff-C) | |
2038 (progn | |
2039 (if (or (ediff-get-visible-buffer-window buff-A) | |
2040 (ediff-get-visible-buffer-window buff-B)) | |
2041 (split-window-vertically)) | |
2042 (switch-to-buffer buff-C) | |
2043 (balance-windows))) | |
2044 (error))) | |
2045 (message "") | |
2046 )) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2047 |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2048 (defun ediff-janitor () |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2049 "Kill buffers A, B, and, possibly, C, if these buffers aren't modified. |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2050 In merge jobs, buffer C is never deleted. |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2051 However, the side effect of cleaning up may be that you cannot compare the same |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2052 buffer in two separate Ediff sessions: quitting one of them will delete this |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2053 buffer in another session as well." |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2054 (or (not (ediff-buffer-live-p ediff-buffer-A)) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2055 (buffer-modified-p ediff-buffer-A) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2056 (ediff-kill-buffer-carefully ediff-buffer-A)) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2057 (or (not (ediff-buffer-live-p ediff-buffer-B)) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2058 (buffer-modified-p ediff-buffer-B) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2059 (ediff-kill-buffer-carefully ediff-buffer-B)) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2060 (if ediff-merge-job ; don't del buf C if merging--del ancestor buf instead |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2061 (or (not (ediff-buffer-live-p ediff-ancestor-buffer)) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2062 (buffer-modified-p ediff-ancestor-buffer) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2063 (ediff-kill-buffer-carefully ediff-ancestor-buffer)) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2064 (or (not (ediff-buffer-live-p ediff-buffer-C)) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2065 (buffer-modified-p ediff-buffer-C) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2066 (ediff-kill-buffer-carefully ediff-buffer-C)))) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2067 |
11042 | 2068 ;; The default way of suspending Ediff. |
2069 ;; Buries Ediff buffers, kills all windows. | |
2070 (defun ediff-default-suspend-hook () | |
2071 (let* ((buf-A ediff-buffer-A) | |
2072 (buf-B ediff-buffer-B) | |
2073 (buf-C ediff-buffer-C) | |
2074 (buf-A-wind (ediff-get-visible-buffer-window buf-A)) | |
2075 (buf-B-wind (ediff-get-visible-buffer-window buf-B)) | |
2076 (buf-C-wind (ediff-get-visible-buffer-window buf-C)) | |
2077 (buf-patch ediff-patch-buf) | |
2078 (buf-patch-diag ediff-patch-diagnostics) | |
2079 (buf-err ediff-error-buffer) | |
2080 (buf-diff ediff-diff-buffer) | |
2081 (buf-custom-diff ediff-custom-diff-buffer) | |
2082 (buf-fine-diff ediff-fine-diff-buffer)) | |
2083 | |
2084 ;; hide the control panel | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2085 (if (and (ediff-window-display-p) (frame-live-p ediff-control-frame)) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2086 (iconify-frame ediff-control-frame) |
11042 | 2087 (bury-buffer)) |
2088 (if buf-err (bury-buffer buf-err)) | |
2089 (if buf-diff (bury-buffer buf-diff)) | |
2090 (if buf-custom-diff (bury-buffer buf-custom-diff)) | |
2091 (if buf-fine-diff (bury-buffer buf-fine-diff)) | |
2092 (if buf-patch (bury-buffer buf-patch)) | |
2093 (if buf-patch-diag (bury-buffer buf-patch-diag)) | |
2094 (if (window-live-p buf-A-wind) | |
2095 (progn | |
2096 (select-window buf-A-wind) | |
2097 (delete-other-windows) | |
2098 (bury-buffer)) | |
2099 (if (ediff-buffer-live-p buf-A) (bury-buffer buf-A))) | |
2100 (if (window-live-p buf-B-wind) | |
2101 (progn | |
2102 (select-window buf-B-wind) | |
2103 (delete-other-windows) | |
2104 (bury-buffer)) | |
2105 (if (ediff-buffer-live-p buf-B) (bury-buffer buf-B))) | |
2106 (if (window-live-p buf-C-wind) | |
2107 (progn | |
2108 (select-window buf-C-wind) | |
2109 (delete-other-windows) | |
2110 (bury-buffer)) | |
2111 (if (ediff-buffer-live-p buf-C) (bury-buffer buf-C))) | |
2112 | |
2113 )) | |
2114 | |
2115 | |
2116 (defun ediff-suspend () | |
2117 "Suspend Ediff. | |
2118 To resume, switch to the appropriate `Ediff Control Panel' | |
2119 buffer and then type \\[ediff-recenter]. Ediff will automatically set | |
2120 up an appropriate window config." | |
2121 (interactive) | |
2122 (let ((key (substitute-command-keys "\\[ediff-recenter]"))) | |
2123 (run-hooks 'ediff-suspend-hooks) | |
2124 (message | |
2125 "To resume, switch to Ediff Control Panel and hit `%s'" key))) | |
2126 | |
2127 | |
2128 (defun ediff-status-info () | |
2129 "Show the names of the buffers or files being operated on by Ediff. | |
2130 Hit \\[ediff-recenter] to reset the windows afterward." | |
2131 (interactive) | |
2132 (with-output-to-temp-buffer " *ediff-info*" | |
2133 (princ (ediff-version)) | |
2134 (princ "\n\n") | |
2135 (ediff-eval-in-buffer ediff-buffer-A | |
2136 (if buffer-file-name | |
2137 (princ | |
2138 (format "File A = %S\n" buffer-file-name)) | |
2139 (princ | |
2140 (format "Buffer A = %S\n" (buffer-name))))) | |
2141 (ediff-eval-in-buffer ediff-buffer-B | |
2142 (if buffer-file-name | |
2143 (princ | |
2144 (format "File B = %S\n" buffer-file-name)) | |
2145 (princ | |
2146 (format "Buffer B = %S\n" (buffer-name))))) | |
2147 (if ediff-3way-job | |
2148 (ediff-eval-in-buffer ediff-buffer-C | |
2149 (if buffer-file-name | |
2150 (princ | |
2151 (format "File C = %S\n" buffer-file-name)) | |
2152 (princ | |
2153 (format "Buffer C = %S\n" (buffer-name)))))) | |
2154 | |
2155 (let* ((A-line (ediff-eval-in-buffer ediff-buffer-A | |
2156 (1+ (count-lines (point-min) (point))))) | |
2157 (B-line (ediff-eval-in-buffer ediff-buffer-B | |
2158 (1+ (count-lines (point-min) (point))))) | |
2159 C-line) | |
2160 (princ (format "\Buffer A's point is on line %d\n" A-line)) | |
2161 (princ (format "Buffer B's point is on line %d\n" B-line)) | |
2162 (if ediff-3way-job | |
2163 (progn | |
2164 (setq C-line (ediff-eval-in-buffer ediff-buffer-C | |
2165 (1+ (count-lines (point-min) (point))))) | |
2166 (princ (format "Buffer C's point is on line %d\n" C-line))))) | |
2167 | |
2168 (princ (format "\nCurrent difference number = %S\n" | |
2169 (cond ((< ediff-current-difference 0) 'start) | |
2170 ((>= ediff-current-difference | |
2171 ediff-number-of-differences) 'end) | |
2172 (t (1+ ediff-current-difference))))) | |
2173 | |
2174 (cond (ediff-ignore-similar-regions | |
2175 (princ "\nSkipping regions that differ only in white space & line breaks")) | |
2176 (t | |
2177 (princ "\nNot skipping regions that differ in white space & line breaks"))) | |
2178 | |
2179 (cond ((eq ediff-skip-diff-region-function 'ediff-show-all-diffs) | |
2180 (princ "\nSelective browsing by regexp is off.\n")) | |
2181 ((eq ediff-skip-diff-region-function 'ediff-hide-regexp-matches) | |
2182 (princ | |
2183 "\nIgnoring regions that match") | |
2184 (princ | |
2185 (format | |
2186 "\n\t regexp `%s' in buffer A %S\n\t regexp `%s' in buffer B\n" | |
2187 ediff-regexp-hide-A ediff-hide-regexp-connective | |
2188 ediff-regexp-hide-B))) | |
2189 ((eq ediff-skip-diff-region-function 'ediff-focus-on-regexp-matches) | |
2190 (princ | |
2191 "\nFocusing on regions that match") | |
2192 (princ | |
2193 (format | |
2194 "\n\t regexp `%s' in buffer A %S\n\t regexp `%s' in buffer B\n" | |
2195 ediff-regexp-focus-A ediff-focus-regexp-connective | |
2196 ediff-regexp-focus-B))) | |
2197 (t (princ "\nSelective browsing via a user-defined method.\n"))) | |
2198 | |
2199 (princ | |
2200 (format "\nBugs/suggestions: type `%s' while in Ediff Control Panel." | |
2201 (substitute-command-keys "\\[ediff-submit-report]"))) | |
2202 )) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2203 |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2204 (defun ediff-documentation () |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2205 "Jump to Ediff's Info file." |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2206 (interactive) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2207 (let ((ctl-window ediff-control-window) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2208 (ctl-buf ediff-control-buffer)) |
11042 | 2209 |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2210 (ediff-skip-unsuitable-frames) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2211 (condition-case nil |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2212 (progn |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2213 (pop-to-buffer (get-buffer-create "*info*")) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2214 (info "ediff") |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2215 (message "Type `i' to search for a specific topic")) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2216 (error (beep 1) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2217 (with-output-to-temp-buffer " *ediff-info*" |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2218 (princ (format " |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2219 The Info file for Ediff does not seem to be installed. |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2220 |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2221 This file is part of the distribution of %sEmacs. |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2222 Please contact your system administrator. " |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2223 (if ediff-xemacs-p "X" "")))) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2224 (if (window-live-p ctl-window) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2225 (progn |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2226 (select-window ctl-window) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2227 (switch-to-buffer ctl-buf))))))) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2228 |
11042 | 2229 |
2230 | |
2231 | |
2232 ;;; Support routines | |
2233 | |
2234 ;; Select a difference by placing the ASCII flags around the appropriate | |
2235 ;; group of lines in the A, B buffers | |
2236 ;; This may have to be modified for buffer C, when it will be supported. | |
2237 (defun ediff-select-difference (n) | |
2238 (if (and (ediff-buffer-live-p ediff-buffer-A) | |
2239 (ediff-buffer-live-p ediff-buffer-B) | |
2240 (ediff-valid-difference-p n)) | |
2241 (progn | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2242 (if (and (ediff-window-display-p) ediff-use-faces) |
11042 | 2243 (progn |
2244 (ediff-highlight-diff n) | |
2245 (setq ediff-highlighting-style 'face)) | |
2246 (setq ediff-highlighting-style 'ascii) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2247 (ediff-place-flags-in-buffer |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2248 'A ediff-buffer-A ediff-control-buffer n) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2249 (ediff-place-flags-in-buffer |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2250 'B ediff-buffer-B ediff-control-buffer n) |
11042 | 2251 (if ediff-3way-job |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2252 (ediff-place-flags-in-buffer |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2253 'C ediff-buffer-C ediff-control-buffer n)) |
11042 | 2254 ) |
2255 | |
2256 (ediff-install-fine-diff-if-necessary n) | |
2257 (run-hooks 'ediff-select-hooks)))) | |
2258 | |
2259 | |
2260 ;; Unselect a difference by removing the ASCII flags in the buffers. | |
2261 ;; This may have to be modified for buffer C, when it will be supported. | |
2262 (defun ediff-unselect-difference (n) | |
2263 (if (ediff-valid-difference-p n) | |
2264 (progn | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2265 (cond ((and (ediff-window-display-p) ediff-use-faces) |
11042 | 2266 (ediff-unhighlight-diff)) |
2267 ((eq ediff-highlighting-style 'ascii) | |
2268 (ediff-remove-flags-from-buffer | |
2269 ediff-buffer-A | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2270 (ediff-get-diff-overlay n 'A)) |
11042 | 2271 (ediff-remove-flags-from-buffer |
2272 ediff-buffer-B | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2273 (ediff-get-diff-overlay n 'B)) |
11042 | 2274 (if ediff-3way-job |
2275 (ediff-remove-flags-from-buffer | |
2276 ediff-buffer-C | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2277 (ediff-get-diff-overlay n 'C))) |
11042 | 2278 )) |
2279 (setq ediff-highlighting-style nil) | |
2280 | |
2281 ;; unhighlight fine diffs | |
2282 (ediff-set-fine-diff-properties ediff-current-difference 'default) | |
2283 (run-hooks 'ediff-unselect-hooks)))) | |
2284 | |
2285 | |
2286 ;; Unselects prev diff and selects a new one, if FLAG has value other than | |
2287 ;; 'select-only or 'unselect-only. If FLAG is 'select-only, the | |
2288 ;; next difference is selected, but the current selection is not | |
2289 ;; unselected. If FLAG is 'unselect-only then the current selection is | |
2290 ;; unselected, but the next one is not selected. If NO-RECENTER is non-nil, | |
2291 ;; don't recenter buffers after selecting/unselecting. | |
2292 ;; | |
2293 (defun ediff-unselect-and-select-difference (n &optional flag no-recenter) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2294 (let ((ediff-current-difference n)) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2295 (or no-recenter |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2296 (ediff-recenter 'no-rehighlight))) |
11042 | 2297 |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2298 (let ((control-buf ediff-control-buffer)) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2299 (unwind-protect |
11042 | 2300 (progn |
2301 (or (eq flag 'select-only) | |
2302 (ediff-unselect-difference ediff-current-difference)) | |
2303 | |
2304 (or (eq flag 'unselect-only) | |
2305 (ediff-select-difference n)) | |
2306 (setq ediff-current-difference n) | |
2307 ) ; end protected section | |
2308 | |
2309 (ediff-eval-in-buffer control-buf | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2310 (ediff-refresh-mode-lines)) |
11042 | 2311 ))) |
2312 | |
2313 | |
2314 (defun ediff-read-file-name (prompt default-dir default-file) | |
2315 ; This is a modified version of a similar function in `emerge.el'. | |
2316 ; PROMPT should not have trailing ': ', so that it can be modified | |
2317 ; according to context. | |
2318 ; If default-file is set, it should be used as the default value. | |
2319 ; If default-dir is non-nil, use it as the default directory. | |
2320 ; Otherwise, use the value of Emacs' variable `default-directory.' | |
2321 | |
2322 ;; hack default-dir if it is not set | |
2323 (setq default-dir | |
2324 (file-name-as-directory | |
2325 (abbreviate-file-name | |
2326 (expand-file-name (or default-dir | |
2327 (and default-file | |
2328 (file-name-directory default-file)) | |
2329 default-directory))))) | |
2330 | |
2331 ;; strip the directory from default-file | |
2332 (if default-file | |
2333 (setq default-file (file-name-nondirectory default-file))) | |
2334 (if (string= default-file "") | |
2335 (setq default-file nil)) | |
2336 | |
2337 (let (f) | |
2338 (setq f (expand-file-name | |
2339 (read-file-name | |
2340 (format "%s%s: " | |
2341 prompt | |
2342 (if default-file | |
2343 (concat " (default " default-file ")") | |
2344 "")) | |
2345 default-dir | |
2346 default-file | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2347 t ; must match, no-confirm |
11042 | 2348 (if default-file (file-name-directory default-file)) |
2349 ) | |
2350 default-dir | |
2351 )) | |
2352 ;; If user enters a directory name, expand the default file in that | |
2353 ;; directory. This allows the user to enter a directory name for the | |
2354 ;; B-file and diff against the default-file in that directory instead | |
2355 ;; of a DIRED listing! | |
2356 (if (and (file-directory-p f) default-file) | |
2357 (setq f (expand-file-name | |
2358 (file-name-nondirectory default-file) f))) | |
2359 f)) | |
2360 | |
2361 ;; If `prefix' is given, then it is used as a prefix for the temp file | |
2362 ;; name. Otherwise, `_buffer-name' is used. If `file' is given, use this | |
2363 ;; file and don't create a new one. | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2364 ;; Also, save buffer from START to END in the file. |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2365 ;; START defaults to (point-min), END to (point-max) |
11042 | 2366 (defun ediff-make-temp-file (&optional prefix given-file start end) |
2367 (let ((f (or given-file | |
2368 (make-temp-name (concat | |
2369 ediff-temp-file-prefix | |
2370 (if prefix | |
2371 (concat prefix "_") | |
2372 "ediff_")))))) | |
2373 ;; create the file | |
2374 (write-region (if start start (point-min)) | |
2375 (if end end (point-max)) | |
2376 f | |
2377 nil ; don't append---erase | |
2378 'no-message) | |
2379 (set-file-modes f ediff-temp-file-mode) | |
2380 f)) | |
2381 | |
2382 ;; Quote metacharacters (using \) when executing diff in Unix, but not in | |
2383 ;; EMX OS/2 | |
2384 (defun ediff-protect-metachars (str) | |
2385 (or (memq system-type '(emx vax-vms axp-vms)) | |
2386 (let ((limit 0)) | |
2387 (while (string-match ediff-metachars str limit) | |
2388 (setq str (concat (substring str 0 (match-beginning 0)) | |
2389 "\\" | |
2390 (substring str (match-beginning 0)))) | |
2391 (setq limit (1+ (match-end 0)))))) | |
2392 str) | |
2393 | |
2394 ;; Make sure the current buffer (for a file) has the same contents as the | |
2395 ;; file on disk, and attempt to remedy the situation if not. | |
2396 ;; Signal an error if we can't make them the same, or the user doesn't want | |
2397 ;; to do what is necessary to make them the same. | |
2398 ;; If file has file handlers (indicated by the optional arg), then we | |
2399 ;; offer to instead of saving. This is one difference with Emerge. | |
2400 ;; Another is that we always offer to revert obsolete files, whether they | |
2401 ;; are modified or not. | |
2402 (defun ediff-verify-file-buffer (&optional file-magic) | |
2403 ;; First check if the file has been modified since the buffer visited it. | |
2404 (if (verify-visited-file-modtime (current-buffer)) | |
2405 (if (buffer-modified-p) | |
2406 ;; If buffer is not obsolete and is modified, offer to save | |
2407 (if (yes-or-no-p | |
2408 (format "Buffer out of sync with visited file. %s file %s? " | |
2409 (if file-magic "Revert" "Save") | |
2410 buffer-file-name)) | |
2411 (if (not file-magic) | |
2412 (save-buffer) | |
2413 ;; for some reason, file-name-handlers append instead of | |
2414 ;; replacing, so we have to erase first. | |
2415 (erase-buffer) | |
2416 (revert-buffer t t)) | |
2417 (error "Buffer out of sync for file %s" buffer-file-name)) | |
2418 ;; If buffer is not obsolete and is not modified, do nothing | |
2419 nil) | |
2420 ;; If buffer is obsolete, offer to revert | |
2421 (if (yes-or-no-p | |
2422 (format "Buffer out of sync with visited file. Revert file %s? " | |
2423 buffer-file-name)) | |
2424 (progn | |
2425 (if file-magic | |
2426 (erase-buffer)) | |
2427 (revert-buffer t t)) | |
2428 (error "Buffer out of sync for file %s" buffer-file-name)))) | |
2429 | |
2430 | |
2431 | |
2432 (defun ediff-check-for-ascii-flags () | |
2433 (eval | |
2434 (cons 'or | |
2435 (mapcar (function (lambda (buf) | |
2436 (if (ediff-buffer-live-p buf) | |
2437 (ediff-eval-in-buffer buf | |
2438 (eq ediff-highlighting-style 'ascii))))) | |
2439 ediff-this-buffer-control-sessions)))) | |
2440 | |
2441 ;; It would be nice to use these two functions as hooks instead of | |
2442 ;; ediff-insert-in-front and ediff-move-disturbed-overlays. | |
2443 ;; However, Emacs has a bug that causes BEG and END, below, to be | |
2444 ;; the same, i.e., the end of inserted text is not passed correctly. | |
2445 ;; Since the overlay doesn't move when these hooks run, | |
2446 ;; there is no way to correctly determine the new (desired) position of | |
2447 ;; the overlay end. | |
2448 ;; Either this bug is fixed, or (better) use sticky overlays when they will | |
2449 ;; be implemented in Emacs, like they are in XEmacs. | |
2450 ;;(defun ediff-capture-inserts-in-front (overl beg end) | |
2451 ;; (if (ediff-overlay-get overl 'ediff-diff-num) | |
2452 ;; (ediff-move-overlay | |
2453 ;; overl beg (+ (- end beg) (ediff-overlay-end overl))) | |
2454 ;; )) | |
2455 ;;(defun ediff-capture-inserts-behind (overl beg end) | |
2456 ;; (if (ediff-overlay-get overl 'ediff-diff-num) | |
2457 ;; (ediff-move-overlay overl (ediff-overlay-start overl) end)) | |
2458 ;; )) | |
2459 | |
2460 ;; to be deleted in due time | |
2461 ;; Capture overlays that had insertions in the front. | |
2462 ;; Called when overlay OVERL gets insertion in front. | |
2463 (defun ediff-insert-in-front (overl &optional flag beg end length) | |
2464 (if (ediff-overlay-get overl 'ediff-diff-num) | |
2465 (setq ediff-disturbed-overlays | |
2466 (cons overl ediff-disturbed-overlays)))) | |
2467 | |
2468 | |
2469 ;; to be deleted in due time | |
2470 ;; We can't move overlays directly in insert-in-front-hooks | |
2471 ;; because when diff is highlighted with ascii flags, they will disturb | |
2472 ;; overlays and so they will be included in them, which we don't want. | |
2473 (defun ediff-move-disturbed-overlays (posn) | |
2474 (mapcar (function (lambda (overl) | |
2475 (ediff-move-overlay overl | |
2476 posn | |
2477 (ediff-overlay-end overl)) | |
2478 )) | |
2479 ediff-disturbed-overlays) | |
2480 (setq ediff-disturbed-overlays nil)) | |
2481 | |
2482 | |
2483 (defun ediff-save-buffer (arg) | |
2484 "Safe way of saving buffers A, B, C, and the diff output. | |
2485 `wa' saves buffer A, `wb' saves buffer B, `wc' saves buffer C, | |
2486 and `wd' saves the diff output." | |
2487 (interactive "P") | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2488 (ediff-eval-in-buffer |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2489 (cond ((memq last-command-char '(?a ?b ?c)) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2490 (ediff-get-buffer |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2491 (ediff-char-to-buftype last-command-char))) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2492 ((eq last-command-char ?d) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2493 (message "Saving diff output ...")(sit-for 1) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2494 (if arg ediff-diff-buffer ediff-custom-diff-buffer) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2495 )) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2496 (save-buffer))) |
11042 | 2497 |
2498 | |
2499 ;; will simplify it in due time, when emacs acquires before/after strings | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2500 (defun ediff-remove-flags-from-buffer (buffer overlay) |
11042 | 2501 (ediff-eval-in-buffer buffer |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2502 (let ((inhibit-read-only t)) |
11042 | 2503 (if ediff-xemacs-p |
2504 (ediff-overlay-put overlay 'begin-glyph nil) | |
2505 ;; before-string is not yet implemented in emacs. | |
2506 ;; when it will be, I will be able to delete much of the rest of | |
2507 ;; this function | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2508 (ediff-overlay-put overlay 'before-string nil)) |
11042 | 2509 |
2510 (if ediff-xemacs-p | |
2511 (ediff-overlay-put overlay 'end-glyph nil) | |
2512 ;; after-string is not yet implemented in emacs. | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2513 (ediff-overlay-put overlay 'after-string nil)) |
11042 | 2514 ))) |
2515 | |
2516 | |
2517 | |
2518 ;; will simplify it in due time, when emacs acquires before/after strings | |
2519 (defun ediff-place-flags-in-buffer (buf-type buffer ctl-buffer diff) | |
2520 (ediff-eval-in-buffer buffer | |
2521 (ediff-place-flags-in-buffer1 buf-type ctl-buffer diff))) | |
2522 | |
2523 | |
2524 (defun ediff-place-flags-in-buffer1 (buf-type ctl-buffer diff-no) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2525 (let* ((curr-overl (ediff-eval-in-buffer ctl-buffer |
11042 | 2526 (ediff-get-diff-overlay diff-no buf-type))) |
2527 (before (ediff-get-diff-posn buf-type 'beg diff-no ctl-buffer)) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2528 after beg-of-line flag) |
11042 | 2529 |
2530 ;; insert flag before the difference | |
2531 (goto-char before) | |
2532 (setq beg-of-line (bolp)) | |
2533 | |
2534 (setq flag (ediff-eval-in-buffer ctl-buffer | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2535 (if (eq ediff-highlighting-style 'ascii) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2536 (if beg-of-line |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2537 ediff-before-flag-bol ediff-before-flag-mol)))) |
11042 | 2538 |
2539 ;; insert the flag itself | |
2540 (if ediff-xemacs-p | |
2541 (ediff-overlay-put curr-overl 'begin-glyph flag) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2542 (ediff-overlay-put curr-overl 'before-string flag)) |
11042 | 2543 |
2544 ;; insert the flag after the difference | |
2545 ;; `after' must be set here, after the before-flag was inserted | |
2546 (setq after (ediff-get-diff-posn buf-type 'end diff-no ctl-buffer)) | |
2547 (goto-char after) | |
2548 (setq beg-of-line (bolp)) | |
2549 | |
2550 (setq flag (ediff-eval-in-buffer ctl-buffer | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2551 (if (eq ediff-highlighting-style 'ascii) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2552 (if beg-of-line |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2553 ediff-after-flag-eol ediff-after-flag-mol)))) |
11042 | 2554 |
2555 ;; insert the flag itself | |
2556 (if ediff-xemacs-p | |
2557 (ediff-overlay-put curr-overl 'end-glyph flag) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2558 (ediff-overlay-put curr-overl 'after-string flag)) |
11042 | 2559 )) |
2560 | |
2561 | |
2562 (defun ediff-get-diff-posn (buf-type pos &optional n control-buf) | |
2563 "Returns positions of difference sectors in the BUF-TYPE buffer. | |
2564 BUF-TYPE should be a symbol--either `A' or `B'. | |
2565 POS is either `beg' or `end'--it specifies whether you want the position at the | |
2566 beginning of a difference or at the end. | |
2567 | |
2568 The optional argument N says which difference \(default: | |
2569 `ediff-current-difference'\). The optional argument CONTROL-BUF says | |
2570 which control buffer is in effect in case it is not the current | |
2571 buffer." | |
2572 (let (diff-overlay) | |
2573 (or control-buf | |
2574 (setq control-buf (current-buffer))) | |
2575 | |
2576 (ediff-eval-in-buffer control-buf | |
2577 (or n (setq n ediff-current-difference)) | |
2578 (if (or (< n 0) (>= n ediff-number-of-differences)) | |
2579 (if (> ediff-number-of-differences 0) | |
2580 (error "There is no diff %d. Valid diffs are 1 to %d" | |
2581 (1+ n) ediff-number-of-differences) | |
2582 (error "No differences found"))) | |
2583 (setq diff-overlay (ediff-get-diff-overlay n buf-type))) | |
2584 | |
2585 (if (eq pos 'beg) | |
2586 (ediff-overlay-start diff-overlay) | |
2587 (ediff-overlay-end diff-overlay)) | |
2588 )) | |
2589 | |
2590 | |
2591 | |
2592 (defun ediff-highlight-diff-in-one-buffer (n buf-type) | |
2593 (if (ediff-buffer-live-p (ediff-get-buffer buf-type)) | |
2594 (let* ((buff (ediff-get-buffer buf-type)) | |
2595 (last (ediff-eval-in-buffer buff (point-max))) | |
2596 (begin (ediff-get-diff-posn buf-type 'beg n)) | |
2597 (end (ediff-get-diff-posn buf-type 'end n)) | |
2598 (xtra (if (equal begin end) 1 0)) | |
2599 (end-hilit (min last (+ end xtra))) | |
2600 (current-diff-overlay | |
2601 (symbol-value | |
2602 (intern (format "ediff-current-diff-overlay-%S" buf-type)))) | |
2603 (odd-diff-face | |
2604 (symbol-value | |
2605 (intern (format "ediff-odd-diff-face-%S" buf-type)))) | |
2606 (even-diff-face | |
2607 (symbol-value | |
2608 (intern (format "ediff-even-diff-face-%S" buf-type)))) | |
2609 (odd-diff-face-var | |
2610 (intern (format "ediff-odd-diff-face-%S-var" buf-type))) | |
2611 (even-diff-face-var | |
2612 (intern (format "ediff-even-diff-face-%S-var" buf-type))) | |
2613 ) | |
2614 | |
2615 (if ediff-xemacs-p | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2616 (ediff-move-overlay current-diff-overlay begin end-hilit) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2617 (ediff-move-overlay current-diff-overlay begin end-hilit buff)) |
11042 | 2618 ;; giving priority of 0 and then changing it may look funny, but |
2619 ;; this overcomes an obscure Emacs bug. | |
2620 (ediff-overlay-put current-diff-overlay 'priority 0) | |
2621 (ediff-overlay-put current-diff-overlay 'priority | |
2622 (ediff-highest-priority begin end-hilit buff)) | |
2623 | |
2624 (or (face-differs-from-default-p odd-diff-face-var) | |
2625 (not ediff-highlight-all-diffs) | |
2626 (progn | |
2627 (copy-face odd-diff-face odd-diff-face-var) | |
2628 (copy-face even-diff-face even-diff-face-var))) | |
2629 | |
2630 ;; unhighlight the background overlay for diff n so they won't | |
2631 ;; interfere with the current diff overlay | |
2632 (ediff-overlay-put (ediff-get-diff-overlay n buf-type) 'face nil) | |
2633 ))) | |
2634 | |
2635 | |
2636 (defun ediff-unhighlight-diff-in-one-buffer (buf-type) | |
2637 (if (ediff-buffer-live-p (ediff-get-buffer buf-type)) | |
2638 (let ((current-diff-overlay | |
2639 (symbol-value | |
2640 (intern (format "ediff-current-diff-overlay-%S" buf-type)))) | |
2641 (odd-diff-face-var | |
2642 (intern (format "ediff-odd-diff-face-%S-var" buf-type))) | |
2643 (even-diff-face-var | |
2644 (intern (format "ediff-even-diff-face-%S-var" buf-type))) | |
2645 (overlay | |
2646 (ediff-get-diff-overlay ediff-current-difference buf-type)) | |
2647 ) | |
2648 | |
2649 (ediff-move-overlay current-diff-overlay 1 1) | |
2650 | |
2651 ;; rehighlight the overlay in the background of the | |
2652 ;; current difference region | |
2653 (ediff-overlay-put overlay | |
2654 'face (if (ediff-odd-p ediff-current-difference) | |
2655 odd-diff-face-var | |
2656 even-diff-face-var)) | |
2657 ))) | |
2658 | |
2659 (defun ediff-unhighlight-diffs-totally-in-one-buffer (buf-type) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2660 (ediff-unselect-and-select-difference -1) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2661 (if (and (ediff-window-display-p) ediff-use-faces) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2662 (let* ((inhibit-quit t) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2663 (current-diff-overlay-var |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2664 (intern (format "ediff-current-diff-overlay-%S" buf-type))) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2665 (current-diff-overlay (symbol-value current-diff-overlay-var)) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2666 (odd-diff-face-var |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2667 (intern (format "ediff-odd-diff-face-%S-var" buf-type))) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2668 (even-diff-face-var |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2669 (intern (format "ediff-even-diff-face-%S-var" buf-type)))) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2670 (if (face-differs-from-default-p odd-diff-face-var) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2671 (progn |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2672 (copy-face 'default odd-diff-face-var) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2673 (copy-face 'default even-diff-face-var))) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2674 (if (ediff-overlayp current-diff-overlay) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2675 (ediff-delete-overlay current-diff-overlay)) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2676 (set current-diff-overlay-var nil) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2677 ))) |
11042 | 2678 |
2679 | |
2680 ;; null out difference overlays so they won't slow down future | |
2681 ;; editing operations | |
2682 ;; VEC is either a difference vector or a fine-diff vector | |
2683 (defun ediff-clear-diff-vector (vec-var &optional fine-diffs-also) | |
2684 (if (vectorp (symbol-value vec-var)) | |
2685 (mapcar (function | |
2686 (lambda (elt) | |
2687 (ediff-delete-overlay | |
2688 (ediff-get-diff-overlay-from-diff-record elt)) | |
2689 (if fine-diffs-also | |
2690 (ediff-clear-fine-diff-vector elt)) | |
2691 )) | |
2692 (symbol-value vec-var))) | |
2693 ;; allow them to be garbage collected | |
2694 (set vec-var nil)) | |
2695 | |
2696 | |
2697 | |
2698 ;;; Misc | |
2699 | |
2700 ;; These two functions are here to neutralize XEmacs unwillingless to | |
2701 ;; handle overlays whose buffers were deleted. | |
2702 (defun ediff-move-overlay (overlay beg end &optional buffer) | |
2703 "Calls `move-overlay' in Emacs and `set-extent-endpoints' in Lemacs. | |
2704 Checks if overlay's buffer exists before actually doing the move." | |
2705 (let ((buf (and overlay (ediff-overlay-buffer overlay)))) | |
2706 (if (ediff-buffer-live-p buf) | |
2707 (if ediff-xemacs-p | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2708 (set-extent-endpoints overlay beg end) |
11042 | 2709 (move-overlay overlay beg end buffer)) |
2710 ;; buffer's dead | |
2711 (if overlay | |
2712 (ediff-delete-overlay overlay))))) | |
2713 | |
2714 (defun ediff-overlay-put (overlay prop value) | |
2715 "Calls `overlay-put' or `set-extent-property' depending on Emacs version. | |
2716 Checks if overlay's buffer exists." | |
2717 (if (ediff-buffer-live-p (ediff-overlay-buffer overlay)) | |
2718 (if ediff-xemacs-p | |
2719 (set-extent-property overlay prop value) | |
2720 (overlay-put overlay prop value)) | |
2721 (ediff-delete-overlay overlay))) | |
2722 | |
2723 | |
2724 ;; In Emacs, this just makes overlay. In the future, when Emacs will start | |
2725 ;; supporting sticky overlays, this function will make a sticky overlay. | |
2726 ;; BEG and END are expressions telling where overlay starts. | |
2727 ;; If they are numbers or buffers, then all is well. Otherwise, they must | |
2728 ;; be expressions to be evaluated in buffer BUF in order to get the overlay | |
2729 ;; bounds. | |
2730 ;; If BUFF is not a live buffer, then return nil; otherwise, return the | |
2731 ;; newly created overlay. | |
2732 (defun ediff-make-bullet-proof-overlay (beg end buff) | |
2733 (if (ediff-buffer-live-p buff) | |
2734 (let (overl) | |
2735 (ediff-eval-in-buffer buff | |
2736 (or (number-or-marker-p beg) | |
2737 (setq beg (eval beg))) | |
2738 (or (number-or-marker-p end) | |
2739 (setq end (eval end))) | |
2740 (setq overl (ediff-make-overlay beg end buff)) | |
2741 | |
2742 (if ediff-xemacs-p | |
2743 (progn | |
2744 ;; take precautions against detached extents | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2745 (ediff-overlay-put overl 'detachable nil) |
11042 | 2746 ;; chars inserted at both ends will be inside extent |
2747 (ediff-overlay-put overl 'start-open nil) | |
2748 (ediff-overlay-put overl 'end-open nil)) | |
2749 (ediff-overlay-put overl 'ediff-diff-num 0) | |
2750 ;;(ediff-overlay-put overl 'insert-in-front-hooks | |
2751 ;; (list 'ediff-capture-inserts-in-front)) | |
2752 ;;(ediff-overlay-put overl 'insert-behind-hooks | |
2753 ;; (list 'ediff-capture-inserts-behind)) | |
2754 ;; These two are not yet implemented in Emacs | |
2755 ;;(ediff-overlay-put overl 'rear-sticky t) | |
2756 ;;(ediff-overlay-put overl 'front-sticky t) | |
2757 ) | |
2758 overl)))) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2759 |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2760 (defsubst ediff-overlay-start (overl) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2761 (if (ediff-overlayp overl) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2762 (if ediff-emacs-p |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2763 (overlay-start overl) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2764 (extent-start-position overl)))) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2765 |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2766 (defsubst ediff-overlay-end (overl) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2767 (if (ediff-overlayp overl) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2768 (if ediff-emacs-p |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2769 (overlay-end overl) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2770 (extent-end-position overl)))) |
11042 | 2771 |
2772 | |
2773 ;; Like other-buffer, but prefers visible buffers and ignores temporary or | |
2774 ;; other insignificant buffers (those beginning with "^[ *]"). | |
2775 ;; Gets one arg--buffer name or a list of buffer names (it won't return | |
2776 ;; these buffers). | |
2777 (defun ediff-other-buffer (buff) | |
2778 (if (not (listp buff)) (setq buff (list buff))) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2779 (let* ((frame-buffers (buffer-list)) |
11042 | 2780 (significant-buffers |
2781 (mapcar | |
2782 (function (lambda (x) | |
2783 (cond ((member (buffer-name x) buff) | |
2784 nil) | |
2785 ((not (ediff-get-visible-buffer-window x)) | |
2786 nil) | |
2787 ((string-match "^ " (buffer-name x)) | |
2788 nil) | |
2789 (t x)))) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2790 frame-buffers)) |
11042 | 2791 (buffers (delq nil significant-buffers)) |
2792 less-significant-buffers) | |
2793 | |
2794 (cond (buffers (car buffers)) | |
2795 ;; try also buffers that are not displayed in windows | |
2796 ((setq less-significant-buffers | |
2797 (delq nil | |
2798 (mapcar | |
2799 (function | |
2800 (lambda (x) | |
2801 (cond ((member (buffer-name x) buff) nil) | |
2802 ((string-match "^[ *]" (buffer-name x)) nil) | |
2803 (t x)))) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2804 frame-buffers))) |
11042 | 2805 (car less-significant-buffers)) |
2806 (t (other-buffer (current-buffer)))) | |
2807 )) | |
2808 | |
2809 | |
2810 ;; Construct a unique buffer name. | |
2811 ;; The first one tried is prefixsuffix, then prefix<2>suffix, | |
2812 ;; prefix<3>suffix, etc. | |
2813 (defun ediff-unique-buffer-name (prefix suffix) | |
2814 (if (null (get-buffer (concat prefix suffix))) | |
2815 (concat prefix suffix) | |
2816 (let ((n 2)) | |
2817 (while (get-buffer (format "%s<%d>%s" prefix n suffix)) | |
2818 (setq n (1+ n))) | |
2819 (format "%s<%d>%s" prefix n suffix)))) | |
2820 | |
2821 | |
2822 (defun ediff-submit-report () | |
2823 "Submit bug report on Ediff." | |
2824 (interactive) | |
2825 (let ((reporter-prompt-for-summary-p t) | |
2826 (ctl-buf ediff-control-buffer) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2827 (ediff-device-type (ediff-device-type)) |
11042 | 2828 varlist salutation buffer-name) |
2829 (setq varlist '(ediff-diff-program ediff-diff-options | |
2830 ediff-patch-program ediff-patch-options | |
2831 ediff-shell | |
2832 ediff-use-faces | |
2833 ediff-auto-refine ediff-highlighting-style | |
2834 ediff-buffer-A ediff-buffer-B ediff-control-buffer | |
2835 ediff-forward-word-function | |
2836 ediff-control-frame | |
2837 ediff-control-frame-parameters | |
2838 ediff-control-frame-position-function | |
2839 ediff-prefer-iconified-control-frame | |
2840 ediff-window-setup-function | |
2841 ediff-split-window-function | |
2842 ediff-job-name | |
2843 ediff-word-mode | |
2844 buffer-name | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2845 ediff-device-type |
11042 | 2846 )) |
2847 (setq salutation " | |
2848 Congratulations! You may have unearthed a bug in Ediff! | |
2849 | |
2850 Please make a concise and accurate summary of what happened | |
2851 and mail it to the address above. | |
2852 ----------------------------------------------------------- | |
2853 ") | |
2854 | |
2855 (ediff-skip-unsuitable-frames) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2856 (ediff-reset-mouse) |
11042 | 2857 |
2858 (switch-to-buffer ediff-msg-buffer) | |
2859 (erase-buffer) | |
2860 (delete-other-windows) | |
2861 (insert " | |
2862 Please read this first: | |
2863 ---------------------- | |
2864 | |
2865 Some ``bugs'' may actually be no bugs at all. For instance, if you are | |
2866 reporting that certain difference regions are not matched as you think they | |
2867 should, this is most likely due to the way Unix diff program decides what | |
2868 constitutes a difference region. Ediff is an Emacs interface to diff, and | |
2869 it has nothing to do with those decisions---it only takes the output from | |
2870 diff and presents it in a way that is better suited for human browsing and | |
2871 manipulation. | |
2872 | |
2873 If Emacs happens to dump core, this is NOT an Ediff problem---it is | |
2874 an Emacs bug. Report this to Emacs maintainers. | |
2875 | |
2876 Another popular topic for reports is compilation messages. Because Ediff | |
2877 interfaces to several other packages and runs under Emacs and XEmacs, | |
2878 byte-compilation may produce output like this: | |
2879 | |
2880 While compiling toplevel forms in file ediff.el: | |
2881 ** reference to free variable pm-color-alist | |
2882 ........................ | |
2883 While compiling the end of the data: | |
2884 ** The following functions are not known to be defined: | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2885 ediff-valid-color-p, ediff-set-face, |
11042 | 2886 ........................ |
2887 | |
2888 These are NOT errors, but inevitable warnings, which ought to be ignored. | |
2889 | |
2890 Please do not report those and similar things. However, comments and | |
2891 suggestions are always welcome. | |
2892 | |
2893 Mail anyway? (y or n) ") | |
2894 | |
2895 (if (y-or-n-p "Mail anyway? ") | |
2896 (progn | |
2897 (if (ediff-buffer-live-p ctl-buf) | |
2898 (set-buffer ctl-buf)) | |
2899 (setq buffer-name (buffer-name)) | |
2900 (require 'reporter) | |
2901 (reporter-submit-bug-report "kifer@cs.sunysb.edu" | |
2902 (ediff-version) | |
2903 varlist | |
2904 nil | |
2905 'delete-other-windows | |
2906 salutation)) | |
2907 (bury-buffer) | |
2908 (beep 1)(message "Bug report aborted") | |
2909 (if (ediff-buffer-live-p ctl-buf) | |
2910 (ediff-eval-in-buffer ctl-buf | |
2911 (ediff-recenter 'no-rehighlight)))) | |
2912 )) | |
2913 | |
2914 | |
2915 (defun ediff-union (list1 list2) | |
2916 "Combine LIST1 and LIST2 using a set-union operation. | |
2917 The result list contains all items that appear in either LIST1 or LIST2. | |
2918 This is a non-destructive function; it makes a copy of the data if necessary | |
2919 to avoid corrupting the original LIST1 and LIST2. | |
2920 This is a slightly simplified version from `cl-seq.el'. Added here to | |
2921 avoid loading cl-*." | |
2922 (cond ((null list1) list2) ((null list2) list1) | |
2923 ((equal list1 list2) list1) | |
2924 (t | |
2925 (or (>= (length list1) (length list2)) | |
2926 (setq list1 (prog1 list2 (setq list2 list1)))) | |
2927 (while list2 | |
2928 (or (memq (car list2) list1) | |
2929 (setq list1 (cons (car list2) list1))) | |
2930 (setq list2 (cdr list2))) | |
2931 list1))) | |
2932 | |
2933 (defun ediff-deactivate-mark () | |
2934 (if ediff-xemacs-p | |
2935 (zmacs-deactivate-region) | |
2936 (deactivate-mark))) | |
2937 | |
2938 (cond ((fboundp 'nuke-selective-display) | |
2939 ;; XEmacs 19.12 has nuke-selective-display | |
2940 (fset 'ediff-nuke-selective-display 'nuke-selective-display)) | |
2941 (t | |
2942 (defun ediff-nuke-selective-display () | |
2943 (save-excursion | |
2944 (save-restriction | |
2945 (widen) | |
2946 (goto-char (point-min)) | |
2947 (let ((mod-p (buffer-modified-p)) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2948 buffer-read-only end) |
11042 | 2949 (and (eq t selective-display) |
2950 (while (search-forward "\^M" nil t) | |
2951 (end-of-line) | |
2952 (setq end (point)) | |
2953 (beginning-of-line) | |
2954 (while (search-forward "\^M" end t) | |
2955 (delete-char -1) | |
2956 (insert "\^J")))) | |
2957 (set-buffer-modified-p mod-p) | |
2958 (setq selective-display nil))))) | |
2959 )) | |
2960 | |
2961 | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2962 ;; The next two are modified versions from emerge.el. |
11042 | 2963 ;; VARS must be a list of symbols |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2964 ;; ediff-save-variables returns an association list: ((var . val) ...) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2965 (defsubst ediff-save-variables (vars) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2966 (mapcar (function (lambda (v) (cons v (symbol-value v)))) |
11042 | 2967 vars)) |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2968 ;; VARS is a list of variable symbols. |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2969 (defun ediff-restore-variables (vars assoc-list) |
11042 | 2970 (while vars |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2971 (set (car vars) (cdr (assoc (car vars) assoc-list))) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2972 (setq vars (cdr vars)))) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2973 (defun ediff-change-saved-variable (var value buf-type) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2974 (let* ((assoc-list |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2975 (symbol-value (intern |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2976 (concat "ediff-buffer-values-orig-" |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2977 (symbol-name buf-type))))) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2978 (assoc-elt (assoc var assoc-list))) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2979 (if assoc-elt |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2980 (setcdr assoc-elt value)))) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2981 |
11042 | 2982 |
2983 ;; must execute in control buf | |
2984 (defun ediff-save-protected-variables () | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2985 (setq ediff-buffer-values-orig-A |
11042 | 2986 (ediff-eval-in-buffer ediff-buffer-A |
2987 (ediff-save-variables ediff-protected-variables))) | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2988 (setq ediff-buffer-values-orig-B |
11042 | 2989 (ediff-eval-in-buffer ediff-buffer-B |
2990 (ediff-save-variables ediff-protected-variables))) | |
2991 (if ediff-3way-comparison-job | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2992 (setq ediff-buffer-values-orig-C |
11042 | 2993 (ediff-eval-in-buffer ediff-buffer-C |
2994 (ediff-save-variables ediff-protected-variables))))) | |
2995 | |
2996 ;; must execute in control buf | |
2997 (defun ediff-restore-protected-variables () | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2998 (let ((values-A ediff-buffer-values-orig-A) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
2999 (values-B ediff-buffer-values-orig-B) |
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
3000 (values-C ediff-buffer-values-orig-C)) |
11042 | 3001 (ediff-eval-in-buffer ediff-buffer-A |
3002 (ediff-restore-variables ediff-protected-variables values-A)) | |
3003 (ediff-eval-in-buffer ediff-buffer-B | |
3004 (ediff-restore-variables ediff-protected-variables values-B)) | |
3005 (if ediff-3way-comparison-job | |
3006 (ediff-eval-in-buffer ediff-buffer-C | |
3007 (ediff-restore-variables ediff-protected-variables values-C))))) | |
3008 | |
3009 | |
3010 ;;; Debug | |
3011 | |
3012 (ediff-defvar-local ediff-command-begin-time '(0 0 0) "") | |
3013 | |
3014 ;; calculate time used by command | |
3015 (defun ediff-calc-command-time () | |
3016 (let ((end (current-time)) | |
3017 micro sec) | |
3018 (setq micro | |
3019 (if (>= (nth 2 end) (nth 2 ediff-command-begin-time)) | |
3020 (- (nth 2 end) (nth 2 ediff-command-begin-time)) | |
3021 (+ (nth 2 end) (- 1000000 (nth 2 ediff-command-begin-time))))) | |
3022 (setq sec (- (nth 1 end) (nth 1 ediff-command-begin-time))) | |
3023 (or (equal ediff-command-begin-time '(0 0 0)) | |
3024 (message "Elapsed time: %d second(s) + %d microsecond(s)" sec micro)))) | |
3025 | |
3026 (defsubst ediff-save-time () | |
3027 (setq ediff-command-begin-time (current-time))) | |
3028 | |
3029 (defun ediff-profile () | |
3030 "Toggle profiling Ediff commands." | |
3031 (interactive) | |
3032 (or (ediff-buffer-live-p ediff-control-buffer) | |
3033 (error "This command runs only out of Ediff Control Buffer")) | |
3034 (make-local-variable 'pre-command-hook) | |
3035 (make-local-variable 'post-command-hook) | |
3036 (if (memq 'ediff-save-time pre-command-hook) | |
3037 (progn (remove-hook 'pre-command-hook 'ediff-save-time) | |
3038 (remove-hook 'post-command-hook 'ediff-calc-command-time) | |
3039 (setq ediff-command-begin-time '(0 0 0)) | |
3040 (message "Ediff profiling disabled")) | |
3041 (add-hook 'pre-command-hook 'ediff-save-time t) | |
3042 (add-hook 'post-command-hook 'ediff-calc-command-time) | |
3043 (message "Ediff profiling enabled"))) | |
3044 | |
3045 (defun ediff-print-diff-vector (diff-vector-var) | |
3046 (princ (format "\n*** %S ***\n" diff-vector-var)) | |
3047 (mapcar (function | |
3048 (lambda (overl-vec) | |
3049 (princ | |
3050 (format | |
3051 "Diff %d: \tOverlay: %S | |
3052 \t\tFine diffs: %s | |
3053 \t\tNo-fine-diff-flag: %S | |
3054 \t\tState-of-diff:\t %S | |
3055 \t\tState-of-merge:\t %S | |
3056 " | |
3057 (1+ (ediff-overlay-get (aref overl-vec 0) 'ediff-diff-num)) | |
3058 (aref overl-vec 0) | |
3059 ;; fine-diff-vector | |
3060 (if (= (length (aref overl-vec 1)) 0) | |
3061 "none\n" | |
3062 (mapconcat 'prin1-to-string | |
3063 (aref overl-vec 1) "\n\t\t\t ")) | |
3064 (aref overl-vec 2) ; no fine diff flag | |
3065 (aref overl-vec 3) ; state-of-diff | |
3066 (aref overl-vec 4) ; state-of-merge | |
3067 )))) | |
3068 (eval diff-vector-var))) | |
3069 | |
3070 | |
3071 | |
3072 (defun ediff-debug-info () | |
3073 (interactive) | |
3074 (or (ediff-buffer-live-p ediff-control-buffer) | |
3075 (error "This command runs only out of Ediff Control Buffer")) | |
3076 (with-output-to-temp-buffer ediff-debug-buffer | |
3077 (princ (format "\nCtl buffer: %S\n" ediff-control-buffer)) | |
3078 (ediff-print-diff-vector (intern (concat "ediff-difference-vector-" "A"))) | |
3079 (ediff-print-diff-vector (intern (concat "ediff-difference-vector-" "B"))) | |
3080 (ediff-print-diff-vector (intern (concat "ediff-difference-vector-" "C"))) | |
3081 )) | |
3082 | |
3083 ;; don't report error if version control package wasn't found | |
3084 ;;(ediff-load-version-control 'silent) | |
3085 | |
3086 (run-hooks 'ediff-load-hooks) | |
3087 | |
12085
589a32fa67a9
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11977
diff
changeset
|
3088 |
11042 | 3089 ;;; Local Variables: |
3090 ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun) | |
3091 ;;; eval: (put 'ediff-eval-in-buffer 'lisp-indent-hook 1) | |
3092 ;;; End: | |
3093 | |
3094 (provide 'ediff-util) | |
3095 | |
3096 ;;; ediff-util.el ends here |