Add arch tagline
[emacs.git] / lisp / ediff-wind.el
blobc2c130ac6bbe1f3e6c6c24454b9b164e6629b33f
1 ;;; ediff-wind.el --- window manipulation utilities
3 ;; Copyright (C) 1994, 1995, 1996, 1997, 2000, 2001, 2002, 2003,
4 ;; 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
6 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 3, or (at your option)
13 ;; any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 ;; Boston, MA 02110-1301, USA.
25 ;;; Commentary:
27 ;;; Code:
30 ;; Compiler pacifier
31 (defvar icon-title-format)
32 (defvar top-toolbar-height)
33 (defvar bottom-toolbar-height)
34 (defvar left-toolbar-height)
35 (defvar right-toolbar-height)
36 (defvar left-toolbar-width)
37 (defvar right-toolbar-width)
38 (defvar default-menubar)
39 (defvar top-gutter)
40 (defvar frame-icon-title-format)
41 (defvar ediff-diff-status)
42 (defvar ediff-emacs-p)
44 (eval-when-compile
45 (let ((load-path (cons (expand-file-name ".") load-path)))
46 (or (featurep 'ediff-init)
47 (load "ediff-init.el" nil nil 'nosuffix))
48 (or (featurep 'ediff-util)
49 (load "ediff-util.el" nil nil 'nosuffix))
50 (or (featurep 'ediff-help)
51 (load "ediff-help.el" nil nil 'nosuffix))
52 (or (featurep 'ediff-tbar)
53 ediff-emacs-p
54 (load "ediff-tbar.el" 'noerror nil 'nosuffix))
56 ;; end pacifier
58 (require 'ediff-init)
60 ;; be careful with ediff-tbar
61 (if ediff-xemacs-p
62 (condition-case nil
63 (require 'ediff-tbar)
64 (error
65 (defun ediff-compute-toolbar-width () 0)))
66 (defun ediff-compute-toolbar-width () 0))
68 (defgroup ediff-window nil
69 "Ediff window manipulation."
70 :prefix "ediff-"
71 :group 'ediff
72 :group 'frames)
75 (defcustom ediff-window-setup-function 'ediff-setup-windows-automatic
76 "*Function called to set up windows.
77 Ediff provides a choice of three functions: `ediff-setup-windows-plain', for
78 doing everything in one frame, `ediff-setup-windows-multiframe', which sets
79 the control panel in a separate frame, and
80 `ediff-setup-windows-automatic' (the default), which chooses an appropriate
81 behaviour based on the current window system. If the multiframe function
82 detects that one of the buffers A/B is seen in some other frame, it will try
83 to keep that buffer in that frame.
85 If you don't like the two functions provided---write your own one.
86 The basic guidelines:
87 1. It should leave the control buffer current and the control window
88 selected.
89 2. It should set `ediff-window-A', `ediff-window-B', `ediff-window-C',
90 and `ediff-control-window' to contain window objects that display
91 the corresponding buffers.
92 3. It should accept the following arguments:
93 buffer-A, buffer-B, buffer-C, control-buffer
94 Buffer C may not be used in jobs that compare only two buffers.
95 If you plan to do something fancy, take a close look at how the two
96 provided functions are written."
97 :type '(choice (const :tag "Automatic" ediff-setup-windows-automatic)
98 (const :tag "Multi Frame" ediff-setup-windows-multiframe)
99 (const :tag "Single Frame" ediff-setup-windows-plain)
100 (function :tag "Other function"))
101 :group 'ediff-window)
103 ;; indicates if we are in a multiframe setup
104 (ediff-defvar-local ediff-multiframe nil "")
106 ;; Share of the frame occupied by the merge window (buffer C)
107 (ediff-defvar-local ediff-merge-window-share 0.45 "")
109 ;; The control window.
110 (ediff-defvar-local ediff-control-window nil "")
111 ;; Official window for buffer A
112 (ediff-defvar-local ediff-window-A nil "")
113 ;; Official window for buffer B
114 (ediff-defvar-local ediff-window-B nil "")
115 ;; Official window for buffer C
116 (ediff-defvar-local ediff-window-C nil "")
117 ;; Ediff's window configuration.
118 ;; Used to minimize the need to rearrange windows.
119 (ediff-defvar-local ediff-window-config-saved "" "")
121 ;; Association between buff-type and ediff-window-*
122 (defconst ediff-window-alist
123 '((A . ediff-window-A)
124 (?A . ediff-window-A)
125 (B . ediff-window-B)
126 (?B . ediff-window-B)
127 (C . ediff-window-C)
128 (?C . ediff-window-C)))
131 (defcustom ediff-split-window-function 'split-window-vertically
132 "*The function used to split the main window between buffer-A and buffer-B.
133 You can set it to a horizontal split instead of the default vertical split
134 by setting this variable to `split-window-horizontally'.
135 You can also have your own function to do fancy splits.
136 This variable has no effect when buffer-A/B are shown in different frames.
137 In this case, Ediff will use those frames to display these buffers."
138 :type 'function
139 :group 'ediff-window)
141 (defcustom ediff-merge-split-window-function 'split-window-horizontally
142 "*The function used to split the main window between buffer-A and buffer-B.
143 You can set it to a vertical split instead of the default horizontal split
144 by setting this variable to `split-window-vertically'.
145 You can also have your own function to do fancy splits.
146 This variable has no effect when buffer-A/B/C are shown in different frames.
147 In this case, Ediff will use those frames to display these buffers."
148 :type 'function
149 :group 'ediff-window)
151 (defconst ediff-control-frame-parameters
152 (list
153 '(name . "Ediff")
154 ;;'(unsplittable . t)
155 '(minibuffer . nil)
156 '(user-position . t) ; Emacs only
157 '(vertical-scroll-bars . nil) ; Emacs only
158 '(scrollbar-width . 0) ; XEmacs only
159 '(scrollbar-height . 0) ; XEmacs only
160 '(menu-bar-lines . 0) ; Emacs only
161 '(tool-bar-lines . 0) ; Emacs 21+ only
162 '(left-fringe . 0)
163 '(right-fringe . 0)
164 ;; don't lower but auto-raise
165 '(auto-lower . nil)
166 '(auto-raise . t)
167 '(visibility . nil)
168 ;; make initial frame small to avoid distraction
169 '(width . 1) '(height . 1)
170 ;; this blocks queries from window manager as to where to put
171 ;; ediff's control frame. we put the frame outside the display,
172 ;; so the initial frame won't jump all over the screen
173 (cons 'top (if (fboundp 'ediff-display-pixel-height)
174 (1+ (ediff-display-pixel-height))
175 3000))
176 (cons 'left (if (fboundp 'ediff-display-pixel-width)
177 (1+ (ediff-display-pixel-width))
178 3000))
180 "Frame parameters for displaying Ediff Control Panel.
181 Used internally---not a user option.")
183 ;; position of the mouse; used to decide whether to warp the mouse into ctl
184 ;; frame
185 (ediff-defvar-local ediff-mouse-pixel-position nil "")
187 ;; not used for now
188 (defvar ediff-mouse-pixel-threshold 30
189 "If the user moves mouse more than this many pixels, Ediff won't warp mouse into control window.")
191 (defcustom ediff-grab-mouse t
192 "*If t, Ediff will always grab the mouse and put it in the control frame.
193 If 'maybe, Ediff will do it sometimes, but not after operations that require
194 relatively long time. If nil, the mouse will be entirely user's
195 responsibility."
196 :type 'boolean
197 :group 'ediff-window)
199 (defcustom ediff-control-frame-position-function 'ediff-make-frame-position
200 "Function to call to determine the desired location for the control panel.
201 Expects three parameters: the control buffer, the desired width and height
202 of the control frame. It returns an association list
203 of the form \(\(top . <position>\) \(left . <position>\)\)"
204 :type 'function
205 :group 'ediff-window)
207 (defcustom ediff-control-frame-upward-shift 42
208 "*The upward shift of control frame from the top of buffer A's frame.
209 Measured in pixels.
210 This is used by the default control frame positioning function,
211 `ediff-make-frame-position'. This variable is provided for easy
212 customization of the default control frame positioning."
213 :type 'integer
214 :group 'ediff-window)
216 (defcustom ediff-narrow-control-frame-leftward-shift (if ediff-xemacs-p 7 3)
217 "*The leftward shift of control frame from the right edge of buf A's frame.
218 Measured in characters.
219 This is used by the default control frame positioning function,
220 `ediff-make-frame-position' to adjust the position of the control frame
221 when it shows the short menu. This variable is provided for easy
222 customization of the default."
223 :type 'integer
224 :group 'ediff-window)
226 (defcustom ediff-wide-control-frame-rightward-shift 7
227 "*The rightward shift of control frame from the left edge of buf A's frame.
228 Measured in characters.
229 This is used by the default control frame positioning function,
230 `ediff-make-frame-position' to adjust the position of the control frame
231 when it shows the full menu. This variable is provided for easy
232 customization of the default."
233 :type 'integer
234 :group 'ediff-window)
237 ;; Wide frame display
239 ;; t means Ediff is using wide display
240 (ediff-defvar-local ediff-wide-display-p nil "")
241 ;; keeps frame config for toggling wide display
242 (ediff-defvar-local ediff-wide-display-orig-parameters nil
243 "Frame parameters to be restored when the user wants to toggle the wide
244 display off.")
245 (ediff-defvar-local ediff-wide-display-frame nil
246 "Frame to be used for wide display.")
247 (ediff-defvar-local ediff-make-wide-display-function 'ediff-make-wide-display
248 "The value is a function that is called to create a wide display.
249 The function is called without arguments. It should resize the frame in
250 which buffers A, B, and C are to be displayed, and it should save the old
251 frame parameters in `ediff-wide-display-orig-parameters'.
252 The variable `ediff-wide-display-frame' should be set to contain
253 the frame used for the wide display.")
255 ;; Frame used for the control panel in a windowing system.
256 (ediff-defvar-local ediff-control-frame nil "")
258 (defcustom ediff-prefer-iconified-control-frame nil
259 "*If t, keep control panel iconified when help message is off.
260 This has effect only on a windowing system.
261 If t, hitting `?' to toggle control panel off iconifies it.
263 This is only useful in Emacs and only for certain kinds of window managers,
264 such as TWM and its derivatives, since the window manager must permit
265 keyboard input to go into icons. XEmacs completely ignores keyboard input
266 into icons, regardless of the window manager."
267 :type 'boolean
268 :group 'ediff-window)
270 ;;; Functions
272 (defun ediff-get-window-by-clicking (wind prev-wind wind-number)
273 (let (event)
274 (message
275 "Select windows by clicking. Please click on Window %d " wind-number)
276 (while (not (ediff-mouse-event-p (setq event (ediff-read-event))))
277 (if (sit-for 1) ; if sequence of events, wait till the final word
278 (beep 1))
279 (message "Please click on Window %d " wind-number))
280 (ediff-read-event) ; discard event
281 (setq wind (ediff-cond-compile-for-xemacs-or-emacs
282 (event-window event) ; xemacs
283 (posn-window (event-start event)) ; emacs
289 ;; Select the lowest window on the frame.
290 (defun ediff-select-lowest-window ()
291 (ediff-cond-compile-for-xemacs-or-emacs
292 (select-window (frame-lowest-window)) ; xemacs
293 ;; emacs
294 (let* ((lowest-window (selected-window))
295 (bottom-edge (car (cdr (cdr (cdr (window-edges))))))
296 (last-window (save-excursion
297 (other-window -1) (selected-window)))
298 (window-search t))
299 (while window-search
300 (let* ((this-window (next-window))
301 (next-bottom-edge
302 (car (cdr (cdr (cdr (window-edges this-window)))))))
303 (if (< bottom-edge next-bottom-edge)
304 (progn
305 (setq bottom-edge next-bottom-edge)
306 (setq lowest-window this-window)))
308 (select-window this-window)
309 (if (eq last-window this-window)
310 (progn
311 (select-window lowest-window)
312 (setq window-search nil))))))
316 ;;; Common window setup routines
318 ;; Set up the window configuration. If POS is given, set the points to
319 ;; the beginnings of the buffers.
320 ;; When 3way comparison is added, this will have to choose the appropriate
321 ;; setup function based on ediff-job-name
322 (defun ediff-setup-windows (buffer-A buffer-B buffer-C control-buffer)
323 ;; Make sure we are not in the minibuffer window when we try to delete
324 ;; all other windows.
325 (run-hooks 'ediff-before-setup-windows-hook)
326 (if (eq (selected-window) (minibuffer-window))
327 (other-window 1))
329 ;; in case user did a no-no on a tty
330 (or (ediff-window-display-p)
331 (setq ediff-window-setup-function 'ediff-setup-windows-plain))
333 (or (ediff-keep-window-config control-buffer)
334 (funcall
335 (ediff-with-current-buffer control-buffer ediff-window-setup-function)
336 buffer-A buffer-B buffer-C control-buffer))
337 (run-hooks 'ediff-after-setup-windows-hook))
339 ;; Set up windows using the correct method based on the current window system.
340 (defun ediff-setup-windows-automatic (buffer-A buffer-B buffer-C control-buffer)
341 (if (ediff-window-display-p)
342 (ediff-setup-windows-multiframe buffer-A buffer-B buffer-C control-buffer)
343 (ediff-setup-windows-plain buffer-A buffer-B buffer-C control-buffer)))
345 ;; Just set up 3 windows.
346 ;; Usually used without windowing systems
347 ;; With windowing, we want to use dedicated frames.
348 (defun ediff-setup-windows-plain (buffer-A buffer-B buffer-C control-buffer)
349 (ediff-with-current-buffer control-buffer
350 (setq ediff-multiframe nil))
351 (if ediff-merge-job
352 (ediff-setup-windows-plain-merge
353 buffer-A buffer-B buffer-C control-buffer)
354 (ediff-setup-windows-plain-compare
355 buffer-A buffer-B buffer-C control-buffer)))
357 (defun ediff-setup-windows-plain-merge (buf-A buf-B buf-C control-buffer)
358 ;; skip dedicated and unsplittable frames
359 (ediff-destroy-control-frame control-buffer)
360 (let ((window-min-height 1)
361 split-window-function
362 merge-window-share merge-window-lines
363 wind-A wind-B wind-C)
364 (ediff-with-current-buffer control-buffer
365 (setq merge-window-share ediff-merge-window-share
366 ;; this lets us have local versions of ediff-split-window-function
367 split-window-function ediff-split-window-function))
368 (delete-other-windows)
369 (split-window-vertically)
370 (ediff-select-lowest-window)
371 (ediff-setup-control-buffer control-buffer)
373 ;; go to the upper window and split it betw A, B, and possibly C
374 (other-window 1)
375 (setq merge-window-lines
376 (max 2 (round (* (window-height) merge-window-share))))
377 (switch-to-buffer buf-A)
378 (setq wind-A (selected-window))
380 ;; XEmacs used to have a lot of trouble with display
381 ;; It did't set things right unless we tell it to sit still
382 ;; 19.12 seems ok.
383 ;;(if ediff-xemacs-p (sit-for 0))
385 (split-window-vertically (max 2 (- (window-height) merge-window-lines)))
386 (if (eq (selected-window) wind-A)
387 (other-window 1))
388 (setq wind-C (selected-window))
389 (switch-to-buffer buf-C)
391 (select-window wind-A)
392 (funcall split-window-function)
394 (if (eq (selected-window) wind-A)
395 (other-window 1))
396 (switch-to-buffer buf-B)
397 (setq wind-B (selected-window))
399 (ediff-with-current-buffer control-buffer
400 (setq ediff-window-A wind-A
401 ediff-window-B wind-B
402 ediff-window-C wind-C))
404 (ediff-select-lowest-window)
405 (ediff-setup-control-buffer control-buffer)
409 ;; This function handles all comparison jobs, including 3way jobs
410 (defun ediff-setup-windows-plain-compare (buf-A buf-B buf-C control-buffer)
411 ;; skip dedicated and unsplittable frames
412 (ediff-destroy-control-frame control-buffer)
413 (let ((window-min-height 1)
414 split-window-function wind-width-or-height
415 three-way-comparison
416 wind-A-start wind-B-start wind-A wind-B wind-C)
417 (ediff-with-current-buffer control-buffer
418 (setq wind-A-start (ediff-overlay-start
419 (ediff-get-value-according-to-buffer-type
420 'A ediff-narrow-bounds))
421 wind-B-start (ediff-overlay-start
422 (ediff-get-value-according-to-buffer-type
423 'B ediff-narrow-bounds))
424 ;; this lets us have local versions of ediff-split-window-function
425 split-window-function ediff-split-window-function
426 three-way-comparison ediff-3way-comparison-job))
427 (delete-other-windows)
428 (split-window-vertically)
429 (ediff-select-lowest-window)
430 (ediff-setup-control-buffer control-buffer)
432 ;; go to the upper window and split it betw A, B, and possibly C
433 (other-window 1)
434 (switch-to-buffer buf-A)
435 (setq wind-A (selected-window))
436 (if three-way-comparison
437 (setq wind-width-or-height
438 (/ (if (eq split-window-function 'split-window-vertically)
439 (window-height wind-A)
440 (window-width wind-A))
441 3)))
443 ;; XEmacs used to have a lot of trouble with display
444 ;; It did't set things right unless we told it to sit still
445 ;; 19.12 seems ok.
446 ;;(if ediff-xemacs-p (sit-for 0))
448 (funcall split-window-function wind-width-or-height)
450 (if (eq (selected-window) wind-A)
451 (other-window 1))
452 (switch-to-buffer buf-B)
453 (setq wind-B (selected-window))
455 (if three-way-comparison
456 (progn
457 (funcall split-window-function) ; equally
458 (if (eq (selected-window) wind-B)
459 (other-window 1))
460 (switch-to-buffer buf-C)
461 (setq wind-C (selected-window))))
463 (ediff-with-current-buffer control-buffer
464 (setq ediff-window-A wind-A
465 ediff-window-B wind-B
466 ediff-window-C wind-C))
468 ;; It is unlikely that we will want to implement 3way window comparison.
469 ;; So, only buffers A and B are used here.
470 (if ediff-windows-job
471 (progn
472 (set-window-start wind-A wind-A-start)
473 (set-window-start wind-B wind-B-start)))
475 (ediff-select-lowest-window)
476 (ediff-setup-control-buffer control-buffer)
480 ;; dispatch an appropriate window setup function
481 (defun ediff-setup-windows-multiframe (buf-A buf-B buf-C control-buf)
482 (ediff-with-current-buffer control-buf
483 (setq ediff-multiframe t))
484 (if ediff-merge-job
485 (ediff-setup-windows-multiframe-merge buf-A buf-B buf-C control-buf)
486 (ediff-setup-windows-multiframe-compare buf-A buf-B buf-C control-buf)))
488 (defun ediff-setup-windows-multiframe-merge (buf-A buf-B buf-C control-buf)
489 ;;; Algorithm:
490 ;;; 1. Never use frames that have dedicated windows in them---it is bad to
491 ;;; destroy dedicated windows.
492 ;;; 2. If A and B are in the same frame but C's frame is different--- use one
493 ;;; frame for A and B and use a separate frame for C.
494 ;;; 3. If C's frame is non-existent, then: if the first suitable
495 ;;; non-dedicated frame is different from A&B's, then use it for C.
496 ;;; Otherwise, put A,B, and C in one frame.
497 ;;; 4. If buffers A, B, C are is separate frames, use them to display these
498 ;;; buffers.
500 ;; Skip dedicated or iconified frames.
501 ;; Unsplittable frames are taken care of later.
502 (ediff-skip-unsuitable-frames 'ok-unsplittable)
504 (let* ((window-min-height 1)
505 (wind-A (ediff-get-visible-buffer-window buf-A))
506 (wind-B (ediff-get-visible-buffer-window buf-B))
507 (wind-C (ediff-get-visible-buffer-window buf-C))
508 (frame-A (if wind-A (window-frame wind-A)))
509 (frame-B (if wind-B (window-frame wind-B)))
510 (frame-C (if wind-C (window-frame wind-C)))
511 ;; on wide display, do things in one frame
512 (force-one-frame
513 (ediff-with-current-buffer control-buf ediff-wide-display-p))
514 ;; this lets us have local versions of ediff-split-window-function
515 (split-window-function
516 (ediff-with-current-buffer control-buf ediff-split-window-function))
517 (orig-wind (selected-window))
518 (orig-frame (selected-frame))
519 (use-same-frame (or force-one-frame
520 ;; A and C must be in one frame
521 (eq frame-A (or frame-C orig-frame))
522 ;; B and C must be in one frame
523 (eq frame-B (or frame-C orig-frame))
524 ;; A or B is not visible
525 (not (frame-live-p frame-A))
526 (not (frame-live-p frame-B))
527 ;; A or B is not suitable for display
528 (not (ediff-window-ok-for-display wind-A))
529 (not (ediff-window-ok-for-display wind-B))
530 ;; A and B in the same frame, and no good frame
531 ;; for C
532 (and (eq frame-A frame-B)
533 (not (frame-live-p frame-C)))
535 ;; use-same-frame-for-AB implies wind A and B are ok for display
536 (use-same-frame-for-AB (and (not use-same-frame)
537 (eq frame-A frame-B)))
538 (merge-window-share (ediff-with-current-buffer control-buf
539 ediff-merge-window-share))
540 merge-window-lines
541 designated-minibuffer-frame
542 done-A done-B done-C)
544 ;; buf-A on its own
545 (if (and (window-live-p wind-A)
546 (null use-same-frame) ; implies wind-A is suitable
547 (null use-same-frame-for-AB))
548 (progn ; bug A on its own
549 ;; buffer buf-A is seen in live wind-A
550 (select-window wind-A)
551 (delete-other-windows)
552 (setq wind-A (selected-window))
553 (setq done-A t)))
555 ;; buf-B on its own
556 (if (and (window-live-p wind-B)
557 (null use-same-frame) ; implies wind-B is suitable
558 (null use-same-frame-for-AB))
559 (progn ; buf B on its own
560 ;; buffer buf-B is seen in live wind-B
561 (select-window wind-B)
562 (delete-other-windows)
563 (setq wind-B (selected-window))
564 (setq done-B t)))
566 ;; buf-C on its own
567 (if (and (window-live-p wind-C)
568 (ediff-window-ok-for-display wind-C)
569 (null use-same-frame)) ; buf C on its own
570 (progn
571 ;; buffer buf-C is seen in live wind-C
572 (select-window wind-C)
573 (delete-other-windows)
574 (setq wind-C (selected-window))
575 (setq done-C t)))
577 (if (and use-same-frame-for-AB ; implies wind A and B are suitable
578 (window-live-p wind-A))
579 (progn
580 ;; wind-A must already be displaying buf-A
581 (select-window wind-A)
582 (delete-other-windows)
583 (setq wind-A (selected-window))
585 (funcall split-window-function)
586 (if (eq (selected-window) wind-A)
587 (other-window 1))
588 (switch-to-buffer buf-B)
589 (setq wind-B (selected-window))
591 (setq done-A t
592 done-B t)))
594 (if use-same-frame
595 (let ((window-min-height 1))
596 (if (and (eq frame-A frame-B)
597 (eq frame-B frame-C)
598 (frame-live-p frame-A))
599 (select-frame frame-A)
600 ;; avoid dedicated and non-splittable windows
601 (ediff-skip-unsuitable-frames))
602 (delete-other-windows)
603 (setq merge-window-lines
604 (max 2 (round (* (window-height) merge-window-share))))
605 (switch-to-buffer buf-A)
606 (setq wind-A (selected-window))
608 (split-window-vertically
609 (max 2 (- (window-height) merge-window-lines)))
610 (if (eq (selected-window) wind-A)
611 (other-window 1))
612 (setq wind-C (selected-window))
613 (switch-to-buffer buf-C)
615 (select-window wind-A)
617 (funcall split-window-function)
618 (if (eq (selected-window) wind-A)
619 (other-window 1))
620 (switch-to-buffer buf-B)
621 (setq wind-B (selected-window))
623 (setq done-A t
624 done-B t
625 done-C t)
628 (or done-A ; Buf A to be set in its own frame,
629 ;;; or it was set before because use-same-frame = 1
630 (progn
631 ;; Buf-A was not set up yet as it wasn't visible,
632 ;; and use-same-frame = nil, use-same-frame-for-AB = nil
633 (select-window orig-wind)
634 (delete-other-windows)
635 (switch-to-buffer buf-A)
636 (setq wind-A (selected-window))
638 (or done-B ; Buf B to be set in its own frame,
639 ;;; or it was set before because use-same-frame = 1
640 (progn
641 ;; Buf-B was not set up yet as it wasn't visible
642 ;; and use-same-frame = nil, use-same-frame-for-AB = nil
643 (select-window orig-wind)
644 (delete-other-windows)
645 (switch-to-buffer buf-B)
646 (setq wind-B (selected-window))
649 (or done-C ; Buf C to be set in its own frame,
650 ;;; or it was set before because use-same-frame = 1
651 (progn
652 ;; Buf-C was not set up yet as it wasn't visible
653 ;; and use-same-frame = nil
654 (select-window orig-wind)
655 (delete-other-windows)
656 (switch-to-buffer buf-C)
657 (setq wind-C (selected-window))
660 (ediff-with-current-buffer control-buf
661 (setq ediff-window-A wind-A
662 ediff-window-B wind-B
663 ediff-window-C wind-C)
664 (setq frame-A (window-frame ediff-window-A)
665 designated-minibuffer-frame
666 (window-frame (minibuffer-window frame-A))))
668 (ediff-setup-control-frame control-buf designated-minibuffer-frame)
672 ;; Window setup for all comparison jobs, including 3way comparisons
673 (defun ediff-setup-windows-multiframe-compare (buf-A buf-B buf-C control-buf)
674 ;;; Algorithm:
675 ;;; If a buffer is seen in a frame, use that frame for that buffer.
676 ;;; If it is not seen, use the current frame.
677 ;;; If both buffers are not seen, they share the current frame. If one
678 ;;; of the buffers is not seen, it is placed in the current frame (where
679 ;;; ediff started). If that frame is displaying the other buffer, it is
680 ;;; shared between the two buffers.
681 ;;; However, if we decide to put both buffers in one frame
682 ;;; and the selected frame isn't splittable, we create a new frame and
683 ;;; put both buffers there, event if one of this buffers is visible in
684 ;;; another frame.
686 ;; Skip dedicated or iconified frames.
687 ;; Unsplittable frames are taken care of later.
688 (ediff-skip-unsuitable-frames 'ok-unsplittable)
690 (let* ((window-min-height 1)
691 (wind-A (ediff-get-visible-buffer-window buf-A))
692 (wind-B (ediff-get-visible-buffer-window buf-B))
693 (wind-C (ediff-get-visible-buffer-window buf-C))
694 (frame-A (if wind-A (window-frame wind-A)))
695 (frame-B (if wind-B (window-frame wind-B)))
696 (frame-C (if wind-C (window-frame wind-C)))
697 (ctl-frame-exists-p (ediff-with-current-buffer control-buf
698 (frame-live-p ediff-control-frame)))
699 ;; on wide display, do things in one frame
700 (force-one-frame
701 (ediff-with-current-buffer control-buf ediff-wide-display-p))
702 ;; this lets us have local versions of ediff-split-window-function
703 (split-window-function
704 (ediff-with-current-buffer control-buf ediff-split-window-function))
705 (three-way-comparison
706 (ediff-with-current-buffer control-buf ediff-3way-comparison-job))
707 (orig-wind (selected-window))
708 (use-same-frame (or force-one-frame
709 (eq frame-A frame-B)
710 (not (ediff-window-ok-for-display wind-A))
711 (not (ediff-window-ok-for-display wind-B))
712 (if three-way-comparison
713 (or (eq frame-A frame-C)
714 (eq frame-B frame-C)
715 (not (ediff-window-ok-for-display wind-C))
716 (not (frame-live-p frame-A))
717 (not (frame-live-p frame-B))
718 (not (frame-live-p frame-C))))
719 (and (not (frame-live-p frame-B))
720 (or ctl-frame-exists-p
721 (eq frame-A (selected-frame))))
722 (and (not (frame-live-p frame-A))
723 (or ctl-frame-exists-p
724 (eq frame-B (selected-frame))))))
725 wind-A-start wind-B-start
726 designated-minibuffer-frame
727 done-A done-B done-C)
729 (ediff-with-current-buffer control-buf
730 (setq wind-A-start (ediff-overlay-start
731 (ediff-get-value-according-to-buffer-type
732 'A ediff-narrow-bounds))
733 wind-B-start (ediff-overlay-start
734 (ediff-get-value-according-to-buffer-type
735 'B ediff-narrow-bounds))))
737 (if (and (window-live-p wind-A) (null use-same-frame)) ; buf-A on its own
738 (progn
739 ;; buffer buf-A is seen in live wind-A
740 (select-window wind-A) ; must be displaying buf-A
741 (delete-other-windows)
742 (setq wind-A (selected-window))
743 (setq done-A t)))
745 (if (and (window-live-p wind-B) (null use-same-frame)) ; buf B on its own
746 (progn
747 ;; buffer buf-B is seen in live wind-B
748 (select-window wind-B) ; must be displaying buf-B
749 (delete-other-windows)
750 (setq wind-B (selected-window))
751 (setq done-B t)))
753 (if (and (window-live-p wind-C) (null use-same-frame)) ; buf C on its own
754 (progn
755 ;; buffer buf-C is seen in live wind-C
756 (select-window wind-C) ; must be displaying buf-C
757 (delete-other-windows)
758 (setq wind-C (selected-window))
759 (setq done-C t)))
761 (if use-same-frame
762 (let (wind-width-or-height) ; this affects 3way setups only
763 (if (and (eq frame-A frame-B) (frame-live-p frame-A))
764 (select-frame frame-A)
765 ;; avoid dedicated and non-splittable windows
766 (ediff-skip-unsuitable-frames))
767 (delete-other-windows)
768 (switch-to-buffer buf-A)
769 (setq wind-A (selected-window))
771 (if three-way-comparison
772 (setq wind-width-or-height
774 (if (eq split-window-function 'split-window-vertically)
775 (window-height wind-A)
776 (window-width wind-A))
777 3)))
779 (funcall split-window-function wind-width-or-height)
780 (if (eq (selected-window) wind-A)
781 (other-window 1))
782 (switch-to-buffer buf-B)
783 (setq wind-B (selected-window))
785 (if three-way-comparison
786 (progn
787 (funcall split-window-function) ; equally
788 (if (memq (selected-window) (list wind-A wind-B))
789 (other-window 1))
790 (switch-to-buffer buf-C)
791 (setq wind-C (selected-window))))
792 (setq done-A t
793 done-B t
794 done-C t)
797 (or done-A ; Buf A to be set in its own frame
798 ;;; or it was set before because use-same-frame = 1
799 (progn
800 ;; Buf-A was not set up yet as it wasn't visible,
801 ;; and use-same-frame = nil
802 (select-window orig-wind)
803 (delete-other-windows)
804 (switch-to-buffer buf-A)
805 (setq wind-A (selected-window))
807 (or done-B ; Buf B to be set in its own frame
808 ;;; or it was set before because use-same-frame = 1
809 (progn
810 ;; Buf-B was not set up yet as it wasn't visible,
811 ;; and use-same-frame = nil
812 (select-window orig-wind)
813 (delete-other-windows)
814 (switch-to-buffer buf-B)
815 (setq wind-B (selected-window))
818 (if three-way-comparison
819 (or done-C ; Buf C to be set in its own frame
820 ;;; or it was set before because use-same-frame = 1
821 (progn
822 ;; Buf-C was not set up yet as it wasn't visible,
823 ;; and use-same-frame = nil
824 (select-window orig-wind)
825 (delete-other-windows)
826 (switch-to-buffer buf-C)
827 (setq wind-C (selected-window))
830 (ediff-with-current-buffer control-buf
831 (setq ediff-window-A wind-A
832 ediff-window-B wind-B
833 ediff-window-C wind-C)
835 (setq frame-A (window-frame ediff-window-A)
836 designated-minibuffer-frame
837 (window-frame (minibuffer-window frame-A))))
839 ;; It is unlikely that we'll implement a version of ediff-windows that
840 ;; would compare 3 windows at once. So, we don't use buffer C here.
841 (if ediff-windows-job
842 (progn
843 (set-window-start wind-A wind-A-start)
844 (set-window-start wind-B wind-B-start)))
846 (ediff-setup-control-frame control-buf designated-minibuffer-frame)
849 ;; skip unsplittable frames and frames that have dedicated windows.
850 ;; create a new splittable frame if none is found
851 (defun ediff-skip-unsuitable-frames (&optional ok-unsplittable)
852 (if (ediff-window-display-p)
853 (let ((wind-frame (window-frame (selected-window)))
854 seen-windows)
855 (while (and (not (memq (selected-window) seen-windows))
857 (ediff-frame-has-dedicated-windows wind-frame)
858 (ediff-frame-iconified-p wind-frame)
859 ;; skip small windows
860 (< (frame-height wind-frame)
861 (* 3 window-min-height))
862 (if ok-unsplittable
864 (ediff-frame-unsplittable-p wind-frame))))
865 ;; remember history
866 (setq seen-windows (cons (selected-window) seen-windows))
867 ;; try new window
868 (other-window 1 t)
869 (setq wind-frame (window-frame (selected-window)))
871 (if (memq (selected-window) seen-windows)
872 ;; fed up, no appropriate frames
873 (setq wind-frame (make-frame '((unsplittable)))))
875 (select-frame wind-frame)
878 (defun ediff-frame-has-dedicated-windows (frame)
879 (let (ans)
880 (walk-windows
881 (lambda (wind) (if (window-dedicated-p wind)
882 (setq ans t)))
883 'ignore-minibuffer
884 frame)
885 ans))
887 ;; window is ok, if it is only one window on the frame, not counting the
888 ;; minibuffer, or none of the frame's windows is dedicated.
889 ;; The idea is that it is bad to destroy dedicated windows while creating an
890 ;; ediff window setup
891 (defun ediff-window-ok-for-display (wind)
892 (and
893 (window-live-p wind)
895 ;; only one window
896 (eq wind (next-window wind 'ignore-minibuffer (window-frame wind)))
897 ;; none is dedicated
898 (not (ediff-frame-has-dedicated-windows (window-frame wind)))
901 ;; Prepare or refresh control frame
902 (defun ediff-setup-control-frame (ctl-buffer designated-minibuffer-frame)
903 (let ((window-min-height 1)
904 ctl-frame-iconified-p dont-iconify-ctl-frame deiconify-ctl-frame
905 ctl-frame old-ctl-frame lines
906 ;; user-grabbed-mouse
907 fheight fwidth adjusted-parameters)
909 (ediff-with-current-buffer ctl-buffer
910 (ediff-cond-compile-for-xemacs-or-emacs
911 (when (featurep 'menubar) (set-buffer-menubar nil)) ; xemacs
912 nil ; emacs
914 ;;(setq user-grabbed-mouse (ediff-user-grabbed-mouse))
915 (run-hooks 'ediff-before-setup-control-frame-hook))
917 (setq old-ctl-frame (ediff-with-current-buffer ctl-buffer ediff-control-frame))
918 (ediff-with-current-buffer ctl-buffer
919 (setq ctl-frame (if (frame-live-p old-ctl-frame)
920 old-ctl-frame
921 (make-frame ediff-control-frame-parameters))
922 ediff-control-frame ctl-frame)
923 ;; protect against undefined face-attribute
924 (condition-case nil
925 (ediff-cond-compile-for-xemacs-or-emacs
926 nil ; xemacs
927 (when (face-attribute 'mode-line :box)
928 (set-face-attribute 'mode-line ctl-frame :box nil))
930 (error))
933 (setq ctl-frame-iconified-p (ediff-frame-iconified-p ctl-frame))
934 (select-frame ctl-frame)
935 (if (window-dedicated-p (selected-window))
937 (delete-other-windows)
938 (switch-to-buffer ctl-buffer))
940 ;; must be before ediff-setup-control-buffer
941 ;; just a precaution--we should be in ctl-buffer already
942 (ediff-with-current-buffer ctl-buffer
943 (make-local-variable 'frame-title-format)
944 (make-local-variable 'frame-icon-title-format) ; XEmacs
945 (make-local-variable 'icon-title-format)) ; Emacs
947 (ediff-setup-control-buffer ctl-buffer)
948 (setq dont-iconify-ctl-frame
949 (not (string= ediff-help-message ediff-brief-help-message)))
950 (setq deiconify-ctl-frame
951 (and (eq this-command 'ediff-toggle-help)
952 dont-iconify-ctl-frame))
954 ;; 1 more line for the modeline
955 (setq lines (1+ (count-lines (point-min) (point-max)))
956 fheight lines
957 fwidth (max (+ (ediff-help-message-line-length) 2)
958 (ediff-compute-toolbar-width))
959 adjusted-parameters
960 (list
961 ;; possibly change surrogate minibuffer
962 (cons 'minibuffer
963 (minibuffer-window
964 designated-minibuffer-frame))
965 (cons 'width fwidth)
966 (cons 'height fheight)
967 (cons 'user-position t)
970 ;; adjust autoraise
971 (setq adjusted-parameters
972 (cons (if ediff-use-long-help-message
973 '(auto-raise . nil)
974 '(auto-raise . t))
975 adjusted-parameters))
977 ;; In XEmacs, buffer menubar needs to be killed before frame parameters
978 ;; are changed.
979 (if (ediff-has-toolbar-support-p)
980 (ediff-cond-compile-for-xemacs-or-emacs
981 (progn ; xemacs
982 (if (ediff-has-gutter-support-p)
983 (set-specifier top-gutter (list ctl-frame nil)))
984 (sit-for 0)
985 (set-specifier top-toolbar-height (list ctl-frame 0))
986 ;;(set-specifier bottom-toolbar-height (list ctl-frame 0))
987 (set-specifier left-toolbar-width (list ctl-frame 0))
988 (set-specifier right-toolbar-width (list ctl-frame 0))
990 nil ; emacs
994 ;; Under OS/2 (emx) we have to call modify frame parameters twice, in order
995 ;; to make sure that at least once we do it for non-iconified frame. If
996 ;; appears that in the OS/2 port of Emacs, one can't modify frame
997 ;; parameters of iconified frames. As a precaution, we do likewise for
998 ;; windows-nt.
999 (if (memq system-type '(emx windows-nt windows-95))
1000 (modify-frame-parameters ctl-frame adjusted-parameters))
1002 ;; make or zap toolbar (if not requested)
1003 (ediff-make-bottom-toolbar ctl-frame)
1005 (goto-char (point-min))
1007 (modify-frame-parameters ctl-frame adjusted-parameters)
1008 (make-frame-visible ctl-frame)
1010 ;; This works around a bug in 19.25 and earlier. There, if frame gets
1011 ;; iconified, the current buffer changes to that of the frame that
1012 ;; becomes exposed as a result of this iconification.
1013 ;; So, we make sure the current buffer doesn't change.
1014 (select-frame ctl-frame)
1015 (ediff-refresh-control-frame)
1017 (cond ((and ediff-prefer-iconified-control-frame
1018 (not ctl-frame-iconified-p) (not dont-iconify-ctl-frame))
1019 (iconify-frame ctl-frame))
1020 ((or deiconify-ctl-frame (not ctl-frame-iconified-p))
1021 (raise-frame ctl-frame)))
1023 (set-window-dedicated-p (selected-window) t)
1025 ;; Now move the frame. We must do it separately due to an obscure bug in
1026 ;; XEmacs
1027 (modify-frame-parameters
1028 ctl-frame
1029 (funcall ediff-control-frame-position-function ctl-buffer fwidth fheight))
1031 ;; synchronize so the cursor will move to control frame
1032 ;; per RMS suggestion
1033 (if (ediff-window-display-p)
1034 (let ((count 7))
1035 (sit-for .1)
1036 (while (and (not (frame-visible-p ctl-frame)) (> count 0))
1037 (setq count (1- count))
1038 (sit-for .3))))
1040 (or (ediff-frame-iconified-p ctl-frame)
1041 ;; don't warp the mouse, unless ediff-grab-mouse = t
1042 (ediff-reset-mouse ctl-frame
1043 (or (eq this-command 'ediff-quit)
1044 (not (eq ediff-grab-mouse t)))))
1046 (if ediff-xemacs-p
1047 (ediff-with-current-buffer ctl-buffer
1048 (ediff-cond-compile-for-xemacs-or-emacs
1049 (make-local-hook 'select-frame-hook) ; xemacs
1050 nil ; emacs
1052 (add-hook
1053 'select-frame-hook 'ediff-xemacs-select-frame-hook nil 'local)
1056 (ediff-with-current-buffer ctl-buffer
1057 (run-hooks 'ediff-after-setup-control-frame-hook))
1061 (defun ediff-destroy-control-frame (ctl-buffer)
1062 (ediff-with-current-buffer ctl-buffer
1063 (if (and (ediff-window-display-p) (frame-live-p ediff-control-frame))
1064 (let ((ctl-frame ediff-control-frame))
1065 (ediff-cond-compile-for-xemacs-or-emacs
1066 (when (featurep 'menubar)
1067 (set-buffer-menubar default-menubar)) ; xemacs
1068 nil ; emacs
1070 (setq ediff-control-frame nil)
1071 (delete-frame ctl-frame)
1073 (ediff-skip-unsuitable-frames)
1074 ;;(ediff-reset-mouse nil)
1078 ;; finds a good place to clip control frame
1079 (defun ediff-make-frame-position (ctl-buffer ctl-frame-width ctl-frame-height)
1080 (ediff-with-current-buffer ctl-buffer
1081 (let* ((frame-A (window-frame ediff-window-A))
1082 (frame-A-parameters (frame-parameters frame-A))
1083 (frame-A-top (eval (cdr (assoc 'top frame-A-parameters))))
1084 (frame-A-left (eval (cdr (assoc 'left frame-A-parameters))))
1085 (frame-A-width (frame-width frame-A))
1086 (ctl-frame ediff-control-frame)
1087 horizontal-adjustment upward-adjustment
1088 ctl-frame-top ctl-frame-left)
1090 ;; Multiple control frames are clipped based on the value of
1091 ;; ediff-control-buffer-number. This is done in order not to obscure
1092 ;; other active control panels.
1093 (setq horizontal-adjustment (* 2 ediff-control-buffer-number)
1094 upward-adjustment (* -14 ediff-control-buffer-number))
1096 (setq ctl-frame-top
1097 (- frame-A-top upward-adjustment ediff-control-frame-upward-shift)
1098 ctl-frame-left
1099 (+ frame-A-left
1100 (if ediff-use-long-help-message
1101 (* (ediff-frame-char-width ctl-frame)
1102 (+ ediff-wide-control-frame-rightward-shift
1103 horizontal-adjustment))
1104 (- (* frame-A-width (ediff-frame-char-width frame-A))
1105 (* (ediff-frame-char-width ctl-frame)
1106 (+ ctl-frame-width
1107 ediff-narrow-control-frame-leftward-shift
1108 horizontal-adjustment))))))
1109 (setq ctl-frame-top
1110 (min ctl-frame-top
1111 (- (ediff-display-pixel-height)
1112 (* 2 ctl-frame-height
1113 (ediff-frame-char-height ctl-frame))))
1114 ctl-frame-left
1115 (min ctl-frame-left
1116 (- (ediff-display-pixel-width)
1117 (* ctl-frame-width (ediff-frame-char-width ctl-frame)))))
1118 ;; keep ctl frame within the visible bounds
1119 (setq ctl-frame-top (max ctl-frame-top 1)
1120 ctl-frame-left (max ctl-frame-left 1))
1122 (list (cons 'top ctl-frame-top)
1123 (cons 'left ctl-frame-left))
1126 (defun ediff-xemacs-select-frame-hook ()
1127 (if (and (equal (selected-frame) ediff-control-frame)
1128 (not ediff-use-long-help-message))
1129 (raise-frame ediff-control-frame)))
1131 (defun ediff-make-wide-display ()
1132 "Construct an alist of parameters for the wide display.
1133 Saves the old frame parameters in `ediff-wide-display-orig-parameters'.
1134 The frame to be resized is kept in `ediff-wide-display-frame'.
1135 This function modifies only the left margin and the width of the display.
1136 It assumes that it is called from within the control buffer."
1137 (if (not (fboundp 'ediff-display-pixel-width))
1138 (error "Can't determine display width"))
1139 (let* ((frame-A (window-frame ediff-window-A))
1140 (frame-A-params (frame-parameters frame-A))
1141 (cw (ediff-frame-char-width frame-A))
1142 (wd (- (/ (ediff-display-pixel-width) cw) 5)))
1143 (setq ediff-wide-display-orig-parameters
1144 (list (cons 'left (max 0 (eval (cdr (assoc 'left frame-A-params)))))
1145 (cons 'width (cdr (assoc 'width frame-A-params))))
1146 ediff-wide-display-frame frame-A)
1147 (modify-frame-parameters
1148 frame-A `((left . ,cw) (width . ,wd) (user-position t)))))
1151 ;; Revise the mode line to display which difference we have selected
1152 ;; Also resets modelines of buffers A/B, since they may be clobbered by
1153 ;; anothe invocations of Ediff.
1154 (defun ediff-refresh-mode-lines ()
1155 (let (buf-A-state-diff buf-B-state-diff buf-C-state-diff buf-C-state-merge)
1157 (if (ediff-valid-difference-p)
1158 (setq
1159 buf-C-state-diff (ediff-get-state-of-diff ediff-current-difference 'C)
1160 buf-C-state-merge (ediff-get-state-of-merge ediff-current-difference)
1161 buf-A-state-diff (ediff-get-state-of-diff ediff-current-difference 'A)
1162 buf-B-state-diff (ediff-get-state-of-diff ediff-current-difference 'B)
1163 buf-A-state-diff (if buf-A-state-diff
1164 (format "[%s] " buf-A-state-diff)
1166 buf-B-state-diff (if buf-B-state-diff
1167 (format "[%s] " buf-B-state-diff)
1169 buf-C-state-diff (if (and (ediff-buffer-live-p ediff-buffer-C)
1170 (or buf-C-state-diff buf-C-state-merge))
1171 (format "[%s%s%s] "
1172 (or buf-C-state-diff "")
1173 (if buf-C-state-merge
1174 (concat " " buf-C-state-merge)
1176 (if (ediff-get-state-of-ancestor
1177 ediff-current-difference)
1178 " AncestorEmpty"
1181 ""))
1182 (setq buf-A-state-diff ""
1183 buf-B-state-diff ""
1184 buf-C-state-diff ""))
1186 ;; control buffer format
1187 (setq mode-line-format
1188 (if (ediff-narrow-control-frame-p)
1189 (list " " mode-line-buffer-identification)
1190 (list "-- " mode-line-buffer-identification " Quick Help")))
1191 ;; control buffer id
1192 (setq mode-line-buffer-identification
1193 (if (ediff-narrow-control-frame-p)
1194 (ediff-make-narrow-control-buffer-id 'skip-name)
1195 (ediff-make-wide-control-buffer-id)))
1196 ;; Force mode-line redisplay
1197 (force-mode-line-update)
1199 (if (and (ediff-window-display-p) (frame-live-p ediff-control-frame))
1200 (ediff-refresh-control-frame))
1202 (ediff-with-current-buffer ediff-buffer-A
1203 (setq ediff-diff-status buf-A-state-diff)
1204 (ediff-strip-mode-line-format)
1205 (setq mode-line-format
1206 (list " A: " 'ediff-diff-status mode-line-format))
1207 (force-mode-line-update))
1208 (ediff-with-current-buffer ediff-buffer-B
1209 (setq ediff-diff-status buf-B-state-diff)
1210 (ediff-strip-mode-line-format)
1211 (setq mode-line-format
1212 (list " B: " 'ediff-diff-status mode-line-format))
1213 (force-mode-line-update))
1214 (if ediff-3way-job
1215 (ediff-with-current-buffer ediff-buffer-C
1216 (setq ediff-diff-status buf-C-state-diff)
1217 (ediff-strip-mode-line-format)
1218 (setq mode-line-format
1219 (list " C: " 'ediff-diff-status mode-line-format))
1220 (force-mode-line-update)))
1221 (if (ediff-buffer-live-p ediff-ancestor-buffer)
1222 (ediff-with-current-buffer ediff-ancestor-buffer
1223 (ediff-strip-mode-line-format)
1224 ;; we keep the second dummy string in the mode line format of the
1225 ;; ancestor, since for other buffers Ediff prepends 2 strings and
1226 ;; ediff-strip-mode-line-format expects that.
1227 (setq mode-line-format
1228 (list " Ancestor: "
1229 (cond ((not (stringp buf-C-state-merge))
1231 ((string-match "prefer-A" buf-C-state-merge)
1232 "[=diff(B)] ")
1233 ((string-match "prefer-B" buf-C-state-merge)
1234 "[=diff(A)] ")
1235 (t ""))
1236 mode-line-format))))
1240 (defun ediff-refresh-control-frame ()
1241 (if ediff-emacs-p
1242 ;; set frame/icon titles for Emacs
1243 (modify-frame-parameters
1244 ediff-control-frame
1245 (list (cons 'title (ediff-make-base-title))
1246 (cons 'icon-name (ediff-make-narrow-control-buffer-id))
1248 ;; set frame/icon titles for XEmacs
1249 (setq frame-title-format (ediff-make-base-title)
1250 frame-icon-title-format (ediff-make-narrow-control-buffer-id))
1251 ;; force an update of the frame title
1252 (modify-frame-parameters ediff-control-frame '(()))))
1255 (defun ediff-make-narrow-control-buffer-id (&optional skip-name)
1256 (concat
1257 (if skip-name
1259 (ediff-make-base-title))
1260 (cond ((< ediff-current-difference 0)
1261 (format " _/%d" ediff-number-of-differences))
1262 ((>= ediff-current-difference ediff-number-of-differences)
1263 (format " $/%d" ediff-number-of-differences))
1265 (format " %d/%d"
1266 (1+ ediff-current-difference)
1267 ediff-number-of-differences)))))
1269 (defun ediff-make-base-title ()
1270 (concat
1271 (cdr (assoc 'name ediff-control-frame-parameters))
1272 ediff-control-buffer-suffix))
1274 (defun ediff-make-wide-control-buffer-id ()
1275 (cond ((< ediff-current-difference 0)
1276 (list (format "%%b At start of %d diffs"
1277 ediff-number-of-differences)))
1278 ((>= ediff-current-difference ediff-number-of-differences)
1279 (list (format "%%b At end of %d diffs"
1280 ediff-number-of-differences)))
1282 (list (format "%%b diff %d of %d"
1283 (1+ ediff-current-difference)
1284 ediff-number-of-differences)))))
1288 ;; If buff is not live, return nil
1289 (defun ediff-get-visible-buffer-window (buff)
1290 (if (ediff-buffer-live-p buff)
1291 (if ediff-xemacs-p
1292 (get-buffer-window buff t)
1293 (get-buffer-window buff 'visible))))
1296 ;;; Functions to decide when to redraw windows
1298 (defun ediff-keep-window-config (control-buf)
1299 (and (eq control-buf (current-buffer))
1300 (/= (buffer-size) 0)
1301 (ediff-with-current-buffer control-buf
1302 (let ((ctl-wind ediff-control-window)
1303 (A-wind ediff-window-A)
1304 (B-wind ediff-window-B)
1305 (C-wind ediff-window-C))
1307 (and
1308 (ediff-window-visible-p A-wind)
1309 (ediff-window-visible-p B-wind)
1310 ;; if buffer C is defined then take it into account
1311 (or (not ediff-3way-job)
1312 (ediff-window-visible-p C-wind))
1313 (eq (window-buffer A-wind) ediff-buffer-A)
1314 (eq (window-buffer B-wind) ediff-buffer-B)
1315 (or (not ediff-3way-job)
1316 (eq (window-buffer C-wind) ediff-buffer-C))
1317 (string= ediff-window-config-saved
1318 (format "%S%S%S%S%S%S%S"
1319 ctl-wind A-wind B-wind C-wind
1320 ediff-split-window-function
1321 (ediff-multiframe-setup-p)
1322 ediff-wide-display-p)))))))
1325 (provide 'ediff-wind)
1328 ;;; Local Variables:
1329 ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun)
1330 ;;; eval: (put 'ediff-with-current-buffer 'lisp-indent-hook 1)
1331 ;;; eval: (put 'ediff-with-current-buffer 'edebug-form-spec '(form body))
1332 ;;; End:
1334 ;;; arch-tag: 73d9a5d7-eed7-4d9c-8b4b-21d5d78eb597
1335 ;;; ediff-wind.el ends here