Mercurial > emacs
annotate lisp/smerge-mode.el @ 30729:b81e74b4a7a6
*** empty log message ***
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Thu, 10 Aug 2000 09:21:43 +0000 |
parents | 636fe93e755c |
children | f7b06560383b |
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 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
3 ;; Copyright (C) 1999 Free Software Foundation, Inc. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
4 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
5 ;; Author: Stefan Monnier <monnier@cs.yale.edu> |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
6 ;; Keywords: merge diff3 cvs conflict |
30358 | 7 ;; Revision: $Id: smerge-mode.el,v 1.3 2000/05/25 18:08:26 fx Exp $ |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
8 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
9 ;; This file is part of GNU Emacs. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
10 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
11 ;; GNU Emacs is free software; you can redistribute it and/or modify |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
12 ;; it under the terms of the GNU General Public License as published by |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
13 ;; the Free Software Foundation; either version 2, or (at your option) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
14 ;; any later version. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
15 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
16 ;; GNU Emacs is distributed in the hope that it will be useful, |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
19 ;; GNU General Public License for more details. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
20 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
21 ;; You should have received a copy of the GNU General Public License |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
24 ;; Boston, MA 02111-1307, USA. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
25 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
26 ;;; Commentary: |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
27 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
28 ;; Provides a lightweight alternative to emerge/ediff. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
29 ;; To use it, simply add to your .emacs the following lines: |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
30 ;; |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
31 ;; (autoload 'smerge-mode "smerge-mode" nil t) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
32 ;; |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
33 ;; you can even have it turned on automatically with the following |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
34 ;; piece of code in your .emacs: |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
35 ;; |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
36 ;; (defun sm-try-smerge () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
37 ;; (save-excursion |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
38 ;; (goto-char (point-min)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
39 ;; (when (re-search-forward "^<<<<<<< " nil t) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
40 ;; (smerge-mode 1)))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
41 ;; (add-hook 'find-file-hooks 'sm-try-smerge t) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
42 |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
43 ;;; Todo: |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
44 |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
45 ;; - if requested, ask the user whether he wants to call ediff right away |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
46 |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
47 ;;; Code: |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
48 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
49 (eval-when-compile (require 'cl)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
50 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
51 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
52 (defgroup smerge () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
53 "Minor mode to resolve diff3 conflicts." |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
54 :group 'tools |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
55 :prefix "smerge-") |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
56 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
57 (defcustom smerge-diff-buffer-name "*smerge-diff*" |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
58 "Buffer name to use for displaying diffs." |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
59 :group 'smerge |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
60 :type '(choice |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
61 (const "*vc-diff*") |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
62 (const "*cvs-diff*") |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
63 (const "*smerge-diff*") |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
64 string)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
65 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
66 (defcustom smerge-diff-switches |
29207
6c4e371d4efd
(smerge-diff-switches): Don't use list* in defcustom.
Dave Love <fx@gnu.org>
parents:
28248
diff
changeset
|
67 (append '("-d" "-b") |
6c4e371d4efd
(smerge-diff-switches): Don't use list* in defcustom.
Dave Love <fx@gnu.org>
parents:
28248
diff
changeset
|
68 (if (listp diff-switches) diff-switches (list diff-switches))) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
69 "*A list of strings specifying switches to be be passed to diff. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
70 Used in `smerge-diff-base-mine' and related functions." |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
71 :group 'smerge |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
72 :type '(repeat string)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
73 |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
74 (defcustom smerge-auto-leave t |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
75 "*Non-nil means to leave `smerge-mode' when the last conflict is resolved." |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
76 :group 'smerge |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
77 :type 'boolean) |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
78 |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
79 (defface smerge-mine-face |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
80 '((t (:foreground "blue"))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
81 "Face for your code." |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
82 :group 'smerge) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
83 (defvar smerge-mine-face 'smerge-mine-face) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
84 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
85 (defface smerge-other-face |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
86 '((t (:foreground "darkgreen"))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
87 "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
|
88 :group 'smerge) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
89 (defvar smerge-other-face 'smerge-other-face) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
90 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
91 (defface smerge-base-face |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
92 '((t (:foreground "red"))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
93 "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
|
94 :group 'smerge) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
95 (defvar smerge-base-face 'smerge-base-face) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
96 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
97 (defface smerge-markers-face |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
98 '((t (:background "grey85"))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
99 "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
|
100 :group 'smerge) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
101 (defvar smerge-markers-face 'smerge-markers-face) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
102 |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
103 (easy-mmode-defmap smerge-basic-map |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
104 '(("n" . smerge-next) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
105 ("p" . smerge-prev) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
106 ("a" . smerge-keep-all) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
107 ("b" . smerge-keep-base) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
108 ("o" . smerge-keep-other) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
109 ("m" . smerge-keep-mine) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
110 ("E" . smerge-ediff) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
111 ("\C-m" . smerge-keep-current) |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
112 ("d<" . smerge-diff-base-mine) |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
113 ("d>" . smerge-diff-base-other) |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
114 ("d=" . 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
|
115 "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
|
116 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
117 (defcustom smerge-command-prefix "\e" |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
118 "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
|
119 :group 'smerge |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
120 :type '(choice (string "\e") (string "C-x^") (string "") string)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
121 |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
122 (easy-mmode-defmap smerge-mode-map |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
123 `((,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
|
124 "Keymap for `smerge-mode'.") |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
125 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
126 (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
|
127 "Menu for `smerge-mode'." |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
128 '("SMerge" |
30358 | 129 ["Next" smerge-next :help "Go to next conflict"] |
130 ["Previous" smerge-prev :help "Go to previous'th conflict"] | |
131 ["Keep All" smerge-keep-all :help "Keep all three versions"] | |
132 ["Revert to Base" smerge-keep-base :help "Revert to base version"] | |
133 ["Keep Other" smerge-keep-other :help "Keep `other' version"] | |
134 ["Keep Yours" smerge-keep-mine :help "Keep your version"] | |
135 ["Keep Current" smerge-keep-current | |
136 :help "Use current (at point) version"] | |
137 "--" | |
138 ["Diff Base/Mine" smerge-diff-base-mine | |
139 :help "Diff `base' and `mine' for current conflict"] | |
140 ["Diff Base/Other" smerge-diff-base-other | |
141 :help "Diff `base' and `other' for current conflict"] | |
142 ["Diff Mine/Other" smerge-diff-mine-other | |
143 :help "Diff `mine' and `other' for current conflict"] | |
144 "--" | |
145 ["Invoke Ediff" smerge-ediff | |
146 :help "Use Ediff to resolve the conflicts"] | |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
147 )) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
148 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
149 (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
|
150 '((smerge-find-conflict |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
151 (1 smerge-mine-face prepend) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
152 (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
|
153 (3 smerge-other-face prepend t) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
154 (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
|
155 (4 nil t t) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
156 (5 nil t t))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
157 "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
|
158 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
159 (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
|
160 (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
|
161 (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
|
162 (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
|
163 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
164 (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
|
165 "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
|
166 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
|
167 - `diff3-E' |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
168 - `diff3-A'") |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
169 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
170 ;; Compiler pacifiers |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
171 (defvar font-lock-mode nil) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
172 (defvar font-lock-keywords nil) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
173 (eval-when-compile |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
174 (unless (fboundp 'font-lock-fontify-region) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
175 (autoload 'font-lock-fontify-region "font-lock"))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
176 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
177 ;;;; |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
178 ;;;; Actual code |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
179 ;;;; |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
180 |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
181 ;; Define smerge-next and smerge-prev |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
182 (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
|
183 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
184 (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
|
185 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
186 (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
|
187 (unless (match-end n) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
188 (error (format "No `%s'" (aref smerge-match-names n))))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
189 |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
190 (defun smerge-auto-leave () |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
191 (when (and smerge-auto-leave |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
192 (save-excursion (goto-char (point-min)) |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
193 (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
|
194 (smerge-mode -1))) |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
195 |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
196 |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
197 (defun smerge-keep-all () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
198 "Keep all three versions. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
199 Convenient for the kind of conflicts that can arise in ChangeLog files." |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
200 (interactive) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
201 (smerge-match-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
202 (replace-match (concat (or (match-string 1) "") |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
203 (or (match-string 2) "") |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
204 (or (match-string 3) "")) |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
205 t t) |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
206 (smerge-auto-leave)) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
207 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
208 (defun smerge-keep-base () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
209 "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
|
210 (interactive) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
211 (smerge-match-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
212 (smerge-ensure-match 2) |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
213 (replace-match (match-string 2) t t) |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
214 (smerge-auto-leave)) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
215 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
216 (defun smerge-keep-other () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
217 "Use \"other\" version." |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
218 (interactive) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
219 (smerge-match-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
220 ;;(smerge-ensure-match 3) |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
221 (replace-match (match-string 3) t t) |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
222 (smerge-auto-leave)) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
223 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
224 (defun smerge-keep-mine () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
225 "Keep your version." |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
226 (interactive) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
227 (smerge-match-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
228 ;;(smerge-ensure-match 1) |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
229 (replace-match (match-string 1) t t) |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
230 (smerge-auto-leave)) |
26776
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 (defun smerge-keep-current () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
233 "Use the current (under the cursor) version." |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
234 (interactive) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
235 (smerge-match-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
236 (let ((i 3)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
237 (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
|
238 (< (point) (match-beginning i)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
239 (>= (point) (match-end i))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
240 (decf i)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
241 (if (<= i 0) (error "Not inside a version") |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
242 (replace-match (match-string i) t t) |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
243 (smerge-auto-leave)))) |
26776
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 (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
|
246 "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
|
247 (interactive) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
248 (smerge-diff 2 1)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
249 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
250 (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
|
251 "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
|
252 (interactive) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
253 (smerge-diff 2 3)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
254 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
255 (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
|
256 "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
|
257 (interactive) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
258 (smerge-diff 1 3)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
259 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
260 (defun smerge-match-conflict () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
261 "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
|
262 The submatches contain: |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
263 0: the whole conflict. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
264 1: your code. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
265 2: the base code. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
266 3: other code. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
267 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
|
268 (save-excursion |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
269 (condition-case nil |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
270 (let* ((orig-point (point)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
271 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
272 (_ (forward-line 1)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
273 (_ (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
|
274 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
275 (start (match-beginning 0)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
276 (mine-start (match-end 0)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
277 (filename (match-string 1)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
278 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
279 (_ (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
|
280 (_ (assert (< orig-point (match-end 0)))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
281 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
282 (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
|
283 (end (match-end 0)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
284 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
285 (_ (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
|
286 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
287 (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
|
288 (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
|
289 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
290 base-start base-end) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
291 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
292 ;; 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
|
293 (cond |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
294 ((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
|
295 ;; a 3-parts conflict |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
296 (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
|
297 (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
|
298 (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
|
299 (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
|
300 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
301 ((string= filename (file-name-nondirectory |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
302 (or buffer-file-name ""))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
303 ;; a 2-parts conflict |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
304 (set (make-local-variable 'smerge-conflict-style) 'diff3-E)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
305 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
306 ((and (not base-start) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
307 (or (eq smerge-conflict-style 'diff3-A) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
308 (string-match "^[.0-9]+\\'" filename))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
309 ;; a same-diff conflict |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
310 (setq base-start mine-start) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
311 (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
|
312 (setq mine-start other-start) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
313 (setq mine-end other-end))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
314 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
315 (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
|
316 mine-start mine-end |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
317 base-start base-end |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
318 other-start other-end |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
319 (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
|
320 (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
|
321 t) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
322 (error "Point not in conflict region")))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
323 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
324 (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
|
325 "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
|
326 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
|
327 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
|
328 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
|
329 (when (re-search-forward smerge-begin-re limit t) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
330 (ignore-errors |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
331 (smerge-match-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
332 (goto-char (match-end 0))))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
333 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
334 (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
|
335 (smerge-match-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
336 (smerge-ensure-match n1) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
337 (smerge-ensure-match n2) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
338 (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
|
339 (name2 (aref smerge-match-names n2)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
340 (file1 (make-temp-file "smerge1")) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
341 (file2 (make-temp-file "smerge2"))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
342 (write-region (match-beginning n1) (match-end n1) file1) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
343 (write-region (match-beginning n2) (match-end n2) file2) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
344 (unwind-protect |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
345 (with-current-buffer (get-buffer-create smerge-diff-buffer-name) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
346 (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
|
347 (erase-buffer) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
348 (apply 'call-process diff-command nil t nil |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
349 (append smerge-diff-switches |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
350 (list "-L" name1 "-L" name2 file1 file2)))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
351 (goto-char (point-min)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
352 (diff-mode) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
353 (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
|
354 (delete-file file1) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
355 (delete-file file2)))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
356 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
357 (eval-when-compile |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
358 ;; compiler pacifiers |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
359 (defvar smerge-ediff-windows) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
360 (defvar smerge-ediff-buf) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
361 (defvar ediff-buffer-A) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
362 (defvar ediff-buffer-B) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
363 (defvar ediff-buffer-C) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
364 (unless (fboundp 'ediff-cleanup-mess) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
365 (autoload 'ediff-cleanup-mess "ediff-util"))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
366 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
367 (defun smerge-ediff () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
368 "Invoke ediff to resolve the conflicts." |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
369 (interactive) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
370 (let* ((buf (current-buffer)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
371 (mode major-mode) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
372 ;;(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
|
373 (config (current-window-configuration)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
374 (filename (file-name-nondirectory buffer-file-name)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
375 (mine (generate-new-buffer (concat "*" filename " MINE*"))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
376 (other (generate-new-buffer (concat "*" filename " OTHER*"))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
377 base) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
378 (with-current-buffer mine |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
379 (buffer-disable-undo) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
380 (insert-buffer-substring buf) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
381 (goto-char (point-min)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
382 (while (smerge-find-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
383 (when (match-beginning 2) (setq base t)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
384 (replace-match (match-string 1) t t)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
385 (buffer-enable-undo) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
386 (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
|
387 (funcall mode)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
388 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
389 (with-current-buffer other |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
390 (buffer-disable-undo) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
391 (insert-buffer-substring buf) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
392 (goto-char (point-min)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
393 (while (smerge-find-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
394 (replace-match (match-string 3) t t)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
395 (buffer-enable-undo) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
396 (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
|
397 (funcall mode)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
398 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
399 (when base |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
400 (setq base (generate-new-buffer (concat "*" filename " BASE*"))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
401 (with-current-buffer base |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
402 (buffer-disable-undo) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
403 (insert-buffer-substring buf) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
404 (goto-char (point-min)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
405 (while (smerge-find-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
406 (replace-match (or (match-string 2) "") t t)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
407 (buffer-enable-undo) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
408 (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
|
409 (funcall mode))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
410 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
411 ;; 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
|
412 ;; Fire up ediff. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
413 (set-buffer |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
414 (if base |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
415 (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
|
416 ;; 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
|
417 (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
|
418 ;; nil 'ediff-merge-revisions buffer-file-name))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
419 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
420 ;; 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
|
421 ;; 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
|
422 (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
|
423 (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
|
424 (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
|
425 (lambda () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
426 (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
|
427 (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
|
428 (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
|
429 (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
|
430 (buf smerge-ediff-buf) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
431 (windows smerge-ediff-windows)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
432 (ediff-cleanup-mess) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
433 (with-current-buffer buf |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
434 (erase-buffer) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
435 (insert-buffer buffer-C) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
436 (kill-buffer buffer-A) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
437 (kill-buffer buffer-B) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
438 (kill-buffer buffer-C) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
439 (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
|
440 (set-window-configuration windows) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
441 (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
|
442 (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
|
443 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
444 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
445 ;;;###autoload |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
446 (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
|
447 "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
|
448 \\{smerge-mode-map}" |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
449 nil " SMerge" nil |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
450 (when font-lock-mode |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
451 (save-excursion |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
452 (if smerge-mode |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
453 (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
|
454 (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
|
455 (goto-char (point-min)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
456 (while (smerge-find-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
457 (font-lock-fontify-region (match-beginning 0) (match-end 0) nil))))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
458 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
459 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
460 (provide 'smerge-mode) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
461 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
462 ;;; Change Log: |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
463 ;; $Log: smerge-mode.el,v $ |
30358 | 464 ;; Revision 1.3 2000/05/25 18:08:26 fx |
465 ;; (smerge-diff-switches): Don't use list* in defcustom. | |
466 ;; | |
29207
6c4e371d4efd
(smerge-diff-switches): Don't use list* in defcustom.
Dave Love <fx@gnu.org>
parents:
28248
diff
changeset
|
467 ;; Revision 1.2 2000/03/22 00:54:55 monnier |
6c4e371d4efd
(smerge-diff-switches): Don't use list* in defcustom.
Dave Love <fx@gnu.org>
parents:
28248
diff
changeset
|
468 ;; (smerge-auto-leave): New function and variable. |
6c4e371d4efd
(smerge-diff-switches): Don't use list* in defcustom.
Dave Love <fx@gnu.org>
parents:
28248
diff
changeset
|
469 ;; (smerge-basic-map): Rename from smerge-basic-keymap. |
6c4e371d4efd
(smerge-diff-switches): Don't use list* in defcustom.
Dave Love <fx@gnu.org>
parents:
28248
diff
changeset
|
470 ;; Change the bindings for smerge-diff-*. |
6c4e371d4efd
(smerge-diff-switches): Don't use list* in defcustom.
Dave Love <fx@gnu.org>
parents:
28248
diff
changeset
|
471 ;; (smerge-*-map): Use easy-mmode-defmap. |
6c4e371d4efd
(smerge-diff-switches): Don't use list* in defcustom.
Dave Love <fx@gnu.org>
parents:
28248
diff
changeset
|
472 ;; (smerge-(next|prev)): Use easy-mmode-define-navigation. |
6c4e371d4efd
(smerge-diff-switches): Don't use list* in defcustom.
Dave Love <fx@gnu.org>
parents:
28248
diff
changeset
|
473 ;; (smerge-keep-*): Use smerge-auto-leave. |
6c4e371d4efd
(smerge-diff-switches): Don't use list* in defcustom.
Dave Love <fx@gnu.org>
parents:
28248
diff
changeset
|
474 ;; |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
475 ;; Revision 1.1 1999/12/09 13:00:21 monnier |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
476 ;; New file. Provides a simple minor-mode for files containing |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
477 ;; diff3-style conflict markers, such as generated by RCS |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
478 ;; |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
479 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
480 ;;; smerge-mode.el ends here |