Mercurial > emacs
annotate lisp/smerge-mode.el @ 91000:cd5e99697764
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 843-844)
- Update from CVS
- Merge from emacs--rel--22
* emacs--rel--22 (patch 84-87)
- Update from CVS
- Change capitalization of VC backend names for new backends
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-241
author | Miles Bader <miles@gnu.org> |
---|---|
date | Fri, 03 Aug 2007 05:57:16 +0000 |
parents | f55f9811f5d7 |
children | aaccdab0ee26 |
rev | line source |
---|---|
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1 ;;; smerge-mode.el --- Minor mode to resolve diff3 conflicts |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
2 |
64762
41bb365f41c4
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64637
diff
changeset
|
3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, |
75347 | 4 ;; 2004, 2005, 2006, 2007 Free Software Foundation, Inc. |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
5 |
70292
2b77fa42947f
Update my email address.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
6 ;; Author: Stefan Monnier <monnier@iro.umontreal.ca> |
66458
f2be1560adf2
Add 'tools' to file keywords.
Romain Francoise <romain@orebokech.com>
parents:
65658
diff
changeset
|
7 ;; Keywords: tools revision-control merge diff3 cvs conflict |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
8 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
9 ;; This file is part of GNU Emacs. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
10 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
11 ;; GNU Emacs is free software; you can redistribute it and/or modify |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
12 ;; it under the terms of the GNU General Public License as published by |
78236
9355f9b7bbff
Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
76397
diff
changeset
|
13 ;; the Free Software Foundation; either version 3, or (at your option) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
14 ;; any later version. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
15 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
16 ;; GNU Emacs is distributed in the hope that it will be useful, |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
19 ;; GNU General Public License for more details. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
20 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
21 ;; You should have received a copy of the GNU General Public License |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
64091 | 23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 ;; Boston, MA 02110-1301, USA. | |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
25 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
26 ;;; Commentary: |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
27 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
28 ;; Provides a lightweight alternative to emerge/ediff. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
29 ;; To use it, simply add to your .emacs the following lines: |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
30 ;; |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
31 ;; (autoload 'smerge-mode "smerge-mode" nil t) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
32 ;; |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
33 ;; you can even have it turned on automatically with the following |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
34 ;; piece of code in your .emacs: |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
35 ;; |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
36 ;; (defun sm-try-smerge () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
37 ;; (save-excursion |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
38 ;; (goto-char (point-min)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
39 ;; (when (re-search-forward "^<<<<<<< " nil t) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
40 ;; (smerge-mode 1)))) |
46899
f00337f04e78
Use find-file-hook instead of find-file-hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41064
diff
changeset
|
41 ;; (add-hook 'find-file-hook 'sm-try-smerge t) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
42 |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
43 ;;; Todo: |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
44 |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
45 ;; - if requested, ask the user whether he wants to call ediff right away |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
46 |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
47 ;;; Code: |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
48 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
49 (eval-when-compile (require 'cl)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
50 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
51 |
63936
1eb58fde25d4
(smerge-mode): Add duplicate defvar near top.
Richard M. Stallman <rms@gnu.org>
parents:
63488
diff
changeset
|
52 ;;; The real definition comes later. |
1eb58fde25d4
(smerge-mode): Add duplicate defvar near top.
Richard M. Stallman <rms@gnu.org>
parents:
63488
diff
changeset
|
53 (defvar smerge-mode) |
1eb58fde25d4
(smerge-mode): Add duplicate defvar near top.
Richard M. Stallman <rms@gnu.org>
parents:
63488
diff
changeset
|
54 |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
55 (defgroup smerge () |
65067
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
56 "Minor mode to highlight and resolve diff3 conflicts." |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
57 :group 'tools |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
58 :prefix "smerge-") |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
59 |
47209
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
60 (defcustom smerge-diff-buffer-name "*vc-diff*" |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
61 "Buffer name to use for displaying diffs." |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
62 :group 'smerge |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
63 :type '(choice |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
64 (const "*vc-diff*") |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
65 (const "*cvs-diff*") |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
66 (const "*smerge-diff*") |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
67 string)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
68 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
69 (defcustom smerge-diff-switches |
29207
6c4e371d4efd
(smerge-diff-switches): Don't use list* in defcustom.
Dave Love <fx@gnu.org>
parents:
28248
diff
changeset
|
70 (append '("-d" "-b") |
6c4e371d4efd
(smerge-diff-switches): Don't use list* in defcustom.
Dave Love <fx@gnu.org>
parents:
28248
diff
changeset
|
71 (if (listp diff-switches) diff-switches (list diff-switches))) |
65067
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
72 "A list of strings specifying switches to be passed to diff. |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
73 Used in `smerge-diff-base-mine' and related functions." |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
74 :group 'smerge |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
75 :type '(repeat string)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
76 |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
77 (defcustom smerge-auto-leave t |
65067
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
78 "Non-nil means to leave `smerge-mode' when the last conflict is resolved." |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
79 :group 'smerge |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
80 :type 'boolean) |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
81 |
63205
6dde8ad3e1a7
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375
Miles Bader <miles@gnu.org>
parents:
61394
diff
changeset
|
82 (defface smerge-mine |
61394
31aa9a390538
* mh-customize.el (mh-speedbar-selected-folder-face): Special case
Dan Nicolaescu <dann@ics.uci.edu>
parents:
61277
diff
changeset
|
83 '((((min-colors 88) (background light)) |
31aa9a390538
* mh-customize.el (mh-speedbar-selected-folder-face): Special case
Dan Nicolaescu <dann@ics.uci.edu>
parents:
61277
diff
changeset
|
84 (:foreground "blue1")) |
31aa9a390538
* mh-customize.el (mh-speedbar-selected-folder-face): Special case
Dan Nicolaescu <dann@ics.uci.edu>
parents:
61277
diff
changeset
|
85 (((background light)) |
32164
a3d5adc99010
(smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents:
30868
diff
changeset
|
86 (:foreground "blue")) |
61394
31aa9a390538
* mh-customize.el (mh-speedbar-selected-folder-face): Special case
Dan Nicolaescu <dann@ics.uci.edu>
parents:
61277
diff
changeset
|
87 (((min-colors 88) (background dark)) |
31aa9a390538
* mh-customize.el (mh-speedbar-selected-folder-face): Special case
Dan Nicolaescu <dann@ics.uci.edu>
parents:
61277
diff
changeset
|
88 (:foreground "cyan1")) |
32164
a3d5adc99010
(smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents:
30868
diff
changeset
|
89 (((background dark)) |
a3d5adc99010
(smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents:
30868
diff
changeset
|
90 (:foreground "cyan"))) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
91 "Face for your code." |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
92 :group 'smerge) |
63205
6dde8ad3e1a7
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375
Miles Bader <miles@gnu.org>
parents:
61394
diff
changeset
|
93 ;; backward-compatibility alias |
6dde8ad3e1a7
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375
Miles Bader <miles@gnu.org>
parents:
61394
diff
changeset
|
94 (put 'smerge-mine-face 'face-alias 'smerge-mine) |
6dde8ad3e1a7
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375
Miles Bader <miles@gnu.org>
parents:
61394
diff
changeset
|
95 (defvar smerge-mine-face 'smerge-mine) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
96 |
63205
6dde8ad3e1a7
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375
Miles Bader <miles@gnu.org>
parents:
61394
diff
changeset
|
97 (defface smerge-other |
32164
a3d5adc99010
(smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents:
30868
diff
changeset
|
98 '((((background light)) |
a3d5adc99010
(smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents:
30868
diff
changeset
|
99 (:foreground "darkgreen")) |
a3d5adc99010
(smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents:
30868
diff
changeset
|
100 (((background dark)) |
a3d5adc99010
(smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents:
30868
diff
changeset
|
101 (:foreground "lightgreen"))) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
102 "Face for the other code." |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
103 :group 'smerge) |
63205
6dde8ad3e1a7
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375
Miles Bader <miles@gnu.org>
parents:
61394
diff
changeset
|
104 ;; backward-compatibility alias |
6dde8ad3e1a7
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375
Miles Bader <miles@gnu.org>
parents:
61394
diff
changeset
|
105 (put 'smerge-other-face 'face-alias 'smerge-other) |
6dde8ad3e1a7
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375
Miles Bader <miles@gnu.org>
parents:
61394
diff
changeset
|
106 (defvar smerge-other-face 'smerge-other) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
107 |
63205
6dde8ad3e1a7
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375
Miles Bader <miles@gnu.org>
parents:
61394
diff
changeset
|
108 (defface smerge-base |
61394
31aa9a390538
* mh-customize.el (mh-speedbar-selected-folder-face): Special case
Dan Nicolaescu <dann@ics.uci.edu>
parents:
61277
diff
changeset
|
109 '((((min-colors 88) (background light)) |
31aa9a390538
* mh-customize.el (mh-speedbar-selected-folder-face): Special case
Dan Nicolaescu <dann@ics.uci.edu>
parents:
61277
diff
changeset
|
110 (:foreground "red1")) |
31aa9a390538
* mh-customize.el (mh-speedbar-selected-folder-face): Special case
Dan Nicolaescu <dann@ics.uci.edu>
parents:
61277
diff
changeset
|
111 (((background light)) |
32164
a3d5adc99010
(smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents:
30868
diff
changeset
|
112 (:foreground "red")) |
a3d5adc99010
(smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents:
30868
diff
changeset
|
113 (((background dark)) |
a3d5adc99010
(smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents:
30868
diff
changeset
|
114 (:foreground "orange"))) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
115 "Face for the base code." |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
116 :group 'smerge) |
63205
6dde8ad3e1a7
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375
Miles Bader <miles@gnu.org>
parents:
61394
diff
changeset
|
117 ;; backward-compatibility alias |
6dde8ad3e1a7
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375
Miles Bader <miles@gnu.org>
parents:
61394
diff
changeset
|
118 (put 'smerge-base-face 'face-alias 'smerge-base) |
6dde8ad3e1a7
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375
Miles Bader <miles@gnu.org>
parents:
61394
diff
changeset
|
119 (defvar smerge-base-face 'smerge-base) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
120 |
63205
6dde8ad3e1a7
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375
Miles Bader <miles@gnu.org>
parents:
61394
diff
changeset
|
121 (defface smerge-markers |
32164
a3d5adc99010
(smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents:
30868
diff
changeset
|
122 '((((background light)) |
a3d5adc99010
(smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents:
30868
diff
changeset
|
123 (:background "grey85")) |
a3d5adc99010
(smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents:
30868
diff
changeset
|
124 (((background dark)) |
a3d5adc99010
(smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents:
30868
diff
changeset
|
125 (:background "grey30"))) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
126 "Face for the conflict markers." |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
127 :group 'smerge) |
63205
6dde8ad3e1a7
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375
Miles Bader <miles@gnu.org>
parents:
61394
diff
changeset
|
128 ;; backward-compatibility alias |
6dde8ad3e1a7
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375
Miles Bader <miles@gnu.org>
parents:
61394
diff
changeset
|
129 (put 'smerge-markers-face 'face-alias 'smerge-markers) |
6dde8ad3e1a7
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375
Miles Bader <miles@gnu.org>
parents:
61394
diff
changeset
|
130 (defvar smerge-markers-face 'smerge-markers) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
131 |
65129
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
132 (defface smerge-refined-change |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
133 '((t :background "yellow")) |
65131
ebbbce58e84c
(smerge-refined-change): Add :group.
Juanma Barranquero <lekktu@gmail.com>
parents:
65129
diff
changeset
|
134 "Face used for char-based changes shown by `smerge-refine'." |
ebbbce58e84c
(smerge-refined-change): Add :group.
Juanma Barranquero <lekktu@gmail.com>
parents:
65129
diff
changeset
|
135 :group 'smerge) |
65129
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
136 |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
137 (easy-mmode-defmap smerge-basic-map |
34840
509ed3724af0
(smerge-basic-map): Use `=' rather than `d'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32217
diff
changeset
|
138 `(("n" . smerge-next) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
139 ("p" . smerge-prev) |
47827
9d7b63dcf005
(smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47821
diff
changeset
|
140 ("r" . smerge-resolve) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
141 ("a" . smerge-keep-all) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
142 ("b" . smerge-keep-base) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
143 ("o" . smerge-keep-other) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
144 ("m" . smerge-keep-mine) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
145 ("E" . smerge-ediff) |
65067
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
146 ("C" . smerge-combine-with-next) |
65129
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
147 ("R" . smerge-refine) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
148 ("\C-m" . smerge-keep-current) |
34840
509ed3724af0
(smerge-basic-map): Use `=' rather than `d'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32217
diff
changeset
|
149 ("=" . ,(make-sparse-keymap "Diff")) |
509ed3724af0
(smerge-basic-map): Use `=' rather than `d'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32217
diff
changeset
|
150 ("=<" "base-mine" . smerge-diff-base-mine) |
509ed3724af0
(smerge-basic-map): Use `=' rather than `d'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32217
diff
changeset
|
151 ("=>" "base-other" . smerge-diff-base-other) |
509ed3724af0
(smerge-basic-map): Use `=' rather than `d'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32217
diff
changeset
|
152 ("==" "mine-other" . smerge-diff-mine-other)) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
153 "The base keymap for `smerge-mode'.") |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
154 |
34840
509ed3724af0
(smerge-basic-map): Use `=' rather than `d'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32217
diff
changeset
|
155 (defcustom smerge-command-prefix "\C-c^" |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
156 "Prefix for `smerge-mode' commands." |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
157 :group 'smerge |
34840
509ed3724af0
(smerge-basic-map): Use `=' rather than `d'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32217
diff
changeset
|
158 :type '(choice (string "\e") (string "\C-c^") (string "") string)) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
159 |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
160 (easy-mmode-defmap smerge-mode-map |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
161 `((,smerge-command-prefix . ,smerge-basic-map)) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
162 "Keymap for `smerge-mode'.") |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
163 |
54332
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
164 (defvar smerge-check-cache nil) |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
165 (make-variable-buffer-local 'smerge-check-cache) |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
166 (defun smerge-check (n) |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
167 (condition-case nil |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
168 (let ((state (cons (point) (buffer-modified-tick)))) |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
169 (unless (equal (cdr smerge-check-cache) state) |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
170 (smerge-match-conflict) |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
171 (setq smerge-check-cache (cons (match-data) state))) |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
172 (nth (* 2 n) (car smerge-check-cache))) |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
173 (error nil))) |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
174 |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
175 (easy-menu-define smerge-mode-menu smerge-mode-map |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
176 "Menu for `smerge-mode'." |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
177 '("SMerge" |
30358 | 178 ["Next" smerge-next :help "Go to next conflict"] |
30868
f7b06560383b
(smerge-mode-menu): Doc fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30358
diff
changeset
|
179 ["Previous" smerge-prev :help "Go to previous conflict"] |
54332
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
180 "--" |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
181 ["Keep All" smerge-keep-all :help "Keep all three versions" |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
182 :active (smerge-check 1)] |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
183 ["Keep Current" smerge-keep-current :help "Use current (at point) version" |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
184 :active (and (smerge-check 1) (> (smerge-get-current) 0))] |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
185 "--" |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
186 ["Revert to Base" smerge-keep-base :help "Revert to base version" |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
187 :active (smerge-check 2)] |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
188 ["Keep Other" smerge-keep-other :help "Keep `other' version" |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
189 :active (smerge-check 3)] |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
190 ["Keep Yours" smerge-keep-mine :help "Keep your version" |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
191 :active (smerge-check 1)] |
30358 | 192 "--" |
193 ["Diff Base/Mine" smerge-diff-base-mine | |
54332
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
194 :help "Diff `base' and `mine' for current conflict" |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
195 :active (smerge-check 2)] |
30358 | 196 ["Diff Base/Other" smerge-diff-base-other |
54332
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
197 :help "Diff `base' and `other' for current conflict" |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
198 :active (smerge-check 2)] |
30358 | 199 ["Diff Mine/Other" smerge-diff-mine-other |
54332
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
200 :help "Diff `mine' and `other' for current conflict" |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
201 :active (smerge-check 1)] |
30358 | 202 "--" |
203 ["Invoke Ediff" smerge-ediff | |
54332
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
204 :help "Use Ediff to resolve the conflicts" |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
205 :active (smerge-check 1)] |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
206 ["Auto Resolve" smerge-resolve |
54527
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
207 :help "Try auto-resolution heuristics" |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
208 :active (smerge-check 1)] |
54332
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
209 ["Combine" smerge-combine-with-next |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
210 :help "Combine current conflict with next" |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
211 :active (smerge-check 1)] |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
212 )) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
213 |
54402
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
214 (easy-menu-define smerge-context-menu nil |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
215 "Context menu for mine area in `smerge-mode'." |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
216 '(nil |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
217 ["Keep Current" smerge-keep-current :help "Use current (at point) version"] |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
218 ["Kill Current" smerge-kill-current :help "Remove current (at point) version"] |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
219 ["Keep All" smerge-keep-all :help "Keep all three versions"] |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
220 "---" |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
221 ["More..." (popup-menu smerge-mode-menu) :help "Show full SMerge mode menu"] |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
222 )) |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
223 |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
224 (defconst smerge-font-lock-keywords |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
225 '((smerge-find-conflict |
35564
b546ef3b2284
(smerge-font-lock-keywords): Relax submatch 1.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
34855
diff
changeset
|
226 (1 smerge-mine-face prepend t) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
227 (2 smerge-base-face prepend t) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
228 (3 smerge-other-face prepend t) |
34840
509ed3724af0
(smerge-basic-map): Use `=' rather than `d'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32217
diff
changeset
|
229 ;; FIXME: `keep' doesn't work right with syntactic fontification. |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
230 (0 smerge-markers-face keep) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
231 (4 nil t t) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
232 (5 nil t t))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
233 "Font lock patterns for `smerge-mode'.") |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
234 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
235 (defconst smerge-begin-re "^<<<<<<< \\(.*\\)\n") |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
236 (defconst smerge-end-re "^>>>>>>> .*\n") |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
237 (defconst smerge-base-re "^||||||| .*\n") |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
238 (defconst smerge-other-re "^=======\n") |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
239 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
240 (defvar smerge-conflict-style nil |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
241 "Keep track of which style of conflict is in use. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
242 Can be nil if the style is undecided, or else: |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
243 - `diff3-E' |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
244 - `diff3-A'") |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
245 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
246 ;; Compiler pacifiers |
52779
3bc7b9f71e34
Previous change was bogus. Something odd in pcl-cvs...
Dave Love <fx@gnu.org>
parents:
52778
diff
changeset
|
247 (defvar font-lock-mode) |
3bc7b9f71e34
Previous change was bogus. Something odd in pcl-cvs...
Dave Love <fx@gnu.org>
parents:
52778
diff
changeset
|
248 (defvar font-lock-keywords) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
249 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
250 ;;;; |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
251 ;;;; Actual code |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
252 ;;;; |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
253 |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
254 ;; Define smerge-next and smerge-prev |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
255 (easy-mmode-define-navigation smerge smerge-begin-re "conflict") |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
256 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
257 (defconst smerge-match-names ["conflict" "mine" "base" "other"]) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
258 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
259 (defun smerge-ensure-match (n) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
260 (unless (match-end n) |
63488
31f53cf94303
(smerge-ensure-match): Don't use `format' on `error' arguments.
Juanma Barranquero <lekktu@gmail.com>
parents:
63205
diff
changeset
|
261 (error "No `%s'" (aref smerge-match-names n)))) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
262 |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
263 (defun smerge-auto-leave () |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
264 (when (and smerge-auto-leave |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
265 (save-excursion (goto-char (point-min)) |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
266 (not (re-search-forward smerge-begin-re nil t)))) |
65067
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
267 (when (and (listp buffer-undo-list) smerge-mode) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
268 (push (list 'apply 'smerge-mode 1) buffer-undo-list)) |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
269 (smerge-mode -1))) |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47827
diff
changeset
|
270 |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
271 |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
272 (defun smerge-keep-all () |
54527
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
273 "Concatenate all versions." |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
274 (interactive) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
275 (smerge-match-conflict) |
54527
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
276 (let ((mb2 (or (match-beginning 2) (point-max))) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
277 (me2 (or (match-end 2) (point-min)))) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
278 (delete-region (match-end 3) (match-end 0)) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
279 (delete-region (max me2 (match-end 1)) (match-beginning 3)) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
280 (if (and (match-end 2) (/= (match-end 1) (match-end 3))) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
281 (delete-region (match-end 1) (match-beginning 2))) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
282 (delete-region (match-beginning 0) (min (match-beginning 1) mb2)) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
283 (smerge-auto-leave))) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
284 |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
285 (defun smerge-keep-n (n) |
65129
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
286 (smerge-remove-props (match-beginning 0) (match-end 0)) |
54527
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
287 ;; We used to use replace-match, but that did not preserve markers so well. |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
288 (delete-region (match-end n) (match-end 0)) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
289 (delete-region (match-beginning 0) (match-beginning n))) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
290 |
47209
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
291 (defun smerge-combine-with-next () |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
292 "Combine the current conflict with the next one." |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
293 (interactive) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
294 (smerge-match-conflict) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
295 (let ((ends nil)) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
296 (dolist (i '(3 2 1 0)) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
297 (push (if (match-end i) (copy-marker (match-end i) t)) ends)) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
298 (setq ends (apply 'vector ends)) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
299 (goto-char (aref ends 0)) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
300 (if (not (re-search-forward smerge-begin-re nil t)) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
301 (error "No next conflict") |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
302 (smerge-match-conflict) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
303 (let ((match-data (mapcar (lambda (m) (if m (copy-marker m))) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
304 (match-data)))) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
305 ;; First copy the in-between text in each alternative. |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
306 (dolist (i '(1 2 3)) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
307 (when (aref ends i) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
308 (goto-char (aref ends i)) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
309 (insert-buffer-substring (current-buffer) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
310 (aref ends 0) (car match-data)))) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
311 (delete-region (aref ends 0) (car match-data)) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
312 ;; Then move the second conflict's alternatives into the first. |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
313 (dolist (i '(1 2 3)) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
314 (set-match-data match-data) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
315 (when (and (aref ends i) (match-end i)) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
316 (goto-char (aref ends i)) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
317 (insert-buffer-substring (current-buffer) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
318 (match-beginning i) (match-end i)))) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
319 (delete-region (car match-data) (cadr match-data)) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
320 ;; Free the markers. |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
321 (dolist (m match-data) (if m (move-marker m nil))) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
322 (mapc (lambda (m) (if m (move-marker m nil))) ends))))) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
323 |
47827
9d7b63dcf005
(smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47821
diff
changeset
|
324 (defvar smerge-resolve-function |
9d7b63dcf005
(smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47821
diff
changeset
|
325 (lambda () (error "Don't know how to resolve")) |
9d7b63dcf005
(smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47821
diff
changeset
|
326 "Mode-specific merge function. |
9d7b63dcf005
(smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47821
diff
changeset
|
327 The function is called with no argument and with the match data set |
9d7b63dcf005
(smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47821
diff
changeset
|
328 according to `smerge-match-conflict'.") |
65067
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
329 (add-to-list 'debug-ignored-errors "Don't know how to resolve") |
47827
9d7b63dcf005
(smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47821
diff
changeset
|
330 |
54402
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
331 (defvar smerge-text-properties |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
332 `(help-echo "merge conflict: mouse-3 shows a menu" |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
333 ;; mouse-face highlight |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
334 keymap (keymap (down-mouse-3 . smerge-popup-context-menu)))) |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
335 |
65129
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
336 (defun smerge-remove-props (beg end) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
337 (remove-overlays beg end 'smerge 'refine) |
65658
5bde6d4759d6
(smerge-remove-props): Cause re-highlighting of the whole conflict.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65379
diff
changeset
|
338 (remove-overlays beg end 'smerge 'conflict) |
5bde6d4759d6
(smerge-remove-props): Cause re-highlighting of the whole conflict.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65379
diff
changeset
|
339 ;; Now that we use overlays rather than text-properties, this function |
5bde6d4759d6
(smerge-remove-props): Cause re-highlighting of the whole conflict.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65379
diff
changeset
|
340 ;; does not cause refontification any more. It can be seen very clearly |
5bde6d4759d6
(smerge-remove-props): Cause re-highlighting of the whole conflict.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65379
diff
changeset
|
341 ;; in buffers where jit-lock-contextually is not t, in which case deleting |
5bde6d4759d6
(smerge-remove-props): Cause re-highlighting of the whole conflict.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65379
diff
changeset
|
342 ;; the "<<<<<<< foobar" leading line leaves the rest of the conflict |
5bde6d4759d6
(smerge-remove-props): Cause re-highlighting of the whole conflict.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65379
diff
changeset
|
343 ;; highlighted as if it were still a valid conflict. Note that in many |
5bde6d4759d6
(smerge-remove-props): Cause re-highlighting of the whole conflict.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65379
diff
changeset
|
344 ;; important cases (such as the previous example) we're actually called |
5bde6d4759d6
(smerge-remove-props): Cause re-highlighting of the whole conflict.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65379
diff
changeset
|
345 ;; during font-locking so inhibit-modification-hooks is non-nil, so we |
5bde6d4759d6
(smerge-remove-props): Cause re-highlighting of the whole conflict.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65379
diff
changeset
|
346 ;; can't just modify the buffer and expect font-lock to be triggered as in: |
5bde6d4759d6
(smerge-remove-props): Cause re-highlighting of the whole conflict.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65379
diff
changeset
|
347 ;; (put-text-property beg end 'smerge-force-highlighting nil) |
76397
e9b063d17531
(smerge-remove-props): Don't mark the buffer modified.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75347
diff
changeset
|
348 (let ((modified (buffer-modified-p))) |
e9b063d17531
(smerge-remove-props): Don't mark the buffer modified.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75347
diff
changeset
|
349 (remove-text-properties beg end '(fontified nil)) |
e9b063d17531
(smerge-remove-props): Don't mark the buffer modified.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75347
diff
changeset
|
350 (restore-buffer-modified-p modified))) |
54402
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
351 |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
352 (defun smerge-popup-context-menu (event) |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
353 "Pop up the Smerge mode context menu under mouse." |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
354 (interactive "e") |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
355 (if (and smerge-mode |
54872
367886fbcfd9
(smerge-popup-context-menu): Use it.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54527
diff
changeset
|
356 (save-excursion (posn-set-point (event-end event)) (smerge-check 1))) |
54402
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
357 (progn |
54872
367886fbcfd9
(smerge-popup-context-menu): Use it.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54527
diff
changeset
|
358 (posn-set-point (event-end event)) |
54527
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
359 (smerge-match-conflict) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
360 (let ((i (smerge-get-current)) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
361 o) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
362 (if (<= i 0) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
363 ;; Out of range |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
364 (popup-menu smerge-mode-menu) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
365 ;; Install overlay. |
55258
04a44f089cc1
(smerge-diff-switches): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
54904
diff
changeset
|
366 (setq o (make-overlay (match-beginning i) (match-end i))) |
54527
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
367 (unwind-protect |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
368 (progn |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
369 (overlay-put o 'face 'highlight) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
370 (sit-for 0) ;Display the new highlighting. |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
371 (popup-menu smerge-context-menu)) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
372 ;; Delete overlay. |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
373 (delete-overlay o))))) |
54402
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
374 ;; There's no conflict at point, the text-props are just obsolete. |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
375 (save-excursion |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
376 (let ((beg (re-search-backward smerge-end-re nil t)) |
54527
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
377 (end (re-search-forward smerge-begin-re nil t))) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
378 (smerge-remove-props (or beg (point-min)) (or end (point-max))) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
379 (push event unread-command-events))))) |
54402
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
380 |
47827
9d7b63dcf005
(smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47821
diff
changeset
|
381 (defun smerge-resolve () |
9d7b63dcf005
(smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47821
diff
changeset
|
382 "Resolve the conflict at point intelligently. |
9d7b63dcf005
(smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47821
diff
changeset
|
383 This relies on mode-specific knowledge and thus only works in |
9d7b63dcf005
(smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47821
diff
changeset
|
384 some major modes. Uses `smerge-resolve-function' to do the actual work." |
9d7b63dcf005
(smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47821
diff
changeset
|
385 (interactive) |
9d7b63dcf005
(smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47821
diff
changeset
|
386 (smerge-match-conflict) |
65379
66ed969ca7cc
(smerge-resolve): Pass args to smerge-remove-props.
Richard M. Stallman <rms@gnu.org>
parents:
65131
diff
changeset
|
387 (smerge-remove-props (match-beginning 0) (match-end 0)) |
54527
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
388 (cond |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
389 ;; Trivial diff3 -A non-conflicts. |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
390 ((and (eq (match-end 1) (match-end 3)) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
391 (eq (match-beginning 1) (match-beginning 3))) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
392 (smerge-keep-n 3)) |
65067
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
393 ;; Mode-specific conflict resolution. |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
394 ((condition-case nil |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
395 (atomic-change-group |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
396 (funcall smerge-resolve-function) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
397 t) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
398 (error nil)) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
399 ;; Nothing to do: the resolution function has done it already. |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
400 nil) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
401 ;; FIXME: Add "if [ diff -b MINE OTHER ]; then select OTHER; fi" |
54527
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
402 ((and (match-end 2) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
403 ;; FIXME: Add "diff -b BASE MINE | patch OTHER". |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
404 ;; FIXME: Add "diff -b BASE OTHER | patch MINE". |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
405 nil) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
406 ) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
407 ((and (not (match-end 2)) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
408 ;; FIXME: Add "diff -b"-based refinement. |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
409 nil) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
410 ) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
411 (t |
65067
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
412 (error "Don't know how to resolve"))) |
47827
9d7b63dcf005
(smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47821
diff
changeset
|
413 (smerge-auto-leave)) |
9d7b63dcf005
(smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47821
diff
changeset
|
414 |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
415 (defun smerge-keep-base () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
416 "Revert to the base version." |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
417 (interactive) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
418 (smerge-match-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
419 (smerge-ensure-match 2) |
54527
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
420 (smerge-keep-n 2) |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
421 (smerge-auto-leave)) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
422 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
423 (defun smerge-keep-other () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
424 "Use \"other\" version." |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
425 (interactive) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
426 (smerge-match-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
427 ;;(smerge-ensure-match 3) |
54527
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
428 (smerge-keep-n 3) |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
429 (smerge-auto-leave)) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
430 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
431 (defun smerge-keep-mine () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
432 "Keep your version." |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
433 (interactive) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
434 (smerge-match-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
435 ;;(smerge-ensure-match 1) |
54527
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
436 (smerge-keep-n 1) |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
437 (smerge-auto-leave)) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
438 |
54332
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
439 (defun smerge-get-current () |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
440 (let ((i 3)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
441 (while (or (not (match-end i)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
442 (< (point) (match-beginning i)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
443 (>= (point) (match-end i))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
444 (decf i)) |
54332
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
445 i)) |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
446 |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
447 (defun smerge-keep-current () |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
448 "Use the current (under the cursor) version." |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
449 (interactive) |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
450 (smerge-match-conflict) |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
451 (let ((i (smerge-get-current))) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
452 (if (<= i 0) (error "Not inside a version") |
54527
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
453 (smerge-keep-n i) |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
454 (smerge-auto-leave)))) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
455 |
54402
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
456 (defun smerge-kill-current () |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
457 "Remove the current (under the cursor) version." |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
458 (interactive) |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
459 (smerge-match-conflict) |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
460 (let ((i (smerge-get-current))) |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
461 (if (<= i 0) (error "Not inside a version") |
54527
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
462 (let ((left nil)) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
463 (dolist (n '(3 2 1)) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
464 (if (and (match-end n) (/= (match-end n) (match-end i))) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
465 (push n left))) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
466 (if (and (cdr left) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
467 (/= (match-end (car left)) (match-end (cadr left)))) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
468 (ding) ;We don't know how to do that. |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
469 (smerge-keep-n (car left)) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
470 (smerge-auto-leave)))))) |
54402
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
471 |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
472 (defun smerge-diff-base-mine () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
473 "Diff 'base' and 'mine' version in current conflict region." |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
474 (interactive) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
475 (smerge-diff 2 1)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
476 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
477 (defun smerge-diff-base-other () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
478 "Diff 'base' and 'other' version in current conflict region." |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
479 (interactive) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
480 (smerge-diff 2 3)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
481 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
482 (defun smerge-diff-mine-other () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
483 "Diff 'mine' and 'other' version in current conflict region." |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
484 (interactive) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
485 (smerge-diff 1 3)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
486 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
487 (defun smerge-match-conflict () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
488 "Get info about the conflict. Puts the info in the `match-data'. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
489 The submatches contain: |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
490 0: the whole conflict. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
491 1: your code. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
492 2: the base code. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
493 3: other code. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
494 An error is raised if not inside a conflict." |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
495 (save-excursion |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
496 (condition-case nil |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
497 (let* ((orig-point (point)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
498 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
499 (_ (forward-line 1)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
500 (_ (re-search-backward smerge-begin-re)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
501 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
502 (start (match-beginning 0)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
503 (mine-start (match-end 0)) |
47827
9d7b63dcf005
(smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47821
diff
changeset
|
504 (filename (or (match-string 1) "")) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
505 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
506 (_ (re-search-forward smerge-end-re)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
507 (_ (assert (< orig-point (match-end 0)))) |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47827
diff
changeset
|
508 |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
509 (other-end (match-beginning 0)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
510 (end (match-end 0)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
511 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
512 (_ (re-search-backward smerge-other-re start)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
513 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
514 (mine-end (match-beginning 0)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
515 (other-start (match-end 0)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
516 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
517 base-start base-end) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
518 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
519 ;; handle the various conflict styles |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
520 (cond |
54903
922f49230ff5
(smerge-match-conflict): Try to do something sensible
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54872
diff
changeset
|
521 ((save-excursion |
922f49230ff5
(smerge-match-conflict): Try to do something sensible
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54872
diff
changeset
|
522 (goto-char mine-start) |
54904
a23bbf466906
(smerge-match-conflict): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54903
diff
changeset
|
523 (re-search-forward smerge-begin-re end t)) |
54903
922f49230ff5
(smerge-match-conflict): Try to do something sensible
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54872
diff
changeset
|
524 ;; There's a nested conflict and we're after the the beginning |
922f49230ff5
(smerge-match-conflict): Try to do something sensible
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54872
diff
changeset
|
525 ;; of the outer one but before the beginning of the inner one. |
65067
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
526 ;; Of course, maybe this is not a nested conflict but in that |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
527 ;; case it can only be something nastier that we don't know how |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
528 ;; to handle, so may as well arbitrarily decide to treat it as |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
529 ;; a nested conflict. --Stef |
54903
922f49230ff5
(smerge-match-conflict): Try to do something sensible
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54872
diff
changeset
|
530 (error "There is a nested conflict")) |
922f49230ff5
(smerge-match-conflict): Try to do something sensible
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54872
diff
changeset
|
531 |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
532 ((re-search-backward smerge-base-re start t) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
533 ;; a 3-parts conflict |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
534 (set (make-local-variable 'smerge-conflict-style) 'diff3-A) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
535 (setq base-end mine-end) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
536 (setq mine-end (match-beginning 0)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
537 (setq base-start (match-end 0))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
538 |
54402
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
539 ((string= filename (file-name-nondirectory |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
540 (or buffer-file-name ""))) |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
541 ;; a 2-parts conflict |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
542 (set (make-local-variable 'smerge-conflict-style) 'diff3-E)) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
543 |
54402
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
544 ((and (not base-start) |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
545 (or (eq smerge-conflict-style 'diff3-A) |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
546 (equal filename "ANCESTOR") |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
547 (string-match "\\`[.0-9]+\\'" filename))) |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
548 ;; a same-diff conflict |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
549 (setq base-start mine-start) |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
550 (setq base-end mine-end) |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
551 (setq mine-start other-start) |
8bf3846fc7dd
2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents:
54332
diff
changeset
|
552 (setq mine-end other-end))) |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47827
diff
changeset
|
553 |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
554 (store-match-data (list start end |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
555 mine-start mine-end |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
556 base-start base-end |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
557 other-start other-end |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
558 (when base-start (1- base-start)) base-start |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
559 (1- other-start) other-start)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
560 t) |
41064
cdd9ef6f603d
(smerge-match-conflict): Fix typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38611
diff
changeset
|
561 (search-failed (error "Point not in conflict region"))))) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
562 |
76397
e9b063d17531
(smerge-remove-props): Don't mark the buffer modified.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75347
diff
changeset
|
563 (add-to-list 'debug-ignored-errors "Point not in conflict region") |
e9b063d17531
(smerge-remove-props): Don't mark the buffer modified.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75347
diff
changeset
|
564 |
65067
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
565 (defun smerge-conflict-overlay (pos) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
566 "Return the conflict overlay at POS if any." |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
567 (let ((ols (overlays-at pos)) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
568 conflict) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
569 (dolist (ol ols) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
570 (if (and (eq (overlay-get ol 'smerge) 'conflict) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
571 (> (overlay-end ol) pos)) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
572 (setq conflict ol))) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
573 conflict)) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
574 |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
575 (defun smerge-find-conflict (&optional limit) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
576 "Find and match a conflict region. Intended as a font-lock MATCHER. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
577 The submatches are the same as in `smerge-match-conflict'. |
65067
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
578 Returns non-nil if a match is found between point and LIMIT. |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
579 Point is moved to the end of the conflict." |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
580 (let ((found nil) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
581 (pos (point)) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
582 conflict) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
583 ;; First check to see if point is already inside a conflict, using |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
584 ;; the conflict overlays. |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
585 (while (and (not found) (setq conflict (smerge-conflict-overlay pos))) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
586 ;; Check the overlay's validity and kill it if it's out of date. |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
587 (condition-case nil |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
588 (progn |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
589 (goto-char (overlay-start conflict)) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
590 (smerge-match-conflict) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
591 (goto-char (match-end 0)) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
592 (if (<= (point) pos) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
593 (error "Matching backward!") |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
594 (setq found t))) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
595 (error (smerge-remove-props |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
596 (overlay-start conflict) (overlay-end conflict)) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
597 (goto-char pos)))) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
598 ;; If we're not already inside a conflict, look for the next conflict |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
599 ;; and add/update its overlay. |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
600 (while (and (not found) (re-search-forward smerge-begin-re limit t)) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
601 (condition-case nil |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
602 (progn |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
603 (smerge-match-conflict) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
604 (goto-char (match-end 0)) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
605 (let ((conflict (smerge-conflict-overlay (1- (point))))) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
606 (if conflict |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
607 ;; Update its location, just in case it got messed up. |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
608 (move-overlay conflict (match-beginning 0) (match-end 0)) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
609 (setq conflict (make-overlay (match-beginning 0) (match-end 0) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
610 nil 'front-advance nil)) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
611 (overlay-put conflict 'evaporate t) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
612 (overlay-put conflict 'smerge 'conflict) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
613 (let ((props smerge-text-properties)) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
614 (while props |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
615 (overlay-put conflict (pop props) (pop props)))))) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
616 (setq found t)) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
617 (error nil))) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
618 found)) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
619 |
65129
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
620 (defun smerge-refine-chopup-region (beg end file) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
621 "Chopup the region into small elements, one per line." |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
622 ;; ediff chops up into words, where the definition of a word is |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
623 ;; customizable. Instead we here keep only one char per line. |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
624 ;; The advantages are that there's nothing to configure, that we get very |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
625 ;; fine results, and that it's trivial to map the line numbers in the |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
626 ;; output of diff back into buffer positions. The disadvantage is that it |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
627 ;; can take more time to compute the diff and that the result is sometimes |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
628 ;; too fine. I'm not too concerned about the slowdown because conflicts |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
629 ;; are usually significantly smaller than the whole file. As for the |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
630 ;; problem of too-fine-refinement, I have found it to be unimportant |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
631 ;; especially when you consider the cases where the fine-grain is just |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
632 ;; what you want. |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
633 (let ((buf (current-buffer))) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
634 (with-temp-buffer |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
635 (insert-buffer-substring buf beg end) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
636 (goto-char (point-min)) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
637 (while (not (eobp)) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
638 (forward-char 1) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
639 (unless (eq (char-before) ?\n) (insert ?\n))) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
640 (let ((coding-system-for-write 'emacs-mule)) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
641 (write-region (point-min) (point-max) file nil 'nomessage))))) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
642 |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
643 (defun smerge-refine-highlight-change (buf beg match-num1 match-num2) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
644 (let* ((startline (string-to-number (match-string match-num1))) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
645 (ol (make-overlay |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
646 (+ beg startline -1) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
647 (+ beg (if (match-end match-num2) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
648 (string-to-number (match-string match-num2)) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
649 startline)) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
650 buf |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
651 'front-advance nil))) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
652 (overlay-put ol 'smerge 'refine) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
653 (overlay-put ol 'evaporate t) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
654 (overlay-put ol 'face 'smerge-refined-change))) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
655 |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
656 |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
657 (defun smerge-refine () |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
658 "Highlight the parts of the conflict that are different." |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
659 (interactive) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
660 ;; FIXME: make it work with 3-way conflicts. |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
661 (smerge-match-conflict) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
662 (remove-overlays (match-beginning 0) (match-end 0) 'smerge 'refine) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
663 (smerge-ensure-match 1) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
664 (smerge-ensure-match 3) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
665 (let ((buf (current-buffer)) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
666 ;; Read them before the match-data gets clobbered. |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
667 (beg1 (match-beginning 1)) (end1 (match-end 1)) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
668 (beg2 (match-beginning 3)) (end2 (match-end 3)) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
669 (file1 (make-temp-file "smerge1")) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
670 (file2 (make-temp-file "smerge2"))) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
671 |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
672 ;; Chop up regions into smaller elements and save into files. |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
673 (smerge-refine-chopup-region beg1 end1 file1) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
674 (smerge-refine-chopup-region beg2 end2 file2) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
675 |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
676 ;; Call diff on those files. |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
677 (unwind-protect |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
678 (with-temp-buffer |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
679 (let ((coding-system-for-read 'emacs-mule)) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
680 (call-process diff-command nil t nil file1 file2)) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
681 ;; Process diff's output. |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
682 (goto-char (point-min)) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
683 (while (not (eobp)) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
684 (if (not (looking-at "\\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)?\\([acd]\\)\\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)?$")) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
685 (error "Unexpected patch hunk header: %s" |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
686 (buffer-substring (point) (line-end-position))) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
687 (let ((op (char-after (match-beginning 3)))) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
688 (when (memq op '(?d ?c)) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
689 (smerge-refine-highlight-change buf beg1 1 2)) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
690 (when (memq op '(?a ?c)) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
691 (smerge-refine-highlight-change buf beg2 4 5))) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
692 (forward-line 1) ;Skip hunk header. |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
693 (and (re-search-forward "^[0-9]" nil 'move) ;Skip hunk body. |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
694 (goto-char (match-beginning 0)))))) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
695 (delete-file file1) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
696 (delete-file file2)))) |
8303172e4c68
(smerge-remove-props): Make the args non-optional.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65067
diff
changeset
|
697 |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
698 (defun smerge-diff (n1 n2) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
699 (smerge-match-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
700 (smerge-ensure-match n1) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
701 (smerge-ensure-match n2) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
702 (let ((name1 (aref smerge-match-names n1)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
703 (name2 (aref smerge-match-names n2)) |
41064
cdd9ef6f603d
(smerge-match-conflict): Fix typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38611
diff
changeset
|
704 ;; Read them before the match-data gets clobbered. |
cdd9ef6f603d
(smerge-match-conflict): Fix typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38611
diff
changeset
|
705 (beg1 (match-beginning n1)) |
cdd9ef6f603d
(smerge-match-conflict): Fix typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38611
diff
changeset
|
706 (end1 (match-end n1)) |
cdd9ef6f603d
(smerge-match-conflict): Fix typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38611
diff
changeset
|
707 (beg2 (match-beginning n2)) |
cdd9ef6f603d
(smerge-match-conflict): Fix typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38611
diff
changeset
|
708 (end2 (match-end n2)) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
709 (file1 (make-temp-file "smerge1")) |
32217
44f7f2635fec
(smerge-diff): Setup the buffer's default-directory
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32164
diff
changeset
|
710 (file2 (make-temp-file "smerge2")) |
44f7f2635fec
(smerge-diff): Setup the buffer's default-directory
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32164
diff
changeset
|
711 (dir default-directory) |
65067
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
712 (file (if buffer-file-name (file-relative-name buffer-file-name))) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
713 ;; We would want to use `emacs-mule-unix' for read&write, but we |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
714 ;; bump into problems with the coding-system used by diff to write |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
715 ;; the file names and the time stamps in the header. |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
716 ;; `buffer-file-coding-system' is not always correct either, but if |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
717 ;; the OS/user uses only one coding-system, then it works. |
41064
cdd9ef6f603d
(smerge-match-conflict): Fix typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38611
diff
changeset
|
718 (coding-system-for-read buffer-file-coding-system)) |
47209
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
719 (write-region beg1 end1 file1 nil 'nomessage) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
720 (write-region beg2 end2 file2 nil 'nomessage) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
721 (unwind-protect |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
722 (with-current-buffer (get-buffer-create smerge-diff-buffer-name) |
32217
44f7f2635fec
(smerge-diff): Setup the buffer's default-directory
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32164
diff
changeset
|
723 (setq default-directory dir) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
724 (let ((inhibit-read-only t)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
725 (erase-buffer) |
47209
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
726 (let ((status |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
727 (apply 'call-process diff-command nil t nil |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
728 (append smerge-diff-switches |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
729 (list "-L" (concat name1 "/" file) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
730 "-L" (concat name2 "/" file) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
731 file1 file2))))) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
732 (if (eq status 0) (insert "No differences found.\n")))) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
733 (goto-char (point-min)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
734 (diff-mode) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
735 (display-buffer (current-buffer) t)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
736 (delete-file file1) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
737 (delete-file file2)))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
738 |
47209
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
739 ;; compiler pacifiers |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
740 (defvar smerge-ediff-windows) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
741 (defvar smerge-ediff-buf) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
742 (defvar ediff-buffer-A) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
743 (defvar ediff-buffer-B) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
744 (defvar ediff-buffer-C) |
65067
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
745 (defvar ediff-ancestor-buffer) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
746 (defvar ediff-quit-hook) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
747 |
47821
45dcf3407814
(smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47756
diff
changeset
|
748 ;;;###autoload |
47756
b2c9ea334a34
(smerge-ediff): Add name-{mine,other,base} args.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47209
diff
changeset
|
749 (defun smerge-ediff (&optional name-mine name-other name-base) |
b2c9ea334a34
(smerge-ediff): Add name-{mine,other,base} args.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47209
diff
changeset
|
750 "Invoke ediff to resolve the conflicts. |
b2c9ea334a34
(smerge-ediff): Add name-{mine,other,base} args.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47209
diff
changeset
|
751 NAME-MINE, NAME-OTHER, and NAME-BASE, if non-nil, are used for the |
b2c9ea334a34
(smerge-ediff): Add name-{mine,other,base} args.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47209
diff
changeset
|
752 buffer names." |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
753 (interactive) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
754 (let* ((buf (current-buffer)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
755 (mode major-mode) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
756 ;;(ediff-default-variant 'default-B) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
757 (config (current-window-configuration)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
758 (filename (file-name-nondirectory buffer-file-name)) |
47756
b2c9ea334a34
(smerge-ediff): Add name-{mine,other,base} args.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47209
diff
changeset
|
759 (mine (generate-new-buffer |
b2c9ea334a34
(smerge-ediff): Add name-{mine,other,base} args.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47209
diff
changeset
|
760 (or name-mine (concat "*" filename " MINE*")))) |
b2c9ea334a34
(smerge-ediff): Add name-{mine,other,base} args.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47209
diff
changeset
|
761 (other (generate-new-buffer |
b2c9ea334a34
(smerge-ediff): Add name-{mine,other,base} args.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47209
diff
changeset
|
762 (or name-other (concat "*" filename " OTHER*")))) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
763 base) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
764 (with-current-buffer mine |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
765 (buffer-disable-undo) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
766 (insert-buffer-substring buf) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
767 (goto-char (point-min)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
768 (while (smerge-find-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
769 (when (match-beginning 2) (setq base t)) |
54527
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
770 (smerge-keep-n 1)) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
771 (buffer-enable-undo) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
772 (set-buffer-modified-p nil) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
773 (funcall mode)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
774 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
775 (with-current-buffer other |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
776 (buffer-disable-undo) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
777 (insert-buffer-substring buf) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
778 (goto-char (point-min)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
779 (while (smerge-find-conflict) |
54527
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
780 (smerge-keep-n 3)) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
781 (buffer-enable-undo) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
782 (set-buffer-modified-p nil) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
783 (funcall mode)) |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47827
diff
changeset
|
784 |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
785 (when base |
47756
b2c9ea334a34
(smerge-ediff): Add name-{mine,other,base} args.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47209
diff
changeset
|
786 (setq base (generate-new-buffer |
b2c9ea334a34
(smerge-ediff): Add name-{mine,other,base} args.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47209
diff
changeset
|
787 (or name-base (concat "*" filename " BASE*")))) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
788 (with-current-buffer base |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
789 (buffer-disable-undo) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
790 (insert-buffer-substring buf) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
791 (goto-char (point-min)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
792 (while (smerge-find-conflict) |
54527
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
793 (if (match-end 2) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
794 (smerge-keep-n 2) |
192fc783e115
(smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54410
diff
changeset
|
795 (delete-region (match-beginning 0) (match-end 0)))) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
796 (buffer-enable-undo) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
797 (set-buffer-modified-p nil) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
798 (funcall mode))) |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47827
diff
changeset
|
799 |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
800 ;; the rest of the code is inspired from vc.el |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
801 ;; Fire up ediff. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
802 (set-buffer |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
803 (if base |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
804 (ediff-merge-buffers-with-ancestor mine other base) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
805 ;; nil 'ediff-merge-revisions-with-ancestor buffer-file-name) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
806 (ediff-merge-buffers mine other))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
807 ;; nil 'ediff-merge-revisions buffer-file-name))) |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47827
diff
changeset
|
808 |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
809 ;; Ediff is now set up, and we are in the control buffer. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
810 ;; Do a few further adjustments and take precautions for exit. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
811 (set (make-local-variable 'smerge-ediff-windows) config) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
812 (set (make-local-variable 'smerge-ediff-buf) buf) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
813 (set (make-local-variable 'ediff-quit-hook) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
814 (lambda () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
815 (let ((buffer-A ediff-buffer-A) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
816 (buffer-B ediff-buffer-B) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
817 (buffer-C ediff-buffer-C) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
818 (buffer-Ancestor ediff-ancestor-buffer) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
819 (buf smerge-ediff-buf) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
820 (windows smerge-ediff-windows)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
821 (ediff-cleanup-mess) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
822 (with-current-buffer buf |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
823 (erase-buffer) |
64637
a975a8beec7f
(smerge-ediff): Use insert-buffer-substring.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64091
diff
changeset
|
824 (insert-buffer-substring buffer-C) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
825 (kill-buffer buffer-A) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
826 (kill-buffer buffer-B) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
827 (kill-buffer buffer-C) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
828 (when (bufferp buffer-Ancestor) (kill-buffer buffer-Ancestor)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
829 (set-window-configuration windows) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
830 (message "Conflict resolution finished; you may save the buffer"))))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
831 (message "Please resolve conflicts now; exit ediff when done"))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
832 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
833 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
834 ;;;###autoload |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
835 (define-minor-mode smerge-mode |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
836 "Minor mode to simplify editing output from the diff3 program. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
837 \\{smerge-mode-map}" |
61277
7fa982932904
(smerge-mode): Specify :group.
Lute Kamstra <lute@gnu.org>
parents:
55258
diff
changeset
|
838 :group 'smerge :lighter " SMerge" |
38611
7f82c0bbe525
(smerge-mode): Check if `font-lock-mode' is bound
Gerd Moellmann <gerd@gnu.org>
parents:
37674
diff
changeset
|
839 (when (and (boundp 'font-lock-mode) font-lock-mode) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
840 (save-excursion |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
841 (if smerge-mode |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
842 (font-lock-add-keywords nil smerge-font-lock-keywords 'append) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
843 (font-lock-remove-keywords nil smerge-font-lock-keywords)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
844 (goto-char (point-min)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
845 (while (smerge-find-conflict) |
34842
f05ec8dfc452
(smerge-basic-map): Use `=' rather than `d'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
34840
diff
changeset
|
846 (save-excursion |
65067
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
847 (font-lock-fontify-region (match-beginning 0) (match-end 0) nil))))) |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
848 (unless smerge-mode |
52de8046c483
(smerge-basic-map): Bind smerge-combine-with-next.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
849 (smerge-remove-props (point-min) (point-max)))) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
850 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
851 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
852 (provide 'smerge-mode) |
52401 | 853 |
54903
922f49230ff5
(smerge-match-conflict): Try to do something sensible
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54872
diff
changeset
|
854 ;; arch-tag: 605c8d1e-e43d-4943-a6f3-1bcc4333e690 |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
855 ;;; smerge-mode.el ends here |