aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/smerge-mode.el
diff options
context:
space:
mode:
authorStefan Monnier <[email protected]>2008-02-13 15:10:57 +0000
committerStefan Monnier <[email protected]>2008-02-13 15:10:57 +0000
commit02dfeba8a4ce93dadd7f5fa7f462fca12fdf28f8 (patch)
tree6f3af2c8cce69d443906f83ed834d82ec34b4a2f /lisp/smerge-mode.el
parent78dc87a23feb2a1a5d5dc0c2a5abc3a310493dcf (diff)
(smerge-auto-combine-max-separation): New var.
(smerge-auto-combine): New fun.
Diffstat (limited to 'lisp/smerge-mode.el')
-rw-r--r--lisp/smerge-mode.el21
1 files changed, 21 insertions, 0 deletions
diff --git a/lisp/smerge-mode.el b/lisp/smerge-mode.el
index f2a7a9caf9..8a3f15bac4 100644
--- a/lisp/smerge-mode.el
+++ b/lisp/smerge-mode.el
@@ -297,6 +297,8 @@ Can be nil if the style is undecided, or else:
(defun smerge-combine-with-next ()
"Combine the current conflict with the next one."
+ ;; `smerge-auto-combine' relies on the finish position (at the beginning
+ ;; of the closing marker).
(interactive)
(smerge-match-conflict)
(let ((ends nil))
@@ -328,6 +330,25 @@ Can be nil if the style is undecided, or else:
(dolist (m match-data) (if m (move-marker m nil)))
(mapc (lambda (m) (if m (move-marker m nil))) ends)))))
+(defvar smerge-auto-combine-max-separation 2
+ "Max number of lines between conflicts that should be combined.")
+
+(defun smerge-auto-combine ()
+ "Automatically combine conflicts that are near each other."
+ (interactive)
+ (save-excursion
+ (goto-char (point-min))
+ (while (smerge-find-conflict)
+ ;; 2 is 1 (default) + 1 (the begin markers).
+ (while (save-excursion
+ (smerge-find-conflict
+ (line-beginning-position
+ (+ 2 smerge-auto-combine-max-separation))))
+ (forward-line -1) ;Go back inside the conflict.
+ (smerge-combine-with-next)
+ (forward-line 1) ;Move past the end of the conflict.
+ ))))
+
(defvar smerge-resolve-function
(lambda () (error "Don't know how to resolve"))
"Mode-specific merge function.