24 |
;;; Commentary: |
;;; Commentary: |
25 |
|
|
26 |
;;; Code: |
;;; Code: |
27 |
|
|
28 |
(provide 'ediff-wind) |
(provide 'ediff-wind) |
29 |
|
|
30 |
;; Compiler pacifier |
;; Compiler pacifier |
94 |
Buffer C may not be used in jobs that compare only two buffers. |
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 |
If you plan to do something fancy, take a close look at how the two |
96 |
provided functions are written." |
provided functions are written." |
97 |
:type 'function |
:type '(choice (const :tag "Multi Frame" ediff-setup-windows-multiframe) |
98 |
|
(const :tag "Single Frame" ediff-setup-windows-plain) |
99 |
|
(function :tag "Other function")) |
100 |
:group 'ediff-window) |
:group 'ediff-window) |
101 |
|
|
102 |
;; indicates if we are in a multiframe setup |
;; indicates if we are in a multiframe setup |
155 |
'(user-position . t) ; Emacs only |
'(user-position . t) ; Emacs only |
156 |
'(vertical-scroll-bars . nil) ; Emacs only |
'(vertical-scroll-bars . nil) ; Emacs only |
157 |
'(scrollbar-width . 0) ; XEmacs only |
'(scrollbar-width . 0) ; XEmacs only |
158 |
|
'(scrollbar-height . 0) ; XEmacs only |
159 |
'(menu-bar-lines . 0) ; Emacs only |
'(menu-bar-lines . 0) ; Emacs only |
160 |
'(tool-bar-lines . 0) ; Emacs 21+ only |
'(tool-bar-lines . 0) ; Emacs 21+ only |
161 |
;; don't lower and auto-raise |
;; don't lower but auto-raise |
162 |
'(auto-lower . nil) |
'(auto-lower . nil) |
163 |
'(auto-raise . t) |
'(auto-raise . t) |
164 |
'(visibility . nil) |
'(visibility . nil) |
281 |
) |
) |
282 |
) |
) |
283 |
)) |
)) |
284 |
|
|
285 |
|
|
286 |
;; Select the lowest window on the frame. |
;; Select the lowest window on the frame. |
287 |
(defun ediff-select-lowest-window () |
(defun ediff-select-lowest-window () |
301 |
(progn |
(progn |
302 |
(setq bottom-edge next-bottom-edge) |
(setq bottom-edge next-bottom-edge) |
303 |
(setq lowest-window this-window))) |
(setq lowest-window this-window))) |
304 |
|
|
305 |
(select-window this-window) |
(select-window this-window) |
306 |
(if (eq last-window this-window) |
(if (eq last-window this-window) |
307 |
(progn |
(progn |
322 |
(run-hooks 'ediff-before-setup-windows-hook) |
(run-hooks 'ediff-before-setup-windows-hook) |
323 |
(if (eq (selected-window) (minibuffer-window)) |
(if (eq (selected-window) (minibuffer-window)) |
324 |
(other-window 1)) |
(other-window 1)) |
325 |
|
|
326 |
;; in case user did a no-no on a tty |
;; in case user did a no-no on a tty |
327 |
(or (ediff-window-display-p) |
(or (ediff-window-display-p) |
328 |
(setq ediff-window-setup-function 'ediff-setup-windows-plain)) |
(setq ediff-window-setup-function 'ediff-setup-windows-plain)) |
329 |
|
|
330 |
(or (ediff-keep-window-config control-buffer) |
(or (ediff-keep-window-config control-buffer) |
331 |
(funcall |
(funcall |
332 |
(ediff-with-current-buffer control-buffer ediff-window-setup-function) |
(ediff-with-current-buffer control-buffer ediff-window-setup-function) |
344 |
buffer-A buffer-B buffer-C control-buffer) |
buffer-A buffer-B buffer-C control-buffer) |
345 |
(ediff-setup-windows-plain-compare |
(ediff-setup-windows-plain-compare |
346 |
buffer-A buffer-B buffer-C control-buffer))) |
buffer-A buffer-B buffer-C control-buffer))) |
347 |
|
|
348 |
(defun ediff-setup-windows-plain-merge (buf-A buf-B buf-C control-buffer) |
(defun ediff-setup-windows-plain-merge (buf-A buf-B buf-C control-buffer) |
349 |
;; skip dedicated and unsplittable frames |
;; skip dedicated and unsplittable frames |
350 |
(ediff-destroy-control-frame control-buffer) |
(ediff-destroy-control-frame control-buffer) |
360 |
(split-window-vertically) |
(split-window-vertically) |
361 |
(ediff-select-lowest-window) |
(ediff-select-lowest-window) |
362 |
(ediff-setup-control-buffer control-buffer) |
(ediff-setup-control-buffer control-buffer) |
363 |
|
|
364 |
;; go to the upper window and split it betw A, B, and possibly C |
;; go to the upper window and split it betw A, B, and possibly C |
365 |
(other-window 1) |
(other-window 1) |
366 |
(setq merge-window-lines |
(setq merge-window-lines |
367 |
(max 2 (round (* (window-height) merge-window-share)))) |
(max 2 (round (* (window-height) merge-window-share)))) |
368 |
(switch-to-buffer buf-A) |
(switch-to-buffer buf-A) |
369 |
(setq wind-A (selected-window)) |
(setq wind-A (selected-window)) |
370 |
|
|
371 |
;; XEmacs used to have a lot of trouble with display |
;; XEmacs used to have a lot of trouble with display |
372 |
;; It did't set things right unless we tell it to sit still |
;; It did't set things right unless we tell it to sit still |
373 |
;; 19.12 seems ok. |
;; 19.12 seems ok. |
374 |
;;(if ediff-xemacs-p (sit-for 0)) |
;;(if ediff-xemacs-p (sit-for 0)) |
375 |
|
|
376 |
(split-window-vertically (max 2 (- (window-height) merge-window-lines))) |
(split-window-vertically (max 2 (- (window-height) merge-window-lines))) |
377 |
(if (eq (selected-window) wind-A) |
(if (eq (selected-window) wind-A) |
378 |
(other-window 1)) |
(other-window 1)) |
379 |
(setq wind-C (selected-window)) |
(setq wind-C (selected-window)) |
380 |
(switch-to-buffer buf-C) |
(switch-to-buffer buf-C) |
381 |
|
|
382 |
(select-window wind-A) |
(select-window wind-A) |
383 |
(funcall split-window-function) |
(funcall split-window-function) |
384 |
|
|
385 |
(if (eq (selected-window) wind-A) |
(if (eq (selected-window) wind-A) |
386 |
(other-window 1)) |
(other-window 1)) |
387 |
(switch-to-buffer buf-B) |
(switch-to-buffer buf-B) |
388 |
(setq wind-B (selected-window)) |
(setq wind-B (selected-window)) |
389 |
|
|
390 |
(ediff-with-current-buffer control-buffer |
(ediff-with-current-buffer control-buffer |
391 |
(setq ediff-window-A wind-A |
(setq ediff-window-A wind-A |
392 |
ediff-window-B wind-B |
ediff-window-B wind-B |
393 |
ediff-window-C wind-C)) |
ediff-window-C wind-C)) |
394 |
|
|
395 |
(ediff-select-lowest-window) |
(ediff-select-lowest-window) |
396 |
(ediff-setup-control-buffer control-buffer) |
(ediff-setup-control-buffer control-buffer) |
397 |
)) |
)) |
398 |
|
|
399 |
|
|
400 |
;; This function handles all comparison jobs, including 3way jobs |
;; This function handles all comparison jobs, including 3way jobs |
401 |
(defun ediff-setup-windows-plain-compare (buf-A buf-B buf-C control-buffer) |
(defun ediff-setup-windows-plain-compare (buf-A buf-B buf-C control-buffer) |
402 |
;; skip dedicated and unsplittable frames |
;; skip dedicated and unsplittable frames |
419 |
(split-window-vertically) |
(split-window-vertically) |
420 |
(ediff-select-lowest-window) |
(ediff-select-lowest-window) |
421 |
(ediff-setup-control-buffer control-buffer) |
(ediff-setup-control-buffer control-buffer) |
422 |
|
|
423 |
;; go to the upper window and split it betw A, B, and possibly C |
;; go to the upper window and split it betw A, B, and possibly C |
424 |
(other-window 1) |
(other-window 1) |
425 |
(switch-to-buffer buf-A) |
(switch-to-buffer buf-A) |
430 |
(window-height wind-A) |
(window-height wind-A) |
431 |
(window-width wind-A)) |
(window-width wind-A)) |
432 |
3))) |
3))) |
433 |
|
|
434 |
;; XEmacs used to have a lot of trouble with display |
;; XEmacs used to have a lot of trouble with display |
435 |
;; It did't set things right unless we told it to sit still |
;; It did't set things right unless we told it to sit still |
436 |
;; 19.12 seems ok. |
;; 19.12 seems ok. |
437 |
;;(if ediff-xemacs-p (sit-for 0)) |
;;(if ediff-xemacs-p (sit-for 0)) |
438 |
|
|
439 |
(funcall split-window-function wind-width-or-height) |
(funcall split-window-function wind-width-or-height) |
440 |
|
|
441 |
(if (eq (selected-window) wind-A) |
(if (eq (selected-window) wind-A) |
442 |
(other-window 1)) |
(other-window 1)) |
443 |
(switch-to-buffer buf-B) |
(switch-to-buffer buf-B) |
444 |
(setq wind-B (selected-window)) |
(setq wind-B (selected-window)) |
445 |
|
|
446 |
(if three-way-comparison |
(if three-way-comparison |
447 |
(progn |
(progn |
448 |
(funcall split-window-function) ; equally |
(funcall split-window-function) ; equally |
450 |
(other-window 1)) |
(other-window 1)) |
451 |
(switch-to-buffer buf-C) |
(switch-to-buffer buf-C) |
452 |
(setq wind-C (selected-window)))) |
(setq wind-C (selected-window)))) |
453 |
|
|
454 |
(ediff-with-current-buffer control-buffer |
(ediff-with-current-buffer control-buffer |
455 |
(setq ediff-window-A wind-A |
(setq ediff-window-A wind-A |
456 |
ediff-window-B wind-B |
ediff-window-B wind-B |
457 |
ediff-window-C wind-C)) |
ediff-window-C wind-C)) |
458 |
|
|
459 |
;; It is unlikely that we will want to implement 3way window comparison. |
;; It is unlikely that we will want to implement 3way window comparison. |
460 |
;; So, only buffers A and B are used here. |
;; So, only buffers A and B are used here. |
461 |
(if ediff-windows-job |
(if ediff-windows-job |
462 |
(progn |
(progn |
463 |
(set-window-start wind-A wind-A-start) |
(set-window-start wind-A wind-A-start) |
464 |
(set-window-start wind-B wind-B-start))) |
(set-window-start wind-B wind-B-start))) |
465 |
|
|
466 |
(ediff-select-lowest-window) |
(ediff-select-lowest-window) |
467 |
(ediff-setup-control-buffer control-buffer) |
(ediff-setup-control-buffer control-buffer) |
468 |
)) |
)) |
469 |
|
|
470 |
|
|
471 |
;; dispatch an appropriate window setup function |
;; dispatch an appropriate window setup function |
472 |
(defun ediff-setup-windows-multiframe (buf-A buf-B buf-C control-buf) |
(defun ediff-setup-windows-multiframe (buf-A buf-B buf-C control-buf) |
473 |
(ediff-with-current-buffer control-buf |
(ediff-with-current-buffer control-buf |
475 |
(if ediff-merge-job |
(if ediff-merge-job |
476 |
(ediff-setup-windows-multiframe-merge buf-A buf-B buf-C control-buf) |
(ediff-setup-windows-multiframe-merge buf-A buf-B buf-C control-buf) |
477 |
(ediff-setup-windows-multiframe-compare buf-A buf-B buf-C control-buf))) |
(ediff-setup-windows-multiframe-compare buf-A buf-B buf-C control-buf))) |
478 |
|
|
479 |
(defun ediff-setup-windows-multiframe-merge (buf-A buf-B buf-C control-buf) |
(defun ediff-setup-windows-multiframe-merge (buf-A buf-B buf-C control-buf) |
480 |
;;; Algorithm: |
;;; Algorithm: |
481 |
;;; 1. Never use frames that have dedicated windows in them---it is bad to |
;;; 1. Never use frames that have dedicated windows in them---it is bad to |
491 |
;; Skip dedicated or iconified frames. |
;; Skip dedicated or iconified frames. |
492 |
;; Unsplittable frames are taken care of later. |
;; Unsplittable frames are taken care of later. |
493 |
(ediff-skip-unsuitable-frames 'ok-unsplittable) |
(ediff-skip-unsuitable-frames 'ok-unsplittable) |
494 |
|
|
495 |
(let* ((window-min-height 1) |
(let* ((window-min-height 1) |
496 |
(wind-A (ediff-get-visible-buffer-window buf-A)) |
(wind-A (ediff-get-visible-buffer-window buf-A)) |
497 |
(wind-B (ediff-get-visible-buffer-window buf-B)) |
(wind-B (ediff-get-visible-buffer-window buf-B)) |
531 |
merge-window-lines |
merge-window-lines |
532 |
designated-minibuffer-frame |
designated-minibuffer-frame |
533 |
done-A done-B done-C) |
done-A done-B done-C) |
534 |
|
|
535 |
;; buf-A on its own |
;; buf-A on its own |
536 |
(if (and (window-live-p wind-A) |
(if (and (window-live-p wind-A) |
537 |
(null use-same-frame) ; implies wind-A is suitable |
(null use-same-frame) ; implies wind-A is suitable |
542 |
(delete-other-windows) |
(delete-other-windows) |
543 |
(setq wind-A (selected-window)) |
(setq wind-A (selected-window)) |
544 |
(setq done-A t))) |
(setq done-A t))) |
545 |
|
|
546 |
;; buf-B on its own |
;; buf-B on its own |
547 |
(if (and (window-live-p wind-B) |
(if (and (window-live-p wind-B) |
548 |
(null use-same-frame) ; implies wind-B is suitable |
(null use-same-frame) ; implies wind-B is suitable |
553 |
(delete-other-windows) |
(delete-other-windows) |
554 |
(setq wind-B (selected-window)) |
(setq wind-B (selected-window)) |
555 |
(setq done-B t))) |
(setq done-B t))) |
556 |
|
|
557 |
;; buf-C on its own |
;; buf-C on its own |
558 |
(if (and (window-live-p wind-C) |
(if (and (window-live-p wind-C) |
559 |
(ediff-window-ok-for-display wind-C) |
(ediff-window-ok-for-display wind-C) |
564 |
(delete-other-windows) |
(delete-other-windows) |
565 |
(setq wind-C (selected-window)) |
(setq wind-C (selected-window)) |
566 |
(setq done-C t))) |
(setq done-C t))) |
567 |
|
|
568 |
(if (and use-same-frame-for-AB ; implies wind A and B are suitable |
(if (and use-same-frame-for-AB ; implies wind A and B are suitable |
569 |
(window-live-p wind-A)) |
(window-live-p wind-A)) |
570 |
(progn |
(progn |
572 |
(select-window wind-A) |
(select-window wind-A) |
573 |
(delete-other-windows) |
(delete-other-windows) |
574 |
(setq wind-A (selected-window)) |
(setq wind-A (selected-window)) |
575 |
|
|
576 |
(funcall split-window-function) |
(funcall split-window-function) |
577 |
(if (eq (selected-window) wind-A) |
(if (eq (selected-window) wind-A) |
578 |
(other-window 1)) |
(other-window 1)) |
579 |
(switch-to-buffer buf-B) |
(switch-to-buffer buf-B) |
580 |
(setq wind-B (selected-window)) |
(setq wind-B (selected-window)) |
581 |
|
|
582 |
(setq done-A t |
(setq done-A t |
583 |
done-B t))) |
done-B t))) |
584 |
|
|
585 |
(if use-same-frame |
(if use-same-frame |
586 |
(let ((window-min-height 1)) |
(let ((window-min-height 1)) |
587 |
(if (and (eq frame-A frame-B) |
(if (and (eq frame-A frame-B) |
595 |
(max 2 (round (* (window-height) merge-window-share)))) |
(max 2 (round (* (window-height) merge-window-share)))) |
596 |
(switch-to-buffer buf-A) |
(switch-to-buffer buf-A) |
597 |
(setq wind-A (selected-window)) |
(setq wind-A (selected-window)) |
598 |
|
|
599 |
(split-window-vertically |
(split-window-vertically |
600 |
(max 2 (- (window-height) merge-window-lines))) |
(max 2 (- (window-height) merge-window-lines))) |
601 |
(if (eq (selected-window) wind-A) |
(if (eq (selected-window) wind-A) |
602 |
(other-window 1)) |
(other-window 1)) |
603 |
(setq wind-C (selected-window)) |
(setq wind-C (selected-window)) |
604 |
(switch-to-buffer buf-C) |
(switch-to-buffer buf-C) |
605 |
|
|
606 |
(select-window wind-A) |
(select-window wind-A) |
607 |
|
|
608 |
(funcall split-window-function) |
(funcall split-window-function) |
609 |
(if (eq (selected-window) wind-A) |
(if (eq (selected-window) wind-A) |
610 |
(other-window 1)) |
(other-window 1)) |
611 |
(switch-to-buffer buf-B) |
(switch-to-buffer buf-B) |
612 |
(setq wind-B (selected-window)) |
(setq wind-B (selected-window)) |
613 |
|
|
614 |
(setq done-A t |
(setq done-A t |
615 |
done-B t |
done-B t |
616 |
done-C t) |
done-C t) |
617 |
)) |
)) |
618 |
|
|
619 |
(or done-A ; Buf A to be set in its own frame, |
(or done-A ; Buf A to be set in its own frame, |
620 |
;;; or it was set before because use-same-frame = 1 |
;;; or it was set before because use-same-frame = 1 |
621 |
(progn |
(progn |
636 |
(switch-to-buffer buf-B) |
(switch-to-buffer buf-B) |
637 |
(setq wind-B (selected-window)) |
(setq wind-B (selected-window)) |
638 |
)) |
)) |
639 |
|
|
640 |
(or done-C ; Buf C to be set in its own frame, |
(or done-C ; Buf C to be set in its own frame, |
641 |
;;; or it was set before because use-same-frame = 1 |
;;; or it was set before because use-same-frame = 1 |
642 |
(progn |
(progn |
647 |
(switch-to-buffer buf-C) |
(switch-to-buffer buf-C) |
648 |
(setq wind-C (selected-window)) |
(setq wind-C (selected-window)) |
649 |
)) |
)) |
650 |
|
|
651 |
(ediff-with-current-buffer control-buf |
(ediff-with-current-buffer control-buf |
652 |
(setq ediff-window-A wind-A |
(setq ediff-window-A wind-A |
653 |
ediff-window-B wind-B |
ediff-window-B wind-B |
655 |
(setq frame-A (window-frame ediff-window-A) |
(setq frame-A (window-frame ediff-window-A) |
656 |
designated-minibuffer-frame |
designated-minibuffer-frame |
657 |
(window-frame (minibuffer-window frame-A)))) |
(window-frame (minibuffer-window frame-A)))) |
658 |
|
|
659 |
(ediff-setup-control-frame control-buf designated-minibuffer-frame) |
(ediff-setup-control-frame control-buf designated-minibuffer-frame) |
660 |
)) |
)) |
661 |
|
|
662 |
|
|
663 |
;; Window setup for all comparison jobs, including 3way comparisons |
;; Window setup for all comparison jobs, including 3way comparisons |
664 |
(defun ediff-setup-windows-multiframe-compare (buf-A buf-B buf-C control-buf) |
(defun ediff-setup-windows-multiframe-compare (buf-A buf-B buf-C control-buf) |
665 |
;;; Algorithm: |
;;; Algorithm: |
673 |
;;; and the selected frame isn't splittable, we create a new frame and |
;;; and the selected frame isn't splittable, we create a new frame and |
674 |
;;; put both buffers there, event if one of this buffers is visible in |
;;; put both buffers there, event if one of this buffers is visible in |
675 |
;;; another frame. |
;;; another frame. |
676 |
|
|
677 |
;; Skip dedicated or iconified frames. |
;; Skip dedicated or iconified frames. |
678 |
;; Unsplittable frames are taken care of later. |
;; Unsplittable frames are taken care of later. |
679 |
(ediff-skip-unsuitable-frames 'ok-unsplittable) |
(ediff-skip-unsuitable-frames 'ok-unsplittable) |
680 |
|
|
681 |
(let* ((window-min-height 1) |
(let* ((window-min-height 1) |
682 |
(wind-A (ediff-get-visible-buffer-window buf-A)) |
(wind-A (ediff-get-visible-buffer-window buf-A)) |
683 |
(wind-B (ediff-get-visible-buffer-window buf-B)) |
(wind-B (ediff-get-visible-buffer-window buf-B)) |
716 |
wind-A-start wind-B-start |
wind-A-start wind-B-start |
717 |
designated-minibuffer-frame |
designated-minibuffer-frame |
718 |
done-A done-B done-C) |
done-A done-B done-C) |
719 |
|
|
720 |
(ediff-with-current-buffer control-buf |
(ediff-with-current-buffer control-buf |
721 |
(setq wind-A-start (ediff-overlay-start |
(setq wind-A-start (ediff-overlay-start |
722 |
(ediff-get-value-according-to-buffer-type |
(ediff-get-value-according-to-buffer-type |
724 |
wind-B-start (ediff-overlay-start |
wind-B-start (ediff-overlay-start |
725 |
(ediff-get-value-according-to-buffer-type |
(ediff-get-value-according-to-buffer-type |
726 |
'B ediff-narrow-bounds)))) |
'B ediff-narrow-bounds)))) |
727 |
|
|
728 |
(if (and (window-live-p wind-A) (null use-same-frame)) ; buf-A on its own |
(if (and (window-live-p wind-A) (null use-same-frame)) ; buf-A on its own |
729 |
(progn |
(progn |
730 |
;; buffer buf-A is seen in live wind-A |
;; buffer buf-A is seen in live wind-A |
732 |
(delete-other-windows) |
(delete-other-windows) |
733 |
(setq wind-A (selected-window)) |
(setq wind-A (selected-window)) |
734 |
(setq done-A t))) |
(setq done-A t))) |
735 |
|
|
736 |
(if (and (window-live-p wind-B) (null use-same-frame)) ; buf B on its own |
(if (and (window-live-p wind-B) (null use-same-frame)) ; buf B on its own |
737 |
(progn |
(progn |
738 |
;; buffer buf-B is seen in live wind-B |
;; buffer buf-B is seen in live wind-B |
740 |
(delete-other-windows) |
(delete-other-windows) |
741 |
(setq wind-B (selected-window)) |
(setq wind-B (selected-window)) |
742 |
(setq done-B t))) |
(setq done-B t))) |
743 |
|
|
744 |
(if (and (window-live-p wind-C) (null use-same-frame)) ; buf C on its own |
(if (and (window-live-p wind-C) (null use-same-frame)) ; buf C on its own |
745 |
(progn |
(progn |
746 |
;; buffer buf-C is seen in live wind-C |
;; buffer buf-C is seen in live wind-C |
748 |
(delete-other-windows) |
(delete-other-windows) |
749 |
(setq wind-C (selected-window)) |
(setq wind-C (selected-window)) |
750 |
(setq done-C t))) |
(setq done-C t))) |
751 |
|
|
752 |
(if use-same-frame |
(if use-same-frame |
753 |
(let (wind-width-or-height) ; this affects 3way setups only |
(let (wind-width-or-height) ; this affects 3way setups only |
754 |
(if (and (eq frame-A frame-B) (frame-live-p frame-A)) |
(if (and (eq frame-A frame-B) (frame-live-p frame-A)) |
758 |
(delete-other-windows) |
(delete-other-windows) |
759 |
(switch-to-buffer buf-A) |
(switch-to-buffer buf-A) |
760 |
(setq wind-A (selected-window)) |
(setq wind-A (selected-window)) |
761 |
|
|
762 |
(if three-way-comparison |
(if three-way-comparison |
763 |
(setq wind-width-or-height |
(setq wind-width-or-height |
764 |
(/ |
(/ |
766 |
(window-height wind-A) |
(window-height wind-A) |
767 |
(window-width wind-A)) |
(window-width wind-A)) |
768 |
3))) |
3))) |
769 |
|
|
770 |
(funcall split-window-function wind-width-or-height) |
(funcall split-window-function wind-width-or-height) |
771 |
(if (eq (selected-window) wind-A) |
(if (eq (selected-window) wind-A) |
772 |
(other-window 1)) |
(other-window 1)) |
773 |
(switch-to-buffer buf-B) |
(switch-to-buffer buf-B) |
774 |
(setq wind-B (selected-window)) |
(setq wind-B (selected-window)) |
775 |
|
|
776 |
(if three-way-comparison |
(if three-way-comparison |
777 |
(progn |
(progn |
778 |
(funcall split-window-function) ; equally |
(funcall split-window-function) ; equally |
784 |
done-B t |
done-B t |
785 |
done-C t) |
done-C t) |
786 |
)) |
)) |
787 |
|
|
788 |
(or done-A ; Buf A to be set in its own frame |
(or done-A ; Buf A to be set in its own frame |
789 |
;;; or it was set before because use-same-frame = 1 |
;;; or it was set before because use-same-frame = 1 |
790 |
(progn |
(progn |
805 |
(switch-to-buffer buf-B) |
(switch-to-buffer buf-B) |
806 |
(setq wind-B (selected-window)) |
(setq wind-B (selected-window)) |
807 |
)) |
)) |
808 |
|
|
809 |
(if three-way-comparison |
(if three-way-comparison |
810 |
(or done-C ; Buf C to be set in its own frame |
(or done-C ; Buf C to be set in its own frame |
811 |
;;; or it was set before because use-same-frame = 1 |
;;; or it was set before because use-same-frame = 1 |
817 |
(switch-to-buffer buf-C) |
(switch-to-buffer buf-C) |
818 |
(setq wind-C (selected-window)) |
(setq wind-C (selected-window)) |
819 |
))) |
))) |
820 |
|
|
821 |
(ediff-with-current-buffer control-buf |
(ediff-with-current-buffer control-buf |
822 |
(setq ediff-window-A wind-A |
(setq ediff-window-A wind-A |
823 |
ediff-window-B wind-B |
ediff-window-B wind-B |
824 |
ediff-window-C wind-C) |
ediff-window-C wind-C) |
825 |
|
|
826 |
(setq frame-A (window-frame ediff-window-A) |
(setq frame-A (window-frame ediff-window-A) |
827 |
designated-minibuffer-frame |
designated-minibuffer-frame |
828 |
(window-frame (minibuffer-window frame-A)))) |
(window-frame (minibuffer-window frame-A)))) |
829 |
|
|
830 |
;; It is unlikely that we'll implement a version of ediff-windows that |
;; It is unlikely that we'll implement a version of ediff-windows that |
831 |
;; would compare 3 windows at once. So, we don't use buffer C here. |
;; would compare 3 windows at once. So, we don't use buffer C here. |
832 |
(if ediff-windows-job |
(if ediff-windows-job |
833 |
(progn |
(progn |
834 |
(set-window-start wind-A wind-A-start) |
(set-window-start wind-A wind-A-start) |
835 |
(set-window-start wind-B wind-B-start))) |
(set-window-start wind-B wind-B-start))) |
836 |
|
|
837 |
(ediff-setup-control-frame control-buf designated-minibuffer-frame) |
(ediff-setup-control-frame control-buf designated-minibuffer-frame) |
838 |
)) |
)) |
839 |
|
|
841 |
;; create a new splittable frame if none is found |
;; create a new splittable frame if none is found |
842 |
(defun ediff-skip-unsuitable-frames (&optional ok-unsplittable) |
(defun ediff-skip-unsuitable-frames (&optional ok-unsplittable) |
843 |
(if (ediff-window-display-p) |
(if (ediff-window-display-p) |
844 |
;;(let (last-window) |
(let ((wind-frame (window-frame (selected-window))) |
845 |
(let (seen-windows) |
seen-windows) |
|
;; (memq ... seen-windows) has quadratic behavior, |
|
|
;; but (eq ... last-window) runs into an emacs bug where next-window |
|
|
;; gets stuck in a loop if the only frame is the minibuffer. |
|
|
;; |
|
|
;;(while (and (not (eq (selected-window) last-window)) |
|
846 |
(while (and (not (memq (selected-window) seen-windows)) |
(while (and (not (memq (selected-window) seen-windows)) |
847 |
(or |
(or |
848 |
(ediff-frame-has-dedicated-windows (selected-frame)) |
(ediff-frame-has-dedicated-windows wind-frame) |
849 |
(ediff-frame-iconified-p (selected-frame)) |
(ediff-frame-iconified-p wind-frame) |
850 |
;; skip small windows |
;; skip small windows |
851 |
(< (frame-height (selected-frame)) |
(< (frame-height wind-frame) |
852 |
(* 3 window-min-height)) |
(* 3 window-min-height)) |
853 |
(if ok-unsplittable |
(if ok-unsplittable |
854 |
nil |
nil |
855 |
(ediff-frame-unsplittable-p (selected-frame))))) |
(ediff-frame-unsplittable-p wind-frame)))) |
856 |
;; remember where started |
;; remember history |
|
;;(or last-window (setq last-window (selected-window))) |
|
857 |
(setq seen-windows (cons (selected-window) seen-windows)) |
(setq seen-windows (cons (selected-window) seen-windows)) |
858 |
;; try new window |
;; try new window |
859 |
(other-window 1 t)) |
(other-window 1 t) |
860 |
;;(if (eq (selected-window) last-window) |
(setq wind-frame (window-frame (selected-window))) |
861 |
|
) |
862 |
(if (memq (selected-window) seen-windows) |
(if (memq (selected-window) seen-windows) |
863 |
;; fed up, no appropriate frame |
;; fed up, no appropriate frames |
864 |
(progn |
(setq wind-frame (make-frame '((unsplittable))))) |
865 |
(select-frame (make-frame '((unsplittable))))))))) |
|
866 |
|
(select-frame wind-frame) |
867 |
|
))) |
868 |
|
|
869 |
(defun ediff-frame-has-dedicated-windows (frame) |
(defun ediff-frame-has-dedicated-windows (frame) |
870 |
(let ((cur-fr (selected-frame)) |
(let (ans) |
871 |
ans) |
(walk-windows |
|
(select-frame frame) |
|
|
(walk-windows |
|
872 |
(lambda (wind) (if (window-dedicated-p wind) |
(lambda (wind) (if (window-dedicated-p wind) |
873 |
(setq ans t))) |
(setq ans t))) |
874 |
'ignore-minibuffer |
'ignore-minibuffer |
875 |
frame) |
frame) |
|
(select-frame cur-fr) |
|
876 |
ans)) |
ans)) |
877 |
|
|
878 |
;; window is ok, if it is only one window on the frame, not counting the |
;; window is ok, if it is only one window on the frame, not counting the |
896 |
ctl-frame old-ctl-frame lines |
ctl-frame old-ctl-frame lines |
897 |
;; user-grabbed-mouse |
;; user-grabbed-mouse |
898 |
fheight fwidth adjusted-parameters) |
fheight fwidth adjusted-parameters) |
899 |
|
|
900 |
(ediff-with-current-buffer ctl-buffer |
(ediff-with-current-buffer ctl-buffer |
901 |
(ediff-cond-compile-for-xemacs-or-emacs |
(ediff-cond-compile-for-xemacs-or-emacs |
902 |
(set-buffer-menubar nil) ; xemacs |
(set-buffer-menubar nil) ; xemacs |
904 |
) |
) |
905 |
;;(setq user-grabbed-mouse (ediff-user-grabbed-mouse)) |
;;(setq user-grabbed-mouse (ediff-user-grabbed-mouse)) |
906 |
(run-hooks 'ediff-before-setup-control-frame-hook)) |
(run-hooks 'ediff-before-setup-control-frame-hook)) |
907 |
|
|
908 |
(setq old-ctl-frame (ediff-with-current-buffer ctl-buffer ediff-control-frame)) |
(setq old-ctl-frame (ediff-with-current-buffer ctl-buffer ediff-control-frame)) |
909 |
(ediff-with-current-buffer ctl-buffer |
(ediff-with-current-buffer ctl-buffer |
910 |
(setq ctl-frame (if (frame-live-p old-ctl-frame) |
(setq ctl-frame (if (frame-live-p old-ctl-frame) |
920 |
) |
) |
921 |
(error)) |
(error)) |
922 |
) |
) |
923 |
|
|
924 |
(setq ctl-frame-iconified-p (ediff-frame-iconified-p ctl-frame)) |
(setq ctl-frame-iconified-p (ediff-frame-iconified-p ctl-frame)) |
925 |
(select-frame ctl-frame) |
(select-frame ctl-frame) |
926 |
(if (window-dedicated-p (selected-window)) |
(if (window-dedicated-p (selected-window)) |
927 |
() |
() |
928 |
(delete-other-windows) |
(delete-other-windows) |
929 |
(switch-to-buffer ctl-buffer)) |
(switch-to-buffer ctl-buffer)) |
930 |
|
|
931 |
;; must be before ediff-setup-control-buffer |
;; must be before ediff-setup-control-buffer |
932 |
;; just a precaution--we should be in ctl-buffer already |
;; just a precaution--we should be in ctl-buffer already |
933 |
(ediff-with-current-buffer ctl-buffer |
(ediff-with-current-buffer ctl-buffer |
934 |
(make-local-variable 'frame-title-format) |
(make-local-variable 'frame-title-format) |
935 |
(make-local-variable 'frame-icon-title-format) ; XEmacs |
(make-local-variable 'frame-icon-title-format) ; XEmacs |
936 |
(make-local-variable 'icon-title-format)) ; Emacs |
(make-local-variable 'icon-title-format)) ; Emacs |
937 |
|
|
938 |
(ediff-setup-control-buffer ctl-buffer) |
(ediff-setup-control-buffer ctl-buffer) |
939 |
(setq dont-iconify-ctl-frame |
(setq dont-iconify-ctl-frame |
940 |
(not (string= ediff-help-message ediff-brief-help-message))) |
(not (string= ediff-help-message ediff-brief-help-message))) |
941 |
(setq deiconify-ctl-frame |
(setq deiconify-ctl-frame |
942 |
(and (eq this-command 'ediff-toggle-help) |
(and (eq this-command 'ediff-toggle-help) |
943 |
dont-iconify-ctl-frame)) |
dont-iconify-ctl-frame)) |
944 |
|
|
945 |
;; 1 more line for the modeline |
;; 1 more line for the modeline |
946 |
(setq lines (1+ (count-lines (point-min) (point-max))) |
(setq lines (1+ (count-lines (point-min) (point-max))) |
947 |
fheight lines |
fheight lines |
956 |
(cons 'width fwidth) |
(cons 'width fwidth) |
957 |
(cons 'height fheight)) |
(cons 'height fheight)) |
958 |
) |
) |
959 |
(if ediff-use-long-help-message |
|
960 |
(setq adjusted-parameters |
;; adjust autoraise |
961 |
(cons '(auto-raise . nil) adjusted-parameters))) |
(setq adjusted-parameters |
962 |
|
(cons (if ediff-use-long-help-message |
963 |
|
'(auto-raise . nil) |
964 |
|
'(auto-raise . t)) |
965 |
|
adjusted-parameters)) |
966 |
|
|
967 |
;; In XEmacs, buffer menubar needs to be killed before frame parameters |
;; In XEmacs, buffer menubar needs to be killed before frame parameters |
968 |
;; are changed. |
;; are changed. |
969 |
(if (ediff-has-toolbar-support-p) |
(if (ediff-has-toolbar-support-p) |
980 |
nil ; emacs |
nil ; emacs |
981 |
) |
) |
982 |
) |
) |
983 |
|
|
984 |
;; Under OS/2 (emx) we have to call modify frame parameters twice, in order |
;; Under OS/2 (emx) we have to call modify frame parameters twice, in order |
985 |
;; to make sure that at least once we do it for non-iconified frame. If |
;; to make sure that at least once we do it for non-iconified frame. If |
986 |
;; appears that in the OS/2 port of Emacs, one can't modify frame |
;; appears that in the OS/2 port of Emacs, one can't modify frame |
988 |
;; windows-nt. |
;; windows-nt. |
989 |
(if (memq system-type '(emx windows-nt windows-95)) |
(if (memq system-type '(emx windows-nt windows-95)) |
990 |
(modify-frame-parameters ctl-frame adjusted-parameters)) |
(modify-frame-parameters ctl-frame adjusted-parameters)) |
991 |
|
|
992 |
;; make or zap toolbar (if not requested) |
;; make or zap toolbar (if not requested) |
993 |
(ediff-make-bottom-toolbar ctl-frame) |
(ediff-make-bottom-toolbar ctl-frame) |
994 |
|
|
995 |
(goto-char (point-min)) |
(goto-char (point-min)) |
996 |
|
|
997 |
(modify-frame-parameters ctl-frame adjusted-parameters) |
(modify-frame-parameters ctl-frame adjusted-parameters) |
998 |
(make-frame-visible ctl-frame) |
(make-frame-visible ctl-frame) |
999 |
|
|
1000 |
;; This works around a bug in 19.25 and earlier. There, if frame gets |
;; This works around a bug in 19.25 and earlier. There, if frame gets |
1001 |
;; iconified, the current buffer changes to that of the frame that |
;; iconified, the current buffer changes to that of the frame that |
1002 |
;; becomes exposed as a result of this iconification. |
;; becomes exposed as a result of this iconification. |
1003 |
;; So, we make sure the current buffer doesn't change. |
;; So, we make sure the current buffer doesn't change. |
1004 |
(select-frame ctl-frame) |
(select-frame ctl-frame) |
1005 |
(ediff-refresh-control-frame) |
(ediff-refresh-control-frame) |
1006 |
|
|
1007 |
(cond ((and ediff-prefer-iconified-control-frame |
(cond ((and ediff-prefer-iconified-control-frame |
1008 |
(not ctl-frame-iconified-p) (not dont-iconify-ctl-frame)) |
(not ctl-frame-iconified-p) (not dont-iconify-ctl-frame)) |
1009 |
(iconify-frame ctl-frame)) |
(iconify-frame ctl-frame)) |
1010 |
((or deiconify-ctl-frame (not ctl-frame-iconified-p)) |
((or deiconify-ctl-frame (not ctl-frame-iconified-p)) |
1011 |
(raise-frame ctl-frame))) |
(raise-frame ctl-frame))) |
1012 |
|
|
1013 |
(set-window-dedicated-p (selected-window) t) |
(set-window-dedicated-p (selected-window) t) |
1014 |
|
|
1015 |
;; Now move the frame. We must do it separately due to an obscure bug in |
;; Now move the frame. We must do it separately due to an obscure bug in |
1017 |
(modify-frame-parameters |
(modify-frame-parameters |
1018 |
ctl-frame |
ctl-frame |
1019 |
(funcall ediff-control-frame-position-function ctl-buffer fwidth fheight)) |
(funcall ediff-control-frame-position-function ctl-buffer fwidth fheight)) |
1020 |
|
|
1021 |
;; synchronize so the cursor will move to control frame |
;; synchronize so the cursor will move to control frame |
1022 |
;; per RMS suggestion |
;; per RMS suggestion |
1023 |
(if (ediff-window-display-p) |
(if (ediff-window-display-p) |
1032 |
(ediff-reset-mouse ctl-frame |
(ediff-reset-mouse ctl-frame |
1033 |
(or (eq this-command 'ediff-quit) |
(or (eq this-command 'ediff-quit) |
1034 |
(not (eq ediff-grab-mouse t))))) |
(not (eq ediff-grab-mouse t))))) |
1035 |
|
|
1036 |
(if ediff-xemacs-p |
(if ediff-xemacs-p |
1037 |
(ediff-with-current-buffer ctl-buffer |
(ediff-with-current-buffer ctl-buffer |
1038 |
(ediff-cond-compile-for-xemacs-or-emacs |
(ediff-cond-compile-for-xemacs-or-emacs |
1042 |
(add-hook |
(add-hook |
1043 |
'select-frame-hook 'ediff-xemacs-select-frame-hook nil 'local) |
'select-frame-hook 'ediff-xemacs-select-frame-hook nil 'local) |
1044 |
)) |
)) |
1045 |
|
|
1046 |
(ediff-with-current-buffer ctl-buffer |
(ediff-with-current-buffer ctl-buffer |
1047 |
(run-hooks 'ediff-after-setup-control-frame-hook)) |
(run-hooks 'ediff-after-setup-control-frame-hook)) |
1048 |
)) |
)) |
1049 |
|
|
1050 |
|
|
1051 |
(defun ediff-destroy-control-frame (ctl-buffer) |
(defun ediff-destroy-control-frame (ctl-buffer) |
1052 |
(ediff-with-current-buffer ctl-buffer |
(ediff-with-current-buffer ctl-buffer |
1053 |
(if (and (ediff-window-display-p) (frame-live-p ediff-control-frame)) |
(if (and (ediff-window-display-p) (frame-live-p ediff-control-frame)) |
1062 |
(ediff-skip-unsuitable-frames) |
(ediff-skip-unsuitable-frames) |
1063 |
;;(ediff-reset-mouse nil) |
;;(ediff-reset-mouse nil) |
1064 |
) |
) |
1065 |
|
|
1066 |
|
|
1067 |
;; finds a good place to clip control frame |
;; finds a good place to clip control frame |
1068 |
(defun ediff-make-frame-position (ctl-buffer ctl-frame-width ctl-frame-height) |
(defun ediff-make-frame-position (ctl-buffer ctl-frame-width ctl-frame-height) |
1075 |
(ctl-frame ediff-control-frame) |
(ctl-frame ediff-control-frame) |
1076 |
horizontal-adjustment upward-adjustment |
horizontal-adjustment upward-adjustment |
1077 |
ctl-frame-top ctl-frame-left) |
ctl-frame-top ctl-frame-left) |
1078 |
|
|
1079 |
;; Multiple control frames are clipped based on the value of |
;; Multiple control frames are clipped based on the value of |
1080 |
;; ediff-control-buffer-number. This is done in order not to obscure |
;; ediff-control-buffer-number. This is done in order not to obscure |
1081 |
;; other active control panels. |
;; other active control panels. |
1107 |
;; keep ctl frame within the visible bounds |
;; keep ctl frame within the visible bounds |
1108 |
(setq ctl-frame-top (max ctl-frame-top 1) |
(setq ctl-frame-top (max ctl-frame-top 1) |
1109 |
ctl-frame-left (max ctl-frame-left 1)) |
ctl-frame-left (max ctl-frame-left 1)) |
1110 |
|
|
1111 |
(list (cons 'top ctl-frame-top) |
(list (cons 'top ctl-frame-top) |
1112 |
(cons 'left ctl-frame-left)) |
(cons 'left ctl-frame-left)) |
1113 |
))) |
))) |
1114 |
|
|
1115 |
(defun ediff-xemacs-select-frame-hook () |
(defun ediff-xemacs-select-frame-hook () |
1116 |
(if (and (equal (selected-frame) ediff-control-frame) |
(if (and (equal (selected-frame) ediff-control-frame) |
1117 |
(not ediff-use-long-help-message)) |
(not ediff-use-long-help-message)) |
1118 |
(raise-frame ediff-control-frame))) |
(raise-frame ediff-control-frame))) |
1119 |
|
|
1120 |
(defun ediff-make-wide-display () |
(defun ediff-make-wide-display () |
1121 |
"Construct an alist of parameters for the wide display. |
"Construct an alist of parameters for the wide display. |
1122 |
Saves the old frame parameters in `ediff-wide-display-orig-parameters'. |
Saves the old frame parameters in `ediff-wide-display-orig-parameters'. |
1135 |
ediff-wide-display-frame frame-A) |
ediff-wide-display-frame frame-A) |
1136 |
(modify-frame-parameters frame-A (list (cons 'left cw) |
(modify-frame-parameters frame-A (list (cons 'left cw) |
1137 |
(cons 'width wd))))) |
(cons 'width wd))))) |
1138 |
|
|
1139 |
|
|
1140 |
|
|
1141 |
;; Revise the mode line to display which difference we have selected |
;; Revise the mode line to display which difference we have selected |
1142 |
;; Also resets modelines of buffers A/B, since they may be clobbered by |
;; Also resets modelines of buffers A/B, since they may be clobbered by |
1143 |
;; anothe invocations of Ediff. |
;; anothe invocations of Ediff. |
1144 |
(defun ediff-refresh-mode-lines () |
(defun ediff-refresh-mode-lines () |
1145 |
(let (buf-A-state-diff buf-B-state-diff buf-C-state-diff buf-C-state-merge) |
(let (buf-A-state-diff buf-B-state-diff buf-C-state-diff buf-C-state-merge) |
1146 |
|
|
1147 |
(if (ediff-valid-difference-p) |
(if (ediff-valid-difference-p) |
1148 |
(setq |
(setq |
1149 |
buf-C-state-diff (ediff-get-state-of-diff ediff-current-difference 'C) |
buf-C-state-diff (ediff-get-state-of-diff ediff-current-difference 'C) |
1172 |
(setq buf-A-state-diff "" |
(setq buf-A-state-diff "" |
1173 |
buf-B-state-diff "" |
buf-B-state-diff "" |
1174 |
buf-C-state-diff "")) |
buf-C-state-diff "")) |
1175 |
|
|
1176 |
;; control buffer format |
;; control buffer format |
1177 |
(setq mode-line-format |
(setq mode-line-format |
1178 |
(if (ediff-narrow-control-frame-p) |
(if (ediff-narrow-control-frame-p) |
1185 |
(ediff-make-wide-control-buffer-id))) |
(ediff-make-wide-control-buffer-id))) |
1186 |
;; Force mode-line redisplay |
;; Force mode-line redisplay |
1187 |
(force-mode-line-update) |
(force-mode-line-update) |
1188 |
|
|
1189 |
(if (and (ediff-window-display-p) (frame-live-p ediff-control-frame)) |
(if (and (ediff-window-display-p) (frame-live-p ediff-control-frame)) |
1190 |
(ediff-refresh-control-frame)) |
(ediff-refresh-control-frame)) |
1191 |
|
|
1192 |
(ediff-with-current-buffer ediff-buffer-A |
(ediff-with-current-buffer ediff-buffer-A |
1193 |
(setq ediff-diff-status buf-A-state-diff) |
(setq ediff-diff-status buf-A-state-diff) |
1194 |
(ediff-strip-mode-line-format) |
(ediff-strip-mode-line-format) |
1225 |
(t "")) |
(t "")) |
1226 |
mode-line-format)))) |
mode-line-format)))) |
1227 |
)) |
)) |
1228 |
|
|
1229 |
|
|
1230 |
(defun ediff-refresh-control-frame () |
(defun ediff-refresh-control-frame () |
1231 |
(if ediff-emacs-p |
(if ediff-emacs-p |
1232 |
;; set frame/icon titles for Emacs |
;; set frame/icon titles for Emacs |
1240 |
frame-icon-title-format (ediff-make-narrow-control-buffer-id)) |
frame-icon-title-format (ediff-make-narrow-control-buffer-id)) |
1241 |
;; force an update of the frame title |
;; force an update of the frame title |
1242 |
(modify-frame-parameters ediff-control-frame '(())))) |
(modify-frame-parameters ediff-control-frame '(())))) |
1243 |
|
|
1244 |
|
|
1245 |
(defun ediff-make-narrow-control-buffer-id (&optional skip-name) |
(defun ediff-make-narrow-control-buffer-id (&optional skip-name) |
1246 |
(concat |
(concat |
1247 |
(if skip-name |
(if skip-name |
1260 |
(concat |
(concat |
1261 |
(cdr (assoc 'name ediff-control-frame-parameters)) |
(cdr (assoc 'name ediff-control-frame-parameters)) |
1262 |
ediff-control-buffer-suffix)) |
ediff-control-buffer-suffix)) |
1263 |
|
|
1264 |
(defun ediff-make-wide-control-buffer-id () |
(defun ediff-make-wide-control-buffer-id () |
1265 |
(cond ((< ediff-current-difference 0) |
(cond ((< ediff-current-difference 0) |
1266 |
(list (format "%%b At start of %d diffs" |
(list (format "%%b At start of %d diffs" |
1281 |
(if ediff-xemacs-p |
(if ediff-xemacs-p |
1282 |
(get-buffer-window buff t) |
(get-buffer-window buff t) |
1283 |
(get-buffer-window buff 'visible)))) |
(get-buffer-window buff 'visible)))) |
1284 |
|
|
1285 |
|
|
1286 |
;;; Functions to decide when to redraw windows |
;;; Functions to decide when to redraw windows |
1287 |
|
|
1288 |
(defun ediff-keep-window-config (control-buf) |
(defun ediff-keep-window-config (control-buf) |
1289 |
(and (eq control-buf (current-buffer)) |
(and (eq control-buf (current-buffer)) |
1290 |
(/= (buffer-size) 0) |
(/= (buffer-size) 0) |
1293 |
(A-wind ediff-window-A) |
(A-wind ediff-window-A) |
1294 |
(B-wind ediff-window-B) |
(B-wind ediff-window-B) |
1295 |
(C-wind ediff-window-C)) |
(C-wind ediff-window-C)) |
1296 |
|
|
1297 |
(and |
(and |
1298 |
(ediff-window-visible-p A-wind) |
(ediff-window-visible-p A-wind) |
1299 |
(ediff-window-visible-p B-wind) |
(ediff-window-visible-p B-wind) |