1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-24 07:20:37 +00:00
emacs/lisp/ediff-wind.el

1322 lines
46 KiB
EmacsLisp
Raw Normal View History

1995-03-16 22:34:51 +00:00
;;; ediff-wind.el --- window manipulation utilities
1996-01-14 07:34:30 +00:00
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu> * viper-init.el (viper-cond-compile-for-xemacs-or-emacs): new macro that replaces viper-emacs-p and viper-xemacs-p in many cases. Used to reduce the number of warnings. * viper-cmd.el: use viper-cond-compile-for-xemacs-or-emacs. (viper-standard-value): moved here from viper.el. (viper-set-unread-command-events): moved to viper-util.el (viper-check-minibuffer-overlay): make sure viper-minibuffer-overlay is moved to cover the entire input field. * viper-util.el: use viper-cond-compile-for-xemacs-or-emacs. (viper-read-key-sequence, viper-set-unread-command-events, viper-char-symbol-sequence-p, viper-char-array-p): moved here. * viper-ex.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-keym.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-mous.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-macs.el (viper-char-array-p, viper-char-symbol-sequence-p, viper-event-vector-p): moved to viper-util.el * viper.el (viper-standard-value): moved to viper-cmd.el. Use viper-cond-compile-for-xemacs-or-emacs. * ediff-help.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-hook.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-init.el (ediff-cond-compile-for-xemacs-or-emacs): new macro designed to be used in many places where ediff-emacs-p or ediff-xemacs-p was previously used. Reduces the number of warnings. Use ediff-cond-compile-for-xemacs-or-emacs in many places in lieue of ediff-xemacs-p. (ediff-make-current-diff-overlay, ediff-highlight-diff-in-one-buffer, ediff-convert-fine-diffs-to-overlays, ediff-empty-diff-region-p, ediff-whitespace-diff-region-p, ediff-get-region-contents): moved to ediff-util.el. (ediff-event-key): moved here. * ediff-merge.el: got rid of unreferenced variables. * ediff-mult.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-util.el: use ediff-cond-compile-for-xemacs-or-emacs. (ediff-cleanup-mess): improved the way windows are set up after quitting ediff. (ediff-janitor): use ediff-dispose-of-variant-according-to-user. (ediff-dispose-of-variant-according-to-user): new function designed to be smarter and also understands indirect buffers. (ediff-highlight-diff-in-one-buffer, ediff-unhighlight-diff-in-one-buffer, ediff-unhighlight-diffs-totally-in-one-buffer, ediff-highlight-diff, ediff-highlight-diff, ediff-unhighlight-diff, ediff-unhighlight-diffs-totally, ediff-empty-diff-region-p, ediff-whitespace-diff-region-p, ediff-get-region-contents, ediff-make-current-diff-overlay): moved here. (ediff-format-bindings-of): new function by Hannu Koivisto <azure@iki.fi>. (ediff-setup): make sure the merge buffer is always widened and modifiable. (ediff-write-merge-buffer-and-maybe-kill): refuse to write the result of a merge into a file visited by another buffer. (ediff-arrange-autosave-in-merge-jobs): check if the merge file is visited by another buffer and ask to save/delete that buffer. (ediff-verify-file-merge-buffer): new function to do the above. * ediff-vers.el: load ediff-init.el at compile time. * ediff-wind.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff.el (ediff-windows, ediff-regions-wordwise, ediff-regions-linewise): use indirect buffers to improve robustness and make it possible to compare regions of the same buffer (even overlapping regions). (ediff-clone-buffer-for-region-comparison, ediff-clone-buffer-for-window-comparison): new functions. (ediff-files-internal): refuse to compare identical files. (ediff-regions-internal): get rid of the warning about comparing regions of the same buffer. * ediff-diff.el (ediff-convert-fine-diffs-to-overlays): moved here. Plus the following fixes courtesy of Dave Love: Doc fixes. (ediff-word-1): Use word class and move - to the front per regexp documentation. (ediff-wordify): Bind forward-word-function outside loop. (ediff-copy-to-buffer): Use insert-buffer-substring rather than consing buffer contents. (ediff-goto-word): Move syntax table setting outside loop.
2002-01-08 04:36:01 +00:00
;; Copyright (C) 1994, 95, 96, 97, 2000, 01, 02 Free Software Foundation, Inc.
1995-03-16 22:34:51 +00:00
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu> * viper-init.el (viper-cond-compile-for-xemacs-or-emacs): new macro that replaces viper-emacs-p and viper-xemacs-p in many cases. Used to reduce the number of warnings. * viper-cmd.el: use viper-cond-compile-for-xemacs-or-emacs. (viper-standard-value): moved here from viper.el. (viper-set-unread-command-events): moved to viper-util.el (viper-check-minibuffer-overlay): make sure viper-minibuffer-overlay is moved to cover the entire input field. * viper-util.el: use viper-cond-compile-for-xemacs-or-emacs. (viper-read-key-sequence, viper-set-unread-command-events, viper-char-symbol-sequence-p, viper-char-array-p): moved here. * viper-ex.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-keym.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-mous.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-macs.el (viper-char-array-p, viper-char-symbol-sequence-p, viper-event-vector-p): moved to viper-util.el * viper.el (viper-standard-value): moved to viper-cmd.el. Use viper-cond-compile-for-xemacs-or-emacs. * ediff-help.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-hook.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-init.el (ediff-cond-compile-for-xemacs-or-emacs): new macro designed to be used in many places where ediff-emacs-p or ediff-xemacs-p was previously used. Reduces the number of warnings. Use ediff-cond-compile-for-xemacs-or-emacs in many places in lieue of ediff-xemacs-p. (ediff-make-current-diff-overlay, ediff-highlight-diff-in-one-buffer, ediff-convert-fine-diffs-to-overlays, ediff-empty-diff-region-p, ediff-whitespace-diff-region-p, ediff-get-region-contents): moved to ediff-util.el. (ediff-event-key): moved here. * ediff-merge.el: got rid of unreferenced variables. * ediff-mult.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-util.el: use ediff-cond-compile-for-xemacs-or-emacs. (ediff-cleanup-mess): improved the way windows are set up after quitting ediff. (ediff-janitor): use ediff-dispose-of-variant-according-to-user. (ediff-dispose-of-variant-according-to-user): new function designed to be smarter and also understands indirect buffers. (ediff-highlight-diff-in-one-buffer, ediff-unhighlight-diff-in-one-buffer, ediff-unhighlight-diffs-totally-in-one-buffer, ediff-highlight-diff, ediff-highlight-diff, ediff-unhighlight-diff, ediff-unhighlight-diffs-totally, ediff-empty-diff-region-p, ediff-whitespace-diff-region-p, ediff-get-region-contents, ediff-make-current-diff-overlay): moved here. (ediff-format-bindings-of): new function by Hannu Koivisto <azure@iki.fi>. (ediff-setup): make sure the merge buffer is always widened and modifiable. (ediff-write-merge-buffer-and-maybe-kill): refuse to write the result of a merge into a file visited by another buffer. (ediff-arrange-autosave-in-merge-jobs): check if the merge file is visited by another buffer and ask to save/delete that buffer. (ediff-verify-file-merge-buffer): new function to do the above. * ediff-vers.el: load ediff-init.el at compile time. * ediff-wind.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff.el (ediff-windows, ediff-regions-wordwise, ediff-regions-linewise): use indirect buffers to improve robustness and make it possible to compare regions of the same buffer (even overlapping regions). (ediff-clone-buffer-for-region-comparison, ediff-clone-buffer-for-window-comparison): new functions. (ediff-files-internal): refuse to compare identical files. (ediff-regions-internal): get rid of the warning about comparing regions of the same buffer. * ediff-diff.el (ediff-convert-fine-diffs-to-overlays): moved here. Plus the following fixes courtesy of Dave Love: Doc fixes. (ediff-word-1): Use word class and move - to the front per regexp documentation. (ediff-wordify): Bind forward-word-function outside loop. (ediff-copy-to-buffer): Use insert-buffer-substring rather than consing buffer contents. (ediff-goto-word): Move syntax table setting outside loop.
2002-01-08 04:36:01 +00:00
;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
1995-03-16 22:34:51 +00:00
;; This file is part of GNU Emacs.
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
1996-01-14 07:34:30 +00:00
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
1995-03-16 22:34:51 +00:00
;;; Commentary:
1996-01-14 07:34:30 +00:00
;;; Code:
2003-02-04 11:26:42 +00:00
1997-05-31 01:10:39 +00:00
(provide 'ediff-wind)
1995-03-16 22:34:51 +00:00
1996-06-22 01:54:34 +00:00
;; Compiler pacifier
(defvar icon-title-format)
(defvar top-toolbar-height)
(defvar bottom-toolbar-height)
(defvar left-toolbar-height)
(defvar right-toolbar-height)
(defvar left-toolbar-width)
(defvar right-toolbar-width)
(defvar default-menubar)
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu> * viper-init.el (viper-cond-compile-for-xemacs-or-emacs): new macro that replaces viper-emacs-p and viper-xemacs-p in many cases. Used to reduce the number of warnings. * viper-cmd.el: use viper-cond-compile-for-xemacs-or-emacs. (viper-standard-value): moved here from viper.el. (viper-set-unread-command-events): moved to viper-util.el (viper-check-minibuffer-overlay): make sure viper-minibuffer-overlay is moved to cover the entire input field. * viper-util.el: use viper-cond-compile-for-xemacs-or-emacs. (viper-read-key-sequence, viper-set-unread-command-events, viper-char-symbol-sequence-p, viper-char-array-p): moved here. * viper-ex.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-keym.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-mous.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-macs.el (viper-char-array-p, viper-char-symbol-sequence-p, viper-event-vector-p): moved to viper-util.el * viper.el (viper-standard-value): moved to viper-cmd.el. Use viper-cond-compile-for-xemacs-or-emacs. * ediff-help.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-hook.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-init.el (ediff-cond-compile-for-xemacs-or-emacs): new macro designed to be used in many places where ediff-emacs-p or ediff-xemacs-p was previously used. Reduces the number of warnings. Use ediff-cond-compile-for-xemacs-or-emacs in many places in lieue of ediff-xemacs-p. (ediff-make-current-diff-overlay, ediff-highlight-diff-in-one-buffer, ediff-convert-fine-diffs-to-overlays, ediff-empty-diff-region-p, ediff-whitespace-diff-region-p, ediff-get-region-contents): moved to ediff-util.el. (ediff-event-key): moved here. * ediff-merge.el: got rid of unreferenced variables. * ediff-mult.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-util.el: use ediff-cond-compile-for-xemacs-or-emacs. (ediff-cleanup-mess): improved the way windows are set up after quitting ediff. (ediff-janitor): use ediff-dispose-of-variant-according-to-user. (ediff-dispose-of-variant-according-to-user): new function designed to be smarter and also understands indirect buffers. (ediff-highlight-diff-in-one-buffer, ediff-unhighlight-diff-in-one-buffer, ediff-unhighlight-diffs-totally-in-one-buffer, ediff-highlight-diff, ediff-highlight-diff, ediff-unhighlight-diff, ediff-unhighlight-diffs-totally, ediff-empty-diff-region-p, ediff-whitespace-diff-region-p, ediff-get-region-contents, ediff-make-current-diff-overlay): moved here. (ediff-format-bindings-of): new function by Hannu Koivisto <azure@iki.fi>. (ediff-setup): make sure the merge buffer is always widened and modifiable. (ediff-write-merge-buffer-and-maybe-kill): refuse to write the result of a merge into a file visited by another buffer. (ediff-arrange-autosave-in-merge-jobs): check if the merge file is visited by another buffer and ask to save/delete that buffer. (ediff-verify-file-merge-buffer): new function to do the above. * ediff-vers.el: load ediff-init.el at compile time. * ediff-wind.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff.el (ediff-windows, ediff-regions-wordwise, ediff-regions-linewise): use indirect buffers to improve robustness and make it possible to compare regions of the same buffer (even overlapping regions). (ediff-clone-buffer-for-region-comparison, ediff-clone-buffer-for-window-comparison): new functions. (ediff-files-internal): refuse to compare identical files. (ediff-regions-internal): get rid of the warning about comparing regions of the same buffer. * ediff-diff.el (ediff-convert-fine-diffs-to-overlays): moved here. Plus the following fixes courtesy of Dave Love: Doc fixes. (ediff-word-1): Use word class and move - to the front per regexp documentation. (ediff-wordify): Bind forward-word-function outside loop. (ediff-copy-to-buffer): Use insert-buffer-substring rather than consing buffer contents. (ediff-goto-word): Move syntax table setting outside loop.
2002-01-08 04:36:01 +00:00
(defvar top-gutter)
1996-06-22 01:54:34 +00:00
(defvar frame-icon-title-format)
1997-05-31 01:10:39 +00:00
(defvar ediff-diff-status)
1999-11-01 07:16:15 +00:00
(defvar ediff-emacs-p)
1997-05-31 01:10:39 +00:00
(eval-when-compile
(let ((load-path (cons (expand-file-name ".") load-path)))
(or (featurep 'ediff-init)
(load "ediff-init.el" nil nil 'nosuffix))
(or (featurep 'ediff-util)
(load "ediff-util.el" nil nil 'nosuffix))
(or (featurep 'ediff-help)
(load "ediff-help.el" nil nil 'nosuffix))
(or (featurep 'ediff-tbar)
1998-05-04 22:42:59 +00:00
ediff-emacs-p
1997-05-31 01:10:39 +00:00
(load "ediff-tbar.el" 'noerror nil 'nosuffix))
))
1996-06-22 01:54:34 +00:00
;; end pacifier
1997-05-31 01:10:39 +00:00
(require 'ediff-init)
;; be careful with ediff-tbar
(if ediff-xemacs-p
(condition-case nil
(require 'ediff-tbar)
(error
(defun ediff-compute-toolbar-width () 0)))
(defun ediff-compute-toolbar-width () 0))
(defgroup ediff-window nil
"Ediff window manipulation"
:prefix "ediff-"
:group 'ediff
:group 'frames)
1995-03-16 22:34:51 +00:00
1997-05-31 01:10:39 +00:00
(defcustom ediff-window-setup-function (if (ediff-window-display-p)
'ediff-setup-windows-multiframe
'ediff-setup-windows-plain)
1995-03-16 22:34:51 +00:00
"*Function called to set up windows.
1999-12-18 16:14:32 +00:00
Ediff provides a choice of two functions: `ediff-setup-windows-plain', for
doing everything in one frame, and `ediff-setup-windows-multiframe',
1999-11-01 07:16:15 +00:00
which sets the control panel in a separate frame. Also, if the latter
1995-03-16 22:34:51 +00:00
function detects that one of the buffers A/B is seen in some other frame,
it will try to keep that buffer in that frame.
If you don't like the two functions provided---write your own one.
The basic guidelines:
1. It should leave the control buffer current and the control window
1999-12-18 16:14:32 +00:00
selected.
2. It should set `ediff-window-A', `ediff-window-B', `ediff-window-C',
and `ediff-control-window' to contain window objects that display
1995-03-16 22:34:51 +00:00
the corresponding buffers.
3. It should accept the following arguments:
buffer-A, buffer-B, buffer-C, control-buffer
Buffer C may not be used in jobs that compare only two buffers.
If you plan to do something fancy, take a close look at how the two
1997-05-31 01:10:39 +00:00
provided functions are written."
:type '(choice (const :tag "Multi Frame" ediff-setup-windows-multiframe)
(const :tag "Single Frame" ediff-setup-windows-plain)
(function :tag "Other function"))
1997-05-31 01:10:39 +00:00
:group 'ediff-window)
1995-03-16 22:34:51 +00:00
;; indicates if we are in a multiframe setup
(ediff-defvar-local ediff-multiframe nil "")
;; Share of the frame occupied by the merge window (buffer C)
(ediff-defvar-local ediff-merge-window-share 0.45 "")
;; The control window.
(ediff-defvar-local ediff-control-window nil "")
;; Official window for buffer A
(ediff-defvar-local ediff-window-A nil "")
;; Official window for buffer B
(ediff-defvar-local ediff-window-B nil "")
;; Official window for buffer C
(ediff-defvar-local ediff-window-C nil "")
;; Ediff's window configuration.
;; Used to minimize the need to rearrange windows.
(ediff-defvar-local ediff-window-config-saved "" "")
1997-07-31 04:04:23 +00:00
;; Association between buff-type and ediff-window-*
(defconst ediff-window-alist
'((A . ediff-window-A)
(?A . ediff-window-A)
(B . ediff-window-B)
(?B . ediff-window-B)
(C . ediff-window-C)
(?C . ediff-window-C)))
1995-03-16 22:34:51 +00:00
1997-05-31 01:10:39 +00:00
(defcustom ediff-split-window-function 'split-window-vertically
1995-03-16 22:34:51 +00:00
"*The function used to split the main window between buffer-A and buffer-B.
You can set it to a horizontal split instead of the default vertical split
by setting this variable to `split-window-horizontally'.
You can also have your own function to do fancy splits.
This variable has no effect when buffer-A/B are shown in different frames.
1997-05-31 01:10:39 +00:00
In this case, Ediff will use those frames to display these buffers."
:type 'function
:group 'ediff-window)
1995-03-16 22:34:51 +00:00
1997-05-31 01:10:39 +00:00
(defcustom ediff-merge-split-window-function 'split-window-horizontally
1995-03-16 22:34:51 +00:00
"*The function used to split the main window between buffer-A and buffer-B.
You can set it to a vertical split instead of the default horizontal split
by setting this variable to `split-window-vertically'.
You can also have your own function to do fancy splits.
This variable has no effect when buffer-A/B/C are shown in different frames.
1997-05-31 01:10:39 +00:00
In this case, Ediff will use those frames to display these buffers."
:type 'function
:group 'ediff-window)
1995-03-16 22:34:51 +00:00
(defconst ediff-control-frame-parameters
1999-12-18 16:14:32 +00:00
(list
1996-02-16 06:36:35 +00:00
'(name . "Ediff")
;;'(unsplittable . t)
'(minibuffer . nil)
'(user-position . t) ; Emacs only
'(vertical-scroll-bars . nil) ; Emacs only
'(scrollbar-width . 0) ; XEmacs only
'(scrollbar-height . 0) ; XEmacs only
1996-02-16 06:36:35 +00:00
'(menu-bar-lines . 0) ; Emacs only
'(tool-bar-lines . 0) ; Emacs 21+ only
;; don't lower but auto-raise
1996-02-16 06:36:35 +00:00
'(auto-lower . nil)
'(auto-raise . t)
1999-11-01 07:16:15 +00:00
'(visibility . nil)
;; make initial frame small to avoid distraction
'(width . 1) '(height . 1)
1996-02-16 06:36:35 +00:00
;; this blocks queries from window manager as to where to put
;; ediff's control frame. we put the frame outside the display,
;; so the initial frame won't jump all over the screen
(cons 'top (if (fboundp 'ediff-display-pixel-height)
(1+ (ediff-display-pixel-height))
3000))
(cons 'left (if (fboundp 'ediff-display-pixel-width)
(1+ (ediff-display-pixel-width))
3000))
)
1995-03-16 22:34:51 +00:00
"Frame parameters for displaying Ediff Control Panel.
1999-11-01 07:16:15 +00:00
Used internally---not a user option.")
1995-03-16 22:34:51 +00:00
;; position of the mouse; used to decide whether to warp the mouse into ctl
;; frame
(ediff-defvar-local ediff-mouse-pixel-position nil "")
;; not used for now
(defvar ediff-mouse-pixel-threshold 30
"If the user moves mouse more than this many pixels, Ediff won't warp mouse into control window.")
1997-05-31 01:10:39 +00:00
(defcustom ediff-grab-mouse t
"*If t, Ediff will always grab the mouse and put it in the control frame.
If 'maybe, Ediff will do it sometimes, but not after operations that require
1999-11-01 07:16:15 +00:00
relatively long time. If nil, the mouse will be entirely user's
1997-05-31 01:10:39 +00:00
responsibility."
:type 'boolean
:group 'ediff-window)
1997-05-31 01:10:39 +00:00
(defcustom ediff-control-frame-position-function 'ediff-make-frame-position
1995-03-16 22:34:51 +00:00
"Function to call to determine the desired location for the control panel.
Expects three parameters: the control buffer, the desired width and height
1999-11-01 07:16:15 +00:00
of the control frame. It returns an association list
1997-05-31 01:10:39 +00:00
of the form \(\(top . <position>\) \(left . <position>\)\)"
1997-07-17 19:37:07 +00:00
:type 'function
1997-05-31 01:10:39 +00:00
:group 'ediff-window)
1995-03-16 22:34:51 +00:00
1999-11-01 07:16:15 +00:00
(defcustom ediff-control-frame-upward-shift 42
1995-03-16 22:34:51 +00:00
"*The upward shift of control frame from the top of buffer A's frame.
Measured in pixels.
This is used by the default control frame positioning function,
1999-11-01 07:16:15 +00:00
`ediff-make-frame-position'. This variable is provided for easy
customization of the default control frame positioning."
1997-05-31 01:10:39 +00:00
:type 'integer
:group 'ediff-window)
1995-03-16 22:34:51 +00:00
1997-05-31 01:10:39 +00:00
(defcustom ediff-narrow-control-frame-leftward-shift (if ediff-xemacs-p 7 3)
1995-03-16 22:34:51 +00:00
"*The leftward shift of control frame from the right edge of buf A's frame.
Measured in characters.
This is used by the default control frame positioning function,
`ediff-make-frame-position' to adjust the position of the control frame
1999-11-01 07:16:15 +00:00
when it shows the short menu. This variable is provided for easy
1997-05-31 01:10:39 +00:00
customization of the default."
:type 'integer
:group 'ediff-window)
1995-03-16 22:34:51 +00:00
1997-05-31 01:10:39 +00:00
(defcustom ediff-wide-control-frame-rightward-shift 7
1995-03-16 22:34:51 +00:00
"*The rightward shift of control frame from the left edge of buf A's frame.
Measured in characters.
This is used by the default control frame positioning function,
`ediff-make-frame-position' to adjust the position of the control frame
1999-11-01 07:16:15 +00:00
when it shows the full menu. This variable is provided for easy
1997-05-31 01:10:39 +00:00
customization of the default."
:type 'integer
:group 'ediff-window)
1995-03-16 22:34:51 +00:00
;; Wide frame display
;; t means Ediff is using wide display
(ediff-defvar-local ediff-wide-display-p nil "")
;; keeps frame config for toggling wide display
1999-12-18 16:14:32 +00:00
(ediff-defvar-local ediff-wide-display-orig-parameters nil
1995-03-16 22:34:51 +00:00
"Frame parameters to be restored when the user wants to toggle the wide
display off.")
(ediff-defvar-local ediff-wide-display-frame nil
"Frame to be used for wide display.")
(ediff-defvar-local ediff-make-wide-display-function 'ediff-make-wide-display
"The value is a function that is called to create a wide display.
1999-11-01 07:16:15 +00:00
The function is called without arguments. It should resize the frame in
1995-03-16 22:34:51 +00:00
which buffers A, B, and C are to be displayed, and it should save the old
frame parameters in `ediff-wide-display-orig-parameters'.
The variable `ediff-wide-display-frame' should be set to contain
the frame used for the wide display.")
;; Frame used for the control panel in a windowing system.
(ediff-defvar-local ediff-control-frame nil "")
1997-05-31 01:10:39 +00:00
(defcustom ediff-prefer-iconified-control-frame nil
1995-03-16 22:34:51 +00:00
"*If t, keep control panel iconified when help message is off.
This has effect only on a windowing system.
If t, hitting `?' to toggle control panel off iconifies it.
1995-03-16 22:34:51 +00:00
This is only useful in Emacs and only for certain kinds of window managers,
such as TWM and its derivatives, since the window manager must permit
1999-11-01 07:16:15 +00:00
keyboard input to go into icons. XEmacs completely ignores keyboard input
1997-05-31 01:10:39 +00:00
into icons, regardless of the window manager."
:type 'boolean
:group 'ediff-window)
1995-03-16 22:34:51 +00:00
;;; Functions
(defun ediff-get-window-by-clicking (wind prev-wind wind-number)
(let (event)
(message
1999-11-01 07:16:15 +00:00
"Select windows by clicking. Please click on Window %d " wind-number)
1995-03-16 22:34:51 +00:00
(while (not (ediff-mouse-event-p (setq event (ediff-read-event))))
(if (sit-for 1) ; if sequence of events, wait till the final word
(beep 1))
(message "Please click on Window %d " wind-number))
(ediff-read-event) ; discard event
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu> * viper-init.el (viper-cond-compile-for-xemacs-or-emacs): new macro that replaces viper-emacs-p and viper-xemacs-p in many cases. Used to reduce the number of warnings. * viper-cmd.el: use viper-cond-compile-for-xemacs-or-emacs. (viper-standard-value): moved here from viper.el. (viper-set-unread-command-events): moved to viper-util.el (viper-check-minibuffer-overlay): make sure viper-minibuffer-overlay is moved to cover the entire input field. * viper-util.el: use viper-cond-compile-for-xemacs-or-emacs. (viper-read-key-sequence, viper-set-unread-command-events, viper-char-symbol-sequence-p, viper-char-array-p): moved here. * viper-ex.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-keym.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-mous.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-macs.el (viper-char-array-p, viper-char-symbol-sequence-p, viper-event-vector-p): moved to viper-util.el * viper.el (viper-standard-value): moved to viper-cmd.el. Use viper-cond-compile-for-xemacs-or-emacs. * ediff-help.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-hook.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-init.el (ediff-cond-compile-for-xemacs-or-emacs): new macro designed to be used in many places where ediff-emacs-p or ediff-xemacs-p was previously used. Reduces the number of warnings. Use ediff-cond-compile-for-xemacs-or-emacs in many places in lieue of ediff-xemacs-p. (ediff-make-current-diff-overlay, ediff-highlight-diff-in-one-buffer, ediff-convert-fine-diffs-to-overlays, ediff-empty-diff-region-p, ediff-whitespace-diff-region-p, ediff-get-region-contents): moved to ediff-util.el. (ediff-event-key): moved here. * ediff-merge.el: got rid of unreferenced variables. * ediff-mult.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-util.el: use ediff-cond-compile-for-xemacs-or-emacs. (ediff-cleanup-mess): improved the way windows are set up after quitting ediff. (ediff-janitor): use ediff-dispose-of-variant-according-to-user. (ediff-dispose-of-variant-according-to-user): new function designed to be smarter and also understands indirect buffers. (ediff-highlight-diff-in-one-buffer, ediff-unhighlight-diff-in-one-buffer, ediff-unhighlight-diffs-totally-in-one-buffer, ediff-highlight-diff, ediff-highlight-diff, ediff-unhighlight-diff, ediff-unhighlight-diffs-totally, ediff-empty-diff-region-p, ediff-whitespace-diff-region-p, ediff-get-region-contents, ediff-make-current-diff-overlay): moved here. (ediff-format-bindings-of): new function by Hannu Koivisto <azure@iki.fi>. (ediff-setup): make sure the merge buffer is always widened and modifiable. (ediff-write-merge-buffer-and-maybe-kill): refuse to write the result of a merge into a file visited by another buffer. (ediff-arrange-autosave-in-merge-jobs): check if the merge file is visited by another buffer and ask to save/delete that buffer. (ediff-verify-file-merge-buffer): new function to do the above. * ediff-vers.el: load ediff-init.el at compile time. * ediff-wind.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff.el (ediff-windows, ediff-regions-wordwise, ediff-regions-linewise): use indirect buffers to improve robustness and make it possible to compare regions of the same buffer (even overlapping regions). (ediff-clone-buffer-for-region-comparison, ediff-clone-buffer-for-window-comparison): new functions. (ediff-files-internal): refuse to compare identical files. (ediff-regions-internal): get rid of the warning about comparing regions of the same buffer. * ediff-diff.el (ediff-convert-fine-diffs-to-overlays): moved here. Plus the following fixes courtesy of Dave Love: Doc fixes. (ediff-word-1): Use word class and move - to the front per regexp documentation. (ediff-wordify): Bind forward-word-function outside loop. (ediff-copy-to-buffer): Use insert-buffer-substring rather than consing buffer contents. (ediff-goto-word): Move syntax table setting outside loop.
2002-01-08 04:36:01 +00:00
(setq wind (ediff-cond-compile-for-xemacs-or-emacs
(event-window event) ; xemacs
(posn-window (event-start event)) ; emacs
)
)
1995-03-16 22:34:51 +00:00
))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
;; Select the lowest window on the frame.
1995-03-16 22:34:51 +00:00
(defun ediff-select-lowest-window ()
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu> * viper-init.el (viper-cond-compile-for-xemacs-or-emacs): new macro that replaces viper-emacs-p and viper-xemacs-p in many cases. Used to reduce the number of warnings. * viper-cmd.el: use viper-cond-compile-for-xemacs-or-emacs. (viper-standard-value): moved here from viper.el. (viper-set-unread-command-events): moved to viper-util.el (viper-check-minibuffer-overlay): make sure viper-minibuffer-overlay is moved to cover the entire input field. * viper-util.el: use viper-cond-compile-for-xemacs-or-emacs. (viper-read-key-sequence, viper-set-unread-command-events, viper-char-symbol-sequence-p, viper-char-array-p): moved here. * viper-ex.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-keym.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-mous.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-macs.el (viper-char-array-p, viper-char-symbol-sequence-p, viper-event-vector-p): moved to viper-util.el * viper.el (viper-standard-value): moved to viper-cmd.el. Use viper-cond-compile-for-xemacs-or-emacs. * ediff-help.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-hook.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-init.el (ediff-cond-compile-for-xemacs-or-emacs): new macro designed to be used in many places where ediff-emacs-p or ediff-xemacs-p was previously used. Reduces the number of warnings. Use ediff-cond-compile-for-xemacs-or-emacs in many places in lieue of ediff-xemacs-p. (ediff-make-current-diff-overlay, ediff-highlight-diff-in-one-buffer, ediff-convert-fine-diffs-to-overlays, ediff-empty-diff-region-p, ediff-whitespace-diff-region-p, ediff-get-region-contents): moved to ediff-util.el. (ediff-event-key): moved here. * ediff-merge.el: got rid of unreferenced variables. * ediff-mult.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-util.el: use ediff-cond-compile-for-xemacs-or-emacs. (ediff-cleanup-mess): improved the way windows are set up after quitting ediff. (ediff-janitor): use ediff-dispose-of-variant-according-to-user. (ediff-dispose-of-variant-according-to-user): new function designed to be smarter and also understands indirect buffers. (ediff-highlight-diff-in-one-buffer, ediff-unhighlight-diff-in-one-buffer, ediff-unhighlight-diffs-totally-in-one-buffer, ediff-highlight-diff, ediff-highlight-diff, ediff-unhighlight-diff, ediff-unhighlight-diffs-totally, ediff-empty-diff-region-p, ediff-whitespace-diff-region-p, ediff-get-region-contents, ediff-make-current-diff-overlay): moved here. (ediff-format-bindings-of): new function by Hannu Koivisto <azure@iki.fi>. (ediff-setup): make sure the merge buffer is always widened and modifiable. (ediff-write-merge-buffer-and-maybe-kill): refuse to write the result of a merge into a file visited by another buffer. (ediff-arrange-autosave-in-merge-jobs): check if the merge file is visited by another buffer and ask to save/delete that buffer. (ediff-verify-file-merge-buffer): new function to do the above. * ediff-vers.el: load ediff-init.el at compile time. * ediff-wind.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff.el (ediff-windows, ediff-regions-wordwise, ediff-regions-linewise): use indirect buffers to improve robustness and make it possible to compare regions of the same buffer (even overlapping regions). (ediff-clone-buffer-for-region-comparison, ediff-clone-buffer-for-window-comparison): new functions. (ediff-files-internal): refuse to compare identical files. (ediff-regions-internal): get rid of the warning about comparing regions of the same buffer. * ediff-diff.el (ediff-convert-fine-diffs-to-overlays): moved here. Plus the following fixes courtesy of Dave Love: Doc fixes. (ediff-word-1): Use word class and move - to the front per regexp documentation. (ediff-wordify): Bind forward-word-function outside loop. (ediff-copy-to-buffer): Use insert-buffer-substring rather than consing buffer contents. (ediff-goto-word): Move syntax table setting outside loop.
2002-01-08 04:36:01 +00:00
(ediff-cond-compile-for-xemacs-or-emacs
(select-window (frame-lowest-window)) ; xemacs
;; emacs
(let* ((lowest-window (selected-window))
(bottom-edge (car (cdr (cdr (cdr (window-edges))))))
(last-window (save-excursion
(other-window -1) (selected-window)))
(window-search t))
(while window-search
(let* ((this-window (next-window))
(next-bottom-edge
(car (cdr (cdr (cdr (window-edges this-window)))))))
(if (< bottom-edge next-bottom-edge)
(progn
(setq bottom-edge next-bottom-edge)
(setq lowest-window this-window)))
2003-02-04 11:26:42 +00:00
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu> * viper-init.el (viper-cond-compile-for-xemacs-or-emacs): new macro that replaces viper-emacs-p and viper-xemacs-p in many cases. Used to reduce the number of warnings. * viper-cmd.el: use viper-cond-compile-for-xemacs-or-emacs. (viper-standard-value): moved here from viper.el. (viper-set-unread-command-events): moved to viper-util.el (viper-check-minibuffer-overlay): make sure viper-minibuffer-overlay is moved to cover the entire input field. * viper-util.el: use viper-cond-compile-for-xemacs-or-emacs. (viper-read-key-sequence, viper-set-unread-command-events, viper-char-symbol-sequence-p, viper-char-array-p): moved here. * viper-ex.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-keym.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-mous.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-macs.el (viper-char-array-p, viper-char-symbol-sequence-p, viper-event-vector-p): moved to viper-util.el * viper.el (viper-standard-value): moved to viper-cmd.el. Use viper-cond-compile-for-xemacs-or-emacs. * ediff-help.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-hook.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-init.el (ediff-cond-compile-for-xemacs-or-emacs): new macro designed to be used in many places where ediff-emacs-p or ediff-xemacs-p was previously used. Reduces the number of warnings. Use ediff-cond-compile-for-xemacs-or-emacs in many places in lieue of ediff-xemacs-p. (ediff-make-current-diff-overlay, ediff-highlight-diff-in-one-buffer, ediff-convert-fine-diffs-to-overlays, ediff-empty-diff-region-p, ediff-whitespace-diff-region-p, ediff-get-region-contents): moved to ediff-util.el. (ediff-event-key): moved here. * ediff-merge.el: got rid of unreferenced variables. * ediff-mult.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-util.el: use ediff-cond-compile-for-xemacs-or-emacs. (ediff-cleanup-mess): improved the way windows are set up after quitting ediff. (ediff-janitor): use ediff-dispose-of-variant-according-to-user. (ediff-dispose-of-variant-according-to-user): new function designed to be smarter and also understands indirect buffers. (ediff-highlight-diff-in-one-buffer, ediff-unhighlight-diff-in-one-buffer, ediff-unhighlight-diffs-totally-in-one-buffer, ediff-highlight-diff, ediff-highlight-diff, ediff-unhighlight-diff, ediff-unhighlight-diffs-totally, ediff-empty-diff-region-p, ediff-whitespace-diff-region-p, ediff-get-region-contents, ediff-make-current-diff-overlay): moved here. (ediff-format-bindings-of): new function by Hannu Koivisto <azure@iki.fi>. (ediff-setup): make sure the merge buffer is always widened and modifiable. (ediff-write-merge-buffer-and-maybe-kill): refuse to write the result of a merge into a file visited by another buffer. (ediff-arrange-autosave-in-merge-jobs): check if the merge file is visited by another buffer and ask to save/delete that buffer. (ediff-verify-file-merge-buffer): new function to do the above. * ediff-vers.el: load ediff-init.el at compile time. * ediff-wind.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff.el (ediff-windows, ediff-regions-wordwise, ediff-regions-linewise): use indirect buffers to improve robustness and make it possible to compare regions of the same buffer (even overlapping regions). (ediff-clone-buffer-for-region-comparison, ediff-clone-buffer-for-window-comparison): new functions. (ediff-files-internal): refuse to compare identical files. (ediff-regions-internal): get rid of the warning about comparing regions of the same buffer. * ediff-diff.el (ediff-convert-fine-diffs-to-overlays): moved here. Plus the following fixes courtesy of Dave Love: Doc fixes. (ediff-word-1): Use word class and move - to the front per regexp documentation. (ediff-wordify): Bind forward-word-function outside loop. (ediff-copy-to-buffer): Use insert-buffer-substring rather than consing buffer contents. (ediff-goto-word): Move syntax table setting outside loop.
2002-01-08 04:36:01 +00:00
(select-window this-window)
(if (eq last-window this-window)
(progn
(select-window lowest-window)
(setq window-search nil))))))
))
1995-03-16 22:34:51 +00:00
;;; Common window setup routines
;; Set up the window configuration. If POS is given, set the points to
;; the beginnings of the buffers.
;; When 3way comparison is added, this will have to choose the appropriate
;; setup function based on ediff-job-name
(defun ediff-setup-windows (buffer-A buffer-B buffer-C control-buffer)
;; Make sure we are not in the minibuffer window when we try to delete
;; all other windows.
(run-hooks 'ediff-before-setup-windows-hook)
1995-03-16 22:34:51 +00:00
(if (eq (selected-window) (minibuffer-window))
(other-window 1))
2003-02-04 11:26:42 +00:00
;; in case user did a no-no on a tty
(or (ediff-window-display-p)
(setq ediff-window-setup-function 'ediff-setup-windows-plain))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(or (ediff-keep-window-config control-buffer)
1999-12-18 16:14:32 +00:00
(funcall
1997-07-31 04:04:23 +00:00
(ediff-with-current-buffer control-buffer ediff-window-setup-function)
1995-03-16 22:34:51 +00:00
buffer-A buffer-B buffer-C control-buffer))
(run-hooks 'ediff-after-setup-windows-hook))
1995-03-16 22:34:51 +00:00
;; Just set up 3 windows.
;; Usually used without windowing systems
;; With windowing, we want to use dedicated frames.
(defun ediff-setup-windows-plain (buffer-A buffer-B buffer-C control-buffer)
1997-07-31 04:04:23 +00:00
(ediff-with-current-buffer control-buffer
1995-03-16 22:34:51 +00:00
(setq ediff-multiframe nil))
(if ediff-merge-job
(ediff-setup-windows-plain-merge
buffer-A buffer-B buffer-C control-buffer)
1999-12-18 16:14:32 +00:00
(ediff-setup-windows-plain-compare
1995-03-16 22:34:51 +00:00
buffer-A buffer-B buffer-C control-buffer)))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(defun ediff-setup-windows-plain-merge (buf-A buf-B buf-C control-buffer)
;; skip dedicated and unsplittable frames
(ediff-destroy-control-frame control-buffer)
1996-02-16 06:36:35 +00:00
(let ((window-min-height 1)
1999-12-18 16:14:32 +00:00
split-window-function
1995-03-16 22:34:51 +00:00
merge-window-share merge-window-lines
wind-A wind-B wind-C)
1997-07-31 04:04:23 +00:00
(ediff-with-current-buffer control-buffer
1995-03-16 22:34:51 +00:00
(setq merge-window-share ediff-merge-window-share
;; this lets us have local versions of ediff-split-window-function
split-window-function ediff-split-window-function))
(delete-other-windows)
(split-window-vertically)
(ediff-select-lowest-window)
(ediff-setup-control-buffer control-buffer)
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
;; go to the upper window and split it betw A, B, and possibly C
1999-12-18 16:14:32 +00:00
(other-window 1)
1995-03-16 22:34:51 +00:00
(setq merge-window-lines
(max 2 (round (* (window-height) merge-window-share))))
(switch-to-buffer buf-A)
(setq wind-A (selected-window))
2003-02-04 11:26:42 +00:00
;; XEmacs used to have a lot of trouble with display
;; It did't set things right unless we tell it to sit still
;; 19.12 seems ok.
;;(if ediff-xemacs-p (sit-for 0))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(split-window-vertically (max 2 (- (window-height) merge-window-lines)))
1999-12-18 16:14:32 +00:00
(if (eq (selected-window) wind-A)
1995-03-16 22:34:51 +00:00
(other-window 1))
(setq wind-C (selected-window))
(switch-to-buffer buf-C)
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(select-window wind-A)
(funcall split-window-function)
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(if (eq (selected-window) wind-A)
(other-window 1))
(switch-to-buffer buf-B)
(setq wind-B (selected-window))
2003-02-04 11:26:42 +00:00
1997-07-31 04:04:23 +00:00
(ediff-with-current-buffer control-buffer
1995-03-16 22:34:51 +00:00
(setq ediff-window-A wind-A
ediff-window-B wind-B
ediff-window-C wind-C))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(ediff-select-lowest-window)
(ediff-setup-control-buffer control-buffer)
))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
;; This function handles all comparison jobs, including 3way jobs
(defun ediff-setup-windows-plain-compare (buf-A buf-B buf-C control-buffer)
;; skip dedicated and unsplittable frames
(ediff-destroy-control-frame control-buffer)
1996-02-16 06:36:35 +00:00
(let ((window-min-height 1)
1995-03-16 22:34:51 +00:00
split-window-function wind-width-or-height
three-way-comparison
wind-A-start wind-B-start wind-A wind-B wind-C)
1997-07-31 04:04:23 +00:00
(ediff-with-current-buffer control-buffer
1995-03-16 22:34:51 +00:00
(setq wind-A-start (ediff-overlay-start
(ediff-get-value-according-to-buffer-type
'A ediff-narrow-bounds))
wind-B-start (ediff-overlay-start
(ediff-get-value-according-to-buffer-type
'B ediff-narrow-bounds))
;; this lets us have local versions of ediff-split-window-function
split-window-function ediff-split-window-function
three-way-comparison ediff-3way-comparison-job))
(delete-other-windows)
(split-window-vertically)
(ediff-select-lowest-window)
(ediff-setup-control-buffer control-buffer)
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
;; go to the upper window and split it betw A, B, and possibly C
1999-12-18 16:14:32 +00:00
(other-window 1)
1995-03-16 22:34:51 +00:00
(switch-to-buffer buf-A)
(setq wind-A (selected-window))
(if three-way-comparison
(setq wind-width-or-height
(/ (if (eq split-window-function 'split-window-vertically)
(window-height wind-A)
(window-width wind-A))
3)))
2003-02-04 11:26:42 +00:00
;; XEmacs used to have a lot of trouble with display
;; It did't set things right unless we told it to sit still
;; 19.12 seems ok.
;;(if ediff-xemacs-p (sit-for 0))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(funcall split-window-function wind-width-or-height)
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(if (eq (selected-window) wind-A)
(other-window 1))
(switch-to-buffer buf-B)
(setq wind-B (selected-window))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(if three-way-comparison
(progn
(funcall split-window-function) ; equally
(if (eq (selected-window) wind-B)
(other-window 1))
(switch-to-buffer buf-C)
(setq wind-C (selected-window))))
2003-02-04 11:26:42 +00:00
1997-07-31 04:04:23 +00:00
(ediff-with-current-buffer control-buffer
1995-03-16 22:34:51 +00:00
(setq ediff-window-A wind-A
ediff-window-B wind-B
ediff-window-C wind-C))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
;; It is unlikely that we will want to implement 3way window comparison.
;; So, only buffers A and B are used here.
(if ediff-windows-job
1995-03-16 22:34:51 +00:00
(progn
(set-window-start wind-A wind-A-start)
(set-window-start wind-B wind-B-start)))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(ediff-select-lowest-window)
(ediff-setup-control-buffer control-buffer)
))
2003-02-04 11:26:42 +00:00
1996-02-16 06:36:35 +00:00
;; dispatch an appropriate window setup function
1995-03-16 22:34:51 +00:00
(defun ediff-setup-windows-multiframe (buf-A buf-B buf-C control-buf)
1997-07-31 04:04:23 +00:00
(ediff-with-current-buffer control-buf
1995-03-16 22:34:51 +00:00
(setq ediff-multiframe t))
(if ediff-merge-job
(ediff-setup-windows-multiframe-merge buf-A buf-B buf-C control-buf)
(ediff-setup-windows-multiframe-compare buf-A buf-B buf-C control-buf)))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(defun ediff-setup-windows-multiframe-merge (buf-A buf-B buf-C control-buf)
;;; Algorithm:
1996-06-22 01:54:34 +00:00
;;; 1. Never use frames that have dedicated windows in them---it is bad to
;;; destroy dedicated windows.
;;; 2. If A and B are in the same frame but C's frame is different--- use one
1999-12-18 16:14:32 +00:00
;;; frame for A and B and use a separate frame for C.
1996-06-22 01:54:34 +00:00
;;; 3. If C's frame is non-existent, then: if the first suitable
;;; non-dedicated frame is different from A&B's, then use it for C.
;;; Otherwise, put A,B, and C in one frame.
;;; 4. If buffers A, B, C are is separate frames, use them to display these
;;; buffers.
1995-03-16 22:34:51 +00:00
1999-12-18 16:14:32 +00:00
;; Skip dedicated or iconified frames.
;; Unsplittable frames are taken care of later.
1995-03-16 22:34:51 +00:00
(ediff-skip-unsuitable-frames 'ok-unsplittable)
2003-02-04 11:26:42 +00:00
1996-02-16 06:36:35 +00:00
(let* ((window-min-height 1)
1995-03-16 22:34:51 +00:00
(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))
(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)))
1995-03-16 22:34:51 +00:00
;; on wide display, do things in one frame
1999-12-18 16:14:32 +00:00
(force-one-frame
1997-07-31 04:04:23 +00:00
(ediff-with-current-buffer control-buf ediff-wide-display-p))
1995-03-16 22:34:51 +00:00
;; this lets us have local versions of ediff-split-window-function
1999-12-18 16:14:32 +00:00
(split-window-function
1997-07-31 04:04:23 +00:00
(ediff-with-current-buffer control-buf ediff-split-window-function))
1995-03-16 22:34:51 +00:00
(orig-wind (selected-window))
(orig-frame (selected-frame))
1995-03-16 22:34:51 +00:00
(use-same-frame (or force-one-frame
1996-06-22 01:54:34 +00:00
;; A and C must be in one frame
1995-03-16 22:34:51 +00:00
(eq frame-A (or frame-C orig-frame))
1996-06-22 01:54:34 +00:00
;; B and C must be in one frame
1995-03-16 22:34:51 +00:00
(eq frame-B (or frame-C orig-frame))
1996-06-22 01:54:34 +00:00
;; A or B is not visible
(not (frame-live-p frame-A))
(not (frame-live-p frame-B))
1996-06-22 01:54:34 +00:00
;; A or B is not suitable for display
(not (ediff-window-ok-for-display wind-A))
(not (ediff-window-ok-for-display wind-B))
;; A and B in the same frame, and no good frame
;; for C
(and (eq frame-A frame-B)
(not (frame-live-p frame-C)))
1995-03-16 22:34:51 +00:00
))
1996-06-22 01:54:34 +00:00
;; use-same-frame-for-AB implies wind A and B are ok for display
1995-03-16 22:34:51 +00:00
(use-same-frame-for-AB (and (not use-same-frame)
(eq frame-A frame-B)))
1997-07-31 04:04:23 +00:00
(merge-window-share (ediff-with-current-buffer control-buf
1995-03-16 22:34:51 +00:00
ediff-merge-window-share))
merge-window-lines
designated-minibuffer-frame
done-A done-B done-C)
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
;; buf-A on its own
(if (and (window-live-p wind-A)
1996-06-22 01:54:34 +00:00
(null use-same-frame) ; implies wind-A is suitable
1995-03-16 22:34:51 +00:00
(null use-same-frame-for-AB))
1996-06-22 01:54:34 +00:00
(progn ; bug A on its own
;; buffer buf-A is seen in live wind-A
1995-03-16 22:34:51 +00:00
(select-window wind-A)
(delete-other-windows)
(setq wind-A (selected-window))
(setq done-A t)))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
;; buf-B on its own
1996-06-22 01:54:34 +00:00
(if (and (window-live-p wind-B)
(null use-same-frame) ; implies wind-B is suitable
(null use-same-frame-for-AB))
(progn ; buf B on its own
;; buffer buf-B is seen in live wind-B
1995-03-16 22:34:51 +00:00
(select-window wind-B)
(delete-other-windows)
(setq wind-B (selected-window))
(setq done-B t)))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
;; buf-C on its own
1996-06-22 01:54:34 +00:00
(if (and (window-live-p wind-C)
(ediff-window-ok-for-display wind-C)
(null use-same-frame)) ; buf C on its own
1995-03-16 22:34:51 +00:00
(progn
1996-06-22 01:54:34 +00:00
;; buffer buf-C is seen in live wind-C
1995-03-16 22:34:51 +00:00
(select-window wind-C)
(delete-other-windows)
(setq wind-C (selected-window))
(setq done-C t)))
2003-02-04 11:26:42 +00:00
1996-06-22 01:54:34 +00:00
(if (and use-same-frame-for-AB ; implies wind A and B are suitable
(window-live-p wind-A))
1999-12-18 16:14:32 +00:00
(progn
1996-06-22 01:54:34 +00:00
;; wind-A must already be displaying buf-A
(select-window wind-A)
1995-03-16 22:34:51 +00:00
(delete-other-windows)
(setq wind-A (selected-window))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(funcall split-window-function)
1999-12-18 16:14:32 +00:00
(if (eq (selected-window) wind-A)
1995-03-16 22:34:51 +00:00
(other-window 1))
(switch-to-buffer buf-B)
(setq wind-B (selected-window))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(setq done-A t
done-B t)))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(if use-same-frame
1996-06-22 01:54:34 +00:00
(let ((window-min-height 1))
1997-05-31 01:10:39 +00:00
(if (and (eq frame-A frame-B)
(eq frame-B frame-C)
(frame-live-p frame-A))
(select-frame frame-A)
;; avoid dedicated and non-splittable windows
(ediff-skip-unsuitable-frames))
1995-03-16 22:34:51 +00:00
(delete-other-windows)
(setq merge-window-lines
(max 2 (round (* (window-height) merge-window-share))))
(switch-to-buffer buf-A)
(setq wind-A (selected-window))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(split-window-vertically
(max 2 (- (window-height) merge-window-lines)))
1999-12-18 16:14:32 +00:00
(if (eq (selected-window) wind-A)
1995-03-16 22:34:51 +00:00
(other-window 1))
(setq wind-C (selected-window))
(switch-to-buffer buf-C)
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(select-window wind-A)
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(funcall split-window-function)
1999-12-18 16:14:32 +00:00
(if (eq (selected-window) wind-A)
1995-03-16 22:34:51 +00:00
(other-window 1))
(switch-to-buffer buf-B)
(setq wind-B (selected-window))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(setq done-A t
done-B t
done-C t)
))
2003-02-04 11:26:42 +00:00
1996-06-22 01:54:34 +00:00
(or done-A ; Buf A to be set in its own frame,
;;; or it was set before because use-same-frame = 1
(progn
;; Buf-A was not set up yet as it wasn't visible,
;; and use-same-frame = nil, use-same-frame-for-AB = nil
1995-03-16 22:34:51 +00:00
(select-window orig-wind)
(delete-other-windows)
(switch-to-buffer buf-A)
(setq wind-A (selected-window))
))
1996-06-22 01:54:34 +00:00
(or done-B ; Buf B to be set in its own frame,
;;; or it was set before because use-same-frame = 1
(progn
;; Buf-B was not set up yet as it wasn't visible
;; and use-same-frame = nil, use-same-frame-for-AB = nil
1995-03-16 22:34:51 +00:00
(select-window orig-wind)
(delete-other-windows)
(switch-to-buffer buf-B)
(setq wind-B (selected-window))
))
2003-02-04 11:26:42 +00:00
1996-06-22 01:54:34 +00:00
(or done-C ; Buf C to be set in its own frame,
;;; or it was set before because use-same-frame = 1
(progn
;; Buf-C was not set up yet as it wasn't visible
;; and use-same-frame = nil
1995-03-16 22:34:51 +00:00
(select-window orig-wind)
(delete-other-windows)
(switch-to-buffer buf-C)
(setq wind-C (selected-window))
))
2003-02-04 11:26:42 +00:00
1997-07-31 04:04:23 +00:00
(ediff-with-current-buffer control-buf
1995-03-16 22:34:51 +00:00
(setq ediff-window-A wind-A
ediff-window-B wind-B
ediff-window-C wind-C)
(setq frame-A (window-frame ediff-window-A)
designated-minibuffer-frame
(window-frame (minibuffer-window frame-A))))
2003-02-04 11:26:42 +00:00
(ediff-setup-control-frame control-buf designated-minibuffer-frame)
1995-03-16 22:34:51 +00:00
))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
;; Window setup for all comparison jobs, including 3way comparisons
(defun ediff-setup-windows-multiframe-compare (buf-A buf-B buf-C control-buf)
;;; Algorithm:
1999-12-18 16:14:32 +00:00
;;; If a buffer is seen in a frame, use that frame for that buffer.
1995-03-16 22:34:51 +00:00
;;; If it is not seen, use the current frame.
;;; If both buffers are not seen, they share the current frame. If one
;;; of the buffers is not seen, it is placed in the current frame (where
1999-11-01 07:16:15 +00:00
;;; ediff started). If that frame is displaying the other buffer, it is
1995-03-16 22:34:51 +00:00
;;; shared between the two buffers.
;;; However, if we decide to put both buffers in one frame
;;; and the selected frame isn't splittable, we create a new frame and
;;; put both buffers there, event if one of this buffers is visible in
;;; another frame.
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
;; Skip dedicated or iconified frames.
;; Unsplittable frames are taken care of later.
(ediff-skip-unsuitable-frames 'ok-unsplittable)
2003-02-04 11:26:42 +00:00
1996-02-16 06:36:35 +00:00
(let* ((window-min-height 1)
1995-03-16 22:34:51 +00:00
(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))
(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)))
1997-07-31 04:04:23 +00:00
(ctl-frame-exists-p (ediff-with-current-buffer control-buf
(frame-live-p ediff-control-frame)))
1995-03-16 22:34:51 +00:00
;; on wide display, do things in one frame
1999-12-18 16:14:32 +00:00
(force-one-frame
1997-07-31 04:04:23 +00:00
(ediff-with-current-buffer control-buf ediff-wide-display-p))
1995-03-16 22:34:51 +00:00
;; this lets us have local versions of ediff-split-window-function
1999-12-18 16:14:32 +00:00
(split-window-function
1997-07-31 04:04:23 +00:00
(ediff-with-current-buffer control-buf ediff-split-window-function))
1995-03-16 22:34:51 +00:00
(three-way-comparison
1997-07-31 04:04:23 +00:00
(ediff-with-current-buffer control-buf ediff-3way-comparison-job))
1995-03-16 22:34:51 +00:00
(orig-wind (selected-window))
(use-same-frame (or force-one-frame
(eq frame-A frame-B)
1996-06-22 01:54:34 +00:00
(not (ediff-window-ok-for-display wind-A))
(not (ediff-window-ok-for-display wind-B))
1995-03-16 22:34:51 +00:00
(if three-way-comparison
(or (eq frame-A frame-C)
(eq frame-B frame-C)
1996-06-22 01:54:34 +00:00
(not (ediff-window-ok-for-display wind-C))
(not (frame-live-p frame-A))
(not (frame-live-p frame-B))
(not (frame-live-p frame-C))))
(and (not (frame-live-p frame-B))
1995-03-16 22:34:51 +00:00
(or ctl-frame-exists-p
(eq frame-A (selected-frame))))
(and (not (frame-live-p frame-A))
1995-03-16 22:34:51 +00:00
(or ctl-frame-exists-p
(eq frame-B (selected-frame))))))
1999-12-18 16:14:32 +00:00
wind-A-start wind-B-start
1995-03-16 22:34:51 +00:00
designated-minibuffer-frame
done-A done-B done-C)
2003-02-04 11:26:42 +00:00
1997-07-31 04:04:23 +00:00
(ediff-with-current-buffer control-buf
1995-03-16 22:34:51 +00:00
(setq wind-A-start (ediff-overlay-start
(ediff-get-value-according-to-buffer-type
'A ediff-narrow-bounds))
wind-B-start (ediff-overlay-start
(ediff-get-value-according-to-buffer-type
'B ediff-narrow-bounds))))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(if (and (window-live-p wind-A) (null use-same-frame)) ; buf-A on its own
(progn
1996-06-22 01:54:34 +00:00
;; buffer buf-A is seen in live wind-A
(select-window wind-A) ; must be displaying buf-A
1995-03-16 22:34:51 +00:00
(delete-other-windows)
(setq wind-A (selected-window))
(setq done-A t)))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(if (and (window-live-p wind-B) (null use-same-frame)) ; buf B on its own
(progn
1996-06-22 01:54:34 +00:00
;; buffer buf-B is seen in live wind-B
(select-window wind-B) ; must be displaying buf-B
1995-03-16 22:34:51 +00:00
(delete-other-windows)
(setq wind-B (selected-window))
(setq done-B t)))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(if (and (window-live-p wind-C) (null use-same-frame)) ; buf C on its own
(progn
1996-06-22 01:54:34 +00:00
;; buffer buf-C is seen in live wind-C
(select-window wind-C) ; must be displaying buf-C
1995-03-16 22:34:51 +00:00
(delete-other-windows)
(setq wind-C (selected-window))
(setq done-C t)))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(if use-same-frame
1996-06-22 01:54:34 +00:00
(let (wind-width-or-height) ; this affects 3way setups only
1997-05-31 01:10:39 +00:00
(if (and (eq frame-A frame-B) (frame-live-p frame-A))
(select-frame frame-A)
;; avoid dedicated and non-splittable windows
(ediff-skip-unsuitable-frames))
1995-03-16 22:34:51 +00:00
(delete-other-windows)
(switch-to-buffer buf-A)
(setq wind-A (selected-window))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(if three-way-comparison
(setq wind-width-or-height
(/
(if (eq split-window-function 'split-window-vertically)
(window-height wind-A)
(window-width wind-A))
3)))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(funcall split-window-function wind-width-or-height)
1999-12-18 16:14:32 +00:00
(if (eq (selected-window) wind-A)
1995-03-16 22:34:51 +00:00
(other-window 1))
(switch-to-buffer buf-B)
(setq wind-B (selected-window))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(if three-way-comparison
(progn
(funcall split-window-function) ; equally
(if (memq (selected-window) (list wind-A wind-B))
(other-window 1))
(switch-to-buffer buf-C)
(setq wind-C (selected-window))))
(setq done-A t
done-B t
done-C t)
))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(or done-A ; Buf A to be set in its own frame
1996-06-22 01:54:34 +00:00
;;; or it was set before because use-same-frame = 1
1999-12-18 16:14:32 +00:00
(progn
1996-06-22 01:54:34 +00:00
;; Buf-A was not set up yet as it wasn't visible,
;; and use-same-frame = nil
1995-03-16 22:34:51 +00:00
(select-window orig-wind)
(delete-other-windows)
(switch-to-buffer buf-A)
(setq wind-A (selected-window))
))
(or done-B ; Buf B to be set in its own frame
1996-06-22 01:54:34 +00:00
;;; or it was set before because use-same-frame = 1
1999-12-18 16:14:32 +00:00
(progn
1996-06-22 01:54:34 +00:00
;; Buf-B was not set up yet as it wasn't visible,
;; and use-same-frame = nil
1995-03-16 22:34:51 +00:00
(select-window orig-wind)
(delete-other-windows)
(switch-to-buffer buf-B)
(setq wind-B (selected-window))
))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(if three-way-comparison
(or done-C ; Buf C to be set in its own frame
1996-06-22 01:54:34 +00:00
;;; or it was set before because use-same-frame = 1
1999-12-18 16:14:32 +00:00
(progn
1996-06-22 01:54:34 +00:00
;; Buf-C was not set up yet as it wasn't visible,
;; and use-same-frame = nil
1995-03-16 22:34:51 +00:00
(select-window orig-wind)
(delete-other-windows)
(switch-to-buffer buf-C)
(setq wind-C (selected-window))
)))
2003-02-04 11:26:42 +00:00
1997-07-31 04:04:23 +00:00
(ediff-with-current-buffer control-buf
1995-03-16 22:34:51 +00:00
(setq ediff-window-A wind-A
ediff-window-B wind-B
ediff-window-C wind-C)
(setq frame-A (window-frame ediff-window-A)
designated-minibuffer-frame
(window-frame (minibuffer-window frame-A))))
2003-02-04 11:26:42 +00:00
1996-06-22 01:54:34 +00:00
;; It is unlikely that we'll implement a version of ediff-windows that
1999-11-01 07:16:15 +00:00
;; would compare 3 windows at once. So, we don't use buffer C here.
(if ediff-windows-job
1995-03-16 22:34:51 +00:00
(progn
(set-window-start wind-A wind-A-start)
(set-window-start wind-B wind-B-start)))
2003-02-04 11:26:42 +00:00
(ediff-setup-control-frame control-buf designated-minibuffer-frame)
1995-03-16 22:34:51 +00:00
))
1996-06-22 01:54:34 +00:00
;; skip unsplittable frames and frames that have dedicated windows.
1995-03-16 22:34:51 +00:00
;; create a new splittable frame if none is found
(defun ediff-skip-unsuitable-frames (&optional ok-unsplittable)
(if (ediff-window-display-p)
(let ((wind-frame (window-frame (selected-window)))
seen-windows)
2000-10-29 Michael Kifer <kifer@cs.sunysb.edu> * viper-cmd.el (viper-preserve-cursor-color): new test that avoids rewrawing the screen when changing cursor color. (viper-insert-state-pre-command-sentinel, viper-replace-state-pre-command-sentinel, viper-replace-state-post-command-sentinel): use viper-preserve-cursor-color. Many functions changed to use viper= instead of = when comparing characters. * viper-util.el (viper-memq-char,viper=): new functions for working with characters. (viper-change-cursor-color): fixed buglet. Many functions changed to use viper= instead of = when comparing characters. * viper.el (viper-insert-state-mode-list): added eshell. * ediff-init.el (ediff-before-setup-hook): new hook. Several typos fixed in various docstrings. * ediff-merg.el (ediff-show-clashes-only): docstring typo fixed. * ediff-nult.el (ediff-before-session-group-setup-hooks): new hook. (ediff-show-meta-buffer): run ediff-before-session-group-setup-hooks. * ediff-util.el (ediff-setup): run ediff-before-setup-hook. (ediff-other-buffer): use selected buffers if in Buffer-menu buffer. (ediff-get-selected-buffers): new function. * ediff-vers.el (ediff-vc-internal,ediff-rcs-internal, ediff-vc-merge-internal,ediff-rcs-merge-internal): use save-window-excursion. * ediff-wind.el (ediff-skip-unsuitable-frames): more robust termination check in while loop. * ediff.el (ediff-get-default-file-name): better defaults when in dired buffer. (ediff-files,ediff-merge-files,ediff-files3, ediff-merge-files-with-ancestor): use ediff-get-default-file-name.
2000-10-29 04:56:45 +00:00
(while (and (not (memq (selected-window) seen-windows))
1995-03-16 22:34:51 +00:00
(or
(ediff-frame-has-dedicated-windows wind-frame)
(ediff-frame-iconified-p wind-frame)
1999-11-01 07:16:15 +00:00
;; skip small windows
(< (frame-height wind-frame)
1999-11-01 07:16:15 +00:00
(* 3 window-min-height))
1995-03-16 22:34:51 +00:00
(if ok-unsplittable
nil
(ediff-frame-unsplittable-p wind-frame))))
;; remember history
2000-10-29 Michael Kifer <kifer@cs.sunysb.edu> * viper-cmd.el (viper-preserve-cursor-color): new test that avoids rewrawing the screen when changing cursor color. (viper-insert-state-pre-command-sentinel, viper-replace-state-pre-command-sentinel, viper-replace-state-post-command-sentinel): use viper-preserve-cursor-color. Many functions changed to use viper= instead of = when comparing characters. * viper-util.el (viper-memq-char,viper=): new functions for working with characters. (viper-change-cursor-color): fixed buglet. Many functions changed to use viper= instead of = when comparing characters. * viper.el (viper-insert-state-mode-list): added eshell. * ediff-init.el (ediff-before-setup-hook): new hook. Several typos fixed in various docstrings. * ediff-merg.el (ediff-show-clashes-only): docstring typo fixed. * ediff-nult.el (ediff-before-session-group-setup-hooks): new hook. (ediff-show-meta-buffer): run ediff-before-session-group-setup-hooks. * ediff-util.el (ediff-setup): run ediff-before-setup-hook. (ediff-other-buffer): use selected buffers if in Buffer-menu buffer. (ediff-get-selected-buffers): new function. * ediff-vers.el (ediff-vc-internal,ediff-rcs-internal, ediff-vc-merge-internal,ediff-rcs-merge-internal): use save-window-excursion. * ediff-wind.el (ediff-skip-unsuitable-frames): more robust termination check in while loop. * ediff.el (ediff-get-default-file-name): better defaults when in dired buffer. (ediff-files,ediff-merge-files,ediff-files3, ediff-merge-files-with-ancestor): use ediff-get-default-file-name.
2000-10-29 04:56:45 +00:00
(setq seen-windows (cons (selected-window) seen-windows))
1995-03-16 22:34:51 +00:00
;; try new window
(other-window 1 t)
(setq wind-frame (window-frame (selected-window)))
)
2000-10-29 Michael Kifer <kifer@cs.sunysb.edu> * viper-cmd.el (viper-preserve-cursor-color): new test that avoids rewrawing the screen when changing cursor color. (viper-insert-state-pre-command-sentinel, viper-replace-state-pre-command-sentinel, viper-replace-state-post-command-sentinel): use viper-preserve-cursor-color. Many functions changed to use viper= instead of = when comparing characters. * viper-util.el (viper-memq-char,viper=): new functions for working with characters. (viper-change-cursor-color): fixed buglet. Many functions changed to use viper= instead of = when comparing characters. * viper.el (viper-insert-state-mode-list): added eshell. * ediff-init.el (ediff-before-setup-hook): new hook. Several typos fixed in various docstrings. * ediff-merg.el (ediff-show-clashes-only): docstring typo fixed. * ediff-nult.el (ediff-before-session-group-setup-hooks): new hook. (ediff-show-meta-buffer): run ediff-before-session-group-setup-hooks. * ediff-util.el (ediff-setup): run ediff-before-setup-hook. (ediff-other-buffer): use selected buffers if in Buffer-menu buffer. (ediff-get-selected-buffers): new function. * ediff-vers.el (ediff-vc-internal,ediff-rcs-internal, ediff-vc-merge-internal,ediff-rcs-merge-internal): use save-window-excursion. * ediff-wind.el (ediff-skip-unsuitable-frames): more robust termination check in while loop. * ediff.el (ediff-get-default-file-name): better defaults when in dired buffer. (ediff-files,ediff-merge-files,ediff-files3, ediff-merge-files-with-ancestor): use ediff-get-default-file-name.
2000-10-29 04:56:45 +00:00
(if (memq (selected-window) seen-windows)
;; fed up, no appropriate frames
(setq wind-frame (make-frame '((unsplittable)))))
(select-frame wind-frame)
)))
1995-03-16 22:34:51 +00:00
1996-06-22 01:54:34 +00:00
(defun ediff-frame-has-dedicated-windows (frame)
(let (ans)
2003-02-04 11:26:42 +00:00
(walk-windows
1999-11-01 07:16:15 +00:00
(lambda (wind) (if (window-dedicated-p wind)
(setq ans t)))
1996-06-22 01:54:34 +00:00
'ignore-minibuffer
frame)
ans))
;; window is ok, if it is only one window on the frame, not counting the
;; minibuffer, or none of the frame's windows is dedicated.
;; The idea is that it is bad to destroy dedicated windows while creating an
;; ediff window setup
(defun ediff-window-ok-for-display (wind)
(and
(window-live-p wind)
1999-12-18 16:14:32 +00:00
(or
1996-06-22 01:54:34 +00:00
;; only one window
(eq wind (next-window wind 'ignore-minibuffer (window-frame wind)))
;; none is dedicated
(not (ediff-frame-has-dedicated-windows (window-frame wind)))
)))
1995-03-16 22:34:51 +00:00
;; Prepare or refresh control frame
(defun ediff-setup-control-frame (ctl-buffer designated-minibuffer-frame)
1996-02-16 06:36:35 +00:00
(let ((window-min-height 1)
1995-03-16 22:34:51 +00:00
ctl-frame-iconified-p dont-iconify-ctl-frame deiconify-ctl-frame
1999-12-18 16:14:32 +00:00
ctl-frame old-ctl-frame lines
1996-06-22 01:54:34 +00:00
;; user-grabbed-mouse
1999-12-18 16:14:32 +00:00
fheight fwidth adjusted-parameters)
2003-02-04 11:26:42 +00:00
1997-07-31 04:04:23 +00:00
(ediff-with-current-buffer ctl-buffer
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu> * viper-init.el (viper-cond-compile-for-xemacs-or-emacs): new macro that replaces viper-emacs-p and viper-xemacs-p in many cases. Used to reduce the number of warnings. * viper-cmd.el: use viper-cond-compile-for-xemacs-or-emacs. (viper-standard-value): moved here from viper.el. (viper-set-unread-command-events): moved to viper-util.el (viper-check-minibuffer-overlay): make sure viper-minibuffer-overlay is moved to cover the entire input field. * viper-util.el: use viper-cond-compile-for-xemacs-or-emacs. (viper-read-key-sequence, viper-set-unread-command-events, viper-char-symbol-sequence-p, viper-char-array-p): moved here. * viper-ex.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-keym.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-mous.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-macs.el (viper-char-array-p, viper-char-symbol-sequence-p, viper-event-vector-p): moved to viper-util.el * viper.el (viper-standard-value): moved to viper-cmd.el. Use viper-cond-compile-for-xemacs-or-emacs. * ediff-help.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-hook.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-init.el (ediff-cond-compile-for-xemacs-or-emacs): new macro designed to be used in many places where ediff-emacs-p or ediff-xemacs-p was previously used. Reduces the number of warnings. Use ediff-cond-compile-for-xemacs-or-emacs in many places in lieue of ediff-xemacs-p. (ediff-make-current-diff-overlay, ediff-highlight-diff-in-one-buffer, ediff-convert-fine-diffs-to-overlays, ediff-empty-diff-region-p, ediff-whitespace-diff-region-p, ediff-get-region-contents): moved to ediff-util.el. (ediff-event-key): moved here. * ediff-merge.el: got rid of unreferenced variables. * ediff-mult.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-util.el: use ediff-cond-compile-for-xemacs-or-emacs. (ediff-cleanup-mess): improved the way windows are set up after quitting ediff. (ediff-janitor): use ediff-dispose-of-variant-according-to-user. (ediff-dispose-of-variant-according-to-user): new function designed to be smarter and also understands indirect buffers. (ediff-highlight-diff-in-one-buffer, ediff-unhighlight-diff-in-one-buffer, ediff-unhighlight-diffs-totally-in-one-buffer, ediff-highlight-diff, ediff-highlight-diff, ediff-unhighlight-diff, ediff-unhighlight-diffs-totally, ediff-empty-diff-region-p, ediff-whitespace-diff-region-p, ediff-get-region-contents, ediff-make-current-diff-overlay): moved here. (ediff-format-bindings-of): new function by Hannu Koivisto <azure@iki.fi>. (ediff-setup): make sure the merge buffer is always widened and modifiable. (ediff-write-merge-buffer-and-maybe-kill): refuse to write the result of a merge into a file visited by another buffer. (ediff-arrange-autosave-in-merge-jobs): check if the merge file is visited by another buffer and ask to save/delete that buffer. (ediff-verify-file-merge-buffer): new function to do the above. * ediff-vers.el: load ediff-init.el at compile time. * ediff-wind.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff.el (ediff-windows, ediff-regions-wordwise, ediff-regions-linewise): use indirect buffers to improve robustness and make it possible to compare regions of the same buffer (even overlapping regions). (ediff-clone-buffer-for-region-comparison, ediff-clone-buffer-for-window-comparison): new functions. (ediff-files-internal): refuse to compare identical files. (ediff-regions-internal): get rid of the warning about comparing regions of the same buffer. * ediff-diff.el (ediff-convert-fine-diffs-to-overlays): moved here. Plus the following fixes courtesy of Dave Love: Doc fixes. (ediff-word-1): Use word class and move - to the front per regexp documentation. (ediff-wordify): Bind forward-word-function outside loop. (ediff-copy-to-buffer): Use insert-buffer-substring rather than consing buffer contents. (ediff-goto-word): Move syntax table setting outside loop.
2002-01-08 04:36:01 +00:00
(ediff-cond-compile-for-xemacs-or-emacs
(set-buffer-menubar nil) ; xemacs
nil ; emacs
)
;;(setq user-grabbed-mouse (ediff-user-grabbed-mouse))
(run-hooks 'ediff-before-setup-control-frame-hook))
2003-02-04 11:26:42 +00:00
1997-07-31 04:04:23 +00:00
(setq old-ctl-frame (ediff-with-current-buffer ctl-buffer ediff-control-frame))
(ediff-with-current-buffer ctl-buffer
1996-02-16 06:36:35 +00:00
(setq ctl-frame (if (frame-live-p old-ctl-frame)
old-ctl-frame
(make-frame ediff-control-frame-parameters))
ediff-control-frame ctl-frame)
;; protect against undefined face-attribute
(condition-case nil
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu> * viper-init.el (viper-cond-compile-for-xemacs-or-emacs): new macro that replaces viper-emacs-p and viper-xemacs-p in many cases. Used to reduce the number of warnings. * viper-cmd.el: use viper-cond-compile-for-xemacs-or-emacs. (viper-standard-value): moved here from viper.el. (viper-set-unread-command-events): moved to viper-util.el (viper-check-minibuffer-overlay): make sure viper-minibuffer-overlay is moved to cover the entire input field. * viper-util.el: use viper-cond-compile-for-xemacs-or-emacs. (viper-read-key-sequence, viper-set-unread-command-events, viper-char-symbol-sequence-p, viper-char-array-p): moved here. * viper-ex.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-keym.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-mous.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-macs.el (viper-char-array-p, viper-char-symbol-sequence-p, viper-event-vector-p): moved to viper-util.el * viper.el (viper-standard-value): moved to viper-cmd.el. Use viper-cond-compile-for-xemacs-or-emacs. * ediff-help.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-hook.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-init.el (ediff-cond-compile-for-xemacs-or-emacs): new macro designed to be used in many places where ediff-emacs-p or ediff-xemacs-p was previously used. Reduces the number of warnings. Use ediff-cond-compile-for-xemacs-or-emacs in many places in lieue of ediff-xemacs-p. (ediff-make-current-diff-overlay, ediff-highlight-diff-in-one-buffer, ediff-convert-fine-diffs-to-overlays, ediff-empty-diff-region-p, ediff-whitespace-diff-region-p, ediff-get-region-contents): moved to ediff-util.el. (ediff-event-key): moved here. * ediff-merge.el: got rid of unreferenced variables. * ediff-mult.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-util.el: use ediff-cond-compile-for-xemacs-or-emacs. (ediff-cleanup-mess): improved the way windows are set up after quitting ediff. (ediff-janitor): use ediff-dispose-of-variant-according-to-user. (ediff-dispose-of-variant-according-to-user): new function designed to be smarter and also understands indirect buffers. (ediff-highlight-diff-in-one-buffer, ediff-unhighlight-diff-in-one-buffer, ediff-unhighlight-diffs-totally-in-one-buffer, ediff-highlight-diff, ediff-highlight-diff, ediff-unhighlight-diff, ediff-unhighlight-diffs-totally, ediff-empty-diff-region-p, ediff-whitespace-diff-region-p, ediff-get-region-contents, ediff-make-current-diff-overlay): moved here. (ediff-format-bindings-of): new function by Hannu Koivisto <azure@iki.fi>. (ediff-setup): make sure the merge buffer is always widened and modifiable. (ediff-write-merge-buffer-and-maybe-kill): refuse to write the result of a merge into a file visited by another buffer. (ediff-arrange-autosave-in-merge-jobs): check if the merge file is visited by another buffer and ask to save/delete that buffer. (ediff-verify-file-merge-buffer): new function to do the above. * ediff-vers.el: load ediff-init.el at compile time. * ediff-wind.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff.el (ediff-windows, ediff-regions-wordwise, ediff-regions-linewise): use indirect buffers to improve robustness and make it possible to compare regions of the same buffer (even overlapping regions). (ediff-clone-buffer-for-region-comparison, ediff-clone-buffer-for-window-comparison): new functions. (ediff-files-internal): refuse to compare identical files. (ediff-regions-internal): get rid of the warning about comparing regions of the same buffer. * ediff-diff.el (ediff-convert-fine-diffs-to-overlays): moved here. Plus the following fixes courtesy of Dave Love: Doc fixes. (ediff-word-1): Use word class and move - to the front per regexp documentation. (ediff-wordify): Bind forward-word-function outside loop. (ediff-copy-to-buffer): Use insert-buffer-substring rather than consing buffer contents. (ediff-goto-word): Move syntax table setting outside loop.
2002-01-08 04:36:01 +00:00
(ediff-cond-compile-for-xemacs-or-emacs
nil ; xemacs
(when (face-attribute 'mode-line :box)
(set-face-attribute 'mode-line ctl-frame :box nil))
)
(error))
)
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(setq ctl-frame-iconified-p (ediff-frame-iconified-p ctl-frame))
(select-frame ctl-frame)
1995-03-16 22:34:51 +00:00
(if (window-dedicated-p (selected-window))
()
(delete-other-windows)
(switch-to-buffer ctl-buffer))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
;; must be before ediff-setup-control-buffer
;; just a precaution--we should be in ctl-buffer already
1997-07-31 04:04:23 +00:00
(ediff-with-current-buffer ctl-buffer
(make-local-variable 'frame-title-format)
(make-local-variable 'frame-icon-title-format) ; XEmacs
(make-local-variable 'icon-title-format)) ; Emacs
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(ediff-setup-control-buffer ctl-buffer)
(setq dont-iconify-ctl-frame
(not (string= ediff-help-message ediff-brief-help-message)))
1999-12-18 16:14:32 +00:00
(setq deiconify-ctl-frame
1995-03-16 22:34:51 +00:00
(and (eq this-command 'ediff-toggle-help)
dont-iconify-ctl-frame))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
;; 1 more line for the modeline
1996-02-16 06:36:35 +00:00
(setq lines (1+ (count-lines (point-min) (point-max)))
1995-03-16 22:34:51 +00:00
fheight lines
1996-12-28 02:53:04 +00:00
fwidth (max (+ (ediff-help-message-line-length) 2)
(ediff-compute-toolbar-width))
1997-05-31 01:10:39 +00:00
adjusted-parameters
(list
;; possibly change surrogate minibuffer
(cons 'minibuffer
(minibuffer-window
designated-minibuffer-frame))
(cons 'width fwidth)
(cons 'height fheight))
)
;; adjust autoraise
(setq adjusted-parameters
(cons (if ediff-use-long-help-message
'(auto-raise . nil)
'(auto-raise . t))
adjusted-parameters))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
;; In XEmacs, buffer menubar needs to be killed before frame parameters
1999-12-18 16:14:32 +00:00
;; are changed.
1998-05-04 22:42:59 +00:00
(if (ediff-has-toolbar-support-p)
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu> * viper-init.el (viper-cond-compile-for-xemacs-or-emacs): new macro that replaces viper-emacs-p and viper-xemacs-p in many cases. Used to reduce the number of warnings. * viper-cmd.el: use viper-cond-compile-for-xemacs-or-emacs. (viper-standard-value): moved here from viper.el. (viper-set-unread-command-events): moved to viper-util.el (viper-check-minibuffer-overlay): make sure viper-minibuffer-overlay is moved to cover the entire input field. * viper-util.el: use viper-cond-compile-for-xemacs-or-emacs. (viper-read-key-sequence, viper-set-unread-command-events, viper-char-symbol-sequence-p, viper-char-array-p): moved here. * viper-ex.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-keym.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-mous.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-macs.el (viper-char-array-p, viper-char-symbol-sequence-p, viper-event-vector-p): moved to viper-util.el * viper.el (viper-standard-value): moved to viper-cmd.el. Use viper-cond-compile-for-xemacs-or-emacs. * ediff-help.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-hook.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-init.el (ediff-cond-compile-for-xemacs-or-emacs): new macro designed to be used in many places where ediff-emacs-p or ediff-xemacs-p was previously used. Reduces the number of warnings. Use ediff-cond-compile-for-xemacs-or-emacs in many places in lieue of ediff-xemacs-p. (ediff-make-current-diff-overlay, ediff-highlight-diff-in-one-buffer, ediff-convert-fine-diffs-to-overlays, ediff-empty-diff-region-p, ediff-whitespace-diff-region-p, ediff-get-region-contents): moved to ediff-util.el. (ediff-event-key): moved here. * ediff-merge.el: got rid of unreferenced variables. * ediff-mult.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-util.el: use ediff-cond-compile-for-xemacs-or-emacs. (ediff-cleanup-mess): improved the way windows are set up after quitting ediff. (ediff-janitor): use ediff-dispose-of-variant-according-to-user. (ediff-dispose-of-variant-according-to-user): new function designed to be smarter and also understands indirect buffers. (ediff-highlight-diff-in-one-buffer, ediff-unhighlight-diff-in-one-buffer, ediff-unhighlight-diffs-totally-in-one-buffer, ediff-highlight-diff, ediff-highlight-diff, ediff-unhighlight-diff, ediff-unhighlight-diffs-totally, ediff-empty-diff-region-p, ediff-whitespace-diff-region-p, ediff-get-region-contents, ediff-make-current-diff-overlay): moved here. (ediff-format-bindings-of): new function by Hannu Koivisto <azure@iki.fi>. (ediff-setup): make sure the merge buffer is always widened and modifiable. (ediff-write-merge-buffer-and-maybe-kill): refuse to write the result of a merge into a file visited by another buffer. (ediff-arrange-autosave-in-merge-jobs): check if the merge file is visited by another buffer and ask to save/delete that buffer. (ediff-verify-file-merge-buffer): new function to do the above. * ediff-vers.el: load ediff-init.el at compile time. * ediff-wind.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff.el (ediff-windows, ediff-regions-wordwise, ediff-regions-linewise): use indirect buffers to improve robustness and make it possible to compare regions of the same buffer (even overlapping regions). (ediff-clone-buffer-for-region-comparison, ediff-clone-buffer-for-window-comparison): new functions. (ediff-files-internal): refuse to compare identical files. (ediff-regions-internal): get rid of the warning about comparing regions of the same buffer. * ediff-diff.el (ediff-convert-fine-diffs-to-overlays): moved here. Plus the following fixes courtesy of Dave Love: Doc fixes. (ediff-word-1): Use word class and move - to the front per regexp documentation. (ediff-wordify): Bind forward-word-function outside loop. (ediff-copy-to-buffer): Use insert-buffer-substring rather than consing buffer contents. (ediff-goto-word): Move syntax table setting outside loop.
2002-01-08 04:36:01 +00:00
(ediff-cond-compile-for-xemacs-or-emacs
(progn ; xemacs
(if (ediff-has-gutter-support-p)
(set-specifier top-gutter (list ctl-frame nil)))
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu> * viper-init.el (viper-cond-compile-for-xemacs-or-emacs): new macro that replaces viper-emacs-p and viper-xemacs-p in many cases. Used to reduce the number of warnings. * viper-cmd.el: use viper-cond-compile-for-xemacs-or-emacs. (viper-standard-value): moved here from viper.el. (viper-set-unread-command-events): moved to viper-util.el (viper-check-minibuffer-overlay): make sure viper-minibuffer-overlay is moved to cover the entire input field. * viper-util.el: use viper-cond-compile-for-xemacs-or-emacs. (viper-read-key-sequence, viper-set-unread-command-events, viper-char-symbol-sequence-p, viper-char-array-p): moved here. * viper-ex.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-keym.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-mous.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-macs.el (viper-char-array-p, viper-char-symbol-sequence-p, viper-event-vector-p): moved to viper-util.el * viper.el (viper-standard-value): moved to viper-cmd.el. Use viper-cond-compile-for-xemacs-or-emacs. * ediff-help.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-hook.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-init.el (ediff-cond-compile-for-xemacs-or-emacs): new macro designed to be used in many places where ediff-emacs-p or ediff-xemacs-p was previously used. Reduces the number of warnings. Use ediff-cond-compile-for-xemacs-or-emacs in many places in lieue of ediff-xemacs-p. (ediff-make-current-diff-overlay, ediff-highlight-diff-in-one-buffer, ediff-convert-fine-diffs-to-overlays, ediff-empty-diff-region-p, ediff-whitespace-diff-region-p, ediff-get-region-contents): moved to ediff-util.el. (ediff-event-key): moved here. * ediff-merge.el: got rid of unreferenced variables. * ediff-mult.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-util.el: use ediff-cond-compile-for-xemacs-or-emacs. (ediff-cleanup-mess): improved the way windows are set up after quitting ediff. (ediff-janitor): use ediff-dispose-of-variant-according-to-user. (ediff-dispose-of-variant-according-to-user): new function designed to be smarter and also understands indirect buffers. (ediff-highlight-diff-in-one-buffer, ediff-unhighlight-diff-in-one-buffer, ediff-unhighlight-diffs-totally-in-one-buffer, ediff-highlight-diff, ediff-highlight-diff, ediff-unhighlight-diff, ediff-unhighlight-diffs-totally, ediff-empty-diff-region-p, ediff-whitespace-diff-region-p, ediff-get-region-contents, ediff-make-current-diff-overlay): moved here. (ediff-format-bindings-of): new function by Hannu Koivisto <azure@iki.fi>. (ediff-setup): make sure the merge buffer is always widened and modifiable. (ediff-write-merge-buffer-and-maybe-kill): refuse to write the result of a merge into a file visited by another buffer. (ediff-arrange-autosave-in-merge-jobs): check if the merge file is visited by another buffer and ask to save/delete that buffer. (ediff-verify-file-merge-buffer): new function to do the above. * ediff-vers.el: load ediff-init.el at compile time. * ediff-wind.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff.el (ediff-windows, ediff-regions-wordwise, ediff-regions-linewise): use indirect buffers to improve robustness and make it possible to compare regions of the same buffer (even overlapping regions). (ediff-clone-buffer-for-region-comparison, ediff-clone-buffer-for-window-comparison): new functions. (ediff-files-internal): refuse to compare identical files. (ediff-regions-internal): get rid of the warning about comparing regions of the same buffer. * ediff-diff.el (ediff-convert-fine-diffs-to-overlays): moved here. Plus the following fixes courtesy of Dave Love: Doc fixes. (ediff-word-1): Use word class and move - to the front per regexp documentation. (ediff-wordify): Bind forward-word-function outside loop. (ediff-copy-to-buffer): Use insert-buffer-substring rather than consing buffer contents. (ediff-goto-word): Move syntax table setting outside loop.
2002-01-08 04:36:01 +00:00
(sit-for 0)
(set-specifier top-toolbar-height (list ctl-frame 0))
;;(set-specifier bottom-toolbar-height (list ctl-frame 0))
(set-specifier left-toolbar-width (list ctl-frame 0))
(set-specifier right-toolbar-width (list ctl-frame 0))
)
nil ; emacs
)
)
2003-02-04 11:26:42 +00:00
1996-02-16 06:36:35 +00:00
;; Under OS/2 (emx) we have to call modify frame parameters twice, in order
1999-11-01 07:16:15 +00:00
;; to make sure that at least once we do it for non-iconified frame. If
1996-02-16 06:36:35 +00:00
;; appears that in the OS/2 port of Emacs, one can't modify frame
1999-11-01 07:16:15 +00:00
;; parameters of iconified frames. As a precaution, we do likewise for
1996-02-16 06:36:35 +00:00
;; windows-nt.
(if (memq system-type '(emx windows-nt windows-95))
(modify-frame-parameters ctl-frame adjusted-parameters))
2003-02-04 11:26:42 +00:00
1997-05-31 01:10:39 +00:00
;; make or zap toolbar (if not requested)
(ediff-make-bottom-toolbar ctl-frame)
2003-02-04 11:26:42 +00:00
1997-05-31 01:10:39 +00:00
(goto-char (point-min))
(modify-frame-parameters ctl-frame adjusted-parameters)
1996-06-22 01:54:34 +00:00
(make-frame-visible ctl-frame)
2003-02-04 11:26:42 +00:00
1999-11-01 07:16:15 +00:00
;; This works around a bug in 19.25 and earlier. There, if frame gets
1995-03-16 22:34:51 +00:00
;; iconified, the current buffer changes to that of the frame that
;; becomes exposed as a result of this iconification.
;; So, we make sure the current buffer doesn't change.
(select-frame ctl-frame)
1995-03-16 22:34:51 +00:00
(ediff-refresh-control-frame)
2003-02-04 11:26:42 +00:00
(cond ((and ediff-prefer-iconified-control-frame
(not ctl-frame-iconified-p) (not dont-iconify-ctl-frame))
(iconify-frame ctl-frame))
((or deiconify-ctl-frame (not ctl-frame-iconified-p))
(raise-frame ctl-frame)))
2003-02-04 11:26:42 +00:00
1996-06-22 01:54:34 +00:00
(set-window-dedicated-p (selected-window) t)
1997-05-31 01:10:39 +00:00
1999-11-01 07:16:15 +00:00
;; Now move the frame. We must do it separately due to an obscure bug in
1997-05-31 01:10:39 +00:00
;; XEmacs
(modify-frame-parameters
ctl-frame
(funcall ediff-control-frame-position-function ctl-buffer fwidth fheight))
2003-02-04 11:26:42 +00:00
1996-06-22 01:54:34 +00:00
;; synchronize so the cursor will move to control frame
;; per RMS suggestion
1996-02-16 06:36:35 +00:00
(if (ediff-window-display-p)
(let ((count 7))
(sit-for .1)
(while (and (not (frame-visible-p ctl-frame)) (> count 0))
(setq count (1- count))
(sit-for .3))))
1995-03-16 22:34:51 +00:00
(or (ediff-frame-iconified-p ctl-frame)
;; don't warp the mouse, unless ediff-grab-mouse = t
1996-02-16 06:36:35 +00:00
(ediff-reset-mouse ctl-frame
(or (eq this-command 'ediff-quit)
(not (eq ediff-grab-mouse t)))))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(if ediff-xemacs-p
1997-07-31 04:04:23 +00:00
(ediff-with-current-buffer ctl-buffer
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu> * viper-init.el (viper-cond-compile-for-xemacs-or-emacs): new macro that replaces viper-emacs-p and viper-xemacs-p in many cases. Used to reduce the number of warnings. * viper-cmd.el: use viper-cond-compile-for-xemacs-or-emacs. (viper-standard-value): moved here from viper.el. (viper-set-unread-command-events): moved to viper-util.el (viper-check-minibuffer-overlay): make sure viper-minibuffer-overlay is moved to cover the entire input field. * viper-util.el: use viper-cond-compile-for-xemacs-or-emacs. (viper-read-key-sequence, viper-set-unread-command-events, viper-char-symbol-sequence-p, viper-char-array-p): moved here. * viper-ex.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-keym.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-mous.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-macs.el (viper-char-array-p, viper-char-symbol-sequence-p, viper-event-vector-p): moved to viper-util.el * viper.el (viper-standard-value): moved to viper-cmd.el. Use viper-cond-compile-for-xemacs-or-emacs. * ediff-help.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-hook.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-init.el (ediff-cond-compile-for-xemacs-or-emacs): new macro designed to be used in many places where ediff-emacs-p or ediff-xemacs-p was previously used. Reduces the number of warnings. Use ediff-cond-compile-for-xemacs-or-emacs in many places in lieue of ediff-xemacs-p. (ediff-make-current-diff-overlay, ediff-highlight-diff-in-one-buffer, ediff-convert-fine-diffs-to-overlays, ediff-empty-diff-region-p, ediff-whitespace-diff-region-p, ediff-get-region-contents): moved to ediff-util.el. (ediff-event-key): moved here. * ediff-merge.el: got rid of unreferenced variables. * ediff-mult.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-util.el: use ediff-cond-compile-for-xemacs-or-emacs. (ediff-cleanup-mess): improved the way windows are set up after quitting ediff. (ediff-janitor): use ediff-dispose-of-variant-according-to-user. (ediff-dispose-of-variant-according-to-user): new function designed to be smarter and also understands indirect buffers. (ediff-highlight-diff-in-one-buffer, ediff-unhighlight-diff-in-one-buffer, ediff-unhighlight-diffs-totally-in-one-buffer, ediff-highlight-diff, ediff-highlight-diff, ediff-unhighlight-diff, ediff-unhighlight-diffs-totally, ediff-empty-diff-region-p, ediff-whitespace-diff-region-p, ediff-get-region-contents, ediff-make-current-diff-overlay): moved here. (ediff-format-bindings-of): new function by Hannu Koivisto <azure@iki.fi>. (ediff-setup): make sure the merge buffer is always widened and modifiable. (ediff-write-merge-buffer-and-maybe-kill): refuse to write the result of a merge into a file visited by another buffer. (ediff-arrange-autosave-in-merge-jobs): check if the merge file is visited by another buffer and ask to save/delete that buffer. (ediff-verify-file-merge-buffer): new function to do the above. * ediff-vers.el: load ediff-init.el at compile time. * ediff-wind.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff.el (ediff-windows, ediff-regions-wordwise, ediff-regions-linewise): use indirect buffers to improve robustness and make it possible to compare regions of the same buffer (even overlapping regions). (ediff-clone-buffer-for-region-comparison, ediff-clone-buffer-for-window-comparison): new functions. (ediff-files-internal): refuse to compare identical files. (ediff-regions-internal): get rid of the warning about comparing regions of the same buffer. * ediff-diff.el (ediff-convert-fine-diffs-to-overlays): moved here. Plus the following fixes courtesy of Dave Love: Doc fixes. (ediff-word-1): Use word class and move - to the front per regexp documentation. (ediff-wordify): Bind forward-word-function outside loop. (ediff-copy-to-buffer): Use insert-buffer-substring rather than consing buffer contents. (ediff-goto-word): Move syntax table setting outside loop.
2002-01-08 04:36:01 +00:00
(ediff-cond-compile-for-xemacs-or-emacs
(make-local-hook 'select-frame-hook) ; xemacs
nil ; emacs
)
(add-hook
'select-frame-hook 'ediff-xemacs-select-frame-hook nil 'local)
1995-03-16 22:34:51 +00:00
))
2003-02-04 11:26:42 +00:00
1997-07-31 04:04:23 +00:00
(ediff-with-current-buffer ctl-buffer
(run-hooks 'ediff-after-setup-control-frame-hook))
))
1997-05-31 01:10:39 +00:00
2003-02-04 11:26:42 +00:00
(defun ediff-destroy-control-frame (ctl-buffer)
1997-07-31 04:04:23 +00:00
(ediff-with-current-buffer ctl-buffer
(if (and (ediff-window-display-p) (frame-live-p ediff-control-frame))
(let ((ctl-frame ediff-control-frame))
2002-01-07 Michael Kifer <kifer@cs.stonybrook.edu> * viper-init.el (viper-cond-compile-for-xemacs-or-emacs): new macro that replaces viper-emacs-p and viper-xemacs-p in many cases. Used to reduce the number of warnings. * viper-cmd.el: use viper-cond-compile-for-xemacs-or-emacs. (viper-standard-value): moved here from viper.el. (viper-set-unread-command-events): moved to viper-util.el (viper-check-minibuffer-overlay): make sure viper-minibuffer-overlay is moved to cover the entire input field. * viper-util.el: use viper-cond-compile-for-xemacs-or-emacs. (viper-read-key-sequence, viper-set-unread-command-events, viper-char-symbol-sequence-p, viper-char-array-p): moved here. * viper-ex.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-keym.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-mous.el: use viper-cond-compile-for-xemacs-or-emacs. * viper-macs.el (viper-char-array-p, viper-char-symbol-sequence-p, viper-event-vector-p): moved to viper-util.el * viper.el (viper-standard-value): moved to viper-cmd.el. Use viper-cond-compile-for-xemacs-or-emacs. * ediff-help.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-hook.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-init.el (ediff-cond-compile-for-xemacs-or-emacs): new macro designed to be used in many places where ediff-emacs-p or ediff-xemacs-p was previously used. Reduces the number of warnings. Use ediff-cond-compile-for-xemacs-or-emacs in many places in lieue of ediff-xemacs-p. (ediff-make-current-diff-overlay, ediff-highlight-diff-in-one-buffer, ediff-convert-fine-diffs-to-overlays, ediff-empty-diff-region-p, ediff-whitespace-diff-region-p, ediff-get-region-contents): moved to ediff-util.el. (ediff-event-key): moved here. * ediff-merge.el: got rid of unreferenced variables. * ediff-mult.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff-util.el: use ediff-cond-compile-for-xemacs-or-emacs. (ediff-cleanup-mess): improved the way windows are set up after quitting ediff. (ediff-janitor): use ediff-dispose-of-variant-according-to-user. (ediff-dispose-of-variant-according-to-user): new function designed to be smarter and also understands indirect buffers. (ediff-highlight-diff-in-one-buffer, ediff-unhighlight-diff-in-one-buffer, ediff-unhighlight-diffs-totally-in-one-buffer, ediff-highlight-diff, ediff-highlight-diff, ediff-unhighlight-diff, ediff-unhighlight-diffs-totally, ediff-empty-diff-region-p, ediff-whitespace-diff-region-p, ediff-get-region-contents, ediff-make-current-diff-overlay): moved here. (ediff-format-bindings-of): new function by Hannu Koivisto <azure@iki.fi>. (ediff-setup): make sure the merge buffer is always widened and modifiable. (ediff-write-merge-buffer-and-maybe-kill): refuse to write the result of a merge into a file visited by another buffer. (ediff-arrange-autosave-in-merge-jobs): check if the merge file is visited by another buffer and ask to save/delete that buffer. (ediff-verify-file-merge-buffer): new function to do the above. * ediff-vers.el: load ediff-init.el at compile time. * ediff-wind.el: use ediff-cond-compile-for-xemacs-or-emacs. * ediff.el (ediff-windows, ediff-regions-wordwise, ediff-regions-linewise): use indirect buffers to improve robustness and make it possible to compare regions of the same buffer (even overlapping regions). (ediff-clone-buffer-for-region-comparison, ediff-clone-buffer-for-window-comparison): new functions. (ediff-files-internal): refuse to compare identical files. (ediff-regions-internal): get rid of the warning about comparing regions of the same buffer. * ediff-diff.el (ediff-convert-fine-diffs-to-overlays): moved here. Plus the following fixes courtesy of Dave Love: Doc fixes. (ediff-word-1): Use word class and move - to the front per regexp documentation. (ediff-wordify): Bind forward-word-function outside loop. (ediff-copy-to-buffer): Use insert-buffer-substring rather than consing buffer contents. (ediff-goto-word): Move syntax table setting outside loop.
2002-01-08 04:36:01 +00:00
(ediff-cond-compile-for-xemacs-or-emacs
(set-buffer-menubar default-menubar) ; xemacs
nil ; emacs
)
(setq ediff-control-frame nil)
(delete-frame ctl-frame)
)))
(ediff-skip-unsuitable-frames)
;;(ediff-reset-mouse nil)
)
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
;; finds a good place to clip control frame
(defun ediff-make-frame-position (ctl-buffer ctl-frame-width ctl-frame-height)
1997-07-31 04:04:23 +00:00
(ediff-with-current-buffer ctl-buffer
(let* ((frame-A (window-frame ediff-window-A))
(frame-A-parameters (frame-parameters frame-A))
(frame-A-top (eval (cdr (assoc 'top frame-A-parameters))))
(frame-A-left (eval (cdr (assoc 'left frame-A-parameters))))
(frame-A-width (frame-width frame-A))
1995-03-16 22:34:51 +00:00
(ctl-frame ediff-control-frame)
horizontal-adjustment upward-adjustment
1999-12-18 16:14:32 +00:00
ctl-frame-top ctl-frame-left)
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
;; Multiple control frames are clipped based on the value of
1999-11-01 07:16:15 +00:00
;; ediff-control-buffer-number. This is done in order not to obscure
1995-03-16 22:34:51 +00:00
;; other active control panels.
(setq horizontal-adjustment (* 2 ediff-control-buffer-number)
upward-adjustment (* -14 ediff-control-buffer-number))
(setq ctl-frame-top
(- frame-A-top upward-adjustment ediff-control-frame-upward-shift)
ctl-frame-left
(+ frame-A-left
1996-02-16 06:36:35 +00:00
(if ediff-use-long-help-message
(* (ediff-frame-char-width ctl-frame)
(+ ediff-wide-control-frame-rightward-shift
horizontal-adjustment))
(- (* frame-A-width (ediff-frame-char-width frame-A))
(* (ediff-frame-char-width ctl-frame)
(+ ctl-frame-width
ediff-narrow-control-frame-leftward-shift
horizontal-adjustment))))))
(setq ctl-frame-top
(min ctl-frame-top
(- (ediff-display-pixel-height)
(* 2 ctl-frame-height
(ediff-frame-char-height ctl-frame))))
ctl-frame-left
(min ctl-frame-left
(- (ediff-display-pixel-width)
(* ctl-frame-width (ediff-frame-char-width ctl-frame)))))
1996-02-16 06:36:35 +00:00
;; keep ctl frame within the visible bounds
(setq ctl-frame-top (max ctl-frame-top 1)
ctl-frame-left (max ctl-frame-left 1))
2003-02-04 11:26:42 +00:00
(list (cons 'top ctl-frame-top)
(cons 'left ctl-frame-left))
)))
2003-02-04 11:26:42 +00:00
(defun ediff-xemacs-select-frame-hook ()
(if (and (equal (selected-frame) ediff-control-frame)
1996-02-16 06:36:35 +00:00
(not ediff-use-long-help-message))
(raise-frame ediff-control-frame)))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(defun ediff-make-wide-display ()
"Construct an alist of parameters for the wide display.
Saves the old frame parameters in `ediff-wide-display-orig-parameters'.
The frame to be resized is kept in `ediff-wide-display-frame'.
This function modifies only the left margin and the width of the display.
It assumes that it is called from within the control buffer."
(if (not (fboundp 'ediff-display-pixel-width))
1999-12-18 16:14:32 +00:00
(error "Can't determine display width"))
(let* ((frame-A (window-frame ediff-window-A))
(frame-A-params (frame-parameters frame-A))
1995-03-16 22:34:51 +00:00
(cw (ediff-frame-char-width frame-A))
(wd (- (/ (ediff-display-pixel-width) cw) 5)))
1999-12-18 16:14:32 +00:00
(setq ediff-wide-display-orig-parameters
(list (cons 'left (max 0 (eval (cdr (assoc 'left frame-A-params)))))
1995-03-16 22:34:51 +00:00
(cons 'width (cdr (assoc 'width frame-A-params))))
ediff-wide-display-frame frame-A)
(modify-frame-parameters frame-A (list (cons 'left cw)
1995-03-16 22:34:51 +00:00
(cons 'width wd)))))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
;; Revise the mode line to display which difference we have selected
;; Also resets modelines of buffers A/B, since they may be clobbered by
;; anothe invocations of Ediff.
(defun ediff-refresh-mode-lines ()
(let (buf-A-state-diff buf-B-state-diff buf-C-state-diff buf-C-state-merge)
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(if (ediff-valid-difference-p)
(setq
buf-C-state-diff (ediff-get-state-of-diff ediff-current-difference 'C)
buf-C-state-merge (ediff-get-state-of-merge ediff-current-difference)
buf-A-state-diff (ediff-get-state-of-diff ediff-current-difference 'A)
buf-B-state-diff (ediff-get-state-of-diff ediff-current-difference 'B)
buf-A-state-diff (if buf-A-state-diff
(format "[%s] " buf-A-state-diff)
"")
buf-B-state-diff (if buf-B-state-diff
(format "[%s] " buf-B-state-diff)
"")
buf-C-state-diff (if (and (ediff-buffer-live-p ediff-buffer-C)
(or buf-C-state-diff buf-C-state-merge))
(format "[%s%s%s] "
1995-03-16 22:34:51 +00:00
(or buf-C-state-diff "")
(if buf-C-state-merge
(concat " " buf-C-state-merge)
"")
1999-12-18 16:14:32 +00:00
(if (ediff-get-state-of-ancestor
ediff-current-difference)
" AncestorEmpty"
"")
)
1995-03-16 22:34:51 +00:00
""))
(setq buf-A-state-diff ""
buf-B-state-diff ""
buf-C-state-diff ""))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
;; control buffer format
(setq mode-line-format
1997-05-31 01:10:39 +00:00
(if (ediff-narrow-control-frame-p)
(list " " mode-line-buffer-identification)
(list "-- " mode-line-buffer-identification " Quick Help")))
1995-03-16 22:34:51 +00:00
;; control buffer id
1999-12-18 16:14:32 +00:00
(setq mode-line-buffer-identification
1995-03-16 22:34:51 +00:00
(if (ediff-narrow-control-frame-p)
(ediff-make-narrow-control-buffer-id 'skip-name)
(ediff-make-wide-control-buffer-id)))
;; Force mode-line redisplay
(force-mode-line-update)
2003-02-04 11:26:42 +00:00
(if (and (ediff-window-display-p) (frame-live-p ediff-control-frame))
1995-03-16 22:34:51 +00:00
(ediff-refresh-control-frame))
2003-02-04 11:26:42 +00:00
1997-07-31 04:04:23 +00:00
(ediff-with-current-buffer ediff-buffer-A
1995-03-16 22:34:51 +00:00
(setq ediff-diff-status buf-A-state-diff)
(ediff-strip-mode-line-format)
(setq mode-line-format
(list " A: " 'ediff-diff-status mode-line-format))
(force-mode-line-update))
1997-07-31 04:04:23 +00:00
(ediff-with-current-buffer ediff-buffer-B
1995-03-16 22:34:51 +00:00
(setq ediff-diff-status buf-B-state-diff)
(ediff-strip-mode-line-format)
(setq mode-line-format
(list " B: " 'ediff-diff-status mode-line-format))
(force-mode-line-update))
(if ediff-3way-job
1997-07-31 04:04:23 +00:00
(ediff-with-current-buffer ediff-buffer-C
1995-03-16 22:34:51 +00:00
(setq ediff-diff-status buf-C-state-diff)
(ediff-strip-mode-line-format)
(setq mode-line-format
(list " C: " 'ediff-diff-status mode-line-format))
(force-mode-line-update)))
(if (ediff-buffer-live-p ediff-ancestor-buffer)
1997-07-31 04:04:23 +00:00
(ediff-with-current-buffer ediff-ancestor-buffer
(ediff-strip-mode-line-format)
;; we keep the second dummy string in the mode line format of the
;; ancestor, since for other buffers Ediff prepends 2 strings and
;; ediff-strip-mode-line-format expects that.
(setq mode-line-format
(list " Ancestor: "
(cond ((not (stringp buf-C-state-merge))
"")
((string-match "prefer-A" buf-C-state-merge)
"[=diff(B)] ")
((string-match "prefer-B" buf-C-state-merge)
"[=diff(A)] ")
(t ""))
mode-line-format))))
1995-03-16 22:34:51 +00:00
))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(defun ediff-refresh-control-frame ()
(if ediff-emacs-p
1996-06-22 01:54:34 +00:00
;; set frame/icon titles for Emacs
(modify-frame-parameters
ediff-control-frame
1996-06-22 01:54:34 +00:00
(list (cons 'title (ediff-make-base-title))
(cons 'icon-name (ediff-make-narrow-control-buffer-id))
))
;; set frame/icon titles for XEmacs
(setq frame-title-format (ediff-make-base-title)
frame-icon-title-format (ediff-make-narrow-control-buffer-id))
;; force an update of the frame title
(modify-frame-parameters ediff-control-frame '(()))))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(defun ediff-make-narrow-control-buffer-id (&optional skip-name)
(concat
(if skip-name
" "
1996-06-22 01:54:34 +00:00
(ediff-make-base-title))
1999-12-18 16:14:32 +00:00
(cond ((< ediff-current-difference 0)
1995-03-16 22:34:51 +00:00
(format " _/%d" ediff-number-of-differences))
((>= ediff-current-difference ediff-number-of-differences)
(format " $/%d" ediff-number-of-differences))
(t
(format " %d/%d"
(1+ ediff-current-difference)
ediff-number-of-differences)))))
1996-06-22 01:54:34 +00:00
(defun ediff-make-base-title ()
(concat
(cdr (assoc 'name ediff-control-frame-parameters))
ediff-control-buffer-suffix))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(defun ediff-make-wide-control-buffer-id ()
(cond ((< ediff-current-difference 0)
(list (format "%%b At start of %d diffs"
ediff-number-of-differences)))
((>= ediff-current-difference ediff-number-of-differences)
(list (format "%%b At end of %d diffs"
ediff-number-of-differences)))
(t
(list (format "%%b diff %d of %d"
(1+ ediff-current-difference)
ediff-number-of-differences)))))
;; If buff is not live, return nil
(defun ediff-get-visible-buffer-window (buff)
(if (ediff-buffer-live-p buff)
(if ediff-xemacs-p
(get-buffer-window buff t)
(get-buffer-window buff 'visible))))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
1996-06-22 01:54:34 +00:00
;;; Functions to decide when to redraw windows
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(defun ediff-keep-window-config (control-buf)
(and (eq control-buf (current-buffer))
(/= (buffer-size) 0)
1997-07-31 04:04:23 +00:00
(ediff-with-current-buffer control-buf
1995-03-16 22:34:51 +00:00
(let ((ctl-wind ediff-control-window)
(A-wind ediff-window-A)
(B-wind ediff-window-B)
(C-wind ediff-window-C))
2003-02-04 11:26:42 +00:00
1995-03-16 22:34:51 +00:00
(and
(ediff-window-visible-p A-wind)
(ediff-window-visible-p B-wind)
;; if buffer C is defined then take it into account
(or (not ediff-3way-job)
(ediff-window-visible-p C-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))
(string= ediff-window-config-saved
(format "%S%S%S%S%S%S%S"
1995-03-16 22:34:51 +00:00
ctl-wind A-wind B-wind C-wind
ediff-split-window-function
(ediff-multiframe-setup-p)
ediff-wide-display-p)))))))
1995-03-16 22:34:51 +00:00
1996-06-22 01:54:34 +00:00
;;; Local Variables:
;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun)
1997-07-31 04:04:23 +00:00
;;; eval: (put 'ediff-with-current-buffer 'lisp-indent-hook 1)
;;; eval: (put 'ediff-with-current-buffer 'edebug-form-spec '(form body))
1996-06-22 01:54:34 +00:00
;;; End:
1995-03-16 22:34:51 +00:00
;;; ediff-wind.el ends here