Mercurial > emacs
annotate lisp/smerge-mode.el @ 28913:363038c049d6
(lisp): Add env.elc.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Mon, 15 May 2000 14:47:33 +0000 |
parents | 108ba8d61036 |
children | 6c4e371d4efd |
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 |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
7 ;; Revision: $Id: smerge-mode.el,v 1.1 1999/12/09 13:00:21 monnier Exp $ |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
8 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
9 ;; This file is part of GNU Emacs. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
10 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
11 ;; GNU Emacs is free software; you can redistribute it and/or modify |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
12 ;; it under the terms of the GNU General Public License as published by |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
13 ;; the Free Software Foundation; either version 2, or (at your option) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
14 ;; any later version. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
15 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
16 ;; GNU Emacs is distributed in the hope that it will be useful, |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
19 ;; GNU General Public License for more details. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
20 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
21 ;; You should have received a copy of the GNU General Public License |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
24 ;; Boston, MA 02111-1307, USA. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
25 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
26 ;;; Commentary: |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
27 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
28 ;; Provides a lightweight alternative to emerge/ediff. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
29 ;; To use it, simply add to your .emacs the following lines: |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
30 ;; |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
31 ;; (autoload 'smerge-mode "smerge-mode" nil t) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
32 ;; |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
33 ;; you can even have it turned on automatically with the following |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
34 ;; piece of code in your .emacs: |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
35 ;; |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
36 ;; (defun sm-try-smerge () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
37 ;; (save-excursion |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
38 ;; (goto-char (point-min)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
39 ;; (when (re-search-forward "^<<<<<<< " nil t) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
40 ;; (smerge-mode 1)))) |
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 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
67 (list* "-d" "-b" |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
68 (if (listp diff-switches) diff-switches (list diff-switches))) |
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" |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
129 ["Invoke Ediff" smerge-ediff t] |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
130 )) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
131 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
132 (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
|
133 '((smerge-find-conflict |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
134 (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
|
135 (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
|
136 (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
|
137 (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
|
138 (4 nil t t) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
139 (5 nil t t))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
140 "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
|
141 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
142 (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
|
143 (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
|
144 (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
|
145 (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
|
146 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
147 (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
|
148 "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
|
149 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
|
150 - `diff3-E' |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
151 - `diff3-A'") |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
152 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
153 ;; Compiler pacifiers |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
154 (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
|
155 (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
|
156 (eval-when-compile |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
157 (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
|
158 (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
|
159 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
160 ;;;; |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
161 ;;;; Actual code |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
162 ;;;; |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
163 |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
164 ;; Define smerge-next and smerge-prev |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
165 (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
|
166 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
167 (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
|
168 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
169 (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
|
170 (unless (match-end n) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
171 (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
|
172 |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
173 (defun smerge-auto-leave () |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
174 (when (and smerge-auto-leave |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
175 (save-excursion (goto-char (point-min)) |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
176 (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
|
177 (smerge-mode -1))) |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
178 |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
179 |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
180 (defun smerge-keep-all () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
181 "Keep all three versions. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
182 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
|
183 (interactive) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
184 (smerge-match-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
185 (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
|
186 (or (match-string 2) "") |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
187 (or (match-string 3) "")) |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
188 t t) |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
189 (smerge-auto-leave)) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
190 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
191 (defun smerge-keep-base () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
192 "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
|
193 (interactive) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
194 (smerge-match-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
195 (smerge-ensure-match 2) |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
196 (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
|
197 (smerge-auto-leave)) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
198 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
199 (defun smerge-keep-other () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
200 "Use \"other\" version." |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
201 (interactive) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
202 (smerge-match-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
203 ;;(smerge-ensure-match 3) |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
204 (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
|
205 (smerge-auto-leave)) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
206 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
207 (defun smerge-keep-mine () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
208 "Keep your version." |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
209 (interactive) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
210 (smerge-match-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
211 ;;(smerge-ensure-match 1) |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
212 (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
|
213 (smerge-auto-leave)) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
214 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
215 (defun smerge-keep-current () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
216 "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
|
217 (interactive) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
218 (smerge-match-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
219 (let ((i 3)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
220 (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
|
221 (< (point) (match-beginning i)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
222 (>= (point) (match-end i))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
223 (decf i)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
224 (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
|
225 (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
|
226 (smerge-auto-leave)))) |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
227 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
228 (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
|
229 "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
|
230 (interactive) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
231 (smerge-diff 2 1)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
232 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
233 (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
|
234 "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
|
235 (interactive) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
236 (smerge-diff 2 3)) |
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 (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
|
239 "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
|
240 (interactive) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
241 (smerge-diff 1 3)) |
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 (defun smerge-match-conflict () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
244 "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
|
245 The submatches contain: |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
246 0: the whole conflict. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
247 1: your code. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
248 2: the base code. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
249 3: other code. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
250 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
|
251 (save-excursion |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
252 (condition-case nil |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
253 (let* ((orig-point (point)) |
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 (_ (forward-line 1)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
256 (_ (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
|
257 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
258 (start (match-beginning 0)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
259 (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
|
260 (filename (match-string 1)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
261 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
262 (_ (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
|
263 (_ (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
|
264 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
265 (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
|
266 (end (match-end 0)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
267 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
268 (_ (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
|
269 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
270 (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
|
271 (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
|
272 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
273 base-start base-end) |
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 ;; 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
|
276 (cond |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
277 ((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
|
278 ;; a 3-parts conflict |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
279 (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
|
280 (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
|
281 (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
|
282 (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
|
283 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
284 ((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
|
285 (or buffer-file-name ""))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
286 ;; a 2-parts conflict |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
287 (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
|
288 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
289 ((and (not base-start) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
290 (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
|
291 (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
|
292 ;; a same-diff conflict |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
293 (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
|
294 (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
|
295 (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
|
296 (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
|
297 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
298 (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
|
299 mine-start mine-end |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
300 base-start base-end |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
301 other-start other-end |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
302 (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
|
303 (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
|
304 t) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
305 (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
|
306 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
307 (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
|
308 "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
|
309 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
|
310 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
|
311 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
|
312 (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
|
313 (ignore-errors |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
314 (smerge-match-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
315 (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
|
316 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
317 (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
|
318 (smerge-match-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
319 (smerge-ensure-match n1) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
320 (smerge-ensure-match n2) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
321 (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
|
322 (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
|
323 (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
|
324 (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
|
325 (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
|
326 (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
|
327 (unwind-protect |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
328 (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
|
329 (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
|
330 (erase-buffer) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
331 (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
|
332 (append smerge-diff-switches |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
333 (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
|
334 (goto-char (point-min)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
335 (diff-mode) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
336 (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
|
337 (delete-file file1) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
338 (delete-file file2)))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
339 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
340 (eval-when-compile |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
341 ;; compiler pacifiers |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
342 (defvar smerge-ediff-windows) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
343 (defvar smerge-ediff-buf) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
344 (defvar ediff-buffer-A) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
345 (defvar ediff-buffer-B) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
346 (defvar ediff-buffer-C) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
347 (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
|
348 (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
|
349 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
350 (defun smerge-ediff () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
351 "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
|
352 (interactive) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
353 (let* ((buf (current-buffer)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
354 (mode major-mode) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
355 ;;(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
|
356 (config (current-window-configuration)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
357 (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
|
358 (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
|
359 (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
|
360 base) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
361 (with-current-buffer mine |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
362 (buffer-disable-undo) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
363 (insert-buffer-substring buf) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
364 (goto-char (point-min)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
365 (while (smerge-find-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
366 (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
|
367 (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
|
368 (buffer-enable-undo) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
369 (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
|
370 (funcall mode)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
371 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
372 (with-current-buffer other |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
373 (buffer-disable-undo) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
374 (insert-buffer-substring buf) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
375 (goto-char (point-min)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
376 (while (smerge-find-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
377 (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
|
378 (buffer-enable-undo) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
379 (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
|
380 (funcall mode)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
381 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
382 (when base |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
383 (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
|
384 (with-current-buffer base |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
385 (buffer-disable-undo) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
386 (insert-buffer-substring buf) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
387 (goto-char (point-min)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
388 (while (smerge-find-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
389 (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
|
390 (buffer-enable-undo) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
391 (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
|
392 (funcall mode))) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
393 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
394 ;; 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
|
395 ;; Fire up ediff. |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
396 (set-buffer |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
397 (if base |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
398 (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
|
399 ;; 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
|
400 (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
|
401 ;; 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
|
402 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
403 ;; 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
|
404 ;; 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
|
405 (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
|
406 (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
|
407 (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
|
408 (lambda () |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
409 (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
|
410 (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
|
411 (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
|
412 (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
|
413 (buf smerge-ediff-buf) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
414 (windows smerge-ediff-windows)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
415 (ediff-cleanup-mess) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
416 (with-current-buffer buf |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
417 (erase-buffer) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
418 (insert-buffer buffer-C) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
419 (kill-buffer buffer-A) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
420 (kill-buffer buffer-B) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
421 (kill-buffer buffer-C) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
422 (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
|
423 (set-window-configuration windows) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
424 (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
|
425 (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
|
426 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
427 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
428 ;;;###autoload |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
429 (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
|
430 "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
|
431 \\{smerge-mode-map}" |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
432 nil " SMerge" nil |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
433 (when font-lock-mode |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
434 (save-excursion |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
435 (if smerge-mode |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
436 (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
|
437 (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
|
438 (goto-char (point-min)) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
439 (while (smerge-find-conflict) |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
440 (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
|
441 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
442 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
443 (provide 'smerge-mode) |
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 ;;; Change Log: |
28248
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
446 ;; $Log: smerge-mode.el,v $ |
108ba8d61036
(smerge-auto-leave): New function and variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26776
diff
changeset
|
447 ;; 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
|
448 ;; 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
|
449 ;; 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
|
450 ;; |
26776
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
451 |
142d6aa7c470
New file. Provides a simple minor-mode for files containing
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
452 ;;; smerge-mode.el ends here |