annotate lisp/vc/ediff-merg.el @ 112439:5610f272341f

* src/image.c: Add cast to fix type clash
author Paul Eggert <eggert@cs.ucla.edu>
date Sat, 22 Jan 2011 20:34:48 -0800
parents ef719132ddfa
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1 ;;; ediff-merg.el --- merging utilities
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
2
64762
41bb365f41c4 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64091
diff changeset
3 ;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
112228
417b1e4d63cd Merge from emacs-23
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110015
diff changeset
4 ;; 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
5
42602
633233bf2bbf 2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 42206
diff changeset
6 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
110015
280c8ae2476d Add "Package:" file headers to denote built-in packages.
Chong Yidong <cyd@stupidchicken.com>
parents: 108970
diff changeset
7 ;; Package: ediff
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
8
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
10
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94604
diff changeset
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94604
diff changeset
13 ;; the Free Software Foundation, either version 3 of the License, or
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94604
diff changeset
14 ;; (at your option) any later version.
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
15
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
20
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94604
diff changeset
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
23
38422
7a94f1c588c4 Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 33394
diff changeset
24 ;;; Commentary:
7a94f1c588c4 Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 33394
diff changeset
25
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
26 ;;; Code:
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
27
18054
0b9d9cbf3cd4 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 16248
diff changeset
28
0b9d9cbf3cd4 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 16248
diff changeset
29 ;; compiler pacifier
0b9d9cbf3cd4 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 16248
diff changeset
30 (defvar ediff-window-A)
0b9d9cbf3cd4 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 16248
diff changeset
31 (defvar ediff-window-B)
0b9d9cbf3cd4 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 16248
diff changeset
32 (defvar ediff-window-C)
0b9d9cbf3cd4 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 16248
diff changeset
33 (defvar ediff-merge-window-share)
0b9d9cbf3cd4 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 16248
diff changeset
34 (defvar ediff-window-config-saved)
0b9d9cbf3cd4 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 16248
diff changeset
35
0b9d9cbf3cd4 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 16248
diff changeset
36 (eval-when-compile
94604
c0dfa9027738 Simplify compilation requirements.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
37 (require 'ediff-util))
18054
0b9d9cbf3cd4 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 16248
diff changeset
38 ;; end pacifier
0b9d9cbf3cd4 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 16248
diff changeset
39
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
40 (require 'ediff-init)
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
41
18839
1405083241e8 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18054
diff changeset
42 (defcustom ediff-quit-merge-hook 'ediff-maybe-save-and-delete-merge
100171
d42aff5ca541 * align.el:
Lute Kamstra <lute@gnu.org>
parents: 95630
diff changeset
43 "Hooks to run before quitting a merge job.
18839
1405083241e8 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18054
diff changeset
44 The most common use is to save and delete the merge buffer."
1405083241e8 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18054
diff changeset
45 :type 'hook
1405083241e8 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18054
diff changeset
46 :group 'ediff-merge)
1405083241e8 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18054
diff changeset
47
15480
43a3308fcf61 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 14582
diff changeset
48
18054
0b9d9cbf3cd4 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 16248
diff changeset
49 (defcustom ediff-default-variant 'combined
100171
d42aff5ca541 * align.el:
Lute Kamstra <lute@gnu.org>
parents: 95630
diff changeset
50 "The variant to be used as a default for buffer C in merging.
18054
0b9d9cbf3cd4 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 16248
diff changeset
51 Valid values are the symbols `default-A', `default-B', and `combined'."
0b9d9cbf3cd4 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 16248
diff changeset
52 :type '(radio (const default-A) (const default-B) (const combined))
0b9d9cbf3cd4 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 16248
diff changeset
53 :group 'ediff-merge)
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
54
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
55 (defcustom ediff-combination-pattern
26585
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
56 '("<<<<<<< variant A" A ">>>>>>> variant B" B "####### Ancestor" Ancestor "======= end")
100171
d42aff5ca541 * align.el:
Lute Kamstra <lute@gnu.org>
parents: 95630
diff changeset
57 "Pattern to be used for combining difference regions in buffers A and B.
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
58 The value must be a list of the form
74585
402a04b0362f (ediff-combination-pattern): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 68997
diff changeset
59 \(STRING1 bufspec1 STRING2 bufspec2 STRING3 bufspec3 STRING4)
26585
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
60 where bufspec is the symbol A, B, or Ancestor. For instance, if the value is
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
61 '(STRING1 A STRING2 Ancestor STRING3 B STRING4) then the
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
62 combined text will look like this:
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
63
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
64 STRING1
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
65 diff region from variant A
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
66 STRING2
26585
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
67 diff region from the ancestor
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
68 STRING3
26585
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
69 diff region from variant B
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
70 STRING4
18054
0b9d9cbf3cd4 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 16248
diff changeset
71 "
26585
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
72 :type '(choice (list string symbol string symbol string)
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
73 (list string symbol string symbol string symbol string))
18054
0b9d9cbf3cd4 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 16248
diff changeset
74 :group 'ediff-merge)
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
75
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
76 (defcustom ediff-show-clashes-only nil
100171
d42aff5ca541 * align.el:
Lute Kamstra <lute@gnu.org>
parents: 95630
diff changeset
77 "If t, show only those diff regions where both buffers disagree with the ancestor.
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
78 This means that regions that have status prefer-A or prefer-B will be
74585
402a04b0362f (ediff-combination-pattern): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 68997
diff changeset
79 skipped over. A value of nil means show all regions."
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
80 :type 'boolean
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
81 :group 'ediff-merge
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
82 )
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
83 (make-variable-buffer-local 'ediff-show-clashes-only)
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
84
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
85 (defcustom ediff-skip-merge-regions-that-differ-from-default nil
100171
d42aff5ca541 * align.el:
Lute Kamstra <lute@gnu.org>
parents: 95630
diff changeset
86 "If t, show only the regions that have not been changed by the user.
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
87 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
88 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
89 `prefer-A' or `prefer-B'.
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
90 A region is considered to have been changed also when it is marked as
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
91 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
92 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
93 Buffer B."
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
94 :type 'boolean
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
95 :group 'ediff-merge
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
96 )
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
97 (make-variable-buffer-local 'ediff-skip-merge-regions-that-differ-from-default)
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
98
65856
d64aeb0dc54e 2005-10-05 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 64762
diff changeset
99 ;; check if there is no clash between the ancestor and one of the variants.
66687
26faad662ac6 2005-11-04 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 65856
diff changeset
100 ;; if it is not a merge job then return true
104277
affb617d6101 2009-08-15 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 101721
diff changeset
101 (defun ediff-merge-region-is-non-clash (n)
66687
26faad662ac6 2005-11-04 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 65856
diff changeset
102 (if (ediff-merge-job)
26faad662ac6 2005-11-04 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 65856
diff changeset
103 (string-match "prefer" (or (ediff-get-state-of-merge n) ""))
26faad662ac6 2005-11-04 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 65856
diff changeset
104 t))
65856
d64aeb0dc54e 2005-10-05 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 64762
diff changeset
105
20003
9bc6a4017c8c new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19047
diff changeset
106 ;; If ediff-show-clashes-only, check if there is no clash between the ancestor
9bc6a4017c8c new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19047
diff changeset
107 ;; and one of the variants.
104277
affb617d6101 2009-08-15 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 101721
diff changeset
108 (defun ediff-merge-region-is-non-clash-to-skip (n)
affb617d6101 2009-08-15 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 101721
diff changeset
109 (and (ediff-merge-job)
affb617d6101 2009-08-15 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 101721
diff changeset
110 ediff-show-clashes-only
65856
d64aeb0dc54e 2005-10-05 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 64762
diff changeset
111 (ediff-merge-region-is-non-clash n)))
20003
9bc6a4017c8c new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 19047
diff changeset
112
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
113 ;; 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
114 ;; 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
115 ;; that the user has made determination as to how to merge for this particular
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
116 ;; region.
104277
affb617d6101 2009-08-15 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 101721
diff changeset
117 (defun ediff-skip-merge-region-if-changed-from-default-p (n)
affb617d6101 2009-08-15 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 101721
diff changeset
118 (and (ediff-merge-job)
affb617d6101 2009-08-15 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 101721
diff changeset
119 ediff-skip-merge-regions-that-differ-from-default
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
120 (ediff-merge-changed-from-default-p n 'prefers-too)))
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
121
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
122
26585
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
123 (defun ediff-get-combined-region (n)
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
124 (let ((pattern-list ediff-combination-pattern)
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
125 (combo-region "")
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
126 (err-msg
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
127 "ediff-combination-pattern: Invalid format. Please consult the documentation")
42602
633233bf2bbf 2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 42206
diff changeset
128 region-delim region-spec)
26585
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
129
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
130 (if (< (length pattern-list) 5)
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
131 (error err-msg))
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
132
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
133 (while (> (length pattern-list) 2)
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
134 (setq region-delim (nth 0 pattern-list)
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
135 region-spec (nth 1 pattern-list))
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
136 (or (and (stringp region-delim) (memq region-spec '(A B Ancestor)))
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
137 (error err-msg))
13216
b9dc8cc658d5 Moved defsubsts up.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 13129
diff changeset
138
42602
633233bf2bbf 2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 42206
diff changeset
139 (condition-case nil
26585
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
140 (setq combo-region
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
141 (concat combo-region
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
142 region-delim "\n"
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
143 (ediff-get-region-contents
26585
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
144 n region-spec ediff-control-buffer)))
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
145 (error ""))
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
146 (setq pattern-list (cdr (cdr pattern-list)))
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
147 )
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
148
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
149 (setq region-delim (nth 0 pattern-list))
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
150 (or (stringp region-delim)
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
151 (error err-msg))
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
152 (setq combo-region (concat combo-region region-delim "\n"))
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
153 ))
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
154
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
155 ;;(defsubst ediff-make-combined-diff (regA regB)
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
156 ;; (concat (nth 0 ediff-combination-pattern) "\n"
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
157 ;; regA
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
158 ;; (nth 1 ediff-combination-pattern) "\n"
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
159 ;; regB
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
160 ;; (nth 2 ediff-combination-pattern) "\n"))
13216
b9dc8cc658d5 Moved defsubsts up.
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 13129
diff changeset
161
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
162 (defsubst ediff-set-state-of-all-diffs-in-all-buffers (ctl-buf)
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
163 (let ((n 0))
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
164 (while (< n ediff-number-of-differences)
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
165 (ediff-set-state-of-diff-in-all-buffers n ctl-buf)
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
166 (setq n (1+ n)))))
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
167
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
168 (defun ediff-set-state-of-diff-in-all-buffers (n ctl-buf)
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
169 (let ((regA (ediff-get-region-contents n 'A ctl-buf))
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
170 (regB (ediff-get-region-contents n 'B ctl-buf))
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
171 (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
172 (cond ((and (string= regA regB) (string= regA regC))
87f8b79217b3 Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents: 11234
diff changeset
173 (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
174 (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
175 (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
176 ((string= regA regB)
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
177 (ediff-set-state-of-diff n 'A "=diff(B)")
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
178 (ediff-set-state-of-diff n 'B "=diff(A)")
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
179 (ediff-set-state-of-diff n 'C nil))
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
180 ((string= regA regC)
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
181 (ediff-set-state-of-diff n 'A "=diff(C)")
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
182 (ediff-set-state-of-diff n 'C "=diff(A)")
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
183 (ediff-set-state-of-diff n 'B nil))
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
184 ((string= regB regC)
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
185 (ediff-set-state-of-diff n 'C "=diff(B)")
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
186 (ediff-set-state-of-diff n 'B "=diff(C)")
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
187 (ediff-set-state-of-diff n 'A nil))
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
188 ((string= regC (ediff-get-combined-region n))
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
189 (ediff-set-state-of-diff n 'A nil)
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
190 (ediff-set-state-of-diff n 'B nil)
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
191 (ediff-set-state-of-diff n 'C "=diff(A+B)"))
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
192 (t (ediff-set-state-of-diff n 'A nil)
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
193 (ediff-set-state-of-diff n 'B nil)
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
194 (ediff-set-state-of-diff n 'C nil)))
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
195 ))
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
196
12167
87f8b79217b3 Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents: 11234
diff changeset
197 (defun ediff-set-merge-mode ()
87f8b79217b3 Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents: 11234
diff changeset
198 (normal-mode t)
87f8b79217b3 Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents: 11234
diff changeset
199 (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
200
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
201
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
202 ;; Go over all diffs starting with DIFF-NUM and copy regions into buffer C
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
203 ;; according to the state of the difference.
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
204 ;; Since ediff-copy-diff refuses to copy identical diff regions, there is
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
205 ;; no need to optimize ediff-do-merge any further.
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
206 ;;
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
207 ;; If re-merging, change state of merge in all diffs starting with
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
208 ;; 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
209 ;; `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
210 ;; since last set by default.
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
211 (defun ediff-do-merge (diff-num &optional remerging)
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
212 (if (< diff-num 0) (setq diff-num 0))
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
213 (let ((n diff-num)
15480
43a3308fcf61 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 14582
diff changeset
214 ;;(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
215 do-not-copy state-of-merge)
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
216 (while (< n ediff-number-of-differences)
15480
43a3308fcf61 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 14582
diff changeset
217 (setq do-not-copy nil) ; reset after each cycle
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
218 (if (= (mod n 10) 0)
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
219 (message "%s buffers A & B into C ... region %d of %d"
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
220 (if remerging "Re-merging" "Merging")
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
221 n
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
222 ediff-number-of-differences))
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
223
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
224 (setq state-of-merge (ediff-get-state-of-merge n))
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
225
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
226 (if remerging
42602
633233bf2bbf 2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 42206
diff changeset
227 ;;(let ((reg-A (ediff-get-region-contents n 'A ediff-control-buffer))
633233bf2bbf 2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 42206
diff changeset
228 ;; (reg-B (ediff-get-region-contents n 'B ediff-control-buffer))
633233bf2bbf 2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 42206
diff changeset
229 ;; (reg-C (ediff-get-region-contents n 'C ediff-control-buffer)))
104993
403125cdfb24 Replace empty `let's with `progn'.
Glenn Morris <rgm@gnu.org>
parents: 104277
diff changeset
230 (progn
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
231
15480
43a3308fcf61 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 14582
diff changeset
232 ;; 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
233 (if (or (ediff-merge-changed-from-default-p n)
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
234 ;; was preferred
12167
87f8b79217b3 Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents: 11234
diff changeset
235 (string-match "prefer" state-of-merge))
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
236 ;; then ignore
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
237 (setq do-not-copy t))
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
238
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
239 ;; 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
240 (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
241 (not do-not-copy))
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
242 (ediff-set-state-of-merge
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
243 n (format "%S" ediff-default-variant)))
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
244 ))
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
245
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
246 ;; 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
247 ;; check it once again
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
248 (setq state-of-merge (ediff-get-state-of-merge n))
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
249
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
250 (or do-not-copy
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
251 (if (string= state-of-merge "combined")
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
252 ;; use n+1 because ediff-combine-diffs works via user numbering
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
253 ;; of diffs, which is 1+ to what ediff uses internally
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
254 (ediff-combine-diffs (1+ n) 'batch)
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
255 (ediff-copy-diff
12167
87f8b79217b3 Converted xemacs *screen* nomenclature to *frame*.
Karl Heuer <kwzh@gnu.org>
parents: 11234
diff changeset
256 n (if (string-match "-A" state-of-merge) 'A 'B) 'C 'batch)))
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
257 (setq n (1+ n)))
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
258 (message "Merging buffers A & B into C ... Done")
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
259 ))
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
260
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
261
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
262 (defun ediff-re-merge ()
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
263 "Remerge unmodified diff regions using a new default. Start with the current region."
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
264 (interactive)
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
265 (let* ((default-variant-alist
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
266 (list '("default-A") '("default-B") '("combined")))
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
267 (actual-alist
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
268 (delete (list (symbol-name ediff-default-variant))
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
269 default-variant-alist)))
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
270 (setq ediff-default-variant
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
271 (intern
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
272 (completing-read
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
273 (format "Current merge default is `%S'. New default: "
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
274 ediff-default-variant)
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
275 actual-alist nil 'must-match)))
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
276 (ediff-do-merge ediff-current-difference 'remerge)
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
277 (ediff-recenter)
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
278 ))
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
279
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
280 (defun ediff-shrink-window-C (arg)
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
281 "Shrink window C to just one line.
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
282 With a prefix argument, returns window C to its normal size.
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
283 Used only for merging jobs."
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
284 (interactive "P")
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
285 (if (not ediff-merge-job)
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
286 (error "ediff-shrink-window-C can be used only for merging jobs"))
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
287 (cond ((eq arg '-) (setq arg -1))
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
288 ((not (numberp arg)) (setq arg nil)))
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
289 (cond ((null arg)
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
290 (let ((ediff-merge-window-share
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
291 (if (< (window-height ediff-window-C) 3)
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
292 ediff-merge-window-share 0)))
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
293 (setq ediff-window-config-saved "") ; force redisplay
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
294 (ediff-recenter 'no-rehighlight)))
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
295 ((and (< arg 0) (> (window-height ediff-window-C) 2))
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
296 (setq ediff-merge-window-share (* ediff-merge-window-share 0.9))
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
297 (setq ediff-window-config-saved "") ; force redisplay
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
298 (ediff-recenter 'no-rehighlight))
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
299 ((and (> arg 0) (> (window-height ediff-window-A) 2))
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
300 (setq ediff-merge-window-share (* ediff-merge-window-share 1.1))
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
301 (setq ediff-window-config-saved "") ; force redisplay
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
302 (ediff-recenter 'no-rehighlight))))
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
303
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
304
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
305 ;; N here is the user's region number. It is 1+ what Ediff uses internally.
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
306 (defun ediff-combine-diffs (n &optional batch-invocation)
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
307 "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
308 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
309 Combining is done according to the specifications in variable
c768f6d7daaa *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 14169
diff changeset
310 `ediff-combination-pattern'."
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
311 (interactive "P")
14582
c768f6d7daaa *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 14169
diff changeset
312 (setq n (if (numberp n) (1- n) ediff-current-difference))
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
313
42602
633233bf2bbf 2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 42206
diff changeset
314 (let (reg-combined)
26585
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
315 ;;(setq regA (ediff-get-region-contents n 'A ediff-control-buffer)
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
316 ;; regB (ediff-get-region-contents n 'B ediff-control-buffer))
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
317 ;;(setq reg-combined (ediff-make-combined-diff regA regB))
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
318 (setq reg-combined (ediff-get-combined-region n))
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
319
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
320 (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
321 (or batch-invocation (ediff-jump-to-difference (1+ n))))
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
322
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
323
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
324 ;; 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
325 ;; in buffers A and B. Return a list (reg-a-beg reg-a-end reg-b-beg reg-b-end)
26585
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
326 ;; These refer to where the delimiters for region A, B, Ancestor start and end
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
327 ;; in buffer C
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
328 (defun ediff-looks-like-combined-merge (region-num)
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
329 (if ediff-merge-job
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
330 (let ((combined (string-match (regexp-quote "(A+B)")
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
331 (or (ediff-get-state-of-diff region-num 'C)
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
332 "")))
26585
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
333 (mrgreg-beg (ediff-get-diff-posn 'C 'beg region-num))
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
334 (mrgreg-end (ediff-get-diff-posn 'C 'end region-num))
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
335 (pattern-list ediff-combination-pattern)
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
336 delim reg-beg reg-end delim-regs-list)
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
337
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
338 (if combined
19047
f90d40b0bff5 new version
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 18839
diff changeset
339 (ediff-with-current-buffer ediff-buffer-C
26585
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
340 (while pattern-list
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
341 (goto-char mrgreg-beg)
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
342 (setq delim (nth 0 pattern-list))
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
343 (search-forward delim mrgreg-end 'noerror)
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
344 (setq reg-beg (match-beginning 0))
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
345 (setq reg-end (match-end 0))
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
346 (if (and reg-beg reg-end)
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
347 (setq delim-regs-list
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
348 ;; in reverse
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
349 (cons reg-end (cons reg-beg delim-regs-list))))
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
350 (if (> (length pattern-list) 1)
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
351 (setq pattern-list (cdr (cdr pattern-list)))
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
352 (setq pattern-list nil))
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
353 )))
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
354
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
355 (reverse delim-regs-list)
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
356 )))
33394
237411236185 (state-or-merge): Defvar when compiling.
Dave Love <fx@gnu.org>
parents: 33019
diff changeset
357
95630
eebbd7f32937 Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents: 94678
diff changeset
358 (defvar state-of-merge) ; dynamic var
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
359
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
360 ;; 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
361 ;; 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
362 ;; 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
363 ;; well.
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
364 (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
365 (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
366 (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
367 (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
368
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
369 (setq state-of-merge (ediff-get-state-of-merge diff-num))
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
370
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
371 ;; 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
372 (or (and (string= state-of-merge "default-A")
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
373 (not (string= reg-A reg-C)))
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
374 (and (string= state-of-merge "default-B")
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
375 (not (string= reg-B reg-C)))
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
376 (and (string= state-of-merge "combined")
26585
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
377 ;;(not (string= (ediff-make-combined-diff reg-A reg-B) reg-C)))
3ec5a485d0ab *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 26263
diff changeset
378 (not (string= (ediff-get-combined-region diff-num) reg-C)))
26263
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
379 (and prefers-too
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
380 (string= state-of-merge "prefer-A")
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
381 (not (string= reg-A reg-C)))
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
382 (and prefers-too
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
383 (string= state-of-merge "prefer-B")
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
384 (not (string= reg-B reg-C)))
4f315ca65976 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 20206
diff changeset
385 )))
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42602
diff changeset
386
11042
57316020d271 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
387
68997
6169b51037af 2006-02-19 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 68651
diff changeset
388 (provide 'ediff-merg)
6169b51037af 2006-02-19 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 68651
diff changeset
389
6169b51037af 2006-02-19 Michael Kifer <kifer@cs.stonybrook.edu>
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 68651
diff changeset
390
101721
c55394eee0de Follow commenting conventions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
391 ;; Local Variables:
c55394eee0de Follow commenting conventions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
392 ;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun)
c55394eee0de Follow commenting conventions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
393 ;; eval: (put 'ediff-with-current-buffer 'lisp-indent-hook 1)
c55394eee0de Follow commenting conventions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
394 ;; eval: (put 'ediff-with-current-buffer 'edebug-form-spec '(form body))
c55394eee0de Follow commenting conventions.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
395 ;; End:
16248
b2fae8abc5b0 *** empty log message ***
Michael Kifer <kifer@cs.stonybrook.edu>
parents: 15480
diff changeset
396
38422
7a94f1c588c4 Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 33394
diff changeset
397 ;;; ediff-merg.el ends here