Mercurial > emacs
annotate lisp/smerge-mode.el @ 54376:43c8c6b5656b
(cvs-mode-add-change-log-entry-other-window): Fix minor bug.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 12 Mar 2004 10:12:14 +0000 |
parents | 118715eba3b3 |
children | 8bf3846fc7dd |
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 |
54332
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
3 ;; Copyright (C) 1999, 2000, 01, 03, 2004 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
|
4 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
5 ;; Author: Stefan Monnier <monnier@cs.yale.edu> |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
6 ;; Keywords: merge diff3 cvs conflict |
54332
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
7 ;; Revision: $Id: smerge-mode.el,v 1.24 2003/10/06 16:34:59 fx Exp $ |
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 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
13 ;; the Free Software Foundation; either version 2, or (at your option) |
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 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
24 ;; Boston, MA 02111-1307, USA. |
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 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
52 (defgroup smerge () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
53 "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
|
54 :group 'tools |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
55 :prefix "smerge-") |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
56 |
47209
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
57 (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
|
58 "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
|
59 :group 'smerge |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
60 :type '(choice |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
61 (const "*vc-diff*") |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
62 (const "*cvs-diff*") |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
63 (const "*smerge-diff*") |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
64 string)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
65 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
66 (defcustom smerge-diff-switches |
29207
6c4e371d4efd
(smerge-diff-switches): Don't use list* in defcustom.
Dave Love <fx@gnu.org>
parents:
28248
diff
changeset
|
67 (append '("-d" "-b") |
6c4e371d4efd
(smerge-diff-switches): Don't use list* in defcustom.
Dave Love <fx@gnu.org>
parents:
28248
diff
changeset
|
68 (if (listp diff-switches) diff-switches (list diff-switches))) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
69 "*A list of strings specifying switches to be be passed to diff. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
70 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
|
71 :group 'smerge |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
72 :type '(repeat string)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
73 |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
74 (defcustom smerge-auto-leave t |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
75 "*Non-nil means to leave `smerge-mode' when the last conflict is resolved." |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
76 :group 'smerge |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
77 :type 'boolean) |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
78 |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
79 (defface smerge-mine-face |
32164
a3d5adc99010
(smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents:
30868
diff
changeset
|
80 '((((background light)) |
a3d5adc99010
(smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents:
30868
diff
changeset
|
81 (:foreground "blue")) |
a3d5adc99010
(smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents:
30868
diff
changeset
|
82 (((background dark)) |
a3d5adc99010
(smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents:
30868
diff
changeset
|
83 (:foreground "cyan"))) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
84 "Face for your code." |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
85 :group 'smerge) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
86 (defvar smerge-mine-face 'smerge-mine-face) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
87 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
88 (defface smerge-other-face |
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 light)) |
a3d5adc99010
(smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents:
30868
diff
changeset
|
90 (:foreground "darkgreen")) |
a3d5adc99010
(smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents:
30868
diff
changeset
|
91 (((background dark)) |
a3d5adc99010
(smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents:
30868
diff
changeset
|
92 (:foreground "lightgreen"))) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
93 "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
|
94 :group 'smerge) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
95 (defvar smerge-other-face 'smerge-other-face) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
96 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
97 (defface smerge-base-face |
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 "red")) |
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 "orange"))) |
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 base code." |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
103 :group 'smerge) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
104 (defvar smerge-base-face 'smerge-base-face) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
105 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
106 (defface smerge-markers-face |
32164
a3d5adc99010
(smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents:
30868
diff
changeset
|
107 '((((background light)) |
a3d5adc99010
(smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents:
30868
diff
changeset
|
108 (:background "grey85")) |
a3d5adc99010
(smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents:
30868
diff
changeset
|
109 (((background dark)) |
a3d5adc99010
(smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents:
30868
diff
changeset
|
110 (:background "grey30"))) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
111 "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
|
112 :group 'smerge) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
113 (defvar smerge-markers-face 'smerge-markers-face) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
114 |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
115 (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
|
116 `(("n" . smerge-next) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
117 ("p" . smerge-prev) |
47827
9d7b63dcf005
(smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47821
diff
changeset
|
118 ("r" . smerge-resolve) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
119 ("a" . smerge-keep-all) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
120 ("b" . smerge-keep-base) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
121 ("o" . smerge-keep-other) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
122 ("m" . smerge-keep-mine) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
123 ("E" . smerge-ediff) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
124 ("\C-m" . smerge-keep-current) |
34840
509ed3724af0
(smerge-basic-map): Use `=' rather than `d'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32217
diff
changeset
|
125 ("=" . ,(make-sparse-keymap "Diff")) |
509ed3724af0
(smerge-basic-map): Use `=' rather than `d'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32217
diff
changeset
|
126 ("=<" "base-mine" . smerge-diff-base-mine) |
509ed3724af0
(smerge-basic-map): Use `=' rather than `d'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32217
diff
changeset
|
127 ("=>" "base-other" . smerge-diff-base-other) |
509ed3724af0
(smerge-basic-map): Use `=' rather than `d'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32217
diff
changeset
|
128 ("==" "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
|
129 "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
|
130 |
34840
509ed3724af0
(smerge-basic-map): Use `=' rather than `d'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32217
diff
changeset
|
131 (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
|
132 "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
|
133 :group 'smerge |
34840
509ed3724af0
(smerge-basic-map): Use `=' rather than `d'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32217
diff
changeset
|
134 :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
|
135 |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
136 (easy-mmode-defmap smerge-mode-map |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
137 `((,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
|
138 "Keymap for `smerge-mode'.") |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
139 |
54332
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
140 (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
|
141 (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
|
142 (defun smerge-check (n) |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
143 (condition-case nil |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
144 (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
|
145 (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
|
146 (smerge-match-conflict) |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
147 (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
|
148 (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
|
149 (error nil))) |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
150 |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
151 (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
|
152 "Menu for `smerge-mode'." |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
153 '("SMerge" |
30358 | 154 ["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
|
155 ["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
|
156 "--" |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
157 ["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
|
158 :active (smerge-check 1)] |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
159 ["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
|
160 :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
|
161 "--" |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
162 ["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
|
163 :active (smerge-check 2)] |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
164 ["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
|
165 :active (smerge-check 3)] |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
166 ["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
|
167 :active (smerge-check 1)] |
30358 | 168 "--" |
169 ["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
|
170 :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
|
171 :active (smerge-check 2)] |
30358 | 172 ["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
|
173 :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
|
174 :active (smerge-check 2)] |
30358 | 175 ["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
|
176 :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
|
177 :active (smerge-check 1)] |
30358 | 178 "--" |
179 ["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
|
180 :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
|
181 :active (smerge-check 1)] |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
182 ["Auto Resolve" smerge-resolve |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
183 :help "Use mode-provided resolution function" |
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) (local-variable-p 'smerge-resolve-function))] |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
185 ["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
|
186 :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
|
187 :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
|
188 )) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
189 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
190 (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
|
191 '((smerge-find-conflict |
35564
b546ef3b2284
(smerge-font-lock-keywords): Relax submatch 1.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
34855
diff
changeset
|
192 (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
|
193 (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
|
194 (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
|
195 ;; 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
|
196 (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
|
197 (4 nil t t) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
198 (5 nil t t))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
199 "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
|
200 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
201 (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
|
202 (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
|
203 (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
|
204 (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
|
205 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
206 (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
|
207 "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
|
208 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
|
209 - `diff3-E' |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
210 - `diff3-A'") |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
211 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
212 ;; Compiler pacifiers |
52779
3bc7b9f71e34
Previous change was bogus. Something odd in pcl-cvs...
Dave Love <fx@gnu.org>
parents:
52778
diff
changeset
|
213 (defvar font-lock-mode) |
3bc7b9f71e34
Previous change was bogus. Something odd in pcl-cvs...
Dave Love <fx@gnu.org>
parents:
52778
diff
changeset
|
214 (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
|
215 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
216 ;;;; |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
217 ;;;; Actual code |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
218 ;;;; |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
219 |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
220 ;; Define smerge-next and smerge-prev |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
221 (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
|
222 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
223 (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
|
224 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
225 (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
|
226 (unless (match-end n) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
227 (error (format "No `%s'" (aref smerge-match-names n))))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
228 |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
229 (defun smerge-auto-leave () |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
230 (when (and smerge-auto-leave |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
231 (save-excursion (goto-char (point-min)) |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
232 (not (re-search-forward smerge-begin-re nil t)))) |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
233 (smerge-mode -1))) |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47827
diff
changeset
|
234 |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
235 |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
236 (defun smerge-keep-all () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
237 "Keep all three versions. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
238 Convenient for the kind of conflicts that can arise in ChangeLog files." |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
239 (interactive) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
240 (smerge-match-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
241 (replace-match (concat (or (match-string 1) "") |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
242 (or (match-string 2) "") |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
243 (or (match-string 3) "")) |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
244 t t) |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
245 (smerge-auto-leave)) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
246 |
47209
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
247 (defun smerge-combine-with-next () |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
248 "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
|
249 (interactive) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
250 (smerge-match-conflict) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
251 (let ((ends nil)) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
252 (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
|
253 (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
|
254 (setq ends (apply 'vector ends)) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
255 (goto-char (aref ends 0)) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
256 (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
|
257 (error "No next conflict") |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
258 (smerge-match-conflict) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
259 (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
|
260 (match-data)))) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
261 ;; 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
|
262 (dolist (i '(1 2 3)) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
263 (when (aref ends i) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
264 (goto-char (aref ends i)) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
265 (insert-buffer-substring (current-buffer) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
266 (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
|
267 (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
|
268 ;; 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
|
269 (dolist (i '(1 2 3)) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
270 (set-match-data match-data) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
271 (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
|
272 (goto-char (aref ends i)) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
273 (insert-buffer-substring (current-buffer) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
274 (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
|
275 (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
|
276 ;; Free the markers. |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
277 (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
|
278 (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
|
279 |
47827
9d7b63dcf005
(smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47821
diff
changeset
|
280 (defvar smerge-resolve-function |
9d7b63dcf005
(smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47821
diff
changeset
|
281 (lambda () (error "Don't know how to resolve")) |
9d7b63dcf005
(smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47821
diff
changeset
|
282 "Mode-specific merge function. |
9d7b63dcf005
(smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47821
diff
changeset
|
283 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
|
284 according to `smerge-match-conflict'.") |
9d7b63dcf005
(smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47821
diff
changeset
|
285 |
9d7b63dcf005
(smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47821
diff
changeset
|
286 (defun smerge-resolve () |
9d7b63dcf005
(smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47821
diff
changeset
|
287 "Resolve the conflict at point intelligently. |
9d7b63dcf005
(smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47821
diff
changeset
|
288 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
|
289 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
|
290 (interactive) |
9d7b63dcf005
(smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47821
diff
changeset
|
291 (smerge-match-conflict) |
9d7b63dcf005
(smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47821
diff
changeset
|
292 (funcall smerge-resolve-function) |
9d7b63dcf005
(smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47821
diff
changeset
|
293 (smerge-auto-leave)) |
9d7b63dcf005
(smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47821
diff
changeset
|
294 |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
295 (defun smerge-keep-base () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
296 "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
|
297 (interactive) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
298 (smerge-match-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
299 (smerge-ensure-match 2) |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
300 (replace-match (match-string 2) t t) |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
301 (smerge-auto-leave)) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
302 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
303 (defun smerge-keep-other () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
304 "Use \"other\" version." |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
305 (interactive) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
306 (smerge-match-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
307 ;;(smerge-ensure-match 3) |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
308 (replace-match (match-string 3) t t) |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
309 (smerge-auto-leave)) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
310 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
311 (defun smerge-keep-mine () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
312 "Keep your version." |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
313 (interactive) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
314 (smerge-match-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
315 ;;(smerge-ensure-match 1) |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
316 (replace-match (match-string 1) t t) |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
317 (smerge-auto-leave)) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
318 |
54332
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
319 (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
|
320 (let ((i 3)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
321 (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
|
322 (< (point) (match-beginning i)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
323 (>= (point) (match-end i))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
324 (decf i)) |
54332
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
325 i)) |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
326 |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
327 (defun smerge-keep-current () |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
328 "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
|
329 (interactive) |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
330 (smerge-match-conflict) |
118715eba3b3
(smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52779
diff
changeset
|
331 (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
|
332 (if (<= i 0) (error "Not inside a version") |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
333 (replace-match (match-string i) t t) |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
334 (smerge-auto-leave)))) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
335 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
336 (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
|
337 "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
|
338 (interactive) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
339 (smerge-diff 2 1)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
340 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
341 (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
|
342 "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
|
343 (interactive) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
344 (smerge-diff 2 3)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
345 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
346 (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
|
347 "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
|
348 (interactive) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
349 (smerge-diff 1 3)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
350 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
351 (defun smerge-match-conflict () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
352 "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
|
353 The submatches contain: |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
354 0: the whole conflict. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
355 1: your code. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
356 2: the base code. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
357 3: other code. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
358 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
|
359 (save-excursion |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
360 (condition-case nil |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
361 (let* ((orig-point (point)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
362 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
363 (_ (forward-line 1)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
364 (_ (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
|
365 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
366 (start (match-beginning 0)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
367 (mine-start (match-end 0)) |
47827
9d7b63dcf005
(smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47821
diff
changeset
|
368 (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
|
369 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
370 (_ (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
|
371 (_ (assert (< orig-point (match-end 0)))) |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47827
diff
changeset
|
372 |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
373 (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
|
374 (end (match-end 0)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
375 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
376 (_ (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
|
377 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
378 (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
|
379 (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
|
380 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
381 base-start base-end) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
382 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
383 ;; 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
|
384 (cond |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
385 ((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
|
386 ;; a 3-parts conflict |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
387 (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
|
388 (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
|
389 (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
|
390 (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
|
391 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
392 ((string= filename (file-name-nondirectory |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
393 (or buffer-file-name ""))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
394 ;; a 2-parts conflict |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
395 (set (make-local-variable 'smerge-conflict-style) 'diff3-E)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
396 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
397 ((and (not base-start) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
398 (or (eq 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
|
399 (string-match "^[.0-9]+\\'" filename))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
400 ;; a same-diff conflict |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
401 (setq base-start mine-start) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
402 (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
|
403 (setq mine-start other-start) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
404 (setq mine-end other-end))) |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47827
diff
changeset
|
405 |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
406 (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
|
407 mine-start mine-end |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
408 base-start base-end |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
409 other-start other-end |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
410 (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
|
411 (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
|
412 t) |
41064
cdd9ef6f603d
(smerge-match-conflict): Fix typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38611
diff
changeset
|
413 (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
|
414 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
415 (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
|
416 "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
|
417 The submatches are the same as in `smerge-match-conflict'. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
418 Returns non-nil if a match is found between the point and LIMIT. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
419 The point is moved to the end of the conflict." |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
420 (when (re-search-forward smerge-begin-re limit t) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
421 (ignore-errors |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
422 (smerge-match-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
423 (goto-char (match-end 0))))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
424 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
425 (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
|
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 n1) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
428 (smerge-ensure-match n2) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
429 (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
|
430 (name2 (aref smerge-match-names n2)) |
41064
cdd9ef6f603d
(smerge-match-conflict): Fix typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38611
diff
changeset
|
431 ;; Read them before the match-data gets clobbered. |
cdd9ef6f603d
(smerge-match-conflict): Fix typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38611
diff
changeset
|
432 (beg1 (match-beginning n1)) |
cdd9ef6f603d
(smerge-match-conflict): Fix typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38611
diff
changeset
|
433 (end1 (match-end n1)) |
cdd9ef6f603d
(smerge-match-conflict): Fix typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38611
diff
changeset
|
434 (beg2 (match-beginning n2)) |
cdd9ef6f603d
(smerge-match-conflict): Fix typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38611
diff
changeset
|
435 (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
|
436 (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
|
437 (file2 (make-temp-file "smerge2")) |
44f7f2635fec
(smerge-diff): Setup the buffer's default-directory
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32164
diff
changeset
|
438 (dir default-directory) |
41064
cdd9ef6f603d
(smerge-match-conflict): Fix typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38611
diff
changeset
|
439 (file (file-relative-name buffer-file-name)) |
cdd9ef6f603d
(smerge-match-conflict): Fix typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38611
diff
changeset
|
440 (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
|
441 (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
|
442 (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
|
443 (unwind-protect |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
444 (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
|
445 (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
|
446 (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
|
447 (erase-buffer) |
47209
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
448 (let ((status |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
449 (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
|
450 (append smerge-diff-switches |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
451 (list "-L" (concat name1 "/" file) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
452 "-L" (concat name2 "/" file) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
453 file1 file2))))) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
454 (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
|
455 (goto-char (point-min)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
456 (diff-mode) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
457 (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
|
458 (delete-file file1) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
459 (delete-file file2)))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
460 |
47209
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
461 ;; compiler pacifiers |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
462 (defvar smerge-ediff-windows) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
463 (defvar smerge-ediff-buf) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
464 (defvar ediff-buffer-A) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
465 (defvar ediff-buffer-B) |
f06f993cfd92
(smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
46899
diff
changeset
|
466 (defvar ediff-buffer-C) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
467 |
47821
45dcf3407814
(smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47756
diff
changeset
|
468 ;;;###autoload |
47756
b2c9ea334a34
(smerge-ediff): Add name-{mine,other,base} args.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47209
diff
changeset
|
469 (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
|
470 "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
|
471 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
|
472 buffer names." |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
473 (interactive) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
474 (let* ((buf (current-buffer)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
475 (mode major-mode) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
476 ;;(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
|
477 (config (current-window-configuration)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
478 (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
|
479 (mine (generate-new-buffer |
b2c9ea334a34
(smerge-ediff): Add name-{mine,other,base} args.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47209
diff
changeset
|
480 (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
|
481 (other (generate-new-buffer |
b2c9ea334a34
(smerge-ediff): Add name-{mine,other,base} args.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47209
diff
changeset
|
482 (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
|
483 base) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
484 (with-current-buffer mine |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
485 (buffer-disable-undo) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
486 (insert-buffer-substring buf) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
487 (goto-char (point-min)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
488 (while (smerge-find-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
489 (when (match-beginning 2) (setq base t)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
490 (replace-match (match-string 1) t t)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
491 (buffer-enable-undo) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
492 (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
|
493 (funcall mode)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
494 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
495 (with-current-buffer other |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
496 (buffer-disable-undo) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
497 (insert-buffer-substring buf) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
498 (goto-char (point-min)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
499 (while (smerge-find-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
500 (replace-match (match-string 3) t t)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
501 (buffer-enable-undo) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
502 (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
|
503 (funcall mode)) |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47827
diff
changeset
|
504 |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
505 (when base |
47756
b2c9ea334a34
(smerge-ediff): Add name-{mine,other,base} args.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47209
diff
changeset
|
506 (setq base (generate-new-buffer |
b2c9ea334a34
(smerge-ediff): Add name-{mine,other,base} args.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47209
diff
changeset
|
507 (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
|
508 (with-current-buffer base |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
509 (buffer-disable-undo) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
510 (insert-buffer-substring buf) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
511 (goto-char (point-min)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
512 (while (smerge-find-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
513 (replace-match (or (match-string 2) "") t t)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
514 (buffer-enable-undo) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
515 (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
|
516 (funcall mode))) |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47827
diff
changeset
|
517 |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
518 ;; 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
|
519 ;; Fire up ediff. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
520 (set-buffer |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
521 (if base |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
522 (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
|
523 ;; 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
|
524 (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
|
525 ;; nil 'ediff-merge-revisions buffer-file-name))) |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47827
diff
changeset
|
526 |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
527 ;; 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
|
528 ;; 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
|
529 (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
|
530 (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
|
531 (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
|
532 (lambda () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
533 (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
|
534 (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
|
535 (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
|
536 (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
|
537 (buf smerge-ediff-buf) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
538 (windows smerge-ediff-windows)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
539 (ediff-cleanup-mess) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
540 (with-current-buffer buf |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
541 (erase-buffer) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
542 (insert-buffer buffer-C) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
543 (kill-buffer buffer-A) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
544 (kill-buffer buffer-B) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
545 (kill-buffer buffer-C) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
546 (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
|
547 (set-window-configuration windows) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
548 (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
|
549 (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
|
550 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
551 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
552 ;;;###autoload |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
553 (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
|
554 "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
|
555 \\{smerge-mode-map}" |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
556 nil " SMerge" nil |
38611
7f82c0bbe525
(smerge-mode): Check if `font-lock-mode' is bound
Gerd Moellmann <gerd@gnu.org>
parents:
37674
diff
changeset
|
557 (when (and (boundp 'font-lock-mode) font-lock-mode) |
37674
11f935c05521
(smerge-mode): Force font-lock-multiline to t.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
36611
diff
changeset
|
558 (set (make-local-variable 'font-lock-multiline) t) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
559 (save-excursion |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
560 (if smerge-mode |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
561 (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
|
562 (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
|
563 (goto-char (point-min)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
564 (while (smerge-find-conflict) |
34842
f05ec8dfc452
(smerge-basic-map): Use `=' rather than `d'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
34840
diff
changeset
|
565 (save-excursion |
f05ec8dfc452
(smerge-basic-map): Use `=' rather than `d'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
34840
diff
changeset
|
566 (font-lock-fontify-region (match-beginning 0) (match-end 0) nil)))))) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
567 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
568 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
569 (provide 'smerge-mode) |
52401 | 570 |
571 ;;; 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
|
572 ;;; smerge-mode.el ends here |