From: Tassilo Horn <tsdh@gnu.org>
Cc: help-gnu-emacs@gnu.org
Subject: Re: How to use emacs as a "diff3 -m" compatible merge tool?
Date: Mon, 13 Jun 2022 15:34:24 +0200 [thread overview]
Message-ID: <87edzsy98u.fsf@gnu.org> (raw)
In-Reply-To: <87ilpaay1j.fsf@gnu.org>
Hi all,
> pacdiff calls the user-defined mergeprog like so:
>
> if $mergeprog "$file" "$base" "$pacfile" >"$merged"; then
> msg2 "Merged without conflicts."
> fi
>
>
> I'd like to use emacs as mergetool so need to support these calling
> convention (which are the ones of "diff3 -m"), i.e.,
>
> 1. args are MY-VERSION BASE THEIR-VERSION
> 2. a successful merge exits zero, an aborted merge exits non-zero
> 3. the merge result is printed to stdout
Here's a version which works for me (on GNU/Linux where /dev/stdout is a
thing) and fulfills all requirements except for 2 which turns out not to
be important at least in my pacdiff use-case. It'll ask if I want to
use the merge result anyhow so exiting successfully even when I abort
the merge is no big deal.
--8<---------------cut here---------------start------------->8---
(defun th/ediff-spit-merge-result-and-kill-emacs ()
(if-let ((merge-buf (ediff-get-buffer 'C)))
(with-current-buffer merge-buf
(append-to-file (point-min) (point-max)
"/dev/stdout")
(kill-emacs))
(error "There is no merge result buffer")))
(defun th/command-line-ediff-merge3 (_switch)
"Do a 3-way merge using `ediff-merge-files-with-ancestor'.
Assumes the command line args were: my-version base-version their-version"
(setq ediff-quit-merge-hook (list #'th/ediff-spit-merge-result-and-kill-emacs))
(let ((make-backup-files nil)
(my-version (pop command-line-args-left))
(base-version (pop command-line-args-left))
(their-version (pop command-line-args-left)))
(ediff-merge-files-with-ancestor
my-version their-version base-version)))
(add-to-list 'command-switch-alist
'("--ediff-merge3" . th/command-line-ediff-merge3))
--8<---------------cut here---------------end--------------->8---
Bye,
Tassilo
prev parent reply other threads:[~2022-06-13 13:34 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-09 10:52 How to use emacs as a "diff3 -m" compatible merge tool? Tassilo Horn
2022-06-09 19:53 ` Michael Heerdegen
2022-06-10 16:42 ` Tassilo Horn
2022-06-10 18:50 ` Michael Heerdegen
2022-06-12 11:31 ` Robert Pluim
2022-06-10 22:52 ` Emanuel Berg
2022-06-13 5:21 ` Tassilo Horn
2022-06-13 8:09 ` Robert Pluim
2022-06-13 9:34 ` Tassilo Horn
2022-06-13 9:52 ` Michael Heerdegen
2022-06-13 11:18 ` Robert Pluim
2022-06-13 21:13 ` Emanuel Berg
2022-06-14 7:50 ` Tassilo Horn
2022-06-14 10:06 ` Emanuel Berg
2022-06-14 11:23 ` Tassilo Horn
2022-06-13 13:34 ` Tassilo Horn [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87edzsy98u.fsf@gnu.org \
--to=tsdh@gnu.org \
--cc=help-gnu-emacs@gnu.org \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.