comparison lisp/ediff-wind.el @ 15480:43a3308fcf61

*** empty log message ***
author Michael Kifer <kifer@cs.stonybrook.edu>
date Sat, 22 Jun 1996 01:54:34 +0000
parents c768f6d7daaa
children b2fae8abc5b0
comparison
equal deleted inserted replaced
15479:78863db629bb 15480:43a3308fcf61
1 ;;; ediff-wind.el --- window manipulation utilities 1 ;;; ediff-wind.el --- window manipulation utilities
2 2
3 ;; Copyright (C) 1994, 1995 Free Software Foundation, Inc. 3 ;; Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
4 4
5 ;; Author: Michael Kifer <kifer@cs.sunysb.edu> 5 ;; Author: Michael Kifer <kifer@cs.sunysb.edu>
6 6
7 ;; This file is part of GNU Emacs. 7 ;; This file is part of GNU Emacs.
8 8
22 ;; Boston, MA 02111-1307, USA. 22 ;; Boston, MA 02111-1307, USA.
23 23
24 ;;; Code: 24 ;;; Code:
25 25
26 (require 'ediff-init) 26 (require 'ediff-init)
27
28 ;; Compiler pacifier
29 (defvar icon-title-format)
30 (defvar top-toolbar-height)
31 (defvar bottom-toolbar-height)
32 (defvar left-toolbar-height)
33 (defvar right-toolbar-height)
34 (defvar left-toolbar-width)
35 (defvar right-toolbar-width)
36 (defvar default-menubar)
37 (defvar frame-icon-title-format)
38 ;; end pacifier
27 39
28 40
29 (defvar ediff-window-setup-function (if (ediff-window-display-p) 41 (defvar ediff-window-setup-function (if (ediff-window-display-p)
30 'ediff-setup-windows-multiframe 42 'ediff-setup-windows-multiframe
31 'ediff-setup-windows-plain) 43 'ediff-setup-windows-plain)
91 '(minibuffer . nil) 103 '(minibuffer . nil)
92 '(user-position . t) ; Emacs only 104 '(user-position . t) ; Emacs only
93 '(vertical-scroll-bars . nil) ; Emacs only 105 '(vertical-scroll-bars . nil) ; Emacs only
94 '(scrollbar-width . 0) ; XEmacs only 106 '(scrollbar-width . 0) ; XEmacs only
95 '(menu-bar-lines . 0) ; Emacs only 107 '(menu-bar-lines . 0) ; Emacs only
96 '(visibility . nil) ; doesn't work for XEmacs yet
97 ;; don't lower and auto-raise 108 ;; don't lower and auto-raise
98 '(auto-lower . nil) 109 '(auto-lower . nil)
99 '(auto-raise . t) 110 '(auto-raise . t)
100 ;; this blocks queries from window manager as to where to put 111 ;; this blocks queries from window manager as to where to put
101 ;; ediff's control frame. we put the frame outside the display, 112 ;; ediff's control frame. we put the frame outside the display,
393 (ediff-setup-windows-multiframe-merge buf-A buf-B buf-C control-buf) 404 (ediff-setup-windows-multiframe-merge buf-A buf-B buf-C control-buf)
394 (ediff-setup-windows-multiframe-compare buf-A buf-B buf-C control-buf))) 405 (ediff-setup-windows-multiframe-compare buf-A buf-B buf-C control-buf)))
395 406
396 (defun ediff-setup-windows-multiframe-merge (buf-A buf-B buf-C control-buf) 407 (defun ediff-setup-windows-multiframe-merge (buf-A buf-B buf-C control-buf)
397 ;;; Algorithm: 408 ;;; Algorithm:
398 ;;; If A and B are in the same frame but C's frame is different--- use one 409 ;;; 1. Never use frames that have dedicated windows in them---it is bad to
399 ;;; frame for A and B and use a separate frame for C. 410 ;;; destroy dedicated windows.
400 ;;; If C's frame is non-existent, then: if the first suitable 411 ;;; 2. If A and B are in the same frame but C's frame is different--- use one
401 ;;; non-dedicated frame is different from A&B's, then use it for C. 412 ;;; frame for A and B and use a separate frame for C.
402 ;;; Otherwise, put A,B, and C in one frame. 413 ;;; 3. If C's frame is non-existent, then: if the first suitable
403 ;;; If buffers A, B, C are is separate frames, use them to display these 414 ;;; non-dedicated frame is different from A&B's, then use it for C.
404 ;;; buffers. 415 ;;; Otherwise, put A,B, and C in one frame.
416 ;;; 4. If buffers A, B, C are is separate frames, use them to display these
417 ;;; buffers.
405 418
406 ;; Skip dedicated or iconified frames. 419 ;; Skip dedicated or iconified frames.
407 ;; Unsplittable frames are taken care of later. 420 ;; Unsplittable frames are taken care of later.
408 (ediff-skip-unsuitable-frames 'ok-unsplittable) 421 (ediff-skip-unsuitable-frames 'ok-unsplittable)
409 422
421 (split-window-function 434 (split-window-function
422 (ediff-eval-in-buffer control-buf ediff-split-window-function)) 435 (ediff-eval-in-buffer control-buf ediff-split-window-function))
423 (orig-wind (selected-window)) 436 (orig-wind (selected-window))
424 (orig-frame (selected-frame)) 437 (orig-frame (selected-frame))
425 (use-same-frame (or force-one-frame 438 (use-same-frame (or force-one-frame
439 ;; A and C must be in one frame
426 (eq frame-A (or frame-C orig-frame)) 440 (eq frame-A (or frame-C orig-frame))
441 ;; B and C must be in one frame
427 (eq frame-B (or frame-C orig-frame)) 442 (eq frame-B (or frame-C orig-frame))
443 ;; A or B is not visible
428 (not (frame-live-p frame-A)) 444 (not (frame-live-p frame-A))
429 (not (frame-live-p frame-B)) 445 (not (frame-live-p frame-B))
446 ;; A or B is not suitable for display
447 (not (ediff-window-ok-for-display wind-A))
448 (not (ediff-window-ok-for-display wind-B))
449 ;; A and B in the same frame, and no good frame
450 ;; for C
430 (and (eq frame-A frame-B) 451 (and (eq frame-A frame-B)
431 (not (frame-live-p frame-C))) 452 (not (frame-live-p frame-C)))
432 )) 453 ))
454 ;; use-same-frame-for-AB implies wind A and B are ok for display
433 (use-same-frame-for-AB (and (not use-same-frame) 455 (use-same-frame-for-AB (and (not use-same-frame)
434 (eq frame-A frame-B))) 456 (eq frame-A frame-B)))
435 (merge-window-share (ediff-eval-in-buffer control-buf 457 (merge-window-share (ediff-eval-in-buffer control-buf
436 ediff-merge-window-share)) 458 ediff-merge-window-share))
437 merge-window-lines 459 merge-window-lines
438 designated-minibuffer-frame 460 designated-minibuffer-frame
439 done-A done-B done-C) 461 done-A done-B done-C)
440 462
441 ;; buf-A on its own 463 ;; buf-A on its own
442 (if (and (window-live-p wind-A) 464 (if (and (window-live-p wind-A)
443 (null use-same-frame) 465 (null use-same-frame) ; implies wind-A is suitable
444 (null use-same-frame-for-AB)) 466 (null use-same-frame-for-AB))
445 (progn 467 (progn ; bug A on its own
468 ;; buffer buf-A is seen in live wind-A
446 (select-window wind-A) 469 (select-window wind-A)
447 (delete-other-windows) 470 (delete-other-windows)
448 (switch-to-buffer buf-A)
449 (setq wind-A (selected-window)) 471 (setq wind-A (selected-window))
450 (setq done-A t))) 472 (setq done-A t)))
451 473
452 ;; buf-B on its own 474 ;; buf-B on its own
453 (if (and (window-live-p wind-B) (null use-same-frame)) ; buf B on its own 475 (if (and (window-live-p wind-B)
454 (progn 476 (null use-same-frame) ; implies wind-B is suitable
477 (null use-same-frame-for-AB))
478 (progn ; buf B on its own
479 ;; buffer buf-B is seen in live wind-B
455 (select-window wind-B) 480 (select-window wind-B)
456 (delete-other-windows) 481 (delete-other-windows)
457 (switch-to-buffer buf-B)
458 (setq wind-B (selected-window)) 482 (setq wind-B (selected-window))
459 (setq done-B t))) 483 (setq done-B t)))
460 484
461 ;; buf-C on its own 485 ;; buf-C on its own
462 (if (and (window-live-p wind-C) (null use-same-frame)) ; buf C on its own 486 (if (and (window-live-p wind-C)
487 (ediff-window-ok-for-display wind-C)
488 (null use-same-frame)) ; buf C on its own
463 (progn 489 (progn
490 ;; buffer buf-C is seen in live wind-C
464 (select-window wind-C) 491 (select-window wind-C)
465 (delete-other-windows) 492 (delete-other-windows)
466 (switch-to-buffer buf-C)
467 (setq wind-C (selected-window)) 493 (setq wind-C (selected-window))
468 (setq done-C t))) 494 (setq done-C t)))
469 495
470 (if use-same-frame-for-AB 496 (if (and use-same-frame-for-AB ; implies wind A and B are suitable
497 (window-live-p wind-A))
471 (progn 498 (progn
472 (select-frame frame-A) 499 ;; wind-A must already be displaying buf-A
473 (switch-to-buffer buf-A) 500 (select-window wind-A)
474 (delete-other-windows) 501 (delete-other-windows)
475 (setq wind-A (selected-window)) 502 (setq wind-A (selected-window))
476 503
477 (funcall split-window-function) 504 (funcall split-window-function)
478 (if (eq (selected-window) wind-A) 505 (if (eq (selected-window) wind-A)
482 509
483 (setq done-A t 510 (setq done-A t
484 done-B t))) 511 done-B t)))
485 512
486 (if use-same-frame 513 (if use-same-frame
487 (let ((curr-frame (selected-frame)) 514 (let ((window-min-height 1))
488 (window-min-height 1))
489 ;; avoid dedicated and non-splittable windows 515 ;; avoid dedicated and non-splittable windows
490 (ediff-skip-unsuitable-frames) 516 (ediff-skip-unsuitable-frames)
491 (or (eq curr-frame (selected-frame))
492 (setq wind-A nil
493 wind-B nil
494 wind-C nil
495 orig-wind (selected-window)))
496
497 ;; set the right frame
498 (cond (wind-A (select-window wind-A))
499 (wind-B (select-window wind-B))
500 (wind-C (select-window wind-C))
501 (t (select-window orig-wind)))
502 (delete-other-windows) 517 (delete-other-windows)
503 (setq merge-window-lines 518 (setq merge-window-lines
504 (max 2 (round (* (window-height) merge-window-share)))) 519 (max 2 (round (* (window-height) merge-window-share))))
505 (switch-to-buffer buf-A) 520 (switch-to-buffer buf-A)
506 (setq wind-A (selected-window)) 521 (setq wind-A (selected-window))
507
508 ;; XEmacs used to have a lot of trouble with display
509 ;; It did't set things right unless we told it to catch breath
510 ;;(if ediff-xemacs-p (sit-for 0))
511 522
512 (split-window-vertically 523 (split-window-vertically
513 (max 2 (- (window-height) merge-window-lines))) 524 (max 2 (- (window-height) merge-window-lines)))
514 (if (eq (selected-window) wind-A) 525 (if (eq (selected-window) wind-A)
515 (other-window 1)) 526 (other-window 1))
527 (setq done-A t 538 (setq done-A t
528 done-B t 539 done-B t
529 done-C t) 540 done-C t)
530 )) 541 ))
531 542
532 (or done-A ; Buf A to be set in its own frame 543 (or done-A ; Buf A to be set in its own frame,
533 (progn ; It was not set up yet as it wasn't visible 544 ;;; or it was set before because use-same-frame = 1
545 (progn
546 ;; Buf-A was not set up yet as it wasn't visible,
547 ;; and use-same-frame = nil, use-same-frame-for-AB = nil
534 (select-window orig-wind) 548 (select-window orig-wind)
535 (delete-other-windows) 549 (delete-other-windows)
536 (switch-to-buffer buf-A) 550 (switch-to-buffer buf-A)
537 (setq wind-A (selected-window)) 551 (setq wind-A (selected-window))
538 )) 552 ))
539 (or done-B ; Buf B to be set in its own frame 553 (or done-B ; Buf B to be set in its own frame,
540 (progn ; It was not set up yet as it wasn't visible 554 ;;; or it was set before because use-same-frame = 1
555 (progn
556 ;; Buf-B was not set up yet as it wasn't visible
557 ;; and use-same-frame = nil, use-same-frame-for-AB = nil
541 (select-window orig-wind) 558 (select-window orig-wind)
542 (delete-other-windows) 559 (delete-other-windows)
543 (switch-to-buffer buf-B) 560 (switch-to-buffer buf-B)
544 (setq wind-B (selected-window)) 561 (setq wind-B (selected-window))
545 )) 562 ))
546 563
547 (or done-C ; Buf C to be set in its own frame. 564 (or done-C ; Buf C to be set in its own frame,
548 (progn ; It was not set up yet as it wasn't visible 565 ;;; or it was set before because use-same-frame = 1
566 (progn
567 ;; Buf-C was not set up yet as it wasn't visible
568 ;; and use-same-frame = nil
549 (select-window orig-wind) 569 (select-window orig-wind)
550 (delete-other-windows) 570 (delete-other-windows)
551 (switch-to-buffer buf-C) 571 (switch-to-buffer buf-C)
552 (setq wind-C (selected-window)) 572 (setq wind-C (selected-window))
553 )) 573 ))
600 (three-way-comparison 620 (three-way-comparison
601 (ediff-eval-in-buffer control-buf ediff-3way-comparison-job)) 621 (ediff-eval-in-buffer control-buf ediff-3way-comparison-job))
602 (orig-wind (selected-window)) 622 (orig-wind (selected-window))
603 (use-same-frame (or force-one-frame 623 (use-same-frame (or force-one-frame
604 (eq frame-A frame-B) 624 (eq frame-A frame-B)
625 (not (ediff-window-ok-for-display wind-A))
626 (not (ediff-window-ok-for-display wind-B))
605 (if three-way-comparison 627 (if three-way-comparison
606 (or (eq frame-A frame-C) 628 (or (eq frame-A frame-C)
607 (eq frame-B frame-C) 629 (eq frame-B frame-C)
630 (not (ediff-window-ok-for-display wind-C))
608 (not (frame-live-p frame-A)) 631 (not (frame-live-p frame-A))
609 (not (frame-live-p frame-B)) 632 (not (frame-live-p frame-B))
610 (not (frame-live-p frame-C)))) 633 (not (frame-live-p frame-C))))
611 (and (not (frame-live-p frame-B)) 634 (and (not (frame-live-p frame-B))
612 (or ctl-frame-exists-p 635 (or ctl-frame-exists-p
626 (ediff-get-value-according-to-buffer-type 649 (ediff-get-value-according-to-buffer-type
627 'B ediff-narrow-bounds)))) 650 'B ediff-narrow-bounds))))
628 651
629 (if (and (window-live-p wind-A) (null use-same-frame)) ; buf-A on its own 652 (if (and (window-live-p wind-A) (null use-same-frame)) ; buf-A on its own
630 (progn 653 (progn
631 (select-window wind-A) 654 ;; buffer buf-A is seen in live wind-A
655 (select-window wind-A) ; must be displaying buf-A
656 (delete-other-windows)
657 (setq wind-A (selected-window))
658 (setq done-A t)))
659
660 (if (and (window-live-p wind-B) (null use-same-frame)) ; buf B on its own
661 (progn
662 ;; buffer buf-B is seen in live wind-B
663 (select-window wind-B) ; must be displaying buf-B
664 (delete-other-windows)
665 (setq wind-B (selected-window))
666 (setq done-B t)))
667
668 (if (and (window-live-p wind-C) (null use-same-frame)) ; buf C on its own
669 (progn
670 ;; buffer buf-C is seen in live wind-C
671 (select-window wind-C) ; must be displaying buf-C
672 (delete-other-windows)
673 (setq wind-C (selected-window))
674 (setq done-C t)))
675
676 (if use-same-frame
677 (let (wind-width-or-height) ; this affects 3way setups only
678 ;; avoid dedicated and non-splittable windows
679 (ediff-skip-unsuitable-frames)
632 (delete-other-windows) 680 (delete-other-windows)
633 (switch-to-buffer buf-A) 681 (switch-to-buffer buf-A)
634 (setq wind-A (selected-window)) 682 (setq wind-A (selected-window))
635 (setq done-A t)))
636
637 (if (and (window-live-p wind-B) (null use-same-frame)) ; buf B on its own
638 (progn
639 (select-window wind-B)
640 (delete-other-windows)
641 (switch-to-buffer buf-B)
642 (setq wind-B (selected-window))
643 (setq done-B t)))
644
645 (if (and (window-live-p wind-C) (null use-same-frame)) ; buf C on its own
646 (progn
647 (select-window wind-C)
648 (delete-other-windows)
649 (switch-to-buffer buf-C)
650 (setq wind-C (selected-window))
651 (setq done-C t)))
652
653 (if use-same-frame
654 (let ((curr-frame (selected-frame))
655 ;; this affects 3way setups only
656 wind-width-or-height)
657 ;; avoid dedicated and non-splittable windows
658 (ediff-skip-unsuitable-frames)
659 (or (eq curr-frame (selected-frame))
660 (setq wind-A nil
661 wind-B nil
662 wind-C nil
663 orig-wind (selected-window)))
664
665 ;; set the right frame
666 (cond (wind-A (select-window wind-A))
667 (wind-B (select-window wind-B))
668 (wind-C (select-window wind-C))
669 (t (select-window orig-wind)))
670 (delete-other-windows)
671 (switch-to-buffer buf-A)
672 (setq wind-A (selected-window))
673
674 ;; XEmacs used to have a lot of trouble with display
675 ;; It didn't set things right unless we told it to catch breath
676 ;;(if ediff-xemacs-p (sit-for 0))
677 683
678 (if three-way-comparison 684 (if three-way-comparison
679 (setq wind-width-or-height 685 (setq wind-width-or-height
680 (/ 686 (/
681 (if (eq split-window-function 'split-window-vertically) 687 (if (eq split-window-function 'split-window-vertically)
700 done-B t 706 done-B t
701 done-C t) 707 done-C t)
702 )) 708 ))
703 709
704 (or done-A ; Buf A to be set in its own frame 710 (or done-A ; Buf A to be set in its own frame
705 (progn ; It was not set up yet as it wasn't visible 711 ;;; or it was set before because use-same-frame = 1
712 (progn
713 ;; Buf-A was not set up yet as it wasn't visible,
714 ;; and use-same-frame = nil
706 (select-window orig-wind) 715 (select-window orig-wind)
707 (delete-other-windows) 716 (delete-other-windows)
708 (switch-to-buffer buf-A) 717 (switch-to-buffer buf-A)
709 (setq wind-A (selected-window)) 718 (setq wind-A (selected-window))
710 )) 719 ))
711 (or done-B ; Buf B to be set in its own frame 720 (or done-B ; Buf B to be set in its own frame
712 (progn ; It was not set up yet as it wasn't visible 721 ;;; or it was set before because use-same-frame = 1
722 (progn
723 ;; Buf-B was not set up yet as it wasn't visible,
724 ;; and use-same-frame = nil
713 (select-window orig-wind) 725 (select-window orig-wind)
714 (delete-other-windows) 726 (delete-other-windows)
715 (switch-to-buffer buf-B) 727 (switch-to-buffer buf-B)
716 (setq wind-B (selected-window)) 728 (setq wind-B (selected-window))
717 )) 729 ))
718 730
719 (if three-way-comparison 731 (if three-way-comparison
720 (or done-C ; Buf C to be set in its own frame 732 (or done-C ; Buf C to be set in its own frame
721 (progn ; It was not set up yet as it wasn't visible 733 ;;; or it was set before because use-same-frame = 1
734 (progn
735 ;; Buf-C was not set up yet as it wasn't visible,
736 ;; and use-same-frame = nil
722 (select-window orig-wind) 737 (select-window orig-wind)
723 (delete-other-windows) 738 (delete-other-windows)
724 (switch-to-buffer buf-C) 739 (switch-to-buffer buf-C)
725 (setq wind-C (selected-window)) 740 (setq wind-C (selected-window))
726 ))) 741 )))
732 747
733 (setq frame-A (window-frame ediff-window-A) 748 (setq frame-A (window-frame ediff-window-A)
734 designated-minibuffer-frame 749 designated-minibuffer-frame
735 (window-frame (minibuffer-window frame-A)))) 750 (window-frame (minibuffer-window frame-A))))
736 751
737 ;; It is unlikely that we'll implement ediff-windows that would compare 752 ;; It is unlikely that we'll implement a version of ediff-windows that
738 ;; 3 windows at once. So, we don't use buffer C here. 753 ;; would compare 3 windows at once. So, we don't use buffer C here.
739 (if ediff-windows-job 754 (if ediff-windows-job
740 (progn 755 (progn
741 (set-window-start wind-A wind-A-start) 756 (set-window-start wind-A wind-A-start)
742 (set-window-start wind-B wind-B-start))) 757 (set-window-start wind-B wind-B-start)))
743 758
744 (ediff-setup-control-frame control-buf designated-minibuffer-frame) 759 (ediff-setup-control-frame control-buf designated-minibuffer-frame)
745 )) 760 ))
746 761
747 ;; skip unsplittable and dedicated windows 762 ;; skip unsplittable frames and frames that have dedicated windows.
748 ;; create a new splittable frame if none is found 763 ;; create a new splittable frame if none is found
749 (defun ediff-skip-unsuitable-frames (&optional ok-unsplittable) 764 (defun ediff-skip-unsuitable-frames (&optional ok-unsplittable)
750 (if (ediff-window-display-p) 765 (if (ediff-window-display-p)
751 (let (last-window) 766 (let (last-window)
752 (while (and (not (eq (selected-window) last-window)) 767 (while (and (not (eq (selected-window) last-window))
753 (or 768 (or
754 (window-dedicated-p (selected-window)) 769 (ediff-frame-has-dedicated-windows (selected-frame))
755 (ediff-frame-iconified-p (selected-frame)) 770 (ediff-frame-iconified-p (selected-frame))
756 (< (frame-height (selected-frame)) 771 (< (frame-height (selected-frame))
757 (* 3 window-min-height)) 772 (* 3 window-min-height))
758 (if ok-unsplittable 773 (if ok-unsplittable
759 nil 774 nil
763 ;; try new window 778 ;; try new window
764 (other-window 1 t)) 779 (other-window 1 t))
765 (if (eq (selected-window) last-window) 780 (if (eq (selected-window) last-window)
766 ;; fed up, no appropriate frame 781 ;; fed up, no appropriate frame
767 (progn 782 (progn
768 ;;(redraw-display)
769 (select-frame (make-frame '((unsplittable))))))))) 783 (select-frame (make-frame '((unsplittable)))))))))
784
785 (defun ediff-frame-has-dedicated-windows (frame)
786 (let ((cur-fr (selected-frame))
787 ans)
788 (select-frame frame)
789 (walk-windows
790 (function (lambda (wind)
791 (if (window-dedicated-p wind)
792 (setq ans t))))
793 'ignore-minibuffer
794 frame)
795 (select-frame cur-fr)
796 ans))
797
798 ;; window is ok, if it is only one window on the frame, not counting the
799 ;; minibuffer, or none of the frame's windows is dedicated.
800 ;; The idea is that it is bad to destroy dedicated windows while creating an
801 ;; ediff window setup
802 (defun ediff-window-ok-for-display (wind)
803 (and
804 (window-live-p wind)
805 (or
806 ;; only one window
807 (eq wind (next-window wind 'ignore-minibuffer (window-frame wind)))
808 ;; none is dedicated
809 (not (ediff-frame-has-dedicated-windows (window-frame wind)))
810 )))
770 811
771 ;; Prepare or refresh control frame 812 ;; Prepare or refresh control frame
772 (defun ediff-setup-control-frame (ctl-buffer designated-minibuffer-frame) 813 (defun ediff-setup-control-frame (ctl-buffer designated-minibuffer-frame)
773 (let ((window-min-height 1) 814 (let ((window-min-height 1)
774 ctl-frame-iconified-p dont-iconify-ctl-frame deiconify-ctl-frame 815 ctl-frame-iconified-p dont-iconify-ctl-frame deiconify-ctl-frame
775 ctl-frame old-ctl-frame lines user-grabbed-mouse 816 ctl-frame old-ctl-frame lines
817 ;; user-grabbed-mouse
776 fheight fwidth adjusted-parameters) 818 fheight fwidth adjusted-parameters)
777 819
778 (ediff-eval-in-buffer ctl-buffer 820 (ediff-eval-in-buffer ctl-buffer
779 (if ediff-xemacs-p (set-buffer-menubar nil)) 821 (if ediff-xemacs-p (set-buffer-menubar nil))
780 ;;(setq user-grabbed-mouse (ediff-user-grabbed-mouse)) 822 ;;(setq user-grabbed-mouse (ediff-user-grabbed-mouse))
811 ;; 1 more line for the modeline 853 ;; 1 more line for the modeline
812 (setq lines (1+ (count-lines (point-min) (point-max))) 854 (setq lines (1+ (count-lines (point-min) (point-max)))
813 fheight lines 855 fheight lines
814 fwidth (+ (ediff-help-message-line-length) 2) 856 fwidth (+ (ediff-help-message-line-length) 2)
815 adjusted-parameters (append (list 857 adjusted-parameters (append (list
816 '(visibility . t)
817 ;; possibly change surrogate minibuffer 858 ;; possibly change surrogate minibuffer
818 (cons 'minibuffer 859 (cons 'minibuffer
819 (minibuffer-window 860 (minibuffer-window
820 designated-minibuffer-frame)) 861 designated-minibuffer-frame))
821 (cons 'width fwidth) 862 (cons 'width fwidth)
849 (modify-frame-parameters ctl-frame adjusted-parameters)) 890 (modify-frame-parameters ctl-frame adjusted-parameters))
850 891
851 (goto-char (point-min)) 892 (goto-char (point-min))
852 893
853 (modify-frame-parameters ctl-frame adjusted-parameters) 894 (modify-frame-parameters ctl-frame adjusted-parameters)
895 (make-frame-visible ctl-frame)
854 896
855 ;; This works around a bug in 19.25 and earlier. There, if frame gets 897 ;; This works around a bug in 19.25 and earlier. There, if frame gets
856 ;; iconified, the current buffer changes to that of the frame that 898 ;; iconified, the current buffer changes to that of the frame that
857 ;; becomes exposed as a result of this iconification. 899 ;; becomes exposed as a result of this iconification.
858 ;; So, we make sure the current buffer doesn't change. 900 ;; So, we make sure the current buffer doesn't change.
863 (not ctl-frame-iconified-p) (not dont-iconify-ctl-frame)) 905 (not ctl-frame-iconified-p) (not dont-iconify-ctl-frame))
864 (iconify-frame ctl-frame)) 906 (iconify-frame ctl-frame))
865 ((or deiconify-ctl-frame (not ctl-frame-iconified-p)) 907 ((or deiconify-ctl-frame (not ctl-frame-iconified-p))
866 (raise-frame ctl-frame))) 908 (raise-frame ctl-frame)))
867 909
868 (if ediff-xemacs-p 910 (set-window-dedicated-p (selected-window) t)
869 (set-window-buffer-dedicated (selected-window) ctl-buffer)
870 (set-window-dedicated-p (selected-window) t))
871 911
872 ;; resynch so the cursor will move to control frame 912 ;; synchronize so the cursor will move to control frame
873 ;; per RMS suggestion 913 ;; per RMS suggestion
874 (if (ediff-window-display-p) 914 (if (ediff-window-display-p)
875 (let ((count 7)) 915 (let ((count 7))
876 (sit-for .1) 916 (sit-for .1)
877 (while (and (not (frame-visible-p ctl-frame)) (> count 0)) 917 (while (and (not (frame-visible-p ctl-frame)) (> count 0))
884 (or (eq this-command 'ediff-quit) 924 (or (eq this-command 'ediff-quit)
885 (not (eq ediff-grab-mouse t))))) 925 (not (eq ediff-grab-mouse t)))))
886 926
887 (if ediff-xemacs-p 927 (if ediff-xemacs-p
888 (ediff-eval-in-buffer ctl-buffer 928 (ediff-eval-in-buffer ctl-buffer
889 (make-local-variable 'select-frame-hook) 929 (make-local-hook 'select-frame-hook)
890 (add-hook 'select-frame-hook 'ediff-xemacs-select-frame-hook) 930 (add-hook 'select-frame-hook 'ediff-xemacs-select-frame-hook nil t)
891 )) 931 ))
892 932
893 (ediff-eval-in-buffer ctl-buffer 933 (ediff-eval-in-buffer ctl-buffer
894 (run-hooks 'ediff-after-setup-control-frame-hook)) 934 (run-hooks 'ediff-after-setup-control-frame-hook))
895 )) 935 ))
1019 1059
1020 ;; control buffer format 1060 ;; control buffer format
1021 (setq mode-line-format 1061 (setq mode-line-format
1022 (list (if (ediff-narrow-control-frame-p) " " "-- ") 1062 (list (if (ediff-narrow-control-frame-p) " " "-- ")
1023 mode-line-buffer-identification 1063 mode-line-buffer-identification
1024 " Howdy!")) 1064 " Quick Help"))
1025 ;; control buffer id 1065 ;; control buffer id
1026 (setq mode-line-buffer-identification 1066 (setq mode-line-buffer-identification
1027 (if (ediff-narrow-control-frame-p) 1067 (if (ediff-narrow-control-frame-p)
1028 (ediff-make-narrow-control-buffer-id 'skip-name) 1068 (ediff-make-narrow-control-buffer-id 'skip-name)
1029 (ediff-make-wide-control-buffer-id))) 1069 (ediff-make-wide-control-buffer-id)))
1070 mode-line-format)))) 1110 mode-line-format))))
1071 )) 1111 ))
1072 1112
1073 1113
1074 (defun ediff-refresh-control-frame () 1114 (defun ediff-refresh-control-frame ()
1075 (setq frame-title-format (ediff-make-narrow-control-buffer-id)
1076 frame-icon-title-format (ediff-make-narrow-control-buffer-id) ; XEmacs
1077 icon-title-format (ediff-make-narrow-control-buffer-id)) ; Emacs
1078 ;; the emacs part will be modified once the 'name and 'title
1079 ;; frame parameters are separated
1080 (if ediff-emacs-p 1115 (if ediff-emacs-p
1116 ;; set frame/icon titles for Emacs
1081 (modify-frame-parameters 1117 (modify-frame-parameters
1082 ediff-control-frame 1118 ediff-control-frame
1083 (list (cons 'name (ediff-make-narrow-control-buffer-id)))) 1119 (list (cons 'title (ediff-make-base-title))
1120 (cons 'icon-name (ediff-make-narrow-control-buffer-id))
1121 ))
1122 ;; set frame/icon titles for XEmacs
1123 (setq frame-title-format (ediff-make-base-title)
1124 frame-icon-title-format (ediff-make-narrow-control-buffer-id))
1084 ;; force an update of the frame title 1125 ;; force an update of the frame title
1085 (modify-frame-parameters ediff-control-frame '(())))) 1126 (modify-frame-parameters ediff-control-frame '(()))))
1086 1127
1087 1128
1088 (defun ediff-make-narrow-control-buffer-id (&optional skip-name) 1129 (defun ediff-make-narrow-control-buffer-id (&optional skip-name)
1089 (concat 1130 (concat
1090 (if skip-name 1131 (if skip-name
1091 " " 1132 " "
1092 (concat 1133 (ediff-make-base-title))
1093 (cdr (assoc 'name ediff-control-frame-parameters))
1094 ediff-control-buffer-suffix))
1095 (cond ((< ediff-current-difference 0) 1134 (cond ((< ediff-current-difference 0)
1096 (format " _/%d" ediff-number-of-differences)) 1135 (format " _/%d" ediff-number-of-differences))
1097 ((>= ediff-current-difference ediff-number-of-differences) 1136 ((>= ediff-current-difference ediff-number-of-differences)
1098 (format " $/%d" ediff-number-of-differences)) 1137 (format " $/%d" ediff-number-of-differences))
1099 (t 1138 (t
1100 (format " %d/%d" 1139 (format " %d/%d"
1101 (1+ ediff-current-difference) 1140 (1+ ediff-current-difference)
1102 ediff-number-of-differences))))) 1141 ediff-number-of-differences)))))
1142
1143 (defun ediff-make-base-title ()
1144 (concat
1145 (cdr (assoc 'name ediff-control-frame-parameters))
1146 ediff-control-buffer-suffix))
1103 1147
1104 (defun ediff-make-wide-control-buffer-id () 1148 (defun ediff-make-wide-control-buffer-id ()
1105 (cond ((< ediff-current-difference 0) 1149 (cond ((< ediff-current-difference 0)
1106 (list (format "%%b At start of %d diffs" 1150 (list (format "%%b At start of %d diffs"
1107 ediff-number-of-differences))) 1151 ediff-number-of-differences)))
1120 (if (ediff-buffer-live-p buff) 1164 (if (ediff-buffer-live-p buff)
1121 (if ediff-xemacs-p 1165 (if ediff-xemacs-p
1122 (get-buffer-window buff t) 1166 (get-buffer-window buff t)
1123 (get-buffer-window buff 'visible)))) 1167 (get-buffer-window buff 'visible))))
1124 1168
1169
1125 ;;; Functions to decide when to redraw windows 1170 ;;; Functions to decide when to redraw windows
1126
1127 1171
1128 (defun ediff-keep-window-config (control-buf) 1172 (defun ediff-keep-window-config (control-buf)
1129 (and (eq control-buf (current-buffer)) 1173 (and (eq control-buf (current-buffer))
1130 (/= (buffer-size) 0) 1174 (/= (buffer-size) 0)
1131 (ediff-eval-in-buffer control-buf 1175 (ediff-eval-in-buffer control-buf
1150 ediff-split-window-function 1194 ediff-split-window-function
1151 (ediff-multiframe-setup-p) 1195 (ediff-multiframe-setup-p)
1152 ediff-wide-display-p))))))) 1196 ediff-wide-display-p)))))))
1153 1197
1154 1198
1199 ;;; Local Variables:
1200 ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun)
1201 ;;; eval: (put 'ediff-eval-in-buffer 'lisp-indent-hook 1)
1202 ;;; End:
1203
1155 (provide 'ediff-wind) 1204 (provide 'ediff-wind)
1156 1205
1157 1206
1158 ;;; ediff-wind.el ends here 1207 ;;; ediff-wind.el ends here