summaryrefslogtreecommitdiff
path: root/lisp/vc/ediff-wind.el
diff options
context:
space:
mode:
authorTino Calancha <tino.calancha@gmail.com>2017-03-14 16:12:29 +0900
committerTino Calancha <tino.calancha@gmail.com>2017-03-14 16:12:29 +0900
commit0f3d1b782353fd1fc0ab5f89d47d9e790f44e6b2 (patch)
tree0f9e4ae51b5bb2aaddc5f38d51c5e25a1bab78d6 /lisp/vc/ediff-wind.el
parente39d593475300ff388cdb69c8134ad513e9310e7 (diff)
downloademacs-0f3d1b782353fd1fc0ab5f89d47d9e790f44e6b2.tar.gz
Show ancestor buffer in 3way merges
Add an option ediff-show-ancestor', to control if the ancestor buffer must be shown in 3way merges (Bug#25493); set it non-nil by default. Add a toggle to change this option interactively; the original value of the option is restored on exit. Update the window setup so that the ancestor buffer is shown in 3way merges when ediff-show-ancestor is non-nil. Any operation on ediff windows must take in account the ancestor window as well, when this is shown. * lisp/vc/ediff-init.el (ediff-show-ancestor): New option. (ediff--show-ancestor-orig): New defvar. * lisp/vc/ediff-wind.el (ediff-window-Ancestor): New defvar. (ediff-setup-windows-plain-merge, ediff-setup-windows-multiframe-merge): Display ancestor buffer if ediff-show-ancestor is non-nil. (ediff-keep-window-config): Expect ancestor window in ediff-window-config-saved. (ediff-window-alist): Add entry for the ancestor window. * lisp/vc/ediff-util.el (ediff-setup-control-buffer): ediff-window-config-saved contains ancestor window. (ediff-show-ancestor): Delete this command. (ediff-setup-keymap): Bind ediff-toggle-show-ancestor to '/' for merge jobs. (ediff-update-diffs): Compute new diffs using ancestor buffer in 3way merges; don't cheat it to think that is performing a comparison, that trick is not necessary anymore: simply call 'ediff-setup-diff-regions-function' with file-A, file-B and the file ancestor. (ediff-recenter): Update doc string. Consider the ancestor buffer. (ediff--check-ancestor-exists): New defun. (ediff-toggle-show-ancestor): New command; toggle ediff-show-ancestor. (ediff--restore-options-on-exit): Restore ediff-show-ancestor on exit. (ediff-scroll-vertically, ediff-scroll-horizontally) (ediff-operate-on-windows): Consider the ancestor as well. * lisp/vc/ediff-help.el (ediff-long-help-message-merge): List ediff-toggle-show-ancestor. * doc/misc/ediff.texi (Introduction, Quick Help Commands): Update manual. ; * etc/NEWS: Announce these changes.
Diffstat (limited to 'lisp/vc/ediff-wind.el')
-rw-r--r--lisp/vc/ediff-wind.el86
1 files changed, 75 insertions, 11 deletions
diff --git a/lisp/vc/ediff-wind.el b/lisp/vc/ediff-wind.el
index cd10288643d..8516c11d136 100644
--- a/lisp/vc/ediff-wind.el
+++ b/lisp/vc/ediff-wind.el
@@ -115,6 +115,8 @@ provided functions are written."
(ediff-defvar-local ediff-window-B nil "")
;; Official window for buffer C
(ediff-defvar-local ediff-window-C nil "")
+;; Official window for buffer Ancestor
+(ediff-defvar-local ediff-window-Ancestor nil "")
;; Ediff's window configuration.
;; Used to minimize the need to rearrange windows.
(ediff-defvar-local ediff-window-config-saved "" "")
@@ -126,7 +128,8 @@ provided functions are written."
(B . ediff-window-B)
(?B . ediff-window-B)
(C . ediff-window-C)
- (?C . ediff-window-C)))
+ (?C . ediff-window-C)
+ (Ancestor . ediff-window-Ancestor)))
(defcustom ediff-split-window-function 'split-window-vertically
@@ -363,9 +366,13 @@ into icons, regardless of the window manager."
;; skip dedicated and unsplittable frames
(ediff-destroy-control-frame control-buffer)
(let ((window-min-height 1)
+ (with-Ancestor-p (ediff-with-current-buffer control-buffer
+ ediff-merge-with-ancestor-job))
split-window-function
merge-window-share merge-window-lines
- wind-A wind-B wind-C)
+ (buf-Ancestor (ediff-with-current-buffer control-buffer
+ ediff-ancestor-buffer))
+ wind-A wind-B wind-C wind-Ancestor)
(ediff-with-current-buffer control-buffer
(setq merge-window-share ediff-merge-window-share
;; this lets us have local versions of ediff-split-window-function
@@ -394,6 +401,14 @@ into icons, regardless of the window manager."
(setq wind-C (selected-window))
(switch-to-buffer buf-C)
+ (when (and ediff-show-ancestor with-Ancestor-p)
+ (select-window wind-C)
+ (funcall split-window-function)
+ (when (eq (selected-window) wind-C)
+ (other-window 1))
+ (switch-to-buffer buf-Ancestor)
+ (setq wind-Ancestor (selected-window)))
+
(select-window wind-A)
(funcall split-window-function)
@@ -405,7 +420,8 @@ into icons, regardless of the window manager."
(ediff-with-current-buffer control-buffer
(setq ediff-window-A wind-A
ediff-window-B wind-B
- ediff-window-C wind-C))
+ ediff-window-C wind-C
+ ediff-window-Ancestor wind-Ancestor))
(ediff-select-lowest-window)
(ediff-setup-control-buffer control-buffer)
@@ -516,9 +532,13 @@ into icons, regardless of the window manager."
(wind-A (ediff-get-visible-buffer-window buf-A))
(wind-B (ediff-get-visible-buffer-window buf-B))
(wind-C (ediff-get-visible-buffer-window buf-C))
+ (buf-Ancestor (ediff-with-current-buffer control-buf
+ ediff-ancestor-buffer))
+ (wind-Ancestor (ediff-get-visible-buffer-window buf-Ancestor))
(frame-A (if wind-A (window-frame wind-A)))
(frame-B (if wind-B (window-frame wind-B)))
(frame-C (if wind-C (window-frame wind-C)))
+ (frame-Ancestor (if wind-Ancestor (window-frame wind-Ancestor)))
;; on wide display, do things in one frame
(force-one-frame
(ediff-with-current-buffer control-buf ediff-wide-display-p))
@@ -549,7 +569,10 @@ into icons, regardless of the window manager."
(merge-window-share (ediff-with-current-buffer control-buf
ediff-merge-window-share))
merge-window-lines
- designated-minibuffer-frame
+ designated-minibuffer-frame ; ediff-merge-with-ancestor-job
+ (with-Ancestor-p (ediff-with-current-buffer control-buf
+ ediff-merge-with-ancestor-job))
+ (done-Ancestor (not with-Ancestor-p))
done-A done-B done-C)
;; buf-A on its own
@@ -585,6 +608,19 @@ into icons, regardless of the window manager."
(setq wind-C (selected-window))
(setq done-C t)))
+ ;; buf-Ancestor on its own
+ (if (and ediff-show-ancestor
+ with-Ancestor-p
+ (window-live-p wind-Ancestor)
+ (ediff-window-ok-for-display wind-Ancestor)
+ (null use-same-frame)) ; buf Ancestor on its own
+ (progn
+ ;; buffer buf-Ancestor is seen in live wind-Ancestor
+ (select-window wind-Ancestor)
+ (delete-other-windows)
+ (setq wind-Ancestor (selected-window))
+ (setq done-Ancestor t)))
+
(if (and use-same-frame-for-AB ; implies wind A and B are suitable
(window-live-p wind-A))
(progn
@@ -606,6 +642,7 @@ into icons, regardless of the window manager."
(let ((window-min-height 1))
(if (and (eq frame-A frame-B)
(eq frame-B frame-C)
+ (eq frame-C frame-Ancestor)
(frame-live-p frame-A))
(select-frame frame-A)
;; avoid dedicated and non-splittable windows
@@ -623,6 +660,14 @@ into icons, regardless of the window manager."
(setq wind-C (selected-window))
(switch-to-buffer buf-C)
+ (when (and ediff-show-ancestor with-Ancestor-p)
+ (select-window wind-C)
+ (funcall split-window-function)
+ (if (eq (selected-window) wind-C)
+ (other-window 1))
+ (switch-to-buffer buf-Ancestor)
+ (setq wind-Ancestor (selected-window)))
+
(select-window wind-A)
(funcall split-window-function)
@@ -633,8 +678,8 @@ into icons, regardless of the window manager."
(setq done-A t
done-B t
- done-C t)
- ))
+ done-C t
+ done-Ancestor t)))
(or done-A ; Buf A to be set in its own frame,
;;; or it was set before because use-same-frame = 1
@@ -668,10 +713,22 @@ into icons, regardless of the window manager."
(setq wind-C (selected-window))
))
+ (or done-Ancestor ; Buf Ancestor to be set in its own frame,
+ (not ediff-show-ancestor)
+ ;;; or it was set before because use-same-frame = 1
+ (progn
+ ;; Buf-Ancestor was not set up yet as it wasn't visible
+ ;; and use-same-frame = nil
+ (select-window orig-wind)
+ (delete-other-windows)
+ (switch-to-buffer buf-Ancestor)
+ (setq wind-Ancestor (selected-window))))
+
(ediff-with-current-buffer control-buf
(setq ediff-window-A wind-A
ediff-window-B wind-B
- ediff-window-C wind-C)
+ ediff-window-C wind-C
+ ediff-window-Ancestor wind-Ancestor)
(setq frame-A (window-frame ediff-window-A)
designated-minibuffer-frame
(window-frame (minibuffer-window frame-A))))
@@ -679,7 +736,6 @@ into icons, regardless of the window manager."
(ediff-setup-control-frame control-buf designated-minibuffer-frame)
))
-
;; Window setup for all comparison jobs, including 3way comparisons
(defun ediff-setup-windows-multiframe-compare (buf-A buf-B buf-C control-buf)
;;; Algorithm:
@@ -1295,7 +1351,9 @@ It assumes that it is called from within the control buffer."
(let ((ctl-wind ediff-control-window)
(A-wind ediff-window-A)
(B-wind ediff-window-B)
- (C-wind ediff-window-C))
+ (C-wind ediff-window-C)
+ (ancestor-job ediff-merge-with-ancestor-job)
+ (Ancestor-wind ediff-window-Ancestor))
(and
(ediff-window-visible-p A-wind)
@@ -1303,13 +1361,19 @@ It assumes that it is called from within the control buffer."
;; if buffer C is defined then take it into account
(or (not ediff-3way-job)
(ediff-window-visible-p C-wind))
+ (or (not ancestor-job)
+ (not ediff-show-ancestor)
+ (ediff-window-visible-p Ancestor-wind))
(eq (window-buffer A-wind) ediff-buffer-A)
(eq (window-buffer B-wind) ediff-buffer-B)
(or (not ediff-3way-job)
(eq (window-buffer C-wind) ediff-buffer-C))
+ (or (not ancestor-job)
+ (not ediff-show-ancestor)
+ (eq (window-buffer Ancestor-wind) ediff-ancestor-buffer))
(string= ediff-window-config-saved
- (format "%S%S%S%S%S%S%S"
- ctl-wind A-wind B-wind C-wind
+ (format "%S%S%S%S%S%S%S%S"
+ ctl-wind A-wind B-wind C-wind Ancestor-wind
ediff-split-window-function
(ediff-multiframe-setup-p)
ediff-wide-display-p)))))))