Add "Package:" file headers to denote built-in packages.
[emacs.git] / lisp / vc / ediff-wind.el
blob8b16c5a4a121b6e4f417f4d17318ea6248679b86
1 ;;; ediff-wind.el --- window manipulation utilities
3 ;; Copyright (C) 1994, 1995, 1996, 1997, 2000, 2001, 2002, 2003,
4 ;; 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
6 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
7 ;; Package: ediff
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24 ;;; Commentary:
26 ;;; Code:
29 ;; Compiler pacifier
30 (defvar icon-title-format)
31 (defvar top-toolbar-height)
32 (defvar bottom-toolbar-height)
33 (defvar left-toolbar-height)
34 (defvar right-toolbar-height)
35 (defvar left-toolbar-width)
36 (defvar right-toolbar-width)
37 (defvar default-menubar)
38 (defvar top-gutter)
39 (defvar frame-icon-title-format)
40 (defvar ediff-diff-status)
42 ;; declare-function does not exist in XEmacs
43 (eval-and-compile
44 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
46 (eval-when-compile
47 (require 'ediff-util)
48 (require 'ediff-help))
49 ;; end pacifier
51 (require 'ediff-init)
53 ;; be careful with ediff-tbar
54 (if (featurep 'xemacs)
55 (require 'ediff-tbar)
56 (defun ediff-compute-toolbar-width () 0))
58 (defgroup ediff-window nil
59 "Ediff window manipulation."
60 :prefix "ediff-"
61 :group 'ediff
62 :group 'frames)
65 ;; Determine which window setup function to use based on current window system.
66 (defun ediff-choose-window-setup-function-automatically ()
67 (if (ediff-window-display-p)
68 'ediff-setup-windows-multiframe
69 'ediff-setup-windows-plain))
71 (defcustom ediff-window-setup-function (ediff-choose-window-setup-function-automatically)
72 "Function called to set up windows.
73 Ediff provides a choice of two functions: `ediff-setup-windows-plain', for
74 doing everything in one frame and `ediff-setup-windows-multiframe', which sets
75 the control panel in a separate frame. By default, the appropriate function is
76 chosen automatically depending on the current window system.
77 However, `ediff-toggle-multiframe' can be used to toggle between the multiframe
78 display and the single frame display.
79 If the multiframe function detects that one of the buffers A/B is seen in some
80 other frame, it will try to keep that buffer in that frame.
82 If you don't like any of the two provided functions, write your own one.
83 The basic guidelines:
84 1. It should leave the control buffer current and the control window
85 selected.
86 2. It should set `ediff-window-A', `ediff-window-B', `ediff-window-C',
87 and `ediff-control-window' to contain window objects that display
88 the corresponding buffers.
89 3. It should accept the following arguments:
90 buffer-A, buffer-B, buffer-C, control-buffer
91 Buffer C may not be used in jobs that compare only two buffers.
92 If you plan to do something fancy, take a close look at how the two
93 provided functions are written."
94 :type '(choice (const :tag "Multi Frame" ediff-setup-windows-multiframe)
95 (const :tag "Single Frame" ediff-setup-windows-plain)
96 (function :tag "Other function"))
97 :group 'ediff-window)
99 ;; indicates if we are in a multiframe setup
100 (ediff-defvar-local ediff-multiframe nil "")
102 ;; Share of the frame occupied by the merge window (buffer C)
103 (ediff-defvar-local ediff-merge-window-share 0.45 "")
105 ;; The control window.
106 (ediff-defvar-local ediff-control-window nil "")
107 ;; Official window for buffer A
108 (ediff-defvar-local ediff-window-A nil "")
109 ;; Official window for buffer B
110 (ediff-defvar-local ediff-window-B nil "")
111 ;; Official window for buffer C
112 (ediff-defvar-local ediff-window-C nil "")
113 ;; Ediff's window configuration.
114 ;; Used to minimize the need to rearrange windows.
115 (ediff-defvar-local ediff-window-config-saved "" "")
117 ;; Association between buff-type and ediff-window-*
118 (defconst ediff-window-alist
119 '((A . ediff-window-A)
120 (?A . ediff-window-A)
121 (B . ediff-window-B)
122 (?B . ediff-window-B)
123 (C . ediff-window-C)
124 (?C . ediff-window-C)))
127 (defcustom ediff-split-window-function 'split-window-vertically
128 "The function used to split the main window between buffer-A and buffer-B.
129 You can set it to a horizontal split instead of the default vertical split
130 by setting this variable to `split-window-horizontally'.
131 You can also have your own function to do fancy splits.
132 This variable has no effect when buffer-A/B are shown in different frames.
133 In this case, Ediff will use those frames to display these buffers."
134 :type '(choice
135 (const :tag "Split vertically" split-window-vertically)
136 (const :tag "Split horizontally" split-window-horizontally)
137 function)
138 :group 'ediff-window)
140 (defcustom ediff-merge-split-window-function 'split-window-horizontally
141 "The function used to split the main window between buffer-A and buffer-B.
142 You can set it to a vertical split instead of the default horizontal split
143 by setting this variable to `split-window-vertically'.
144 You can also have your own function to do fancy splits.
145 This variable has no effect when buffer-A/B/C are shown in different frames.
146 In this case, Ediff will use those frames to display these buffers."
147 :type '(choice
148 (const :tag "Split vertically" split-window-vertically)
149 (const :tag "Split horizontally" split-window-horizontally)
150 function)
151 :group 'ediff-window)
153 ;; Definitions hidden from the compiler by compat wrappers.
154 (declare-function ediff-display-pixel-width "ediff-init")
155 (declare-function ediff-display-pixel-height "ediff-init")
157 (defconst ediff-control-frame-parameters
158 (list
159 '(name . "Ediff")
160 ;;'(unsplittable . t)
161 '(minibuffer . nil)
162 '(user-position . t) ; Emacs only
163 '(vertical-scroll-bars . nil) ; Emacs only
164 '(scrollbar-width . 0) ; XEmacs only
165 '(scrollbar-height . 0) ; XEmacs only
166 '(menu-bar-lines . 0) ; Emacs only
167 '(tool-bar-lines . 0) ; Emacs 21+ only
168 '(left-fringe . 0)
169 '(right-fringe . 0)
170 ;; don't lower but auto-raise
171 '(auto-lower . nil)
172 '(auto-raise . t)
173 '(visibility . nil)
174 ;; make initial frame small to avoid distraction
175 '(width . 1) '(height . 1)
176 ;; this blocks queries from window manager as to where to put
177 ;; ediff's control frame. we put the frame outside the display,
178 ;; so the initial frame won't jump all over the screen
179 (cons 'top (if (fboundp 'ediff-display-pixel-height)
180 (1+ (ediff-display-pixel-height))
181 3000))
182 (cons 'left (if (fboundp 'ediff-display-pixel-width)
183 (1+ (ediff-display-pixel-width))
184 3000))
186 "Frame parameters for displaying Ediff Control Panel.
187 Used internally---not a user option.")
189 ;; position of the mouse; used to decide whether to warp the mouse into ctl
190 ;; frame
191 (ediff-defvar-local ediff-mouse-pixel-position nil "")
193 ;; not used for now
194 (defvar ediff-mouse-pixel-threshold 30
195 "If the user moves mouse more than this many pixels, Ediff won't warp mouse into control window.")
197 (defcustom ediff-grab-mouse t
198 "If t, Ediff will always grab the mouse and put it in the control frame.
199 If 'maybe, Ediff will do it sometimes, but not after operations that require
200 relatively long time. If nil, the mouse will be entirely user's
201 responsibility."
202 :type 'boolean
203 :group 'ediff-window)
205 (defcustom ediff-control-frame-position-function 'ediff-make-frame-position
206 "Function to call to determine the desired location for the control panel.
207 Expects three parameters: the control buffer, the desired width and height
208 of the control frame. It returns an association list
209 of the form \(\(top . <position>\) \(left . <position>\)\)"
210 :type 'function
211 :group 'ediff-window)
213 (defcustom ediff-control-frame-upward-shift 42
214 "The upward shift of control frame from the top of buffer A's frame.
215 Measured in pixels.
216 This is used by the default control frame positioning function,
217 `ediff-make-frame-position'. This variable is provided for easy
218 customization of the default control frame positioning."
219 :type 'integer
220 :group 'ediff-window)
222 (defcustom ediff-narrow-control-frame-leftward-shift (if (featurep 'xemacs) 7 3)
223 "The leftward shift of control frame from the right edge of buf A's frame.
224 Measured in characters.
225 This is used by the default control frame positioning function,
226 `ediff-make-frame-position' to adjust the position of the control frame
227 when it shows the short menu. This variable is provided for easy
228 customization of the default."
229 :type 'integer
230 :group 'ediff-window)
232 (defcustom ediff-wide-control-frame-rightward-shift 7
233 "The rightward shift of control frame from the left edge of buf A's frame.
234 Measured in characters.
235 This is used by the default control frame positioning function,
236 `ediff-make-frame-position' to adjust the position of the control frame
237 when it shows the full menu. This variable is provided for easy
238 customization of the default."
239 :type 'integer
240 :group 'ediff-window)
243 ;; Wide frame display
245 ;; t means Ediff is using wide display
246 (ediff-defvar-local ediff-wide-display-p nil "")
247 ;; keeps frame config for toggling wide display
248 (ediff-defvar-local ediff-wide-display-orig-parameters nil
249 "Frame parameters to be restored when the user wants to toggle the wide
250 display off.")
251 (ediff-defvar-local ediff-wide-display-frame nil
252 "Frame to be used for wide display.")
253 (ediff-defvar-local ediff-make-wide-display-function 'ediff-make-wide-display
254 "The value is a function that is called to create a wide display.
255 The function is called without arguments. It should resize the frame in
256 which buffers A, B, and C are to be displayed, and it should save the old
257 frame parameters in `ediff-wide-display-orig-parameters'.
258 The variable `ediff-wide-display-frame' should be set to contain
259 the frame used for the wide display.")
261 ;; Frame used for the control panel in a windowing system.
262 (ediff-defvar-local ediff-control-frame nil "")
264 (defcustom ediff-prefer-iconified-control-frame nil
265 "If t, keep control panel iconified when help message is off.
266 This has effect only on a windowing system.
267 If t, hitting `?' to toggle control panel off iconifies it.
269 This is only useful in Emacs and only for certain kinds of window managers,
270 such as TWM and its derivatives, since the window manager must permit
271 keyboard input to go into icons. XEmacs completely ignores keyboard input
272 into icons, regardless of the window manager."
273 :type 'boolean
274 :group 'ediff-window)
276 ;;; Functions
278 (defun ediff-get-window-by-clicking (wind prev-wind wind-number)
279 (let (event)
280 (message
281 "Select windows by clicking. Please click on Window %d " wind-number)
282 (while (not (ediff-mouse-event-p (setq event (ediff-read-event))))
283 (if (sit-for 1) ; if sequence of events, wait till the final word
284 (beep 1))
285 (message "Please click on Window %d " wind-number))
286 (ediff-read-event) ; discard event
287 (setq wind (if (featurep 'xemacs)
288 (event-window event)
289 (posn-window (event-start event))))))
292 ;; Select the lowest window on the frame.
293 (defun ediff-select-lowest-window ()
294 (if (featurep 'xemacs)
295 (select-window (frame-lowest-window))
296 (let* ((lowest-window (selected-window))
297 (bottom-edge (car (cdr (cdr (cdr (window-edges))))))
298 (last-window (save-excursion
299 (other-window -1) (selected-window)))
300 (window-search t))
301 (while window-search
302 (let* ((this-window (next-window))
303 (next-bottom-edge
304 (car (cdr (cdr (cdr (window-edges this-window)))))))
305 (if (< bottom-edge next-bottom-edge)
306 (setq bottom-edge next-bottom-edge
307 lowest-window this-window))
308 (select-window this-window)
309 (when (eq last-window this-window)
310 (select-window lowest-window)
311 (setq window-search nil)))))))
314 ;;; Common window setup routines
316 ;; Set up the window configuration. If POS is given, set the points to
317 ;; the beginnings of the buffers.
318 ;; When 3way comparison is added, this will have to choose the appropriate
319 ;; setup function based on ediff-job-name
320 (defun ediff-setup-windows (buffer-A buffer-B buffer-C control-buffer)
321 ;; Make sure we are not in the minibuffer window when we try to delete
322 ;; all other windows.
323 (run-hooks 'ediff-before-setup-windows-hook)
324 (if (eq (selected-window) (minibuffer-window))
325 (other-window 1))
327 ;; in case user did a no-no on a tty
328 (or (ediff-window-display-p)
329 (setq ediff-window-setup-function 'ediff-setup-windows-plain))
331 (or (ediff-keep-window-config control-buffer)
332 (funcall
333 (ediff-with-current-buffer control-buffer ediff-window-setup-function)
334 buffer-A buffer-B buffer-C control-buffer))
335 (run-hooks 'ediff-after-setup-windows-hook))
337 ;; Just set up 3 windows.
338 ;; Usually used without windowing systems
339 ;; With windowing, we want to use dedicated frames.
340 (defun ediff-setup-windows-plain (buffer-A buffer-B buffer-C control-buffer)
341 (ediff-with-current-buffer control-buffer
342 (setq ediff-multiframe nil))
343 (if ediff-merge-job
344 (ediff-setup-windows-plain-merge
345 buffer-A buffer-B buffer-C control-buffer)
346 (ediff-setup-windows-plain-compare
347 buffer-A buffer-B buffer-C control-buffer)))
349 (defun ediff-setup-windows-plain-merge (buf-A buf-B buf-C control-buffer)
350 ;; skip dedicated and unsplittable frames
351 (ediff-destroy-control-frame control-buffer)
352 (let ((window-min-height 1)
353 split-window-function
354 merge-window-share merge-window-lines
355 wind-A wind-B wind-C)
356 (ediff-with-current-buffer control-buffer
357 (setq merge-window-share ediff-merge-window-share
358 ;; this lets us have local versions of ediff-split-window-function
359 split-window-function ediff-split-window-function))
360 (delete-other-windows)
361 (set-window-dedicated-p (selected-window) nil)
362 (split-window-vertically)
363 (ediff-select-lowest-window)
364 (ediff-setup-control-buffer control-buffer)
366 ;; go to the upper window and split it betw A, B, and possibly C
367 (other-window 1)
368 (setq merge-window-lines
369 (max 2 (round (* (window-height) merge-window-share))))
370 (switch-to-buffer buf-A)
371 (setq wind-A (selected-window))
373 ;; XEmacs used to have a lot of trouble with display
374 ;; It did't set things right unless we tell it to sit still
375 ;; 19.12 seems ok.
376 ;;(if (featurep 'xemacs) (sit-for 0))
378 (split-window-vertically (max 2 (- (window-height) merge-window-lines)))
379 (if (eq (selected-window) wind-A)
380 (other-window 1))
381 (setq wind-C (selected-window))
382 (switch-to-buffer buf-C)
384 (select-window wind-A)
385 (funcall split-window-function)
387 (if (eq (selected-window) wind-A)
388 (other-window 1))
389 (switch-to-buffer buf-B)
390 (setq wind-B (selected-window))
392 (ediff-with-current-buffer control-buffer
393 (setq ediff-window-A wind-A
394 ediff-window-B wind-B
395 ediff-window-C wind-C))
397 (ediff-select-lowest-window)
398 (ediff-setup-control-buffer control-buffer)
402 ;; This function handles all comparison jobs, including 3way jobs
403 (defun ediff-setup-windows-plain-compare (buf-A buf-B buf-C control-buffer)
404 ;; skip dedicated and unsplittable frames
405 (ediff-destroy-control-frame control-buffer)
406 (let ((window-min-height 1)
407 split-window-function wind-width-or-height
408 three-way-comparison
409 wind-A-start wind-B-start wind-A wind-B wind-C)
410 (ediff-with-current-buffer control-buffer
411 (setq wind-A-start (ediff-overlay-start
412 (ediff-get-value-according-to-buffer-type
413 'A ediff-narrow-bounds))
414 wind-B-start (ediff-overlay-start
415 (ediff-get-value-according-to-buffer-type
416 'B ediff-narrow-bounds))
417 ;; this lets us have local versions of ediff-split-window-function
418 split-window-function ediff-split-window-function
419 three-way-comparison ediff-3way-comparison-job))
420 ;; if in minibuffer go somewhere else
421 (if (save-match-data
422 (string-match "\*Minibuf-" (buffer-name (window-buffer))))
423 (select-window (next-window nil 'ignore-minibuf)))
424 (delete-other-windows)
425 (set-window-dedicated-p (selected-window) nil)
426 (split-window-vertically)
427 (ediff-select-lowest-window)
428 (ediff-setup-control-buffer control-buffer)
430 ;; go to the upper window and split it betw A, B, and possibly C
431 (other-window 1)
432 (switch-to-buffer buf-A)
433 (setq wind-A (selected-window))
434 (if three-way-comparison
435 (setq wind-width-or-height
436 (/ (if (eq split-window-function 'split-window-vertically)
437 (window-height wind-A)
438 (window-width wind-A))
439 3)))
441 ;; XEmacs used to have a lot of trouble with display
442 ;; It did't set things right unless we told it to sit still
443 ;; 19.12 seems ok.
444 ;;(if (featurep 'xemacs) (sit-for 0))
446 (funcall split-window-function wind-width-or-height)
448 (if (eq (selected-window) wind-A)
449 (other-window 1))
450 (switch-to-buffer buf-B)
451 (setq wind-B (selected-window))
453 (if three-way-comparison
454 (progn
455 (funcall split-window-function) ; equally
456 (if (eq (selected-window) wind-B)
457 (other-window 1))
458 (switch-to-buffer buf-C)
459 (setq wind-C (selected-window))))
461 (ediff-with-current-buffer control-buffer
462 (setq ediff-window-A wind-A
463 ediff-window-B wind-B
464 ediff-window-C wind-C))
466 ;; It is unlikely that we will want to implement 3way window comparison.
467 ;; So, only buffers A and B are used here.
468 (if ediff-windows-job
469 (progn
470 (set-window-start wind-A wind-A-start)
471 (set-window-start wind-B wind-B-start)))
473 (ediff-select-lowest-window)
474 (ediff-setup-control-buffer control-buffer)
478 ;; dispatch an appropriate window setup function
479 (defun ediff-setup-windows-multiframe (buf-A buf-B buf-C control-buf)
480 (ediff-with-current-buffer control-buf
481 (setq ediff-multiframe t))
482 (if ediff-merge-job
483 (ediff-setup-windows-multiframe-merge buf-A buf-B buf-C control-buf)
484 (ediff-setup-windows-multiframe-compare buf-A buf-B buf-C control-buf)))
486 (defun ediff-setup-windows-multiframe-merge (buf-A buf-B buf-C control-buf)
487 ;;; Algorithm:
488 ;;; 1. Never use frames that have dedicated windows in them---it is bad to
489 ;;; destroy dedicated windows.
490 ;;; 2. If A and B are in the same frame but C's frame is different--- use one
491 ;;; frame for A and B and use a separate frame for C.
492 ;;; 3. If C's frame is non-existent, then: if the first suitable
493 ;;; non-dedicated frame is different from A&B's, then use it for C.
494 ;;; Otherwise, put A,B, and C in one frame.
495 ;;; 4. If buffers A, B, C are is separate frames, use them to display these
496 ;;; buffers.
498 ;; Skip dedicated or iconified frames.
499 ;; Unsplittable frames are taken care of later.
500 (ediff-skip-unsuitable-frames 'ok-unsplittable)
502 (let* ((window-min-height 1)
503 (wind-A (ediff-get-visible-buffer-window buf-A))
504 (wind-B (ediff-get-visible-buffer-window buf-B))
505 (wind-C (ediff-get-visible-buffer-window buf-C))
506 (frame-A (if wind-A (window-frame wind-A)))
507 (frame-B (if wind-B (window-frame wind-B)))
508 (frame-C (if wind-C (window-frame wind-C)))
509 ;; on wide display, do things in one frame
510 (force-one-frame
511 (ediff-with-current-buffer control-buf ediff-wide-display-p))
512 ;; this lets us have local versions of ediff-split-window-function
513 (split-window-function
514 (ediff-with-current-buffer control-buf ediff-split-window-function))
515 (orig-wind (selected-window))
516 (orig-frame (selected-frame))
517 (use-same-frame (or force-one-frame
518 ;; A and C must be in one frame
519 (eq frame-A (or frame-C orig-frame))
520 ;; B and C must be in one frame
521 (eq frame-B (or frame-C orig-frame))
522 ;; A or B is not visible
523 (not (frame-live-p frame-A))
524 (not (frame-live-p frame-B))
525 ;; A or B is not suitable for display
526 (not (ediff-window-ok-for-display wind-A))
527 (not (ediff-window-ok-for-display wind-B))
528 ;; A and B in the same frame, and no good frame
529 ;; for C
530 (and (eq frame-A frame-B)
531 (not (frame-live-p frame-C)))
533 ;; use-same-frame-for-AB implies wind A and B are ok for display
534 (use-same-frame-for-AB (and (not use-same-frame)
535 (eq frame-A frame-B)))
536 (merge-window-share (ediff-with-current-buffer control-buf
537 ediff-merge-window-share))
538 merge-window-lines
539 designated-minibuffer-frame
540 done-A done-B done-C)
542 ;; buf-A on its own
543 (if (and (window-live-p wind-A)
544 (null use-same-frame) ; implies wind-A is suitable
545 (null use-same-frame-for-AB))
546 (progn ; bug A on its own
547 ;; buffer buf-A is seen in live wind-A
548 (select-window wind-A)
549 (delete-other-windows)
550 (setq wind-A (selected-window))
551 (setq done-A t)))
553 ;; buf-B on its own
554 (if (and (window-live-p wind-B)
555 (null use-same-frame) ; implies wind-B is suitable
556 (null use-same-frame-for-AB))
557 (progn ; buf B on its own
558 ;; buffer buf-B is seen in live wind-B
559 (select-window wind-B)
560 (delete-other-windows)
561 (setq wind-B (selected-window))
562 (setq done-B t)))
564 ;; buf-C on its own
565 (if (and (window-live-p wind-C)
566 (ediff-window-ok-for-display wind-C)
567 (null use-same-frame)) ; buf C on its own
568 (progn
569 ;; buffer buf-C is seen in live wind-C
570 (select-window wind-C)
571 (delete-other-windows)
572 (setq wind-C (selected-window))
573 (setq done-C t)))
575 (if (and use-same-frame-for-AB ; implies wind A and B are suitable
576 (window-live-p wind-A))
577 (progn
578 ;; wind-A must already be displaying buf-A
579 (select-window wind-A)
580 (delete-other-windows)
581 (setq wind-A (selected-window))
583 (funcall split-window-function)
584 (if (eq (selected-window) wind-A)
585 (other-window 1))
586 (switch-to-buffer buf-B)
587 (setq wind-B (selected-window))
589 (setq done-A t
590 done-B t)))
592 (if use-same-frame
593 (let ((window-min-height 1))
594 (if (and (eq frame-A frame-B)
595 (eq frame-B frame-C)
596 (frame-live-p frame-A))
597 (select-frame frame-A)
598 ;; avoid dedicated and non-splittable windows
599 (ediff-skip-unsuitable-frames))
600 (delete-other-windows)
601 (setq merge-window-lines
602 (max 2 (round (* (window-height) merge-window-share))))
603 (switch-to-buffer buf-A)
604 (setq wind-A (selected-window))
606 (split-window-vertically
607 (max 2 (- (window-height) merge-window-lines)))
608 (if (eq (selected-window) wind-A)
609 (other-window 1))
610 (setq wind-C (selected-window))
611 (switch-to-buffer buf-C)
613 (select-window wind-A)
615 (funcall split-window-function)
616 (if (eq (selected-window) wind-A)
617 (other-window 1))
618 (switch-to-buffer buf-B)
619 (setq wind-B (selected-window))
621 (setq done-A t
622 done-B t
623 done-C t)
626 (or done-A ; Buf A to be set in its own frame,
627 ;;; or it was set before because use-same-frame = 1
628 (progn
629 ;; Buf-A was not set up yet as it wasn't visible,
630 ;; and use-same-frame = nil, use-same-frame-for-AB = nil
631 (select-window orig-wind)
632 (delete-other-windows)
633 (switch-to-buffer buf-A)
634 (setq wind-A (selected-window))
636 (or done-B ; Buf B to be set in its own frame,
637 ;;; or it was set before because use-same-frame = 1
638 (progn
639 ;; Buf-B was not set up yet as it wasn't visible
640 ;; and use-same-frame = nil, use-same-frame-for-AB = nil
641 (select-window orig-wind)
642 (delete-other-windows)
643 (switch-to-buffer buf-B)
644 (setq wind-B (selected-window))
647 (or done-C ; Buf C to be set in its own frame,
648 ;;; or it was set before because use-same-frame = 1
649 (progn
650 ;; Buf-C was not set up yet as it wasn't visible
651 ;; and use-same-frame = nil
652 (select-window orig-wind)
653 (delete-other-windows)
654 (switch-to-buffer buf-C)
655 (setq wind-C (selected-window))
658 (ediff-with-current-buffer control-buf
659 (setq ediff-window-A wind-A
660 ediff-window-B wind-B
661 ediff-window-C wind-C)
662 (setq frame-A (window-frame ediff-window-A)
663 designated-minibuffer-frame
664 (window-frame (minibuffer-window frame-A))))
666 (ediff-setup-control-frame control-buf designated-minibuffer-frame)
670 ;; Window setup for all comparison jobs, including 3way comparisons
671 (defun ediff-setup-windows-multiframe-compare (buf-A buf-B buf-C control-buf)
672 ;;; Algorithm:
673 ;;; If a buffer is seen in a frame, use that frame for that buffer.
674 ;;; If it is not seen, use the current frame.
675 ;;; If both buffers are not seen, they share the current frame. If one
676 ;;; of the buffers is not seen, it is placed in the current frame (where
677 ;;; ediff started). If that frame is displaying the other buffer, it is
678 ;;; shared between the two buffers.
679 ;;; However, if we decide to put both buffers in one frame
680 ;;; and the selected frame isn't splittable, we create a new frame and
681 ;;; put both buffers there, event if one of this buffers is visible in
682 ;;; another frame.
684 ;; Skip dedicated or iconified frames.
685 ;; Unsplittable frames are taken care of later.
686 (ediff-skip-unsuitable-frames 'ok-unsplittable)
688 (let* ((window-min-height 1)
689 (wind-A (ediff-get-visible-buffer-window buf-A))
690 (wind-B (ediff-get-visible-buffer-window buf-B))
691 (wind-C (ediff-get-visible-buffer-window buf-C))
692 (frame-A (if wind-A (window-frame wind-A)))
693 (frame-B (if wind-B (window-frame wind-B)))
694 (frame-C (if wind-C (window-frame wind-C)))
695 (ctl-frame-exists-p (ediff-with-current-buffer control-buf
696 (frame-live-p ediff-control-frame)))
697 ;; on wide display, do things in one frame
698 (force-one-frame
699 (ediff-with-current-buffer control-buf ediff-wide-display-p))
700 ;; this lets us have local versions of ediff-split-window-function
701 (split-window-function
702 (ediff-with-current-buffer control-buf ediff-split-window-function))
703 (three-way-comparison
704 (ediff-with-current-buffer control-buf ediff-3way-comparison-job))
705 (orig-wind (selected-window))
706 (use-same-frame (or force-one-frame
707 (eq frame-A frame-B)
708 (not (ediff-window-ok-for-display wind-A))
709 (not (ediff-window-ok-for-display wind-B))
710 (if three-way-comparison
711 (or (eq frame-A frame-C)
712 (eq frame-B frame-C)
713 (not (ediff-window-ok-for-display wind-C))
714 (not (frame-live-p frame-A))
715 (not (frame-live-p frame-B))
716 (not (frame-live-p frame-C))))
717 (and (not (frame-live-p frame-B))
718 (or ctl-frame-exists-p
719 (eq frame-A (selected-frame))))
720 (and (not (frame-live-p frame-A))
721 (or ctl-frame-exists-p
722 (eq frame-B (selected-frame))))))
723 wind-A-start wind-B-start
724 designated-minibuffer-frame
725 done-A done-B done-C)
727 (ediff-with-current-buffer control-buf
728 (setq wind-A-start (ediff-overlay-start
729 (ediff-get-value-according-to-buffer-type
730 'A ediff-narrow-bounds))
731 wind-B-start (ediff-overlay-start
732 (ediff-get-value-according-to-buffer-type
733 'B ediff-narrow-bounds))))
735 (if (and (window-live-p wind-A) (null use-same-frame)) ; buf-A on its own
736 (progn
737 ;; buffer buf-A is seen in live wind-A
738 (select-window wind-A) ; must be displaying buf-A
739 (delete-other-windows)
740 (setq wind-A (selected-window))
741 (setq done-A t)))
743 (if (and (window-live-p wind-B) (null use-same-frame)) ; buf B on its own
744 (progn
745 ;; buffer buf-B is seen in live wind-B
746 (select-window wind-B) ; must be displaying buf-B
747 (delete-other-windows)
748 (setq wind-B (selected-window))
749 (setq done-B t)))
751 (if (and (window-live-p wind-C) (null use-same-frame)) ; buf C on its own
752 (progn
753 ;; buffer buf-C is seen in live wind-C
754 (select-window wind-C) ; must be displaying buf-C
755 (delete-other-windows)
756 (setq wind-C (selected-window))
757 (setq done-C t)))
759 (if use-same-frame
760 (let (wind-width-or-height) ; this affects 3way setups only
761 (if (and (eq frame-A frame-B) (frame-live-p frame-A))
762 (select-frame frame-A)
763 ;; avoid dedicated and non-splittable windows
764 (ediff-skip-unsuitable-frames))
765 (delete-other-windows)
766 (switch-to-buffer buf-A)
767 (setq wind-A (selected-window))
769 (if three-way-comparison
770 (setq wind-width-or-height
772 (if (eq split-window-function 'split-window-vertically)
773 (window-height wind-A)
774 (window-width wind-A))
775 3)))
777 (funcall split-window-function wind-width-or-height)
778 (if (eq (selected-window) wind-A)
779 (other-window 1))
780 (switch-to-buffer buf-B)
781 (setq wind-B (selected-window))
783 (if three-way-comparison
784 (progn
785 (funcall split-window-function) ; equally
786 (if (memq (selected-window) (list wind-A wind-B))
787 (other-window 1))
788 (switch-to-buffer buf-C)
789 (setq wind-C (selected-window))))
790 (setq done-A t
791 done-B t
792 done-C t)
795 (or done-A ; Buf A to be set in its own frame
796 ;;; or it was set before because use-same-frame = 1
797 (progn
798 ;; Buf-A was not set up yet as it wasn't visible,
799 ;; and use-same-frame = nil
800 (select-window orig-wind)
801 (delete-other-windows)
802 (switch-to-buffer buf-A)
803 (setq wind-A (selected-window))
805 (or done-B ; Buf B to be set in its own frame
806 ;;; or it was set before because use-same-frame = 1
807 (progn
808 ;; Buf-B was not set up yet as it wasn't visible,
809 ;; and use-same-frame = nil
810 (select-window orig-wind)
811 (delete-other-windows)
812 (switch-to-buffer buf-B)
813 (setq wind-B (selected-window))
816 (if three-way-comparison
817 (or done-C ; Buf C to be set in its own frame
818 ;;; or it was set before because use-same-frame = 1
819 (progn
820 ;; Buf-C was not set up yet as it wasn't visible,
821 ;; and use-same-frame = nil
822 (select-window orig-wind)
823 (delete-other-windows)
824 (switch-to-buffer buf-C)
825 (setq wind-C (selected-window))
828 (ediff-with-current-buffer control-buf
829 (setq ediff-window-A wind-A
830 ediff-window-B wind-B
831 ediff-window-C wind-C)
833 (setq frame-A (window-frame ediff-window-A)
834 designated-minibuffer-frame
835 (window-frame (minibuffer-window frame-A))))
837 ;; It is unlikely that we'll implement a version of ediff-windows that
838 ;; would compare 3 windows at once. So, we don't use buffer C here.
839 (if ediff-windows-job
840 (progn
841 (set-window-start wind-A wind-A-start)
842 (set-window-start wind-B wind-B-start)))
844 (ediff-setup-control-frame control-buf designated-minibuffer-frame)
847 ;; skip unsplittable frames and frames that have dedicated windows.
848 ;; create a new splittable frame if none is found
849 (defun ediff-skip-unsuitable-frames (&optional ok-unsplittable)
850 (if (ediff-window-display-p)
851 (let ((wind-frame (window-frame (selected-window)))
852 seen-windows)
853 (while (and (not (memq (selected-window) seen-windows))
855 (ediff-frame-has-dedicated-windows wind-frame)
856 (ediff-frame-iconified-p wind-frame)
857 ;; skip small windows
858 (< (frame-height wind-frame)
859 (* 3 window-min-height))
860 (if ok-unsplittable
862 (ediff-frame-unsplittable-p wind-frame))))
863 ;; remember history
864 (setq seen-windows (cons (selected-window) seen-windows))
865 ;; try new window
866 (other-window 1 t)
867 (setq wind-frame (window-frame (selected-window)))
869 (if (memq (selected-window) seen-windows)
870 ;; fed up, no appropriate frames
871 (setq wind-frame (make-frame '((unsplittable)))))
873 (select-frame wind-frame)
876 (defun ediff-frame-has-dedicated-windows (frame)
877 (let (ans)
878 (walk-windows
879 (lambda (wind) (if (window-dedicated-p wind)
880 (setq ans t)))
881 'ignore-minibuffer
882 frame)
883 ans))
885 ;; window is ok, if it is only one window on the frame, not counting the
886 ;; minibuffer, or none of the frame's windows is dedicated.
887 ;; The idea is that it is bad to destroy dedicated windows while creating an
888 ;; ediff window setup
889 (defun ediff-window-ok-for-display (wind)
890 (and
891 (window-live-p wind)
893 ;; only one window
894 (eq wind (next-window wind 'ignore-minibuffer (window-frame wind)))
895 ;; none is dedicated (in multiframe setup)
896 (not (ediff-frame-has-dedicated-windows (window-frame wind)))
899 ;; Prepare or refresh control frame
900 (defun ediff-setup-control-frame (ctl-buffer designated-minibuffer-frame)
901 (let ((window-min-height 1)
902 ctl-frame-iconified-p dont-iconify-ctl-frame deiconify-ctl-frame
903 ctl-frame old-ctl-frame lines
904 ;; user-grabbed-mouse
905 fheight fwidth adjusted-parameters)
907 (ediff-with-current-buffer ctl-buffer
908 (if (and (featurep 'xemacs) (featurep 'menubar))
909 (set-buffer-menubar nil))
910 ;;(setq user-grabbed-mouse (ediff-user-grabbed-mouse))
911 (run-hooks 'ediff-before-setup-control-frame-hook))
913 (setq old-ctl-frame (ediff-with-current-buffer ctl-buffer ediff-control-frame))
914 (ediff-with-current-buffer ctl-buffer
915 (setq ctl-frame (if (frame-live-p old-ctl-frame)
916 old-ctl-frame
917 (make-frame ediff-control-frame-parameters))
918 ediff-control-frame ctl-frame)
919 ;; protect against undefined face-attribute
920 (condition-case nil
921 (if (and (featurep 'emacs) (face-attribute 'mode-line :box))
922 (set-face-attribute 'mode-line ctl-frame :box nil))
923 (error)))
925 (setq ctl-frame-iconified-p (ediff-frame-iconified-p ctl-frame))
926 (select-frame ctl-frame)
927 (if (window-dedicated-p (selected-window))
929 (delete-other-windows)
930 (switch-to-buffer ctl-buffer))
932 ;; must be before ediff-setup-control-buffer
933 ;; just a precaution--we should be in ctl-buffer already
934 (ediff-with-current-buffer ctl-buffer
935 (make-local-variable 'frame-title-format)
936 (make-local-variable 'frame-icon-title-format) ; XEmacs
937 (make-local-variable 'icon-title-format)) ; Emacs
939 (ediff-setup-control-buffer ctl-buffer)
940 (setq dont-iconify-ctl-frame
941 (not (string= ediff-help-message ediff-brief-help-message)))
942 (setq deiconify-ctl-frame
943 (and (eq this-command 'ediff-toggle-help)
944 dont-iconify-ctl-frame))
946 ;; 1 more line for the modeline
947 (setq lines (1+ (count-lines (point-min) (point-max)))
948 fheight lines
949 fwidth (max (+ (ediff-help-message-line-length) 2)
950 (ediff-compute-toolbar-width))
951 adjusted-parameters
952 (list
953 ;; possibly change surrogate minibuffer
954 (cons 'minibuffer
955 (minibuffer-window
956 designated-minibuffer-frame))
957 (cons 'width fwidth)
958 (cons 'height fheight)
959 (cons 'user-position t)
962 ;; adjust autoraise
963 (setq adjusted-parameters
964 (cons (if ediff-use-long-help-message
965 '(auto-raise . nil)
966 '(auto-raise . t))
967 adjusted-parameters))
969 ;; In XEmacs, buffer menubar needs to be killed before frame parameters
970 ;; are changed.
971 (if (ediff-has-toolbar-support-p)
972 (when (featurep 'xemacs)
973 (if (ediff-has-gutter-support-p)
974 (set-specifier top-gutter (list ctl-frame nil)))
975 (sit-for 0)
976 (set-specifier top-toolbar-height (list ctl-frame 0))
977 ;;(set-specifier bottom-toolbar-height (list ctl-frame 0))
978 (set-specifier left-toolbar-width (list ctl-frame 0))
979 (set-specifier right-toolbar-width (list ctl-frame 0))))
981 ;; Under OS/2 (emx) we have to call modify frame parameters twice, in order
982 ;; to make sure that at least once we do it for non-iconified frame. If
983 ;; appears that in the OS/2 port of Emacs, one can't modify frame
984 ;; parameters of iconified frames. As a precaution, we do likewise for
985 ;; windows-nt.
986 (if (memq system-type '(emx windows-nt windows-95))
987 (modify-frame-parameters ctl-frame adjusted-parameters))
989 ;; make or zap toolbar (if not requested)
990 (ediff-make-bottom-toolbar ctl-frame)
992 (goto-char (point-min))
994 (modify-frame-parameters ctl-frame adjusted-parameters)
995 (make-frame-visible ctl-frame)
997 ;; This works around a bug in 19.25 and earlier. There, if frame gets
998 ;; iconified, the current buffer changes to that of the frame that
999 ;; becomes exposed as a result of this iconification.
1000 ;; So, we make sure the current buffer doesn't change.
1001 (select-frame ctl-frame)
1002 (ediff-refresh-control-frame)
1004 (cond ((and ediff-prefer-iconified-control-frame
1005 (not ctl-frame-iconified-p) (not dont-iconify-ctl-frame))
1006 (iconify-frame ctl-frame))
1007 ((or deiconify-ctl-frame (not ctl-frame-iconified-p))
1008 (raise-frame ctl-frame)))
1010 (set-window-dedicated-p (selected-window) t)
1012 ;; Now move the frame. We must do it separately due to an obscure bug in
1013 ;; XEmacs
1014 (modify-frame-parameters
1015 ctl-frame
1016 (funcall ediff-control-frame-position-function ctl-buffer fwidth fheight))
1018 ;; synchronize so the cursor will move to control frame
1019 ;; per RMS suggestion
1020 (if (ediff-window-display-p)
1021 (let ((count 7))
1022 (sit-for .1)
1023 (while (and (not (frame-visible-p ctl-frame)) (> count 0))
1024 (setq count (1- count))
1025 (sit-for .3))))
1027 (or (ediff-frame-iconified-p ctl-frame)
1028 ;; don't warp the mouse, unless ediff-grab-mouse = t
1029 (ediff-reset-mouse ctl-frame
1030 (or (eq this-command 'ediff-quit)
1031 (not (eq ediff-grab-mouse t)))))
1033 (when (featurep 'xemacs)
1034 (ediff-with-current-buffer ctl-buffer
1035 (make-local-hook 'select-frame-hook)
1036 (add-hook 'select-frame-hook
1037 'ediff-xemacs-select-frame-hook nil 'local)))
1039 (ediff-with-current-buffer ctl-buffer
1040 (run-hooks 'ediff-after-setup-control-frame-hook))))
1043 (defun ediff-destroy-control-frame (ctl-buffer)
1044 (ediff-with-current-buffer ctl-buffer
1045 (if (and (ediff-window-display-p) (frame-live-p ediff-control-frame))
1046 (let ((ctl-frame ediff-control-frame))
1047 (if (and (featurep 'xemacs) (featurep 'menubar))
1048 (set-buffer-menubar default-menubar))
1049 (setq ediff-control-frame nil)
1050 (delete-frame ctl-frame))))
1051 (if ediff-multiframe
1052 (ediff-skip-unsuitable-frames))
1053 ;;(ediff-reset-mouse nil)
1057 ;; finds a good place to clip control frame
1058 (defun ediff-make-frame-position (ctl-buffer ctl-frame-width ctl-frame-height)
1059 (ediff-with-current-buffer ctl-buffer
1060 (let* ((frame-A (window-frame ediff-window-A))
1061 (frame-A-parameters (frame-parameters frame-A))
1062 (frame-A-top (eval (cdr (assoc 'top frame-A-parameters))))
1063 (frame-A-left (eval (cdr (assoc 'left frame-A-parameters))))
1064 (frame-A-width (frame-width frame-A))
1065 (ctl-frame ediff-control-frame)
1066 horizontal-adjustment upward-adjustment
1067 ctl-frame-top ctl-frame-left)
1069 ;; Multiple control frames are clipped based on the value of
1070 ;; ediff-control-buffer-number. This is done in order not to obscure
1071 ;; other active control panels.
1072 (setq horizontal-adjustment (* 2 ediff-control-buffer-number)
1073 upward-adjustment (* -14 ediff-control-buffer-number))
1075 (setq ctl-frame-top
1076 (- frame-A-top upward-adjustment ediff-control-frame-upward-shift)
1077 ctl-frame-left
1078 (+ frame-A-left
1079 (if ediff-use-long-help-message
1080 (* (ediff-frame-char-width ctl-frame)
1081 (+ ediff-wide-control-frame-rightward-shift
1082 horizontal-adjustment))
1083 (- (* frame-A-width (ediff-frame-char-width frame-A))
1084 (* (ediff-frame-char-width ctl-frame)
1085 (+ ctl-frame-width
1086 ediff-narrow-control-frame-leftward-shift
1087 horizontal-adjustment))))))
1088 (setq ctl-frame-top
1089 (min ctl-frame-top
1090 (- (ediff-display-pixel-height)
1091 (* 2 ctl-frame-height
1092 (ediff-frame-char-height ctl-frame))))
1093 ctl-frame-left
1094 (min ctl-frame-left
1095 (- (ediff-display-pixel-width)
1096 (* ctl-frame-width (ediff-frame-char-width ctl-frame)))))
1097 ;; keep ctl frame within the visible bounds
1098 (setq ctl-frame-top (max ctl-frame-top 1)
1099 ctl-frame-left (max ctl-frame-left 1))
1101 (list (cons 'top ctl-frame-top)
1102 (cons 'left ctl-frame-left))
1105 (defun ediff-xemacs-select-frame-hook ()
1106 (if (and (equal (selected-frame) ediff-control-frame)
1107 (not ediff-use-long-help-message))
1108 (raise-frame ediff-control-frame)))
1110 (defun ediff-make-wide-display ()
1111 "Construct an alist of parameters for the wide display.
1112 Saves the old frame parameters in `ediff-wide-display-orig-parameters'.
1113 The frame to be resized is kept in `ediff-wide-display-frame'.
1114 This function modifies only the left margin and the width of the display.
1115 It assumes that it is called from within the control buffer."
1116 (if (not (fboundp 'ediff-display-pixel-width))
1117 (error "Can't determine display width"))
1118 (let* ((frame-A (window-frame ediff-window-A))
1119 (frame-A-params (frame-parameters frame-A))
1120 (cw (ediff-frame-char-width frame-A))
1121 (wd (- (/ (ediff-display-pixel-width) cw) 5)))
1122 (setq ediff-wide-display-orig-parameters
1123 (list (cons 'left (max 0 (eval (cdr (assoc 'left frame-A-params)))))
1124 (cons 'width (cdr (assoc 'width frame-A-params))))
1125 ediff-wide-display-frame frame-A)
1126 (modify-frame-parameters
1127 frame-A `((left . ,cw) (width . ,wd) (user-position . t)))))
1130 ;; Revise the mode line to display which difference we have selected
1131 ;; Also resets modelines of buffers A/B, since they may be clobbered by
1132 ;; anothe invocations of Ediff.
1133 (defun ediff-refresh-mode-lines ()
1134 (let (buf-A-state-diff buf-B-state-diff buf-C-state-diff buf-C-state-merge)
1136 (if (ediff-valid-difference-p)
1137 (setq
1138 buf-C-state-diff (ediff-get-state-of-diff ediff-current-difference 'C)
1139 buf-C-state-merge (ediff-get-state-of-merge ediff-current-difference)
1140 buf-A-state-diff (ediff-get-state-of-diff ediff-current-difference 'A)
1141 buf-B-state-diff (ediff-get-state-of-diff ediff-current-difference 'B)
1142 buf-A-state-diff (if buf-A-state-diff
1143 (format "[%s] " buf-A-state-diff)
1145 buf-B-state-diff (if buf-B-state-diff
1146 (format "[%s] " buf-B-state-diff)
1148 buf-C-state-diff (if (and (ediff-buffer-live-p ediff-buffer-C)
1149 (or buf-C-state-diff buf-C-state-merge))
1150 (format "[%s%s%s] "
1151 (or buf-C-state-diff "")
1152 (if buf-C-state-merge
1153 (concat " " buf-C-state-merge)
1155 (if (ediff-get-state-of-ancestor
1156 ediff-current-difference)
1157 " AncestorEmpty"
1160 ""))
1161 (setq buf-A-state-diff ""
1162 buf-B-state-diff ""
1163 buf-C-state-diff ""))
1165 ;; control buffer format
1166 (setq mode-line-format
1167 (if (ediff-narrow-control-frame-p)
1168 (list " " mode-line-buffer-identification)
1169 (list "-- " mode-line-buffer-identification " Quick Help")))
1170 ;; control buffer id
1171 (setq mode-line-buffer-identification
1172 (if (ediff-narrow-control-frame-p)
1173 (ediff-make-narrow-control-buffer-id 'skip-name)
1174 (ediff-make-wide-control-buffer-id)))
1175 ;; Force mode-line redisplay
1176 (force-mode-line-update)
1178 (if (and (ediff-window-display-p) (frame-live-p ediff-control-frame))
1179 (ediff-refresh-control-frame))
1181 (ediff-with-current-buffer ediff-buffer-A
1182 (setq ediff-diff-status buf-A-state-diff)
1183 (ediff-strip-mode-line-format)
1184 (setq mode-line-format
1185 (list " A: " 'ediff-diff-status mode-line-format))
1186 (force-mode-line-update))
1187 (ediff-with-current-buffer ediff-buffer-B
1188 (setq ediff-diff-status buf-B-state-diff)
1189 (ediff-strip-mode-line-format)
1190 (setq mode-line-format
1191 (list " B: " 'ediff-diff-status mode-line-format))
1192 (force-mode-line-update))
1193 (if ediff-3way-job
1194 (ediff-with-current-buffer ediff-buffer-C
1195 (setq ediff-diff-status buf-C-state-diff)
1196 (ediff-strip-mode-line-format)
1197 (setq mode-line-format
1198 (list " C: " 'ediff-diff-status mode-line-format))
1199 (force-mode-line-update)))
1200 (if (ediff-buffer-live-p ediff-ancestor-buffer)
1201 (ediff-with-current-buffer ediff-ancestor-buffer
1202 (ediff-strip-mode-line-format)
1203 ;; we keep the second dummy string in the mode line format of the
1204 ;; ancestor, since for other buffers Ediff prepends 2 strings and
1205 ;; ediff-strip-mode-line-format expects that.
1206 (setq mode-line-format
1207 (list " Ancestor: "
1208 (cond ((not (stringp buf-C-state-merge))
1210 ((string-match "prefer-A" buf-C-state-merge)
1211 "[=diff(B)] ")
1212 ((string-match "prefer-B" buf-C-state-merge)
1213 "[=diff(A)] ")
1214 (t ""))
1215 mode-line-format))))
1219 (defun ediff-refresh-control-frame ()
1220 (if (featurep 'emacs)
1221 ;; set frame/icon titles for Emacs
1222 (modify-frame-parameters
1223 ediff-control-frame
1224 (list (cons 'title (ediff-make-base-title))
1225 (cons 'icon-name (ediff-make-narrow-control-buffer-id))
1227 ;; set frame/icon titles for XEmacs
1228 (setq frame-title-format (ediff-make-base-title)
1229 frame-icon-title-format (ediff-make-narrow-control-buffer-id))
1230 ;; force an update of the frame title
1231 (modify-frame-parameters ediff-control-frame '(()))))
1234 (defun ediff-make-narrow-control-buffer-id (&optional skip-name)
1235 (concat
1236 (if skip-name
1238 (ediff-make-base-title))
1239 (cond ((< ediff-current-difference 0)
1240 (format " _/%d" ediff-number-of-differences))
1241 ((>= ediff-current-difference ediff-number-of-differences)
1242 (format " $/%d" ediff-number-of-differences))
1244 (format " %d/%d"
1245 (1+ ediff-current-difference)
1246 ediff-number-of-differences)))))
1248 (defun ediff-make-base-title ()
1249 (concat
1250 (cdr (assoc 'name ediff-control-frame-parameters))
1251 ediff-control-buffer-suffix))
1253 (defun ediff-make-wide-control-buffer-id ()
1254 (cond ((< ediff-current-difference 0)
1255 (list (format "%%b At start of %d diffs"
1256 ediff-number-of-differences)))
1257 ((>= ediff-current-difference ediff-number-of-differences)
1258 (list (format "%%b At end of %d diffs"
1259 ediff-number-of-differences)))
1261 (list (format "%%b diff %d of %d"
1262 (1+ ediff-current-difference)
1263 ediff-number-of-differences)))))
1267 ;; If buff is not live, return nil
1268 (defun ediff-get-visible-buffer-window (buff)
1269 (if (ediff-buffer-live-p buff)
1270 (if (featurep 'xemacs)
1271 (get-buffer-window buff t)
1272 (get-buffer-window buff 'visible))))
1275 ;;; Functions to decide when to redraw windows
1277 (defun ediff-keep-window-config (control-buf)
1278 (and (eq control-buf (current-buffer))
1279 (/= (buffer-size) 0)
1280 (ediff-with-current-buffer control-buf
1281 (let ((ctl-wind ediff-control-window)
1282 (A-wind ediff-window-A)
1283 (B-wind ediff-window-B)
1284 (C-wind ediff-window-C))
1286 (and
1287 (ediff-window-visible-p A-wind)
1288 (ediff-window-visible-p B-wind)
1289 ;; if buffer C is defined then take it into account
1290 (or (not ediff-3way-job)
1291 (ediff-window-visible-p C-wind))
1292 (eq (window-buffer A-wind) ediff-buffer-A)
1293 (eq (window-buffer B-wind) ediff-buffer-B)
1294 (or (not ediff-3way-job)
1295 (eq (window-buffer C-wind) ediff-buffer-C))
1296 (string= ediff-window-config-saved
1297 (format "%S%S%S%S%S%S%S"
1298 ctl-wind A-wind B-wind C-wind
1299 ediff-split-window-function
1300 (ediff-multiframe-setup-p)
1301 ediff-wide-display-p)))))))
1304 (provide 'ediff-wind)
1307 ;; Local Variables:
1308 ;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun)
1309 ;; eval: (put 'ediff-with-current-buffer 'lisp-indent-hook 1)
1310 ;; eval: (put 'ediff-with-current-buffer 'edebug-form-spec '(form body))
1311 ;; End:
1313 ;; arch-tag: 73d9a5d7-eed7-4d9c-8b4b-21d5d78eb597
1314 ;;; ediff-wind.el ends here