Mercurial > emacs
diff lisp/smerge-mode.el @ 91813:ca1e1298a3d8
(smerge-auto-combine-max-separation): New var.
(smerge-auto-combine): New fun.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Wed, 13 Feb 2008 15:10:57 +0000 |
parents | 8f1628da223f |
children | a6d8268a0da6 |
line wrap: on
line diff
--- a/lisp/smerge-mode.el Tue Feb 12 23:41:59 2008 +0000 +++ b/lisp/smerge-mode.el Wed Feb 13 15:10:57 2008 +0000 @@ -297,6 +297,8 @@ (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 @@ (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.