From: David Kastrup <dak@gnu.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: smerge-ediff "MINE" and "OTHER" monikers unhelpful
Date: Sat, 23 Nov 2013 15:07:03 +0100 [thread overview]
Message-ID: <87a9gvnreg.fsf@fencepost.gnu.org> (raw)
In-Reply-To: <jwvy54faobb.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Fri, 22 Nov 2013 20:42:41 -0500")
[-- Attachment #1: Type: text/plain, Size: 619 bytes --]
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> Sounds OK (i.e. patch welcome). Just be careful that diff3 markers
> don't always come with useful "names". Also mine/other is used as
> mnemonic for key-bindings, so the terminology is "deeply" embedded in
> smerge-mode, so maybe we should use "MINE - HEAD" and "OTHER -
> 2c633c8... Issue 3656/2: disambiguate our own ::to_string from
> std::to_string" for the names.
>
> In any case, please make it a bug-report, so we have a number to
> track it.
At any rate, this is what I went with. Feel free to take it; I have a
copyright assignment for Emacs on file.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Let-smerge-mode-choose-default-buffer-names-based-on.patch --]
[-- Type: text/x-diff, Size: 3074 bytes --]
From 05ca072a856d0121422228ec3688a240194d8784 Mon Sep 17 00:00:00 2001
From: David Kastrup <dak@gnu.org>
Date: Sat, 23 Nov 2013 14:53:05 +0100
Subject: [PATCH] Let smerge-mode choose default buffer names based on conflict
markers
* vc/smerge-mode.el (smerge-ediff): Let smerge-mode choose
default buffer names based on the conflict markers when
available.
(smerge-get-marker): New function.
---
lisp/ChangeLog | 7 +++++++
lisp/vc/smerge-mode.el | 24 +++++++++++++++++++-----
2 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 8d2a754..c791fe2 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
+2013-11-23 David Kastrup <dak@gnu.org>
+
+ * vc/smerge-mode.el (smerge-ediff): Let smerge-mode choose
+ default buffer names based on the conflict markers when
+ available.
+ (smerge-get-marker): New function.
+
2013-11-23 Ivan Shmakov <ivan@siamics.net> (tiny change)
* vc/diff-mode.el (diff-mode): Only allow diff-default-read-only
diff --git a/lisp/vc/smerge-mode.el b/lisp/vc/smerge-mode.el
index 87336b6..63ddd13 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)))
+ (match-string-no-properties 1)
+ default)))
+
;;;###autoload
(defun smerge-ediff (&optional name-mine name-other name-base)
"Invoke ediff to resolve the conflicts.
@@ -1194,9 +1202,13 @@ buffer names."
(config (current-window-configuration))
(filename (file-name-nondirectory 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 +1233,9 @@ 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)
--
1.8.3.2
[-- Attachment #3: Type: text/plain, Size: 20 bytes --]
--
David Kastrup
next prev parent reply other threads:[~2013-11-23 14:07 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <87zjowpn2s.fsf@fencepost.gnu.org>
2013-11-23 1:42 ` smerge-ediff "MINE" and "OTHER" monikers unhelpful Stefan Monnier
2013-11-23 6:23 ` David Kastrup
2013-11-23 14:33 ` Stefan Monnier
2013-11-23 15:03 ` David Kastrup
2013-11-23 14:07 ` David Kastrup [this message]
2013-11-25 15:40 ` Stefan Monnier
2013-11-27 10:45 ` David Kastrup
2013-11-27 17:37 ` Stefan Monnier
2013-11-27 18:07 ` David Kastrup
2013-11-27 18:45 ` David Kastrup
2013-11-27 20:46 ` Stefan Monnier
2013-11-27 20:54 ` David Kastrup
2013-11-28 8:44 ` Thien-Thi Nguyen
2013-11-28 18:31 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a9gvnreg.fsf@fencepost.gnu.org \
--to=dak@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).