(diff-default-read-only): Change default.
[emacs.git] / lisp / smerge-mode.el
blob9778bb35b012916b922507da34dc74cc23f9fdb5
1 ;;; smerge-mode.el --- Minor mode to resolve diff3 conflicts
3 ;; Copyright (C) 1999, 2000, 01, 03, 2004 Free Software Foundation, Inc.
5 ;; Author: Stefan Monnier <monnier@cs.yale.edu>
6 ;; Keywords: revision-control merge diff3 cvs conflict
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
25 ;;; Commentary:
27 ;; Provides a lightweight alternative to emerge/ediff.
28 ;; To use it, simply add to your .emacs the following lines:
30 ;; (autoload 'smerge-mode "smerge-mode" nil t)
32 ;; you can even have it turned on automatically with the following
33 ;; piece of code in your .emacs:
35 ;; (defun sm-try-smerge ()
36 ;; (save-excursion
37 ;; (goto-char (point-min))
38 ;; (when (re-search-forward "^<<<<<<< " nil t)
39 ;; (smerge-mode 1))))
40 ;; (add-hook 'find-file-hook 'sm-try-smerge t)
42 ;;; Todo:
44 ;; - if requested, ask the user whether he wants to call ediff right away
46 ;;; Code:
48 (eval-when-compile (require 'cl))
51 (defgroup smerge ()
52 "Minor mode to resolve diff3 conflicts."
53 :group 'tools
54 :prefix "smerge-")
56 (defcustom smerge-diff-buffer-name "*vc-diff*"
57 "Buffer name to use for displaying diffs."
58 :group 'smerge
59 :type '(choice
60 (const "*vc-diff*")
61 (const "*cvs-diff*")
62 (const "*smerge-diff*")
63 string))
65 (defcustom smerge-diff-switches
66 (append '("-d" "-b")
67 (if (listp diff-switches) diff-switches (list diff-switches)))
68 "*A list of strings specifying switches to be be passed to diff.
69 Used in `smerge-diff-base-mine' and related functions."
70 :group 'smerge
71 :type '(repeat string))
73 (defcustom smerge-auto-leave t
74 "*Non-nil means to leave `smerge-mode' when the last conflict is resolved."
75 :group 'smerge
76 :type 'boolean)
78 (defface smerge-mine-face
79 '((((background light))
80 (:foreground "blue"))
81 (((background dark))
82 (:foreground "cyan")))
83 "Face for your code."
84 :group 'smerge)
85 (defvar smerge-mine-face 'smerge-mine-face)
87 (defface smerge-other-face
88 '((((background light))
89 (:foreground "darkgreen"))
90 (((background dark))
91 (:foreground "lightgreen")))
92 "Face for the other code."
93 :group 'smerge)
94 (defvar smerge-other-face 'smerge-other-face)
96 (defface smerge-base-face
97 '((((background light))
98 (:foreground "red"))
99 (((background dark))
100 (:foreground "orange")))
101 "Face for the base code."
102 :group 'smerge)
103 (defvar smerge-base-face 'smerge-base-face)
105 (defface smerge-markers-face
106 '((((background light))
107 (:background "grey85"))
108 (((background dark))
109 (:background "grey30")))
110 "Face for the conflict markers."
111 :group 'smerge)
112 (defvar smerge-markers-face 'smerge-markers-face)
114 (easy-mmode-defmap smerge-basic-map
115 `(("n" . smerge-next)
116 ("p" . smerge-prev)
117 ("r" . smerge-resolve)
118 ("a" . smerge-keep-all)
119 ("b" . smerge-keep-base)
120 ("o" . smerge-keep-other)
121 ("m" . smerge-keep-mine)
122 ("E" . smerge-ediff)
123 ("\C-m" . smerge-keep-current)
124 ("=" . ,(make-sparse-keymap "Diff"))
125 ("=<" "base-mine" . smerge-diff-base-mine)
126 ("=>" "base-other" . smerge-diff-base-other)
127 ("==" "mine-other" . smerge-diff-mine-other))
128 "The base keymap for `smerge-mode'.")
130 (defcustom smerge-command-prefix "\C-c^"
131 "Prefix for `smerge-mode' commands."
132 :group 'smerge
133 :type '(choice (string "\e") (string "\C-c^") (string "") string))
135 (easy-mmode-defmap smerge-mode-map
136 `((,smerge-command-prefix . ,smerge-basic-map))
137 "Keymap for `smerge-mode'.")
139 (defvar smerge-check-cache nil)
140 (make-variable-buffer-local 'smerge-check-cache)
141 (defun smerge-check (n)
142 (condition-case nil
143 (let ((state (cons (point) (buffer-modified-tick))))
144 (unless (equal (cdr smerge-check-cache) state)
145 (smerge-match-conflict)
146 (setq smerge-check-cache (cons (match-data) state)))
147 (nth (* 2 n) (car smerge-check-cache)))
148 (error nil)))
150 (easy-menu-define smerge-mode-menu smerge-mode-map
151 "Menu for `smerge-mode'."
152 '("SMerge"
153 ["Next" smerge-next :help "Go to next conflict"]
154 ["Previous" smerge-prev :help "Go to previous conflict"]
155 "--"
156 ["Keep All" smerge-keep-all :help "Keep all three versions"
157 :active (smerge-check 1)]
158 ["Keep Current" smerge-keep-current :help "Use current (at point) version"
159 :active (and (smerge-check 1) (> (smerge-get-current) 0))]
160 "--"
161 ["Revert to Base" smerge-keep-base :help "Revert to base version"
162 :active (smerge-check 2)]
163 ["Keep Other" smerge-keep-other :help "Keep `other' version"
164 :active (smerge-check 3)]
165 ["Keep Yours" smerge-keep-mine :help "Keep your version"
166 :active (smerge-check 1)]
167 "--"
168 ["Diff Base/Mine" smerge-diff-base-mine
169 :help "Diff `base' and `mine' for current conflict"
170 :active (smerge-check 2)]
171 ["Diff Base/Other" smerge-diff-base-other
172 :help "Diff `base' and `other' for current conflict"
173 :active (smerge-check 2)]
174 ["Diff Mine/Other" smerge-diff-mine-other
175 :help "Diff `mine' and `other' for current conflict"
176 :active (smerge-check 1)]
177 "--"
178 ["Invoke Ediff" smerge-ediff
179 :help "Use Ediff to resolve the conflicts"
180 :active (smerge-check 1)]
181 ["Auto Resolve" smerge-resolve
182 :help "Try auto-resolution heuristics"
183 :active (smerge-check 1)]
184 ["Combine" smerge-combine-with-next
185 :help "Combine current conflict with next"
186 :active (smerge-check 1)]
189 (easy-menu-define smerge-context-menu nil
190 "Context menu for mine area in `smerge-mode'."
191 '(nil
192 ["Keep Current" smerge-keep-current :help "Use current (at point) version"]
193 ["Kill Current" smerge-kill-current :help "Remove current (at point) version"]
194 ["Keep All" smerge-keep-all :help "Keep all three versions"]
195 "---"
196 ["More..." (popup-menu smerge-mode-menu) :help "Show full SMerge mode menu"]
199 (defconst smerge-font-lock-keywords
200 '((smerge-find-conflict
201 (1 smerge-mine-face prepend t)
202 (2 smerge-base-face prepend t)
203 (3 smerge-other-face prepend t)
204 ;; FIXME: `keep' doesn't work right with syntactic fontification.
205 (0 smerge-markers-face keep)
206 (4 nil t t)
207 (5 nil t t)))
208 "Font lock patterns for `smerge-mode'.")
210 (defconst smerge-begin-re "^<<<<<<< \\(.*\\)\n")
211 (defconst smerge-end-re "^>>>>>>> .*\n")
212 (defconst smerge-base-re "^||||||| .*\n")
213 (defconst smerge-other-re "^=======\n")
215 (defvar smerge-conflict-style nil
216 "Keep track of which style of conflict is in use.
217 Can be nil if the style is undecided, or else:
218 - `diff3-E'
219 - `diff3-A'")
221 ;; Compiler pacifiers
222 (defvar font-lock-mode)
223 (defvar font-lock-keywords)
225 ;;;;
226 ;;;; Actual code
227 ;;;;
229 ;; Define smerge-next and smerge-prev
230 (easy-mmode-define-navigation smerge smerge-begin-re "conflict")
232 (defconst smerge-match-names ["conflict" "mine" "base" "other"])
234 (defun smerge-ensure-match (n)
235 (unless (match-end n)
236 (error (format "No `%s'" (aref smerge-match-names n)))))
238 (defun smerge-auto-leave ()
239 (when (and smerge-auto-leave
240 (save-excursion (goto-char (point-min))
241 (not (re-search-forward smerge-begin-re nil t))))
242 (smerge-mode -1)))
245 (defun smerge-keep-all ()
246 "Concatenate all versions."
247 (interactive)
248 (smerge-match-conflict)
249 (let ((mb2 (or (match-beginning 2) (point-max)))
250 (me2 (or (match-end 2) (point-min))))
251 (delete-region (match-end 3) (match-end 0))
252 (delete-region (max me2 (match-end 1)) (match-beginning 3))
253 (if (and (match-end 2) (/= (match-end 1) (match-end 3)))
254 (delete-region (match-end 1) (match-beginning 2)))
255 (delete-region (match-beginning 0) (min (match-beginning 1) mb2))
256 (smerge-auto-leave)))
258 (defun smerge-keep-n (n)
259 ;; We used to use replace-match, but that did not preserve markers so well.
260 (delete-region (match-end n) (match-end 0))
261 (delete-region (match-beginning 0) (match-beginning n)))
263 (defun smerge-combine-with-next ()
264 "Combine the current conflict with the next one."
265 (interactive)
266 (smerge-match-conflict)
267 (let ((ends nil))
268 (dolist (i '(3 2 1 0))
269 (push (if (match-end i) (copy-marker (match-end i) t)) ends))
270 (setq ends (apply 'vector ends))
271 (goto-char (aref ends 0))
272 (if (not (re-search-forward smerge-begin-re nil t))
273 (error "No next conflict")
274 (smerge-match-conflict)
275 (let ((match-data (mapcar (lambda (m) (if m (copy-marker m)))
276 (match-data))))
277 ;; First copy the in-between text in each alternative.
278 (dolist (i '(1 2 3))
279 (when (aref ends i)
280 (goto-char (aref ends i))
281 (insert-buffer-substring (current-buffer)
282 (aref ends 0) (car match-data))))
283 (delete-region (aref ends 0) (car match-data))
284 ;; Then move the second conflict's alternatives into the first.
285 (dolist (i '(1 2 3))
286 (set-match-data match-data)
287 (when (and (aref ends i) (match-end i))
288 (goto-char (aref ends i))
289 (insert-buffer-substring (current-buffer)
290 (match-beginning i) (match-end i))))
291 (delete-region (car match-data) (cadr match-data))
292 ;; Free the markers.
293 (dolist (m match-data) (if m (move-marker m nil)))
294 (mapc (lambda (m) (if m (move-marker m nil))) ends)))))
296 (defvar smerge-resolve-function
297 (lambda () (error "Don't know how to resolve"))
298 "Mode-specific merge function.
299 The function is called with no argument and with the match data set
300 according to `smerge-match-conflict'.")
302 (defvar smerge-text-properties
303 `(help-echo "merge conflict: mouse-3 shows a menu"
304 ;; mouse-face highlight
305 keymap (keymap (down-mouse-3 . smerge-popup-context-menu))))
307 (defun smerge-remove-props (&optional beg end)
308 (remove-text-properties
309 (or beg (match-beginning 0))
310 (or end (match-end 0))
311 smerge-text-properties))
313 (defun smerge-popup-context-menu (event)
314 "Pop up the Smerge mode context menu under mouse."
315 (interactive "e")
316 (if (and smerge-mode
317 (save-excursion (mouse-set-point event) (smerge-check 1)))
318 (progn
319 (mouse-set-point event)
320 (smerge-match-conflict)
321 (let ((i (smerge-get-current))
323 (if (<= i 0)
324 ;; Out of range
325 (popup-menu smerge-mode-menu)
326 ;; Install overlay.
327 (setq o (make-overlay (match-beginning i) (match-end i)))
328 (unwind-protect
329 (progn
330 (overlay-put o 'face 'highlight)
331 (sit-for 0) ;Display the new highlighting.
332 (popup-menu smerge-context-menu))
333 ;; Delete overlay.
334 (delete-overlay o)))))
335 ;; There's no conflict at point, the text-props are just obsolete.
336 (save-excursion
337 (let ((beg (re-search-backward smerge-end-re nil t))
338 (end (re-search-forward smerge-begin-re nil t)))
339 (smerge-remove-props (or beg (point-min)) (or end (point-max)))
340 (push event unread-command-events)))))
342 (defun smerge-resolve ()
343 "Resolve the conflict at point intelligently.
344 This relies on mode-specific knowledge and thus only works in
345 some major modes. Uses `smerge-resolve-function' to do the actual work."
346 (interactive)
347 (smerge-match-conflict)
348 (smerge-remove-props)
349 (cond
350 ;; Trivial diff3 -A non-conflicts.
351 ((and (eq (match-end 1) (match-end 3))
352 (eq (match-beginning 1) (match-beginning 3)))
353 ;; FIXME: Add "if [ diff -b MINE OTHER ]; then select OTHER; fi"
354 (smerge-keep-n 3))
355 ((and (match-end 2)
356 ;; FIXME: Add "diff -b BASE MINE | patch OTHER".
357 ;; FIXME: Add "diff -b BASE OTHER | patch MINE".
358 nil)
360 ((and (not (match-end 2))
361 ;; FIXME: Add "diff -b"-based refinement.
362 nil)
365 ;; Mode-specific conflict resolution.
366 (funcall smerge-resolve-function)))
367 (smerge-auto-leave))
369 (defun smerge-keep-base ()
370 "Revert to the base version."
371 (interactive)
372 (smerge-match-conflict)
373 (smerge-ensure-match 2)
374 (smerge-remove-props)
375 (smerge-keep-n 2)
376 (smerge-auto-leave))
378 (defun smerge-keep-other ()
379 "Use \"other\" version."
380 (interactive)
381 (smerge-match-conflict)
382 ;;(smerge-ensure-match 3)
383 (smerge-remove-props)
384 (smerge-keep-n 3)
385 (smerge-auto-leave))
387 (defun smerge-keep-mine ()
388 "Keep your version."
389 (interactive)
390 (smerge-match-conflict)
391 ;;(smerge-ensure-match 1)
392 (smerge-remove-props)
393 (smerge-keep-n 1)
394 (smerge-auto-leave))
396 (defun smerge-get-current ()
397 (let ((i 3))
398 (while (or (not (match-end i))
399 (< (point) (match-beginning i))
400 (>= (point) (match-end i)))
401 (decf i))
404 (defun smerge-keep-current ()
405 "Use the current (under the cursor) version."
406 (interactive)
407 (smerge-match-conflict)
408 (let ((i (smerge-get-current)))
409 (if (<= i 0) (error "Not inside a version")
410 (smerge-remove-props)
411 (smerge-keep-n i)
412 (smerge-auto-leave))))
414 (defun smerge-kill-current ()
415 "Remove the current (under the cursor) version."
416 (interactive)
417 (smerge-match-conflict)
418 (let ((i (smerge-get-current)))
419 (if (<= i 0) (error "Not inside a version")
420 (smerge-remove-props)
421 (let ((left nil))
422 (dolist (n '(3 2 1))
423 (if (and (match-end n) (/= (match-end n) (match-end i)))
424 (push n left)))
425 (if (and (cdr left)
426 (/= (match-end (car left)) (match-end (cadr left))))
427 (ding) ;We don't know how to do that.
428 (smerge-keep-n (car left))
429 (smerge-auto-leave))))))
431 (defun smerge-diff-base-mine ()
432 "Diff 'base' and 'mine' version in current conflict region."
433 (interactive)
434 (smerge-diff 2 1))
436 (defun smerge-diff-base-other ()
437 "Diff 'base' and 'other' version in current conflict region."
438 (interactive)
439 (smerge-diff 2 3))
441 (defun smerge-diff-mine-other ()
442 "Diff 'mine' and 'other' version in current conflict region."
443 (interactive)
444 (smerge-diff 1 3))
446 (defun smerge-match-conflict ()
447 "Get info about the conflict. Puts the info in the `match-data'.
448 The submatches contain:
449 0: the whole conflict.
450 1: your code.
451 2: the base code.
452 3: other code.
453 An error is raised if not inside a conflict."
454 (save-excursion
455 (condition-case nil
456 (let* ((orig-point (point))
458 (_ (forward-line 1))
459 (_ (re-search-backward smerge-begin-re))
461 (start (match-beginning 0))
462 (mine-start (match-end 0))
463 (filename (or (match-string 1) ""))
465 (_ (re-search-forward smerge-end-re))
466 (_ (assert (< orig-point (match-end 0))))
468 (other-end (match-beginning 0))
469 (end (match-end 0))
471 (_ (re-search-backward smerge-other-re start))
473 (mine-end (match-beginning 0))
474 (other-start (match-end 0))
476 base-start base-end)
478 ;; handle the various conflict styles
479 (cond
480 ((re-search-backward smerge-base-re start t)
481 ;; a 3-parts conflict
482 (set (make-local-variable 'smerge-conflict-style) 'diff3-A)
483 (setq base-end mine-end)
484 (setq mine-end (match-beginning 0))
485 (setq base-start (match-end 0)))
487 ((string= filename (file-name-nondirectory
488 (or buffer-file-name "")))
489 ;; a 2-parts conflict
490 (set (make-local-variable 'smerge-conflict-style) 'diff3-E))
492 ((and (not base-start)
493 (or (eq smerge-conflict-style 'diff3-A)
494 (equal filename "ANCESTOR")
495 (string-match "\\`[.0-9]+\\'" filename)))
496 ;; a same-diff conflict
497 (setq base-start mine-start)
498 (setq base-end mine-end)
499 (setq mine-start other-start)
500 (setq mine-end other-end)))
502 (let ((inhibit-read-only t)
503 (inhibit-modification-hooks t)
504 (m (buffer-modified-p)))
505 (unwind-protect
506 (add-text-properties start end smerge-text-properties)
507 (restore-buffer-modified-p m)))
509 (store-match-data (list start end
510 mine-start mine-end
511 base-start base-end
512 other-start other-end
513 (when base-start (1- base-start)) base-start
514 (1- other-start) other-start))
516 (search-failed (error "Point not in conflict region")))))
518 (defun smerge-find-conflict (&optional limit)
519 "Find and match a conflict region. Intended as a font-lock MATCHER.
520 The submatches are the same as in `smerge-match-conflict'.
521 Returns non-nil if a match is found between the point and LIMIT.
522 The point is moved to the end of the conflict."
523 (when (re-search-forward smerge-begin-re limit t)
524 (ignore-errors
525 (smerge-match-conflict)
526 (goto-char (match-end 0)))))
528 (defun smerge-diff (n1 n2)
529 (smerge-match-conflict)
530 (smerge-ensure-match n1)
531 (smerge-ensure-match n2)
532 (let ((name1 (aref smerge-match-names n1))
533 (name2 (aref smerge-match-names n2))
534 ;; Read them before the match-data gets clobbered.
535 (beg1 (match-beginning n1))
536 (end1 (match-end n1))
537 (beg2 (match-beginning n2))
538 (end2 (match-end n2))
539 (file1 (make-temp-file "smerge1"))
540 (file2 (make-temp-file "smerge2"))
541 (dir default-directory)
542 (file (file-relative-name buffer-file-name))
543 (coding-system-for-read buffer-file-coding-system))
544 (write-region beg1 end1 file1 nil 'nomessage)
545 (write-region beg2 end2 file2 nil 'nomessage)
546 (unwind-protect
547 (with-current-buffer (get-buffer-create smerge-diff-buffer-name)
548 (setq default-directory dir)
549 (let ((inhibit-read-only t))
550 (erase-buffer)
551 (let ((status
552 (apply 'call-process diff-command nil t nil
553 (append smerge-diff-switches
554 (list "-L" (concat name1 "/" file)
555 "-L" (concat name2 "/" file)
556 file1 file2)))))
557 (if (eq status 0) (insert "No differences found.\n"))))
558 (goto-char (point-min))
559 (diff-mode)
560 (display-buffer (current-buffer) t))
561 (delete-file file1)
562 (delete-file file2))))
564 ;; compiler pacifiers
565 (defvar smerge-ediff-windows)
566 (defvar smerge-ediff-buf)
567 (defvar ediff-buffer-A)
568 (defvar ediff-buffer-B)
569 (defvar ediff-buffer-C)
571 ;;;###autoload
572 (defun smerge-ediff (&optional name-mine name-other name-base)
573 "Invoke ediff to resolve the conflicts.
574 NAME-MINE, NAME-OTHER, and NAME-BASE, if non-nil, are used for the
575 buffer names."
576 (interactive)
577 (let* ((buf (current-buffer))
578 (mode major-mode)
579 ;;(ediff-default-variant 'default-B)
580 (config (current-window-configuration))
581 (filename (file-name-nondirectory buffer-file-name))
582 (mine (generate-new-buffer
583 (or name-mine (concat "*" filename " MINE*"))))
584 (other (generate-new-buffer
585 (or name-other (concat "*" filename " OTHER*"))))
586 base)
587 (with-current-buffer mine
588 (buffer-disable-undo)
589 (insert-buffer-substring buf)
590 (goto-char (point-min))
591 (while (smerge-find-conflict)
592 (when (match-beginning 2) (setq base t))
593 (smerge-keep-n 1))
594 (buffer-enable-undo)
595 (set-buffer-modified-p nil)
596 (funcall mode))
598 (with-current-buffer other
599 (buffer-disable-undo)
600 (insert-buffer-substring buf)
601 (goto-char (point-min))
602 (while (smerge-find-conflict)
603 (smerge-keep-n 3))
604 (buffer-enable-undo)
605 (set-buffer-modified-p nil)
606 (funcall mode))
608 (when base
609 (setq base (generate-new-buffer
610 (or name-base (concat "*" filename " BASE*"))))
611 (with-current-buffer base
612 (buffer-disable-undo)
613 (insert-buffer-substring buf)
614 (goto-char (point-min))
615 (while (smerge-find-conflict)
616 (if (match-end 2)
617 (smerge-keep-n 2)
618 (delete-region (match-beginning 0) (match-end 0))))
619 (buffer-enable-undo)
620 (set-buffer-modified-p nil)
621 (funcall mode)))
623 ;; the rest of the code is inspired from vc.el
624 ;; Fire up ediff.
625 (set-buffer
626 (if base
627 (ediff-merge-buffers-with-ancestor mine other base)
628 ;; nil 'ediff-merge-revisions-with-ancestor buffer-file-name)
629 (ediff-merge-buffers mine other)))
630 ;; nil 'ediff-merge-revisions buffer-file-name)))
632 ;; Ediff is now set up, and we are in the control buffer.
633 ;; Do a few further adjustments and take precautions for exit.
634 (set (make-local-variable 'smerge-ediff-windows) config)
635 (set (make-local-variable 'smerge-ediff-buf) buf)
636 (set (make-local-variable 'ediff-quit-hook)
637 (lambda ()
638 (let ((buffer-A ediff-buffer-A)
639 (buffer-B ediff-buffer-B)
640 (buffer-C ediff-buffer-C)
641 (buffer-Ancestor ediff-ancestor-buffer)
642 (buf smerge-ediff-buf)
643 (windows smerge-ediff-windows))
644 (ediff-cleanup-mess)
645 (with-current-buffer buf
646 (erase-buffer)
647 (insert-buffer buffer-C)
648 (kill-buffer buffer-A)
649 (kill-buffer buffer-B)
650 (kill-buffer buffer-C)
651 (when (bufferp buffer-Ancestor) (kill-buffer buffer-Ancestor))
652 (set-window-configuration windows)
653 (message "Conflict resolution finished; you may save the buffer")))))
654 (message "Please resolve conflicts now; exit ediff when done")))
657 ;;;###autoload
658 (define-minor-mode smerge-mode
659 "Minor mode to simplify editing output from the diff3 program.
660 \\{smerge-mode-map}"
661 nil " SMerge" nil
662 (when (and (boundp 'font-lock-mode) font-lock-mode)
663 (set (make-local-variable 'font-lock-multiline) t)
664 (save-excursion
665 (if smerge-mode
666 (font-lock-add-keywords nil smerge-font-lock-keywords 'append)
667 (font-lock-remove-keywords nil smerge-font-lock-keywords))
668 (goto-char (point-min))
669 (while (smerge-find-conflict)
670 (save-excursion
671 (font-lock-fontify-region (match-beginning 0) (match-end 0) nil))))))
674 (provide 'smerge-mode)
676 ;;; arch-tag: 605c8d1e-e43d-4943-a6f3-1bcc4333e690
677 ;;; smerge-mode.el ends here