From 04465c0edf1750b68fab6512f1bb31c7a9146128 Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Wed, 21 Aug 2013 10:16:24 -0400 Subject: [PATCH] [emacs] add commandline switches for ediff mode --- .emacs.d/init.d/ediff.el | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .emacs.d/init.d/ediff.el diff --git a/.emacs.d/init.d/ediff.el b/.emacs.d/init.d/ediff.el new file mode 100644 index 0000000..0610a0a --- /dev/null +++ b/.emacs.d/init.d/ediff.el @@ -0,0 +1,24 @@ +;; Ediff +(defun command-line-diff (switch) + (let ((file1 (pop command-line-args-left)) + (file2 (pop command-line-args-left))) + (ediff file1 file2))) + +(add-to-list 'command-switch-alist '("diff" . command-line-diff)) + +(defun git-mergetool (switch) + (let ((local (pop command-line-args-left)) + (remote (pop command-line-args-left)) + (base (pop command-line-args-left)) + (merged (pop command-line-args-left))) + (setq ediff-quit-hook 'kill-emacs + ediff-quit-merge-hook (lambda () + (let ((file ediff-merge-store-file)) + (set-buffer ediff-buffer-C) + (write-region (point-min) (point-max) file) + (message "Merge buffer saved in: %s" file) + (set-buffer-modified-p nil) + (sit-for 1)))) + (emerge-files-with-ancestor local remote base nil merged))) + +(add-to-list 'command-switch-alist '("mergetool" . git-mergetool))