]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/vc/smerge-mode.el (smerge-ediff): Choose default buffer names based
authorDavid Kastrup <dak@gnu.org>
Mon, 25 Nov 2013 15:40:31 +0000 (10:40 -0500)
committerStefan Monnier <monnier@iro.umontreal.ca>
Mon, 25 Nov 2013 15:40:31 +0000 (10:40 -0500)
on the conflict markers when available.
(smerge--get-marker): New function.
(smerge-end-re, smerge-base-re): Add subgroup.

lisp/ChangeLog
lisp/vc/smerge-mode.el

index f52ca143ba7983edcfdd49281c0bae09beddfe70..7975d6eecbbc36a17c6e6c17684482f023500fd6 100644 (file)
@@ -1,3 +1,10 @@
+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
index 87336b6a357e4542aa03164c47dfeb263eb34e90..25e9f82345d2ed74444ca71467a04e9e9ddac11c 100644 (file)
@@ -243,8 +243,8 @@ Used in `smerge-diff-base-mine' and related functions."
   "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
@@ -1182,6 +1182,14 @@ repeating the command will highlight other two parts."
 (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.
@@ -1192,11 +1200,17 @@ buffer names."
         (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)
@@ -1221,7 +1235,10 @@ buffer names."
 
     (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)