annotate lisp/smerge-mode.el @ 48102:3883fe056b71

*** empty log message ***
author Kim F. Storm <storm@cua.dk>
date Thu, 31 Oct 2002 22:07:34 +0000
parents 9d7b63dcf005
children e88404e8f2cf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
38611
7f82c0bbe525 (smerge-mode): Check if `font-lock-mode' is bound
Gerd Moellmann <gerd@gnu.org>
parents: 37674
diff changeset
3 ;; Copyright (C) 1999, 2000, 2001 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
47827
9d7b63dcf005 (smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47821
diff changeset
7 ;; Revision: $Id: smerge-mode.el,v 1.19 2002/10/10 13:01:14 monnier 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
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
140 (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
141 "Menu for `smerge-mode'."
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
142 '("SMerge"
30358
636fe93e755c (smerge-mode-menu): Fill it out.
Dave Love <fx@gnu.org>
parents: 29207
diff changeset
143 ["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
144 ["Previous" smerge-prev :help "Go to previous conflict"]
30358
636fe93e755c (smerge-mode-menu): Fill it out.
Dave Love <fx@gnu.org>
parents: 29207
diff changeset
145 ["Keep All" smerge-keep-all :help "Keep all three versions"]
636fe93e755c (smerge-mode-menu): Fill it out.
Dave Love <fx@gnu.org>
parents: 29207
diff changeset
146 ["Revert to Base" smerge-keep-base :help "Revert to base version"]
636fe93e755c (smerge-mode-menu): Fill it out.
Dave Love <fx@gnu.org>
parents: 29207
diff changeset
147 ["Keep Other" smerge-keep-other :help "Keep `other' version"]
636fe93e755c (smerge-mode-menu): Fill it out.
Dave Love <fx@gnu.org>
parents: 29207
diff changeset
148 ["Keep Yours" smerge-keep-mine :help "Keep your version"]
30868
f7b06560383b (smerge-mode-menu): Doc fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30358
diff changeset
149 ["Keep Current" smerge-keep-current :help "Use current (at point) version"]
30358
636fe93e755c (smerge-mode-menu): Fill it out.
Dave Love <fx@gnu.org>
parents: 29207
diff changeset
150 "--"
636fe93e755c (smerge-mode-menu): Fill it out.
Dave Love <fx@gnu.org>
parents: 29207
diff changeset
151 ["Diff Base/Mine" smerge-diff-base-mine
636fe93e755c (smerge-mode-menu): Fill it out.
Dave Love <fx@gnu.org>
parents: 29207
diff changeset
152 :help "Diff `base' and `mine' for current conflict"]
636fe93e755c (smerge-mode-menu): Fill it out.
Dave Love <fx@gnu.org>
parents: 29207
diff changeset
153 ["Diff Base/Other" smerge-diff-base-other
636fe93e755c (smerge-mode-menu): Fill it out.
Dave Love <fx@gnu.org>
parents: 29207
diff changeset
154 :help "Diff `base' and `other' for current conflict"]
636fe93e755c (smerge-mode-menu): Fill it out.
Dave Love <fx@gnu.org>
parents: 29207
diff changeset
155 ["Diff Mine/Other" smerge-diff-mine-other
636fe93e755c (smerge-mode-menu): Fill it out.
Dave Love <fx@gnu.org>
parents: 29207
diff changeset
156 :help "Diff `mine' and `other' for current conflict"]
636fe93e755c (smerge-mode-menu): Fill it out.
Dave Love <fx@gnu.org>
parents: 29207
diff changeset
157 "--"
636fe93e755c (smerge-mode-menu): Fill it out.
Dave Love <fx@gnu.org>
parents: 29207
diff changeset
158 ["Invoke Ediff" smerge-ediff
636fe93e755c (smerge-mode-menu): Fill it out.
Dave Love <fx@gnu.org>
parents: 29207
diff changeset
159 :help "Use Ediff to resolve the conflicts"]
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
160 ))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
161
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
162 (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
163 '((smerge-find-conflict
35564
b546ef3b2284 (smerge-font-lock-keywords): Relax submatch 1.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34855
diff changeset
164 (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
165 (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
166 (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
167 ;; 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
168 (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
169 (4 nil t t)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
170 (5 nil t t)))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
171 "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
172
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
173 (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
174 (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
175 (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
176 (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
177
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
178 (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
179 "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
180 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
181 - `diff3-E'
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
182 - `diff3-A'")
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
183
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
184 ;; Compiler pacifiers
36611
c0360458748f (font-lock-keywords, font-lock-mode): Don't bind, just declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 35564
diff changeset
185 (defvar font-lock-mode)
c0360458748f (font-lock-keywords, font-lock-mode): Don't bind, just declare.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 35564
diff changeset
186 (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
187
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 ;;;; Actual code
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
190 ;;;;
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
191
28248
108ba8d61036 (smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26776
diff changeset
192 ;; Define smerge-next and smerge-prev
108ba8d61036 (smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26776
diff changeset
193 (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
194
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
195 (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
196
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
197 (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
198 (unless (match-end n)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
199 (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
200
28248
108ba8d61036 (smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26776
diff changeset
201 (defun smerge-auto-leave ()
108ba8d61036 (smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26776
diff changeset
202 (when (and smerge-auto-leave
108ba8d61036 (smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26776
diff changeset
203 (save-excursion (goto-char (point-min))
108ba8d61036 (smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26776
diff changeset
204 (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
205 (smerge-mode -1)))
108ba8d61036 (smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26776
diff changeset
206
108ba8d61036 (smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26776
diff changeset
207
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
208 (defun smerge-keep-all ()
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
209 "Keep all three versions.
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
210 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
211 (interactive)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
212 (smerge-match-conflict)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
213 (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
214 (or (match-string 2) "")
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
215 (or (match-string 3) ""))
28248
108ba8d61036 (smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26776
diff changeset
216 t t)
108ba8d61036 (smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26776
diff changeset
217 (smerge-auto-leave))
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
218
47209
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
219 (defun smerge-combine-with-next ()
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
220 "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
221 (interactive)
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
222 (smerge-match-conflict)
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
223 (let ((ends nil))
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
224 (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
225 (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
226 (setq ends (apply 'vector ends))
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
227 (goto-char (aref ends 0))
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
228 (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
229 (error "No next conflict")
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
230 (smerge-match-conflict)
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
231 (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
232 (match-data))))
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
233 ;; 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
234 (dolist (i '(1 2 3))
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
235 (when (aref ends i)
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
236 (goto-char (aref ends i))
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
237 (insert-buffer-substring (current-buffer)
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
238 (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
239 (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
240 ;; 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
241 (dolist (i '(1 2 3))
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
242 (set-match-data match-data)
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
243 (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
244 (goto-char (aref ends i))
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
245 (insert-buffer-substring (current-buffer)
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
246 (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
247 (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
248 ;; Free the markers.
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
249 (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
250 (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
251
47827
9d7b63dcf005 (smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47821
diff changeset
252 (defvar smerge-resolve-function
9d7b63dcf005 (smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47821
diff changeset
253 (lambda () (error "Don't know how to resolve"))
9d7b63dcf005 (smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47821
diff changeset
254 "Mode-specific merge function.
9d7b63dcf005 (smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47821
diff changeset
255 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
256 according to `smerge-match-conflict'.")
9d7b63dcf005 (smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47821
diff changeset
257
9d7b63dcf005 (smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47821
diff changeset
258 (defun smerge-resolve ()
9d7b63dcf005 (smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47821
diff changeset
259 "Resolve the conflict at point intelligently.
9d7b63dcf005 (smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47821
diff changeset
260 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
261 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
262 (interactive)
9d7b63dcf005 (smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47821
diff changeset
263 (smerge-match-conflict)
9d7b63dcf005 (smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47821
diff changeset
264 (funcall smerge-resolve-function)
9d7b63dcf005 (smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47821
diff changeset
265 (smerge-auto-leave))
9d7b63dcf005 (smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47821
diff changeset
266
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
267 (defun smerge-keep-base ()
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
268 "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
269 (interactive)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
270 (smerge-match-conflict)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
271 (smerge-ensure-match 2)
28248
108ba8d61036 (smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26776
diff changeset
272 (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
273 (smerge-auto-leave))
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
274
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
275 (defun smerge-keep-other ()
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
276 "Use \"other\" version."
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
277 (interactive)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
278 (smerge-match-conflict)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
279 ;;(smerge-ensure-match 3)
28248
108ba8d61036 (smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26776
diff changeset
280 (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
281 (smerge-auto-leave))
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
282
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
283 (defun smerge-keep-mine ()
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
284 "Keep your version."
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
285 (interactive)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
286 (smerge-match-conflict)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
287 ;;(smerge-ensure-match 1)
28248
108ba8d61036 (smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26776
diff changeset
288 (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
289 (smerge-auto-leave))
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
290
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
291 (defun smerge-keep-current ()
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
292 "Use the current (under the cursor) version."
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
293 (interactive)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
294 (smerge-match-conflict)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
295 (let ((i 3))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
296 (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
297 (< (point) (match-beginning i))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
298 (>= (point) (match-end i)))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
299 (decf i))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
300 (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
301 (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
302 (smerge-auto-leave))))
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
303
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
304 (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
305 "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
306 (interactive)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
307 (smerge-diff 2 1))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
308
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
309 (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
310 "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
311 (interactive)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
312 (smerge-diff 2 3))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
313
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
314 (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
315 "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
316 (interactive)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
317 (smerge-diff 1 3))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
318
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
319 (defun smerge-match-conflict ()
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
320 "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
321 The submatches contain:
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
322 0: the whole conflict.
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
323 1: your code.
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
324 2: the base code.
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
325 3: other code.
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
326 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
327 (save-excursion
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
328 (condition-case nil
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
329 (let* ((orig-point (point))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
330
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
331 (_ (forward-line 1))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
332 (_ (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
333
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
334 (start (match-beginning 0))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
335 (mine-start (match-end 0))
47827
9d7b63dcf005 (smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47821
diff changeset
336 (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
337
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
338 (_ (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
339 (_ (assert (< orig-point (match-end 0))))
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 (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
342 (end (match-end 0))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
343
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
344 (_ (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
345
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
346 (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
347 (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
348
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
349 base-start base-end)
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 ;; 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
352 (cond
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
353 ((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
354 ;; a 3-parts conflict
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
355 (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
356 (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
357 (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
358 (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
359
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
360 ((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
361 (or buffer-file-name "")))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
362 ;; a 2-parts conflict
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
363 (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
364
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
365 ((and (not base-start)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
366 (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
367 (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
368 ;; a same-diff conflict
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
369 (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
370 (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
371 (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
372 (setq mine-end other-end)))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
373
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
374 (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
375 mine-start mine-end
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
376 base-start base-end
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
377 other-start other-end
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
378 (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
379 (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
380 t)
41064
cdd9ef6f603d (smerge-match-conflict): Fix typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38611
diff changeset
381 (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
382
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
383 (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
384 "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
385 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
386 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
387 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
388 (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
389 (ignore-errors
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
390 (smerge-match-conflict)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
391 (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
392
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
393 (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
394 (smerge-match-conflict)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
395 (smerge-ensure-match n1)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
396 (smerge-ensure-match n2)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
397 (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
398 (name2 (aref smerge-match-names n2))
41064
cdd9ef6f603d (smerge-match-conflict): Fix typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38611
diff changeset
399 ;; Read them before the match-data gets clobbered.
cdd9ef6f603d (smerge-match-conflict): Fix typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38611
diff changeset
400 (beg1 (match-beginning n1))
cdd9ef6f603d (smerge-match-conflict): Fix typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38611
diff changeset
401 (end1 (match-end n1))
cdd9ef6f603d (smerge-match-conflict): Fix typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38611
diff changeset
402 (beg2 (match-beginning n2))
cdd9ef6f603d (smerge-match-conflict): Fix typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38611
diff changeset
403 (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
404 (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
405 (file2 (make-temp-file "smerge2"))
44f7f2635fec (smerge-diff): Setup the buffer's default-directory
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32164
diff changeset
406 (dir default-directory)
41064
cdd9ef6f603d (smerge-match-conflict): Fix typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38611
diff changeset
407 (file (file-relative-name buffer-file-name))
cdd9ef6f603d (smerge-match-conflict): Fix typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38611
diff changeset
408 (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
409 (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
410 (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
411 (unwind-protect
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
412 (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
413 (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
414 (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
415 (erase-buffer)
47209
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
416 (let ((status
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
417 (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
418 (append smerge-diff-switches
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
419 (list "-L" (concat name1 "/" file)
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
420 "-L" (concat name2 "/" file)
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
421 file1 file2)))))
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
422 (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
423 (goto-char (point-min))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
424 (diff-mode)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
425 (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
426 (delete-file file1)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
427 (delete-file file2))))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
428
47209
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
429 ;; compiler pacifiers
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
430 (defvar smerge-ediff-windows)
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
431 (defvar smerge-ediff-buf)
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
432 (defvar ediff-buffer-A)
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
433 (defvar ediff-buffer-B)
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
434 (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
435
47821
45dcf3407814 (smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47756
diff changeset
436 ;;;###autoload
47756
b2c9ea334a34 (smerge-ediff): Add name-{mine,other,base} args.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47209
diff changeset
437 (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
438 "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
439 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
440 buffer names."
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
441 (interactive)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
442 (let* ((buf (current-buffer))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
443 (mode major-mode)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
444 ;;(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
445 (config (current-window-configuration))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
446 (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
447 (mine (generate-new-buffer
b2c9ea334a34 (smerge-ediff): Add name-{mine,other,base} args.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47209
diff changeset
448 (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
449 (other (generate-new-buffer
b2c9ea334a34 (smerge-ediff): Add name-{mine,other,base} args.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47209
diff changeset
450 (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
451 base)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
452 (with-current-buffer mine
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
453 (buffer-disable-undo)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
454 (insert-buffer-substring buf)
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 (while (smerge-find-conflict)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
457 (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
458 (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
459 (buffer-enable-undo)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
460 (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
461 (funcall mode))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
462
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
463 (with-current-buffer other
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
464 (buffer-disable-undo)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
465 (insert-buffer-substring buf)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
466 (goto-char (point-min))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
467 (while (smerge-find-conflict)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
468 (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
469 (buffer-enable-undo)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
470 (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
471 (funcall mode))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
472
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
473 (when base
47756
b2c9ea334a34 (smerge-ediff): Add name-{mine,other,base} args.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47209
diff changeset
474 (setq base (generate-new-buffer
b2c9ea334a34 (smerge-ediff): Add name-{mine,other,base} args.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47209
diff changeset
475 (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
476 (with-current-buffer base
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
477 (buffer-disable-undo)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
478 (insert-buffer-substring buf)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
479 (goto-char (point-min))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
480 (while (smerge-find-conflict)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
481 (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
482 (buffer-enable-undo)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
483 (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
484 (funcall mode)))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
485
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
486 ;; 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
487 ;; Fire up ediff.
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
488 (set-buffer
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
489 (if base
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
490 (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
491 ;; 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
492 (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
493 ;; nil 'ediff-merge-revisions buffer-file-name)))
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 ;; 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
496 ;; 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
497 (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
498 (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
499 (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
500 (lambda ()
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
501 (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
502 (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
503 (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
504 (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
505 (buf smerge-ediff-buf)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
506 (windows smerge-ediff-windows))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
507 (ediff-cleanup-mess)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
508 (with-current-buffer buf
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
509 (erase-buffer)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
510 (insert-buffer buffer-C)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
511 (kill-buffer buffer-A)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
512 (kill-buffer buffer-B)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
513 (kill-buffer buffer-C)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
514 (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
515 (set-window-configuration windows)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
516 (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
517 (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
518
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
519
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
520 ;;;###autoload
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
521 (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
522 "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
523 \\{smerge-mode-map}"
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
524 nil " SMerge" nil
38611
7f82c0bbe525 (smerge-mode): Check if `font-lock-mode' is bound
Gerd Moellmann <gerd@gnu.org>
parents: 37674
diff changeset
525 (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
526 (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
527 (save-excursion
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
528 (if smerge-mode
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
529 (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
530 (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
531 (goto-char (point-min))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
532 (while (smerge-find-conflict)
34842
f05ec8dfc452 (smerge-basic-map): Use `=' rather than `d'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34840
diff changeset
533 (save-excursion
f05ec8dfc452 (smerge-basic-map): Use `=' rather than `d'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34840
diff changeset
534 (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
535
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
536
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
537 (provide 'smerge-mode)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
538 ;;; smerge-mode.el ends here