annotate lisp/smerge-mode.el @ 64424:feba2f2d875e

(x_bitmap_icon, x_make_frame_visible): Remove declarations. (XSetFont): Add declaration. (mac_set_forecolor, mac_set_backcolor, mac_set_colors): Remove functions. (GC_FORE_COLOR, GC_BACK_COLOR, GC_FONT, MAC_WINDOW_NORMAL_GC): New defines. (XDrawLine, mac_draw_line_to_pixmap, XClearWindow) (mac_draw_bitmap, XCreatePixmapFromBitmapData, XFillRectangle) (mac_draw_rectangle, mac_draw_string_common, mac_scroll_area): Use them. (mac_erase_rectangle): New function. (XClearArea, x_draw_fringe_bitmap, x_clear_glyph_string_rect) (x_draw_stretch_glyph_string): Use it. (XChangeGC, XCreateGC, XGetGCValues, XSetForeground) (XSetBackground, XSetFont): Adjust for new GC implementation. (x_draw_fringe_bitmap, x_draw_box_rect): Use GC to set colors. (XTset_vertical_scroll_bar): Clear area under scroll bar.
author YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
date Mon, 18 Jul 2005 05:40:30 +0000
parents 6fb026ad601f
children a975a8beec7f 6c13700d1c13 f9a65d7ebd29
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
61277
7fa982932904 (smerge-mode): Specify :group.
Lute Kamstra <lute@gnu.org>
parents: 55258
diff changeset
3 ;; Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005 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>
54402
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
6 ;; Keywords: revision-control merge diff3 cvs conflict
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
7
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
8 ;; 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
9
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
10 ;; 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
11 ;; 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
12 ;; 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
13 ;; any later version.
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
14
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
15 ;; 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
16 ;; 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
17 ;; 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
18 ;; 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
19
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
20 ;; 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
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64091
6fb026ad601f Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 63936
diff changeset
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
6fb026ad601f Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 63936
diff changeset
23 ;; Boston, MA 02110-1301, USA.
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
24
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
25 ;;; Commentary:
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
26
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
27 ;; 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
28 ;; 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
29 ;;
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
30 ;; (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
31 ;;
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
32 ;; 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
33 ;; 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
34 ;;
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
35 ;; (defun sm-try-smerge ()
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
36 ;; (save-excursion
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
37 ;; (goto-char (point-min))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
38 ;; (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
39 ;; (smerge-mode 1))))
46899
f00337f04e78 Use find-file-hook instead of find-file-hooks.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 41064
diff changeset
40 ;; (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
41
28248
108ba8d61036 (smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26776
diff changeset
42 ;;; Todo:
108ba8d61036 (smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26776
diff changeset
43
108ba8d61036 (smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26776
diff changeset
44 ;; - 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
45
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
46 ;;; Code:
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
47
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
48 (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
49
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
50
63936
1eb58fde25d4 (smerge-mode): Add duplicate defvar near top.
Richard M. Stallman <rms@gnu.org>
parents: 63488
diff changeset
51 ;;; The real definition comes later.
1eb58fde25d4 (smerge-mode): Add duplicate defvar near top.
Richard M. Stallman <rms@gnu.org>
parents: 63488
diff changeset
52 (defvar smerge-mode)
1eb58fde25d4 (smerge-mode): Add duplicate defvar near top.
Richard M. Stallman <rms@gnu.org>
parents: 63488
diff changeset
53
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
54 (defgroup smerge ()
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
55 "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
56 :group 'tools
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
57 :prefix "smerge-")
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
58
47209
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
59 (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
60 "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
61 :group 'smerge
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
62 :type '(choice
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
63 (const "*vc-diff*")
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
64 (const "*cvs-diff*")
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
65 (const "*smerge-diff*")
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
66 string))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
67
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
68 (defcustom smerge-diff-switches
29207
6c4e371d4efd (smerge-diff-switches): Don't use list* in defcustom.
Dave Love <fx@gnu.org>
parents: 28248
diff changeset
69 (append '("-d" "-b")
6c4e371d4efd (smerge-diff-switches): Don't use list* in defcustom.
Dave Love <fx@gnu.org>
parents: 28248
diff changeset
70 (if (listp diff-switches) diff-switches (list diff-switches)))
55258
04a44f089cc1 (smerge-diff-switches): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 54904
diff changeset
71 "*A list of strings specifying switches to be passed to diff.
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
72 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
73 :group 'smerge
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
74 :type '(repeat string))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
75
28248
108ba8d61036 (smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26776
diff changeset
76 (defcustom smerge-auto-leave t
108ba8d61036 (smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26776
diff changeset
77 "*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
78 :group 'smerge
108ba8d61036 (smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26776
diff changeset
79 :type 'boolean)
108ba8d61036 (smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26776
diff changeset
80
63205
6dde8ad3e1a7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375
Miles Bader <miles@gnu.org>
parents: 61394
diff changeset
81 (defface smerge-mine
61394
31aa9a390538 * mh-customize.el (mh-speedbar-selected-folder-face): Special case
Dan Nicolaescu <dann@ics.uci.edu>
parents: 61277
diff changeset
82 '((((min-colors 88) (background light))
31aa9a390538 * mh-customize.el (mh-speedbar-selected-folder-face): Special case
Dan Nicolaescu <dann@ics.uci.edu>
parents: 61277
diff changeset
83 (:foreground "blue1"))
31aa9a390538 * mh-customize.el (mh-speedbar-selected-folder-face): Special case
Dan Nicolaescu <dann@ics.uci.edu>
parents: 61277
diff changeset
84 (((background light))
32164
a3d5adc99010 (smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents: 30868
diff changeset
85 (:foreground "blue"))
61394
31aa9a390538 * mh-customize.el (mh-speedbar-selected-folder-face): Special case
Dan Nicolaescu <dann@ics.uci.edu>
parents: 61277
diff changeset
86 (((min-colors 88) (background dark))
31aa9a390538 * mh-customize.el (mh-speedbar-selected-folder-face): Special case
Dan Nicolaescu <dann@ics.uci.edu>
parents: 61277
diff changeset
87 (:foreground "cyan1"))
32164
a3d5adc99010 (smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents: 30868
diff changeset
88 (((background dark))
a3d5adc99010 (smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents: 30868
diff changeset
89 (:foreground "cyan")))
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
90 "Face for your code."
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
91 :group 'smerge)
63205
6dde8ad3e1a7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375
Miles Bader <miles@gnu.org>
parents: 61394
diff changeset
92 ;; backward-compatibility alias
6dde8ad3e1a7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375
Miles Bader <miles@gnu.org>
parents: 61394
diff changeset
93 (put 'smerge-mine-face 'face-alias 'smerge-mine)
6dde8ad3e1a7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375
Miles Bader <miles@gnu.org>
parents: 61394
diff changeset
94 (defvar smerge-mine-face 'smerge-mine)
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
95
63205
6dde8ad3e1a7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375
Miles Bader <miles@gnu.org>
parents: 61394
diff changeset
96 (defface smerge-other
32164
a3d5adc99010 (smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents: 30868
diff changeset
97 '((((background light))
a3d5adc99010 (smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents: 30868
diff changeset
98 (:foreground "darkgreen"))
a3d5adc99010 (smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents: 30868
diff changeset
99 (((background dark))
a3d5adc99010 (smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents: 30868
diff changeset
100 (:foreground "lightgreen")))
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
101 "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
102 :group 'smerge)
63205
6dde8ad3e1a7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375
Miles Bader <miles@gnu.org>
parents: 61394
diff changeset
103 ;; backward-compatibility alias
6dde8ad3e1a7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375
Miles Bader <miles@gnu.org>
parents: 61394
diff changeset
104 (put 'smerge-other-face 'face-alias 'smerge-other)
6dde8ad3e1a7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375
Miles Bader <miles@gnu.org>
parents: 61394
diff changeset
105 (defvar smerge-other-face 'smerge-other)
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
106
63205
6dde8ad3e1a7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375
Miles Bader <miles@gnu.org>
parents: 61394
diff changeset
107 (defface smerge-base
61394
31aa9a390538 * mh-customize.el (mh-speedbar-selected-folder-face): Special case
Dan Nicolaescu <dann@ics.uci.edu>
parents: 61277
diff changeset
108 '((((min-colors 88) (background light))
31aa9a390538 * mh-customize.el (mh-speedbar-selected-folder-face): Special case
Dan Nicolaescu <dann@ics.uci.edu>
parents: 61277
diff changeset
109 (:foreground "red1"))
31aa9a390538 * mh-customize.el (mh-speedbar-selected-folder-face): Special case
Dan Nicolaescu <dann@ics.uci.edu>
parents: 61277
diff changeset
110 (((background light))
32164
a3d5adc99010 (smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents: 30868
diff changeset
111 (:foreground "red"))
a3d5adc99010 (smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents: 30868
diff changeset
112 (((background dark))
a3d5adc99010 (smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents: 30868
diff changeset
113 (:foreground "orange")))
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
114 "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
115 :group 'smerge)
63205
6dde8ad3e1a7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375
Miles Bader <miles@gnu.org>
parents: 61394
diff changeset
116 ;; backward-compatibility alias
6dde8ad3e1a7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375
Miles Bader <miles@gnu.org>
parents: 61394
diff changeset
117 (put 'smerge-base-face 'face-alias 'smerge-base)
6dde8ad3e1a7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375
Miles Bader <miles@gnu.org>
parents: 61394
diff changeset
118 (defvar smerge-base-face 'smerge-base)
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
119
63205
6dde8ad3e1a7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375
Miles Bader <miles@gnu.org>
parents: 61394
diff changeset
120 (defface smerge-markers
32164
a3d5adc99010 (smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents: 30868
diff changeset
121 '((((background light))
a3d5adc99010 (smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents: 30868
diff changeset
122 (:background "grey85"))
a3d5adc99010 (smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents: 30868
diff changeset
123 (((background dark))
a3d5adc99010 (smerge-mine-face, smerge-other-face, smerge-base-face, smerge-markers-face):
Miles Bader <miles@gnu.org>
parents: 30868
diff changeset
124 (:background "grey30")))
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
125 "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
126 :group 'smerge)
63205
6dde8ad3e1a7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375
Miles Bader <miles@gnu.org>
parents: 61394
diff changeset
127 ;; backward-compatibility alias
6dde8ad3e1a7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375
Miles Bader <miles@gnu.org>
parents: 61394
diff changeset
128 (put 'smerge-markers-face 'face-alias 'smerge-markers)
6dde8ad3e1a7 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-375
Miles Bader <miles@gnu.org>
parents: 61394
diff changeset
129 (defvar smerge-markers-face 'smerge-markers)
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
130
28248
108ba8d61036 (smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26776
diff changeset
131 (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
132 `(("n" . smerge-next)
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
133 ("p" . smerge-prev)
47827
9d7b63dcf005 (smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47821
diff changeset
134 ("r" . smerge-resolve)
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
135 ("a" . smerge-keep-all)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
136 ("b" . smerge-keep-base)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
137 ("o" . smerge-keep-other)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
138 ("m" . smerge-keep-mine)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
139 ("E" . smerge-ediff)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
140 ("\C-m" . smerge-keep-current)
34840
509ed3724af0 (smerge-basic-map): Use `=' rather than `d'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32217
diff changeset
141 ("=" . ,(make-sparse-keymap "Diff"))
509ed3724af0 (smerge-basic-map): Use `=' rather than `d'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32217
diff changeset
142 ("=<" "base-mine" . smerge-diff-base-mine)
509ed3724af0 (smerge-basic-map): Use `=' rather than `d'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32217
diff changeset
143 ("=>" "base-other" . smerge-diff-base-other)
509ed3724af0 (smerge-basic-map): Use `=' rather than `d'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32217
diff changeset
144 ("==" "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
145 "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
146
34840
509ed3724af0 (smerge-basic-map): Use `=' rather than `d'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32217
diff changeset
147 (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
148 "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
149 :group 'smerge
34840
509ed3724af0 (smerge-basic-map): Use `=' rather than `d'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32217
diff changeset
150 :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
151
28248
108ba8d61036 (smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26776
diff changeset
152 (easy-mmode-defmap smerge-mode-map
108ba8d61036 (smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26776
diff changeset
153 `((,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
154 "Keymap for `smerge-mode'.")
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
155
54332
118715eba3b3 (smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52779
diff changeset
156 (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
157 (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
158 (defun smerge-check (n)
118715eba3b3 (smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52779
diff changeset
159 (condition-case nil
118715eba3b3 (smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52779
diff changeset
160 (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
161 (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
162 (smerge-match-conflict)
118715eba3b3 (smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52779
diff changeset
163 (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
164 (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
165 (error nil)))
118715eba3b3 (smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52779
diff changeset
166
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
167 (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
168 "Menu for `smerge-mode'."
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
169 '("SMerge"
30358
636fe93e755c (smerge-mode-menu): Fill it out.
Dave Love <fx@gnu.org>
parents: 29207
diff changeset
170 ["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
171 ["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
172 "--"
118715eba3b3 (smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52779
diff changeset
173 ["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
174 :active (smerge-check 1)]
118715eba3b3 (smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52779
diff changeset
175 ["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
176 :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
177 "--"
118715eba3b3 (smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52779
diff changeset
178 ["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
179 :active (smerge-check 2)]
118715eba3b3 (smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52779
diff changeset
180 ["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
181 :active (smerge-check 3)]
118715eba3b3 (smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52779
diff changeset
182 ["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
183 :active (smerge-check 1)]
30358
636fe93e755c (smerge-mode-menu): Fill it out.
Dave Love <fx@gnu.org>
parents: 29207
diff changeset
184 "--"
636fe93e755c (smerge-mode-menu): Fill it out.
Dave Love <fx@gnu.org>
parents: 29207
diff changeset
185 ["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
186 :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
187 :active (smerge-check 2)]
30358
636fe93e755c (smerge-mode-menu): Fill it out.
Dave Love <fx@gnu.org>
parents: 29207
diff changeset
188 ["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
189 :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
190 :active (smerge-check 2)]
30358
636fe93e755c (smerge-mode-menu): Fill it out.
Dave Love <fx@gnu.org>
parents: 29207
diff changeset
191 ["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
192 :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
193 :active (smerge-check 1)]
30358
636fe93e755c (smerge-mode-menu): Fill it out.
Dave Love <fx@gnu.org>
parents: 29207
diff changeset
194 "--"
636fe93e755c (smerge-mode-menu): Fill it out.
Dave Love <fx@gnu.org>
parents: 29207
diff changeset
195 ["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
196 :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
197 :active (smerge-check 1)]
118715eba3b3 (smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52779
diff changeset
198 ["Auto Resolve" smerge-resolve
54527
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
199 :help "Try auto-resolution heuristics"
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
200 :active (smerge-check 1)]
54332
118715eba3b3 (smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52779
diff changeset
201 ["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
202 :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
203 :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
204 ))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
205
54402
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
206 (easy-menu-define smerge-context-menu nil
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
207 "Context menu for mine area in `smerge-mode'."
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
208 '(nil
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
209 ["Keep Current" smerge-keep-current :help "Use current (at point) version"]
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
210 ["Kill Current" smerge-kill-current :help "Remove current (at point) version"]
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
211 ["Keep All" smerge-keep-all :help "Keep all three versions"]
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
212 "---"
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
213 ["More..." (popup-menu smerge-mode-menu) :help "Show full SMerge mode menu"]
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
214 ))
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
215
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
216 (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
217 '((smerge-find-conflict
35564
b546ef3b2284 (smerge-font-lock-keywords): Relax submatch 1.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34855
diff changeset
218 (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
219 (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
220 (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
221 ;; 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
222 (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
223 (4 nil t t)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
224 (5 nil t t)))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
225 "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
226
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
227 (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
228 (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
229 (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
230 (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
231
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
232 (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
233 "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
234 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
235 - `diff3-E'
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
236 - `diff3-A'")
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
237
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
238 ;; Compiler pacifiers
52779
3bc7b9f71e34 Previous change was bogus. Something odd in pcl-cvs...
Dave Love <fx@gnu.org>
parents: 52778
diff changeset
239 (defvar font-lock-mode)
3bc7b9f71e34 Previous change was bogus. Something odd in pcl-cvs...
Dave Love <fx@gnu.org>
parents: 52778
diff changeset
240 (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
241
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
242 ;;;;
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
243 ;;;; Actual code
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
244 ;;;;
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
245
28248
108ba8d61036 (smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26776
diff changeset
246 ;; Define smerge-next and smerge-prev
108ba8d61036 (smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26776
diff changeset
247 (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
248
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
249 (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
250
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
251 (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
252 (unless (match-end n)
63488
31f53cf94303 (smerge-ensure-match): Don't use `format' on `error' arguments.
Juanma Barranquero <lekktu@gmail.com>
parents: 63205
diff changeset
253 (error "No `%s'" (aref smerge-match-names n))))
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
254
28248
108ba8d61036 (smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26776
diff changeset
255 (defun smerge-auto-leave ()
108ba8d61036 (smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26776
diff changeset
256 (when (and smerge-auto-leave
108ba8d61036 (smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26776
diff changeset
257 (save-excursion (goto-char (point-min))
108ba8d61036 (smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26776
diff changeset
258 (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
259 (smerge-mode -1)))
49597
e88404e8f2cf Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47827
diff changeset
260
28248
108ba8d61036 (smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26776
diff changeset
261
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
262 (defun smerge-keep-all ()
54527
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
263 "Concatenate all versions."
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
264 (interactive)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
265 (smerge-match-conflict)
54527
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
266 (let ((mb2 (or (match-beginning 2) (point-max)))
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
267 (me2 (or (match-end 2) (point-min))))
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
268 (delete-region (match-end 3) (match-end 0))
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
269 (delete-region (max me2 (match-end 1)) (match-beginning 3))
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
270 (if (and (match-end 2) (/= (match-end 1) (match-end 3)))
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
271 (delete-region (match-end 1) (match-beginning 2)))
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
272 (delete-region (match-beginning 0) (min (match-beginning 1) mb2))
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
273 (smerge-auto-leave)))
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
274
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
275 (defun smerge-keep-n (n)
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
276 ;; We used to use replace-match, but that did not preserve markers so well.
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
277 (delete-region (match-end n) (match-end 0))
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
278 (delete-region (match-beginning 0) (match-beginning n)))
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
279
47209
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
280 (defun smerge-combine-with-next ()
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
281 "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
282 (interactive)
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
283 (smerge-match-conflict)
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
284 (let ((ends nil))
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
285 (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
286 (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
287 (setq ends (apply 'vector ends))
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
288 (goto-char (aref ends 0))
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
289 (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
290 (error "No next conflict")
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
291 (smerge-match-conflict)
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
292 (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
293 (match-data))))
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
294 ;; 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
295 (dolist (i '(1 2 3))
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
296 (when (aref ends i)
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
297 (goto-char (aref ends i))
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
298 (insert-buffer-substring (current-buffer)
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
299 (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
300 (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
301 ;; 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
302 (dolist (i '(1 2 3))
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
303 (set-match-data match-data)
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
304 (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
305 (goto-char (aref ends i))
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
306 (insert-buffer-substring (current-buffer)
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
307 (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
308 (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
309 ;; Free the markers.
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
310 (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
311 (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
312
47827
9d7b63dcf005 (smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47821
diff changeset
313 (defvar smerge-resolve-function
9d7b63dcf005 (smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47821
diff changeset
314 (lambda () (error "Don't know how to resolve"))
9d7b63dcf005 (smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47821
diff changeset
315 "Mode-specific merge function.
9d7b63dcf005 (smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47821
diff changeset
316 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
317 according to `smerge-match-conflict'.")
9d7b63dcf005 (smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47821
diff changeset
318
54402
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
319 (defvar smerge-text-properties
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
320 `(help-echo "merge conflict: mouse-3 shows a menu"
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
321 ;; mouse-face highlight
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
322 keymap (keymap (down-mouse-3 . smerge-popup-context-menu))))
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
323
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
324 (defun smerge-remove-props (&optional beg end)
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
325 (remove-text-properties
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
326 (or beg (match-beginning 0))
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
327 (or end (match-end 0))
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
328 smerge-text-properties))
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
329
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
330 (defun smerge-popup-context-menu (event)
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
331 "Pop up the Smerge mode context menu under mouse."
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
332 (interactive "e")
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
333 (if (and smerge-mode
54872
367886fbcfd9 (smerge-popup-context-menu): Use it.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54527
diff changeset
334 (save-excursion (posn-set-point (event-end event)) (smerge-check 1)))
54402
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
335 (progn
54872
367886fbcfd9 (smerge-popup-context-menu): Use it.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54527
diff changeset
336 (posn-set-point (event-end event))
54527
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
337 (smerge-match-conflict)
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
338 (let ((i (smerge-get-current))
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
339 o)
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
340 (if (<= i 0)
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
341 ;; Out of range
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
342 (popup-menu smerge-mode-menu)
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
343 ;; Install overlay.
55258
04a44f089cc1 (smerge-diff-switches): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 54904
diff changeset
344 (setq o (make-overlay (match-beginning i) (match-end i)))
54527
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
345 (unwind-protect
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
346 (progn
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
347 (overlay-put o 'face 'highlight)
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
348 (sit-for 0) ;Display the new highlighting.
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
349 (popup-menu smerge-context-menu))
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
350 ;; Delete overlay.
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
351 (delete-overlay o)))))
54402
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
352 ;; There's no conflict at point, the text-props are just obsolete.
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
353 (save-excursion
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
354 (let ((beg (re-search-backward smerge-end-re nil t))
54527
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
355 (end (re-search-forward smerge-begin-re nil t)))
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
356 (smerge-remove-props (or beg (point-min)) (or end (point-max)))
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
357 (push event unread-command-events)))))
54402
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
358
47827
9d7b63dcf005 (smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47821
diff changeset
359 (defun smerge-resolve ()
9d7b63dcf005 (smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47821
diff changeset
360 "Resolve the conflict at point intelligently.
9d7b63dcf005 (smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47821
diff changeset
361 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
362 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
363 (interactive)
9d7b63dcf005 (smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47821
diff changeset
364 (smerge-match-conflict)
54402
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
365 (smerge-remove-props)
54527
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
366 (cond
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
367 ;; Trivial diff3 -A non-conflicts.
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
368 ((and (eq (match-end 1) (match-end 3))
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
369 (eq (match-beginning 1) (match-beginning 3)))
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
370 ;; FIXME: Add "if [ diff -b MINE OTHER ]; then select OTHER; fi"
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
371 (smerge-keep-n 3))
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
372 ((and (match-end 2)
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
373 ;; FIXME: Add "diff -b BASE MINE | patch OTHER".
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
374 ;; FIXME: Add "diff -b BASE OTHER | patch MINE".
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
375 nil)
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
376 )
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
377 ((and (not (match-end 2))
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
378 ;; FIXME: Add "diff -b"-based refinement.
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
379 nil)
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
380 )
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
381 (t
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
382 ;; Mode-specific conflict resolution.
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
383 (funcall smerge-resolve-function)))
47827
9d7b63dcf005 (smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47821
diff changeset
384 (smerge-auto-leave))
9d7b63dcf005 (smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47821
diff changeset
385
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
386 (defun smerge-keep-base ()
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
387 "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
388 (interactive)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
389 (smerge-match-conflict)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
390 (smerge-ensure-match 2)
54402
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
391 (smerge-remove-props)
54527
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
392 (smerge-keep-n 2)
28248
108ba8d61036 (smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26776
diff changeset
393 (smerge-auto-leave))
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
394
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
395 (defun smerge-keep-other ()
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
396 "Use \"other\" version."
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
397 (interactive)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
398 (smerge-match-conflict)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
399 ;;(smerge-ensure-match 3)
54402
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
400 (smerge-remove-props)
54527
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
401 (smerge-keep-n 3)
28248
108ba8d61036 (smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26776
diff changeset
402 (smerge-auto-leave))
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
403
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
404 (defun smerge-keep-mine ()
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
405 "Keep your version."
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
406 (interactive)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
407 (smerge-match-conflict)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
408 ;;(smerge-ensure-match 1)
54402
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
409 (smerge-remove-props)
54527
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
410 (smerge-keep-n 1)
28248
108ba8d61036 (smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26776
diff changeset
411 (smerge-auto-leave))
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
412
54332
118715eba3b3 (smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52779
diff changeset
413 (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
414 (let ((i 3))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
415 (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
416 (< (point) (match-beginning i))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
417 (>= (point) (match-end i)))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
418 (decf i))
54332
118715eba3b3 (smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52779
diff changeset
419 i))
118715eba3b3 (smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52779
diff changeset
420
118715eba3b3 (smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52779
diff changeset
421 (defun smerge-keep-current ()
118715eba3b3 (smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52779
diff changeset
422 "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
423 (interactive)
118715eba3b3 (smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52779
diff changeset
424 (smerge-match-conflict)
118715eba3b3 (smerge-check-cache, smerge-check): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52779
diff changeset
425 (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
426 (if (<= i 0) (error "Not inside a version")
54402
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
427 (smerge-remove-props)
54527
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
428 (smerge-keep-n i)
28248
108ba8d61036 (smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26776
diff changeset
429 (smerge-auto-leave))))
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
430
54402
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
431 (defun smerge-kill-current ()
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
432 "Remove the current (under the cursor) version."
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
433 (interactive)
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
434 (smerge-match-conflict)
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
435 (let ((i (smerge-get-current)))
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
436 (if (<= i 0) (error "Not inside a version")
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
437 (smerge-remove-props)
54527
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
438 (let ((left nil))
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
439 (dolist (n '(3 2 1))
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
440 (if (and (match-end n) (/= (match-end n) (match-end i)))
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
441 (push n left)))
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
442 (if (and (cdr left)
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
443 (/= (match-end (car left)) (match-end (cadr left))))
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
444 (ding) ;We don't know how to do that.
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
445 (smerge-keep-n (car left))
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
446 (smerge-auto-leave))))))
54402
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
447
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
448 (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
449 "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
450 (interactive)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
451 (smerge-diff 2 1))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
452
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
453 (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
454 "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
455 (interactive)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
456 (smerge-diff 2 3))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
457
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
458 (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
459 "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
460 (interactive)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
461 (smerge-diff 1 3))
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 (defun smerge-match-conflict ()
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
464 "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
465 The submatches contain:
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
466 0: the whole conflict.
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
467 1: your code.
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
468 2: the base code.
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
469 3: other code.
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
470 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
471 (save-excursion
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
472 (condition-case nil
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
473 (let* ((orig-point (point))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
474
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
475 (_ (forward-line 1))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
476 (_ (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
477
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
478 (start (match-beginning 0))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
479 (mine-start (match-end 0))
47827
9d7b63dcf005 (smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47821
diff changeset
480 (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
481
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
482 (_ (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
483 (_ (assert (< orig-point (match-end 0))))
49597
e88404e8f2cf Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47827
diff changeset
484
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
485 (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
486 (end (match-end 0))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
487
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
488 (_ (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
489
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
490 (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
491 (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
492
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
493 base-start base-end)
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 ;; 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
496 (cond
54903
922f49230ff5 (smerge-match-conflict): Try to do something sensible
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54872
diff changeset
497 ((save-excursion
922f49230ff5 (smerge-match-conflict): Try to do something sensible
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54872
diff changeset
498 (goto-char mine-start)
54904
a23bbf466906 (smerge-match-conflict): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54903
diff changeset
499 (re-search-forward smerge-begin-re end t))
54903
922f49230ff5 (smerge-match-conflict): Try to do something sensible
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54872
diff changeset
500 ;; There's a nested conflict and we're after the the beginning
922f49230ff5 (smerge-match-conflict): Try to do something sensible
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54872
diff changeset
501 ;; of the outer one but before the beginning of the inner one.
922f49230ff5 (smerge-match-conflict): Try to do something sensible
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54872
diff changeset
502 (error "There is a nested conflict"))
922f49230ff5 (smerge-match-conflict): Try to do something sensible
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54872
diff changeset
503
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
504 ((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
505 ;; a 3-parts conflict
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
506 (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
507 (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
508 (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
509 (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
510
54402
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
511 ((string= filename (file-name-nondirectory
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
512 (or buffer-file-name "")))
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
513 ;; a 2-parts conflict
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
514 (set (make-local-variable 'smerge-conflict-style) 'diff3-E))
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
515
54402
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
516 ((and (not base-start)
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
517 (or (eq smerge-conflict-style 'diff3-A)
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
518 (equal filename "ANCESTOR")
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
519 (string-match "\\`[.0-9]+\\'" filename)))
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
520 ;; a same-diff conflict
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
521 (setq base-start mine-start)
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
522 (setq base-end mine-end)
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
523 (setq mine-start other-start)
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
524 (setq mine-end other-end)))
49597
e88404e8f2cf Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47827
diff changeset
525
54402
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
526 (let ((inhibit-read-only t)
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
527 (inhibit-modification-hooks t)
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
528 (m (buffer-modified-p)))
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
529 (unwind-protect
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
530 (add-text-properties start end smerge-text-properties)
8bf3846fc7dd 2004-03-15 Masatake YAMATO <jet@gyve.org>
Masatake YAMATO <jet@gyve.org>
parents: 54332
diff changeset
531 (restore-buffer-modified-p m)))
55258
04a44f089cc1 (smerge-diff-switches): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 54904
diff changeset
532
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
533 (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
534 mine-start mine-end
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
535 base-start base-end
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
536 other-start other-end
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
537 (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
538 (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
539 t)
41064
cdd9ef6f603d (smerge-match-conflict): Fix typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38611
diff changeset
540 (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
541
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
542 (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
543 "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
544 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
545 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
546 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
547 (when (re-search-forward smerge-begin-re limit t)
54903
922f49230ff5 (smerge-match-conflict): Try to do something sensible
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54872
diff changeset
548 (condition-case err
922f49230ff5 (smerge-match-conflict): Try to do something sensible
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54872
diff changeset
549 (progn
922f49230ff5 (smerge-match-conflict): Try to do something sensible
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54872
diff changeset
550 (smerge-match-conflict)
922f49230ff5 (smerge-match-conflict): Try to do something sensible
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54872
diff changeset
551 (goto-char (match-end 0)))
922f49230ff5 (smerge-match-conflict): Try to do something sensible
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54872
diff changeset
552 (error (smerge-find-conflict limit)))))
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
553
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
554 (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
555 (smerge-match-conflict)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
556 (smerge-ensure-match n1)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
557 (smerge-ensure-match n2)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
558 (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
559 (name2 (aref smerge-match-names n2))
41064
cdd9ef6f603d (smerge-match-conflict): Fix typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38611
diff changeset
560 ;; Read them before the match-data gets clobbered.
cdd9ef6f603d (smerge-match-conflict): Fix typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38611
diff changeset
561 (beg1 (match-beginning n1))
cdd9ef6f603d (smerge-match-conflict): Fix typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38611
diff changeset
562 (end1 (match-end n1))
cdd9ef6f603d (smerge-match-conflict): Fix typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38611
diff changeset
563 (beg2 (match-beginning n2))
cdd9ef6f603d (smerge-match-conflict): Fix typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38611
diff changeset
564 (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
565 (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
566 (file2 (make-temp-file "smerge2"))
44f7f2635fec (smerge-diff): Setup the buffer's default-directory
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32164
diff changeset
567 (dir default-directory)
41064
cdd9ef6f603d (smerge-match-conflict): Fix typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38611
diff changeset
568 (file (file-relative-name buffer-file-name))
cdd9ef6f603d (smerge-match-conflict): Fix typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38611
diff changeset
569 (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
570 (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
571 (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
572 (unwind-protect
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
573 (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
574 (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
575 (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
576 (erase-buffer)
47209
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
577 (let ((status
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
578 (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
579 (append smerge-diff-switches
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
580 (list "-L" (concat name1 "/" file)
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
581 "-L" (concat name2 "/" file)
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
582 file1 file2)))))
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
583 (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
584 (goto-char (point-min))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
585 (diff-mode)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
586 (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
587 (delete-file file1)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
588 (delete-file file2))))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
589
47209
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
590 ;; compiler pacifiers
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
591 (defvar smerge-ediff-windows)
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
592 (defvar smerge-ediff-buf)
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
593 (defvar ediff-buffer-A)
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
594 (defvar ediff-buffer-B)
f06f993cfd92 (smerge-diff-buffer-name): Default to *vc-diff*.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 46899
diff changeset
595 (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
596
47821
45dcf3407814 (smerge-ediff): Autoload.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47756
diff changeset
597 ;;;###autoload
47756
b2c9ea334a34 (smerge-ediff): Add name-{mine,other,base} args.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47209
diff changeset
598 (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
599 "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
600 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
601 buffer names."
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
602 (interactive)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
603 (let* ((buf (current-buffer))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
604 (mode major-mode)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
605 ;;(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
606 (config (current-window-configuration))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
607 (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
608 (mine (generate-new-buffer
b2c9ea334a34 (smerge-ediff): Add name-{mine,other,base} args.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47209
diff changeset
609 (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
610 (other (generate-new-buffer
b2c9ea334a34 (smerge-ediff): Add name-{mine,other,base} args.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47209
diff changeset
611 (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
612 base)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
613 (with-current-buffer mine
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
614 (buffer-disable-undo)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
615 (insert-buffer-substring buf)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
616 (goto-char (point-min))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
617 (while (smerge-find-conflict)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
618 (when (match-beginning 2) (setq base t))
54527
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
619 (smerge-keep-n 1))
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
620 (buffer-enable-undo)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
621 (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
622 (funcall mode))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
623
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
624 (with-current-buffer other
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
625 (buffer-disable-undo)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
626 (insert-buffer-substring buf)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
627 (goto-char (point-min))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
628 (while (smerge-find-conflict)
54527
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
629 (smerge-keep-n 3))
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
630 (buffer-enable-undo)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
631 (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
632 (funcall mode))
49597
e88404e8f2cf Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47827
diff changeset
633
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
634 (when base
47756
b2c9ea334a34 (smerge-ediff): Add name-{mine,other,base} args.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47209
diff changeset
635 (setq base (generate-new-buffer
b2c9ea334a34 (smerge-ediff): Add name-{mine,other,base} args.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47209
diff changeset
636 (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
637 (with-current-buffer base
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
638 (buffer-disable-undo)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
639 (insert-buffer-substring buf)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
640 (goto-char (point-min))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
641 (while (smerge-find-conflict)
54527
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
642 (if (match-end 2)
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
643 (smerge-keep-n 2)
192fc783e115 (smerge-mode-menu): Fix activate pred for resolve.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54410
diff changeset
644 (delete-region (match-beginning 0) (match-end 0))))
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
645 (buffer-enable-undo)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
646 (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
647 (funcall mode)))
49597
e88404e8f2cf Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47827
diff changeset
648
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
649 ;; 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
650 ;; Fire up ediff.
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
651 (set-buffer
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
652 (if base
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
653 (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
654 ;; 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
655 (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
656 ;; nil 'ediff-merge-revisions buffer-file-name)))
49597
e88404e8f2cf Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 47827
diff changeset
657
26776
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
658 ;; 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
659 ;; 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
660 (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
661 (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
662 (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
663 (lambda ()
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
664 (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
665 (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
666 (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
667 (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
668 (buf smerge-ediff-buf)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
669 (windows smerge-ediff-windows))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
670 (ediff-cleanup-mess)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
671 (with-current-buffer buf
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
672 (erase-buffer)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
673 (insert-buffer buffer-C)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
674 (kill-buffer buffer-A)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
675 (kill-buffer buffer-B)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
676 (kill-buffer buffer-C)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
677 (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
678 (set-window-configuration windows)
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
679 (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
680 (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
681
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
682
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
683 ;;;###autoload
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
684 (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
685 "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
686 \\{smerge-mode-map}"
61277
7fa982932904 (smerge-mode): Specify :group.
Lute Kamstra <lute@gnu.org>
parents: 55258
diff changeset
687 :group 'smerge :lighter " SMerge"
38611
7f82c0bbe525 (smerge-mode): Check if `font-lock-mode' is bound
Gerd Moellmann <gerd@gnu.org>
parents: 37674
diff changeset
688 (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
689 (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
690 (save-excursion
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
691 (if smerge-mode
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
692 (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
693 (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
694 (goto-char (point-min))
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
695 (while (smerge-find-conflict)
34842
f05ec8dfc452 (smerge-basic-map): Use `=' rather than `d'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34840
diff changeset
696 (save-excursion
f05ec8dfc452 (smerge-basic-map): Use `=' rather than `d'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 34840
diff changeset
697 (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
698
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
699
142d6aa7c470 New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
700 (provide 'smerge-mode)
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49597
diff changeset
701
54903
922f49230ff5 (smerge-match-conflict): Try to do something sensible
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54872
diff changeset
702 ;; 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
703 ;;; smerge-mode.el ends here