+2013-11-23 David Kastrup <dak@gnu.org>
+
+ * vc/smerge-mode.el (smerge-ediff): Choose default buffer names based
+ on the conflict markers when available.
+ (smerge--get-marker): New function.
+ (smerge-end-re, smerge-base-re): Add subgroup.
+
2013-11-25 Stefan Monnier <monnier@iro.umontreal.ca>
* frame.el (handle-focus-in, handle-focus-out): Add missing
"Font lock patterns for `smerge-mode'.")
(defconst smerge-begin-re "^<<<<<<< \\(.*\\)\n")
-(defconst smerge-end-re "^>>>>>>> .*\n")
-(defconst smerge-base-re "^||||||| .*\n")
+(defconst smerge-end-re "^>>>>>>> \\(.*\\)\n")
+(defconst smerge-base-re "^||||||| \\(.*\\)\n")
(defconst smerge-other-re "^=======\n")
(defvar smerge-conflict-style nil
(defvar ediff-quit-hook)
(declare-function ediff-cleanup-mess "ediff-util" nil)
+(defun smerge--get-marker (regexp default)
+ (save-excursion
+ (goto-char (point-min))
+ (if (and (search-forward-regexp regexp nil t)
+ (> (match-end 1) (match-beginning 1)))
+ (concat default "=" (match-string-no-properties 1))
+ default)))
+
;;;###autoload
(defun smerge-ediff (&optional name-mine name-other name-base)
"Invoke ediff to resolve the conflicts.
(mode major-mode)
;;(ediff-default-variant 'default-B)
(config (current-window-configuration))
- (filename (file-name-nondirectory buffer-file-name))
+ (filename (file-name-nondirectory (or buffer-file-name "-")))
(mine (generate-new-buffer
- (or name-mine (concat "*" filename " MINE*"))))
+ (or name-mine
+ (concat "*" filename " "
+ (smerge--get-marker smerge-begin-re "MINE")
+ "*"))))
(other (generate-new-buffer
- (or name-other (concat "*" filename " OTHER*"))))
+ (or name-other
+ (concat "*" filename " "
+ (smerge--get-marker smerge-end-re "OTHER")
+ "*"))))
base)
(with-current-buffer mine
(buffer-disable-undo)
(when base
(setq base (generate-new-buffer
- (or name-base (concat "*" filename " BASE*"))))
+ (or name-base
+ (concat "*" filename " "
+ (smerge--get-marker smerge-base-re "BASE")
+ "*"))))
(with-current-buffer base
(buffer-disable-undo)
(insert-buffer-substring buf)