summaryrefslogtreecommitdiff
path: root/lisp/vc/smerge-mode.el
diff options
context:
space:
mode:
authorDavid Kastrup <dak@gnu.org>2013-11-25 10:40:31 -0500
committerStefan Monnier <monnier@iro.umontreal.ca>2013-11-25 10:40:31 -0500
commit5f5b128d48afce520ddb675849224977ea253294 (patch)
tree63159e98cc0a3721cac6e2104a93d195004c9b73 /lisp/vc/smerge-mode.el
parent623891e5c6643587e7a61dea25aacdc470a4d866 (diff)
downloademacs-5f5b128d48afce520ddb675849224977ea253294.tar.gz
* lisp/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.
Diffstat (limited to 'lisp/vc/smerge-mode.el')
-rw-r--r--lisp/vc/smerge-mode.el29
1 files changed, 23 insertions, 6 deletions
diff --git a/lisp/vc/smerge-mode.el b/lisp/vc/smerge-mode.el
index 87336b6a357..25e9f82345d 100644
--- a/lisp/vc/smerge-mode.el
+++ b/lisp/vc/smerge-mode.el
@@ -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)