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