Mercurial > emacs
annotate lisp/ediff-merg.el @ 26531:a52135fe746e
(enum gdb_lisp_params): Put in #if 0, since it doesn't
work on systems not allowing enumerators > INT_MAX, and it
won't work if EMACS_INT is long long.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Mon, 22 Nov 1999 13:17:23 +0000 |
parents | 4f315ca65976 |
children | 3ec5a485d0ab |
rev | line source |
---|---|
11042 | 1 ;;; ediff-merg.el --- merging utilities |
14169 | 2 |
18054 | 3 ;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. |
11042 | 4 |
5 ;; Author: Michael Kifer <kifer@cs.sunysb.edu> | |
6 | |
7 ;; This file is part of GNU Emacs. | |
8 | |
9 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
10 ;; it under the terms of the GNU General Public License as published by | |
11 ;; the Free Software Foundation; either version 2, or (at your option) | |
12 ;; any later version. | |
13 | |
14 ;; GNU Emacs is distributed in the hope that it will be useful, | |
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 ;; GNU General Public License for more details. | |
18 | |
19 ;; You should have received a copy of the GNU General Public License | |
14169 | 20 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
22 ;; Boston, MA 02111-1307, USA. | |
11042 | 23 |
14169 | 24 ;;; Code: |
11042 | 25 |
18054 | 26 (provide 'ediff-merg) |
27 | |
28 ;; compiler pacifier | |
29 (defvar ediff-window-A) | |
30 (defvar ediff-window-B) | |
31 (defvar ediff-window-C) | |
32 (defvar ediff-merge-window-share) | |
33 (defvar ediff-window-config-saved) | |
34 | |
35 (eval-when-compile | |
36 (let ((load-path (cons (expand-file-name ".") load-path))) | |
37 (or (featurep 'ediff-init) | |
38 (load "ediff-init.el" nil nil 'nosuffix)) | |
39 (or (featurep 'ediff-util) | |
40 (load "ediff-util.el" nil nil 'nosuffix)) | |
41 )) | |
42 ;; end pacifier | |
43 | |
11042 | 44 (require 'ediff-init) |
45 | |
18839 | 46 (defcustom ediff-quit-merge-hook 'ediff-maybe-save-and-delete-merge |
47 "*Hooks to run before quitting a merge job. | |
48 The most common use is to save and delete the merge buffer." | |
49 :type 'hook | |
50 :group 'ediff-merge) | |
51 | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
52 |
18054 | 53 (defcustom ediff-default-variant 'combined |
11042 | 54 "*The variant to be used as a default for buffer C in merging. |
18054 | 55 Valid values are the symbols `default-A', `default-B', and `combined'." |
56 :type '(radio (const default-A) (const default-B) (const combined)) | |
57 :group 'ediff-merge) | |
11042 | 58 |
18054 | 59 (defcustom ediff-combination-pattern |
14582
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
60 '("<<<<<<<<<<<<<< variant A" ">>>>>>>>>>>>>> variant B" "======= end of combination") |
11042 | 61 "*Pattern to be used for combining difference regions in buffers A and B. |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
62 The value is (STRING1 STRING2 STRING3). The combined text will look like this: |
11042 | 63 |
64 STRING1 | |
65 diff region from variant A | |
66 STRING2 | |
67 diff region from variant B | |
68 STRING3 | |
18054 | 69 " |
70 :type '(list string string string) | |
71 :group 'ediff-merge) | |
11042 | 72 |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
73 (defcustom ediff-show-clashes-only nil |
11042 | 74 "*If t, show only those diff regions where both buffers disagree with the ancestor. |
75 This means that regions that have status prefer-A or prefer-B will be | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
76 skiped over. Nil means show all regions." |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
77 :type 'boolean |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
78 :group 'ediff-merge |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
79 ) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
80 (make-variable-buffer-local 'ediff-show-clashes-only) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
81 |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
82 (defcustom ediff-skip-merge-regions-that-differ-from-default nil |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
83 "*If t, show only the regions that have not been changed by the user. |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
84 A region is considered to have been changed if it is different from the current |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
85 default (`default-A', `default-B', `combined') and it hasn't been marked as |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
86 `prefer-A' or `prefer-B'. |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
87 A region is considered to have been changed also when it is marked as |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
88 as `prefer-A', but is different from the corresponding difference region in |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
89 Buffer A or if it is marked as `prefer-B' and is different from the region in |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
90 Buffer B." |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
91 :type 'boolean |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
92 :group 'ediff-merge |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
93 ) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
94 (make-variable-buffer-local 'ediff-skip-merge-regions-that-differ-from-default) |
11042 | 95 |
20003 | 96 ;; If ediff-show-clashes-only, check if there is no clash between the ancestor |
97 ;; and one of the variants. | |
98 (defsubst ediff-merge-region-is-non-clash (n) | |
99 (and ediff-show-clashes-only | |
100 (string-match "prefer" (or (ediff-get-state-of-merge n) "")))) | |
101 | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
102 ;; If ediff-skip-changed-regions, check if the merge region differs from |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
103 ;; the current default. If a region is different from the default, it means |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
104 ;; that the user has made determination as to how to merge for this particular |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
105 ;; region. |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
106 (defsubst ediff-skip-merge-region-if-changed-from-default-p (n) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
107 (and ediff-skip-merge-regions-that-differ-from-default |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
108 (ediff-merge-changed-from-default-p n 'prefers-too))) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
109 |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
110 |
11042 | 111 |
112 (defsubst ediff-get-combined-region (n) | |
113 (concat (nth 0 ediff-combination-pattern) "\n" | |
114 (ediff-get-region-contents n 'A ediff-control-buffer) | |
115 (nth 1 ediff-combination-pattern) "\n" | |
116 (ediff-get-region-contents n 'B ediff-control-buffer) | |
117 (nth 2 ediff-combination-pattern) "\n")) | |
13216
b9dc8cc658d5
Moved defsubsts up.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
13129
diff
changeset
|
118 |
b9dc8cc658d5
Moved defsubsts up.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
13129
diff
changeset
|
119 (defsubst ediff-make-combined-diff (regA regB) |
b9dc8cc658d5
Moved defsubsts up.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
13129
diff
changeset
|
120 (concat (nth 0 ediff-combination-pattern) "\n" |
b9dc8cc658d5
Moved defsubsts up.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
13129
diff
changeset
|
121 regA |
b9dc8cc658d5
Moved defsubsts up.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
13129
diff
changeset
|
122 (nth 1 ediff-combination-pattern) "\n" |
b9dc8cc658d5
Moved defsubsts up.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
13129
diff
changeset
|
123 regB |
b9dc8cc658d5
Moved defsubsts up.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
13129
diff
changeset
|
124 (nth 2 ediff-combination-pattern) "\n")) |
b9dc8cc658d5
Moved defsubsts up.
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
13129
diff
changeset
|
125 |
11042 | 126 (defsubst ediff-set-state-of-all-diffs-in-all-buffers (ctl-buf) |
127 (let ((n 0)) | |
128 (while (< n ediff-number-of-differences) | |
129 (ediff-set-state-of-diff-in-all-buffers n ctl-buf) | |
130 (setq n (1+ n))))) | |
131 | |
132 (defun ediff-set-state-of-diff-in-all-buffers (n ctl-buf) | |
133 (let ((regA (ediff-get-region-contents n 'A ctl-buf)) | |
134 (regB (ediff-get-region-contents n 'B ctl-buf)) | |
135 (regC (ediff-get-region-contents n 'C ctl-buf))) | |
12167
87f8b79217b3
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11234
diff
changeset
|
136 (cond ((and (string= regA regB) (string= regA regC)) |
87f8b79217b3
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11234
diff
changeset
|
137 (ediff-set-state-of-diff n 'A "=diff(B)") |
87f8b79217b3
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11234
diff
changeset
|
138 (ediff-set-state-of-diff n 'B "=diff(C)") |
87f8b79217b3
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11234
diff
changeset
|
139 (ediff-set-state-of-diff n 'C "=diff(A)")) |
87f8b79217b3
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11234
diff
changeset
|
140 ((string= regA regB) |
11042 | 141 (ediff-set-state-of-diff n 'A "=diff(B)") |
142 (ediff-set-state-of-diff n 'B "=diff(A)") | |
143 (ediff-set-state-of-diff n 'C nil)) | |
144 ((string= regA regC) | |
145 (ediff-set-state-of-diff n 'A "=diff(C)") | |
146 (ediff-set-state-of-diff n 'C "=diff(A)") | |
147 (ediff-set-state-of-diff n 'B nil)) | |
148 ((string= regB regC) | |
149 (ediff-set-state-of-diff n 'C "=diff(B)") | |
150 (ediff-set-state-of-diff n 'B "=diff(C)") | |
151 (ediff-set-state-of-diff n 'A nil)) | |
152 ((string= regC (ediff-get-combined-region n)) | |
153 (ediff-set-state-of-diff n 'A nil) | |
154 (ediff-set-state-of-diff n 'B nil) | |
155 (ediff-set-state-of-diff n 'C "=diff(A+B)")) | |
156 (t (ediff-set-state-of-diff n 'A nil) | |
157 (ediff-set-state-of-diff n 'B nil) | |
158 (ediff-set-state-of-diff n 'C nil))) | |
159 )) | |
12167
87f8b79217b3
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11234
diff
changeset
|
160 |
87f8b79217b3
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11234
diff
changeset
|
161 (defun ediff-set-merge-mode () |
87f8b79217b3
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11234
diff
changeset
|
162 (normal-mode t) |
87f8b79217b3
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11234
diff
changeset
|
163 (remove-hook 'local-write-file-hooks 'ediff-set-merge-mode)) |
13129
9d432c26c3a7
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
12167
diff
changeset
|
164 |
11042 | 165 |
166 ;; Go over all diffs starting with DIFF-NUM and copy regions into buffer C | |
167 ;; according to the state of the difference. | |
168 ;; Since ediff-copy-diff refuses to copy identical diff regions, there is | |
169 ;; no need to optimize ediff-do-merge any further. | |
170 ;; | |
171 ;; If re-merging, change state of merge in all diffs starting with | |
172 ;; DIFF-NUM, except those where the state is prefer-* or where it is | |
12167
87f8b79217b3
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11234
diff
changeset
|
173 ;; `default-*' or `combined' but the buf C region appears to be modified |
87f8b79217b3
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11234
diff
changeset
|
174 ;; since last set by default. |
11042 | 175 (defun ediff-do-merge (diff-num &optional remerging) |
176 (if (< diff-num 0) (setq diff-num 0)) | |
177 (let ((n diff-num) | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
178 ;;(default-state-of-merge (format "%S" ediff-default-variant)) |
12167
87f8b79217b3
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11234
diff
changeset
|
179 do-not-copy state-of-merge) |
11042 | 180 (while (< n ediff-number-of-differences) |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
181 (setq do-not-copy nil) ; reset after each cycle |
11042 | 182 (if (= (mod n 10) 0) |
183 (message "%s buffers A & B into C ... region %d of %d" | |
184 (if remerging "Re-merging" "Merging") | |
185 n | |
186 ediff-number-of-differences)) | |
187 | |
188 (setq state-of-merge (ediff-get-state-of-merge n)) | |
189 | |
190 (if remerging | |
191 (let ((reg-A (ediff-get-region-contents n 'A ediff-control-buffer)) | |
192 (reg-B (ediff-get-region-contents n 'B ediff-control-buffer)) | |
193 (reg-C (ediff-get-region-contents n 'C ediff-control-buffer))) | |
194 | |
15480
43a3308fcf61
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14582
diff
changeset
|
195 ;; if region was edited since it was first set by default |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
196 (if (or (ediff-merge-changed-from-default-p n) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
197 ;; was preferred |
12167
87f8b79217b3
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11234
diff
changeset
|
198 (string-match "prefer" state-of-merge)) |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
199 ;; then ignore |
11042 | 200 (setq do-not-copy t)) |
201 | |
202 ;; change state of merge for this diff, if necessary | |
12167
87f8b79217b3
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11234
diff
changeset
|
203 (if (and (string-match "\\(default\\|combined\\)" state-of-merge) |
87f8b79217b3
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11234
diff
changeset
|
204 (not do-not-copy)) |
11042 | 205 (ediff-set-state-of-merge |
206 n (format "%S" ediff-default-variant))) | |
207 )) | |
208 | |
209 ;; state-of-merge may have changed via ediff-set-state-of-merge, so | |
12167
87f8b79217b3
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11234
diff
changeset
|
210 ;; check it once again |
11042 | 211 (setq state-of-merge (ediff-get-state-of-merge n)) |
212 | |
213 (or do-not-copy | |
214 (if (string= state-of-merge "combined") | |
215 ;; use n+1 because ediff-combine-diffs works via user numbering | |
216 ;; of diffs, which is 1+ to what ediff uses internally | |
217 (ediff-combine-diffs (1+ n) 'batch) | |
12167
87f8b79217b3
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11234
diff
changeset
|
218 (ediff-copy-diff |
87f8b79217b3
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11234
diff
changeset
|
219 n (if (string-match "-A" state-of-merge) 'A 'B) 'C 'batch))) |
11042 | 220 (setq n (1+ n))) |
221 (message "Merging buffers A & B into C ... Done") | |
222 )) | |
223 | |
224 | |
225 (defun ediff-re-merge () | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
226 "Remerge unmodified diff regions using a new default. Start with the current region." |
11042 | 227 (interactive) |
228 (let* ((default-variant-alist | |
229 (list '("default-A") '("default-B") '("combined"))) | |
230 (actual-alist | |
231 (delete (list (symbol-name ediff-default-variant)) | |
232 default-variant-alist))) | |
233 (setq ediff-default-variant | |
234 (intern | |
235 (completing-read | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
236 (format "Current merge default is `%S'. New default: " |
11042 | 237 ediff-default-variant) |
238 actual-alist nil 'must-match))) | |
239 (ediff-do-merge ediff-current-difference 'remerge) | |
240 (ediff-recenter) | |
241 )) | |
242 | |
243 (defun ediff-shrink-window-C (arg) | |
244 "Shrink window C to just one line. | |
245 With a prefix argument, returns window C to its normal size. | |
246 Used only for merging jobs." | |
247 (interactive "P") | |
248 (if (not ediff-merge-job) | |
249 (error "ediff-shrink-window-C can be used only for merging jobs")) | |
250 (cond ((eq arg '-) (setq arg -1)) | |
251 ((not (numberp arg)) (setq arg nil))) | |
252 (cond ((null arg) | |
253 (let ((ediff-merge-window-share | |
254 (if (< (window-height ediff-window-C) 3) | |
255 ediff-merge-window-share 0))) | |
256 (setq ediff-window-config-saved "") ; force redisplay | |
257 (ediff-recenter 'no-rehighlight))) | |
258 ((and (< arg 0) (> (window-height ediff-window-C) 2)) | |
259 (setq ediff-merge-window-share (* ediff-merge-window-share 0.9)) | |
260 (setq ediff-window-config-saved "") ; force redisplay | |
261 (ediff-recenter 'no-rehighlight)) | |
262 ((and (> arg 0) (> (window-height ediff-window-A) 2)) | |
263 (setq ediff-merge-window-share (* ediff-merge-window-share 1.1)) | |
264 (setq ediff-window-config-saved "") ; force redisplay | |
265 (ediff-recenter 'no-rehighlight)))) | |
266 | |
267 | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
268 ;; N here is the user's region number. It is 1+ what Ediff uses internally. |
11042 | 269 (defun ediff-combine-diffs (n &optional batch-invocation) |
270 "Combine Nth diff regions of buffers A and B and place the combination in C. | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
271 N is a prefix argument. If nil, combine the current difference regions. |
14582
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
272 Combining is done according to the specifications in variable |
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
273 `ediff-combination-pattern'." |
11042 | 274 (interactive "P") |
14582
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
275 (setq n (if (numberp n) (1- n) ediff-current-difference)) |
11042 | 276 |
277 (let (regA regB reg-combined) | |
278 (setq regA (ediff-get-region-contents n 'A ediff-control-buffer) | |
279 regB (ediff-get-region-contents n 'B ediff-control-buffer)) | |
280 | |
12167
87f8b79217b3
Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents:
11234
diff
changeset
|
281 (setq reg-combined (ediff-make-combined-diff regA regB)) |
11042 | 282 |
283 (ediff-copy-diff n nil 'C batch-invocation reg-combined)) | |
14582
c768f6d7daaa
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
14169
diff
changeset
|
284 (or batch-invocation (ediff-jump-to-difference (1+ n)))) |
11042 | 285 |
286 | |
287 ;; Checks if the region in buff C looks like a combination of the regions | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
288 ;; in buffers A and B. Return a list (reg-a-beg reg-a-end reg-b-beg reg-b-end) |
11042 | 289 ;; These refer to where the copies of region A and B start and end in buffer C |
290 (defun ediff-looks-like-combined-merge (region-num) | |
291 (if ediff-merge-job | |
292 (let ((combined (string-match (regexp-quote "(A+B)") | |
293 (or (ediff-get-state-of-diff region-num 'C) | |
294 ""))) | |
295 (reg-beg (ediff-get-diff-posn 'C 'beg region-num)) | |
296 (reg-end (ediff-get-diff-posn 'C 'end region-num)) | |
297 (pat1 (nth 0 ediff-combination-pattern)) | |
298 (pat2 (nth 1 ediff-combination-pattern)) | |
299 (pat3 (nth 2 ediff-combination-pattern)) | |
300 reg-a-beg reg-a-end reg-b-beg reg-b-end reg-c-beg reg-c-end) | |
301 | |
302 (if combined | |
19047 | 303 (ediff-with-current-buffer ediff-buffer-C |
11042 | 304 (goto-char reg-beg) |
305 (search-forward pat1 reg-end 'noerror) | |
306 (setq reg-a-beg (match-beginning 0)) | |
307 (setq reg-a-end (match-end 0)) | |
308 (search-forward pat2 reg-end 'noerror) | |
309 (setq reg-b-beg (match-beginning 0)) | |
310 (setq reg-b-end (match-end 0)) | |
311 (search-forward pat3 reg-end 'noerror) | |
312 (setq reg-c-beg (match-beginning 0)) | |
313 (setq reg-c-end (match-end 0)))) | |
314 | |
315 (if (and reg-a-beg reg-a-end reg-b-beg reg-b-end) | |
316 (list reg-a-beg reg-a-end reg-b-beg reg-b-end reg-c-beg reg-c-end)) | |
317 ))) | |
26263
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
318 |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
319 |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
320 ;; Check if the non-preferred merge has been modified since originally set. |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
321 ;; This affects only the regions that are marked as default-A/B or combined. |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
322 ;; If PREFERS-TOO is non-nil, then look at the regions marked as prefers-A/B as |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
323 ;; well. |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
324 (defun ediff-merge-changed-from-default-p (diff-num &optional prefers-too) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
325 (let ((reg-A (ediff-get-region-contents diff-num 'A ediff-control-buffer)) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
326 (reg-B (ediff-get-region-contents diff-num 'B ediff-control-buffer)) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
327 (reg-C (ediff-get-region-contents diff-num 'C ediff-control-buffer))) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
328 |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
329 (setq state-of-merge (ediff-get-state-of-merge diff-num)) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
330 |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
331 ;; if region was edited since it was first set by default |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
332 (or (and (string= state-of-merge "default-A") |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
333 (not (string= reg-A reg-C))) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
334 (and (string= state-of-merge "default-B") |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
335 (not (string= reg-B reg-C))) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
336 (and (string= state-of-merge "combined") |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
337 (not (string= (ediff-make-combined-diff reg-A reg-B) reg-C))) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
338 (and prefers-too |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
339 (string= state-of-merge "prefer-A") |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
340 (not (string= reg-A reg-C))) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
341 (and prefers-too |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
342 (string= state-of-merge "prefer-B") |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
343 (not (string= reg-B reg-C))) |
4f315ca65976
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
20206
diff
changeset
|
344 ))) |
11042 | 345 |
346 | |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
347 ;;; Local Variables: |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
348 ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun) |
19047 | 349 ;;; eval: (put 'ediff-with-current-buffer 'lisp-indent-hook 1) |
350 ;;; eval: (put 'ediff-with-current-buffer 'edebug-form-spec '(form body)) | |
16248
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
351 ;;; End: |
b2fae8abc5b0
*** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents:
15480
diff
changeset
|
352 |
11042 | 353 ;; ediff-merg.el ends here |