]> code.delx.au - gnu-emacs/blobdiff - lisp/ediff-wind.el
(fast_install): Bring commands up-to-date, and fix typo.
[gnu-emacs] / lisp / ediff-wind.el
index f4033cf5b8572a78c3febf83e3c54c28cb90b4a7..9ae1673250d01724f4772f1b879a2a59efbc5d88 100644 (file)
@@ -1,6 +1,6 @@
 ;;; ediff-wind.el --- window manipulation utilities
 
-;; Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.sunysb.edu>
 
@@ -22,8 +22,8 @@
 ;; Boston, MA 02111-1307, USA.
 
 ;;; Code:
-
-(require 'ediff-init)
+        
+(provide 'ediff-wind)
 
 ;; Compiler pacifier
 (defvar icon-title-format)
 (defvar right-toolbar-width)
 (defvar default-menubar)
 (defvar frame-icon-title-format)
+(defvar ediff-diff-status)
+(defvar ediff-emacs-p)
+
+(eval-when-compile
+  (let ((load-path (cons (expand-file-name ".") load-path)))
+    (or (featurep 'ediff-init)
+       (load "ediff-init.el" nil nil 'nosuffix))
+    (or (featurep 'ediff-util)
+       (load "ediff-util.el" nil nil 'nosuffix))
+    (or (featurep 'ediff-help)
+       (load "ediff-help.el" nil nil 'nosuffix))
+    (or (featurep 'ediff-tbar)
+       ediff-emacs-p
+       (load "ediff-tbar.el" 'noerror nil 'nosuffix))
+    ))
 ;; end pacifier
 
+(require 'ediff-init)
 
-(defvar ediff-window-setup-function (if (ediff-window-display-p)
+;; be careful with ediff-tbar
+(if ediff-xemacs-p
+    (condition-case nil
+       (require 'ediff-tbar)
+      (error
+       (defun ediff-compute-toolbar-width () 0)))
+  (defun ediff-compute-toolbar-width () 0))
+
+(defgroup ediff-window nil
+  "Ediff window manipulation"
+  :prefix "ediff-"
+  :group 'ediff
+  :group 'frames)
+
+
+(defcustom ediff-window-setup-function (if (ediff-window-display-p)
                                        'ediff-setup-windows-multiframe
                                      'ediff-setup-windows-plain)
   "*Function called to set up windows.
 Ediff provides a choice of two functions: ediff-setup-windows-plain, for
 doing everything in one frame, and ediff-setup-windows-multiframe,
-which sets the control panel in a separate frame. Also, if the latter
+which sets the control panel in a separate frame.  Also, if the latter
 function detects that one of the buffers A/B is seen in some other frame,
 it will try to keep that buffer in that frame.
 
@@ -59,7 +90,9 @@ The basic guidelines:
        buffer-A, buffer-B, buffer-C, control-buffer
        Buffer C may not be used in jobs that compare only two buffers.
 If you plan to do something fancy, take a close look at how the two
-provided functions are written.")
+provided functions are written."
+  :type 'function
+  :group 'ediff-window)
 
 ;; indicates if we are in a multiframe setup
 (ediff-defvar-local ediff-multiframe nil "")
@@ -79,22 +112,35 @@ provided functions are written.")
 ;; Used to minimize the need to rearrange windows.
 (ediff-defvar-local ediff-window-config-saved "" "")
 
+;; Association between buff-type and ediff-window-*
+(defconst ediff-window-alist
+  '((A . ediff-window-A)
+    (?A . ediff-window-A)
+    (B . ediff-window-B)
+    (?B . ediff-window-B)
+    (C . ediff-window-C)
+    (?C . ediff-window-C)))
 
-(defvar ediff-split-window-function 'split-window-vertically
+
+(defcustom ediff-split-window-function 'split-window-vertically
   "*The function used to split the main window between buffer-A and buffer-B.
 You can set it to a horizontal split instead of the default vertical split
 by setting this variable to `split-window-horizontally'.
 You can also have your own function to do fancy splits.
 This variable has no effect when buffer-A/B are shown in different frames.
-In this case, Ediff will use those frames to display these buffers.")
+In this case, Ediff will use those frames to display these buffers."
+  :type 'function
+  :group 'ediff-window)
 
-(defvar ediff-merge-split-window-function 'split-window-horizontally
+(defcustom ediff-merge-split-window-function 'split-window-horizontally
   "*The function used to split the main window between buffer-A and buffer-B.
 You can set it to a vertical split instead of the default horizontal split
 by setting this variable to `split-window-vertically'.
 You can also have your own function to do fancy splits.
 This variable has no effect when buffer-A/B/C are shown in different frames.
-In this case, Ediff will use those frames to display these buffers.")
+In this case, Ediff will use those frames to display these buffers."
+  :type 'function
+  :group 'ediff-window)
 
 (defconst ediff-control-frame-parameters
   (list 
@@ -108,6 +154,9 @@ In this case, Ediff will use those frames to display these buffers.")
    ;; don't lower and auto-raise
    '(auto-lower . nil)
    '(auto-raise . t)
+   '(visibility . nil)
+   ;; make initial frame small to avoid distraction
+   '(width . 1) '(height . 1)
    ;; this blocks queries from  window manager as to where to put
    ;; ediff's control frame. we put the frame outside the display,
    ;; so the initial frame won't jump all over the screen
@@ -119,7 +168,7 @@ In this case, Ediff will use those frames to display these buffers.")
                 3000))
    )
   "Frame parameters for displaying Ediff Control Panel.
-Do not specify width and height here. These are computed automatically.")
+Used internally---not a user option.")
 
 ;; position of the mouse; used to decide whether to warp the mouse into ctl
 ;; frame
@@ -129,40 +178,50 @@ Do not specify width and height here. These are computed automatically.")
 (defvar ediff-mouse-pixel-threshold 30
   "If the user moves mouse more than this many pixels, Ediff won't warp mouse into control window.")
 
-(defvar ediff-grab-mouse t
+(defcustom ediff-grab-mouse t
   "*If t, Ediff will always grab the mouse and put it in the control frame.
 If 'maybe, Ediff will do it sometimes, but not after operations that require
-relatively long time. If nil, the mouse will be entirely user's
-responsibility.")
+relatively long time.  If nil, the mouse will be entirely user's
+responsibility."
+  :type 'boolean
+  :group 'ediff-window)
 
-(defvar ediff-control-frame-position-function 'ediff-make-frame-position
+(defcustom ediff-control-frame-position-function 'ediff-make-frame-position
   "Function to call to determine the desired location for the control panel.
 Expects three parameters: the control buffer, the desired width and height
-of the control frame. It returns an association list
-of the form \(\(top . <position>\) \(left . <position>\)\)")
+of the control frame.  It returns an association list
+of the form \(\(top . <position>\) \(left . <position>\)\)"
+  :type 'function
+  :group 'ediff-window)
 
-(defvar ediff-control-frame-upward-shift (if ediff-xemacs-p 42 14)
+(defcustom ediff-control-frame-upward-shift 42
   "*The upward shift of control frame from the top of buffer A's frame.
 Measured in pixels.
 This is used by the default control frame positioning function,
-`ediff-make-frame-position'. This variable is provided for easy
-customization of the default.")
+`ediff-make-frame-position'.  This variable is provided for easy
+customization of the default control frame positioning."
+  :type 'integer
+  :group 'ediff-window)
 
-(defvar ediff-narrow-control-frame-leftward-shift (if ediff-xemacs-p 7 3)
+(defcustom ediff-narrow-control-frame-leftward-shift (if ediff-xemacs-p 7 3)
   "*The leftward shift of control frame from the right edge of buf A's frame.
 Measured in characters.
 This is used by the default control frame positioning function,
 `ediff-make-frame-position' to adjust the position of the control frame
-when it shows the short menu. This variable is provided for easy
-customization of the default.")
+when it shows the short menu.  This variable is provided for easy
+customization of the default."
+  :type 'integer
+  :group 'ediff-window)
 
-(defvar ediff-wide-control-frame-rightward-shift 7
+(defcustom ediff-wide-control-frame-rightward-shift 7
   "*The rightward shift of control frame from the left edge of buf A's frame.
 Measured in characters.
 This is used by the default control frame positioning function,
 `ediff-make-frame-position' to adjust the position of the control frame
-when it shows the full menu. This variable is provided for easy
-customization of the default.")
+when it shows the full menu.  This variable is provided for easy
+customization of the default."
+  :type 'integer
+  :group 'ediff-window)
 
 
 ;; Wide frame display
@@ -177,7 +236,7 @@ display off.")
   "Frame to be used for wide display.")
 (ediff-defvar-local ediff-make-wide-display-function 'ediff-make-wide-display
   "The value is a function that is called to create a wide display.
-The function is called without arguments. It should resize the frame in
+The function is called without arguments.  It should resize the frame in
 which buffers A, B, and C are to be displayed, and it should save the old
 frame parameters in `ediff-wide-display-orig-parameters'.
 The variable `ediff-wide-display-frame' should be set to contain
@@ -186,22 +245,24 @@ the frame used for the wide display.")
 ;; Frame used for the control panel in a windowing system.
 (ediff-defvar-local ediff-control-frame nil "")
 
-(defvar ediff-prefer-iconified-control-frame nil
+(defcustom ediff-prefer-iconified-control-frame nil
   "*If t, keep control panel iconified when help message is off.
 This has effect only on a windowing system.
 If t, hitting `?' to toggle control panel off iconifies it.
 
 This is only useful in Emacs and only for certain kinds of window managers,
 such as TWM and its derivatives, since the window manager must permit
-keyboard input to go into icons. XEmacs completely ignores keyboard input
-into icons, regardless of the window manager.")
+keyboard input to go into icons.  XEmacs completely ignores keyboard input
+into icons, regardless of the window manager."
+  :type 'boolean
+  :group 'ediff-window)
 
 ;;; Functions
 
 (defun ediff-get-window-by-clicking (wind prev-wind wind-number)
   (let (event)
     (message
-     "Select windows by clicking. Please click on Window %d " wind-number)
+     "Select windows by clicking.  Please click on Window %d " wind-number)
     (while (not (ediff-mouse-event-p (setq event (ediff-read-event))))
       (if (sit-for 1) ; if sequence of events, wait till the final word
          (beep 1))
@@ -257,7 +318,7 @@ into icons, regardless of the window manager.")
   
   (or (ediff-keep-window-config control-buffer)
       (funcall 
-       (ediff-eval-in-buffer control-buffer ediff-window-setup-function)
+       (ediff-with-current-buffer control-buffer ediff-window-setup-function)
        buffer-A buffer-B buffer-C control-buffer))
   (run-hooks 'ediff-after-setup-windows-hook))
 
@@ -265,7 +326,7 @@ into icons, regardless of the window manager.")
 ;; Usually used without windowing systems
 ;; With windowing, we want to use dedicated frames.
 (defun ediff-setup-windows-plain (buffer-A buffer-B buffer-C control-buffer)
-  (ediff-eval-in-buffer control-buffer
+  (ediff-with-current-buffer control-buffer
     (setq ediff-multiframe nil))
   (if ediff-merge-job
       (ediff-setup-windows-plain-merge
@@ -280,7 +341,7 @@ into icons, regardless of the window manager.")
        split-window-function 
        merge-window-share merge-window-lines
        wind-A wind-B wind-C)
-    (ediff-eval-in-buffer control-buffer
+    (ediff-with-current-buffer control-buffer
       (setq merge-window-share ediff-merge-window-share
            ;; this lets us have local versions of ediff-split-window-function
            split-window-function ediff-split-window-function))
@@ -315,7 +376,7 @@ into icons, regardless of the window manager.")
     (switch-to-buffer buf-B)
     (setq wind-B (selected-window))
          
-    (ediff-eval-in-buffer control-buffer
+    (ediff-with-current-buffer control-buffer
       (setq ediff-window-A wind-A
            ediff-window-B wind-B
            ediff-window-C wind-C))
@@ -333,7 +394,7 @@ into icons, regardless of the window manager.")
        split-window-function wind-width-or-height
        three-way-comparison
        wind-A-start wind-B-start wind-A wind-B wind-C)
-    (ediff-eval-in-buffer control-buffer
+    (ediff-with-current-buffer control-buffer
       (setq wind-A-start (ediff-overlay-start
                          (ediff-get-value-according-to-buffer-type
                           'A ediff-narrow-bounds))
@@ -379,7 +440,7 @@ into icons, regardless of the window manager.")
          (switch-to-buffer buf-C)
          (setq wind-C (selected-window))))
          
-    (ediff-eval-in-buffer control-buffer
+    (ediff-with-current-buffer control-buffer
       (setq ediff-window-A wind-A
            ediff-window-B wind-B
            ediff-window-C wind-C))
@@ -398,7 +459,7 @@ into icons, regardless of the window manager.")
     
 ;; dispatch an appropriate window setup function
 (defun ediff-setup-windows-multiframe (buf-A buf-B buf-C control-buf)
-  (ediff-eval-in-buffer control-buf
+  (ediff-with-current-buffer control-buf
     (setq ediff-multiframe t))
   (if ediff-merge-job
       (ediff-setup-windows-multiframe-merge buf-A buf-B buf-C control-buf)
@@ -429,10 +490,10 @@ into icons, regardless of the window manager.")
         (frame-C (if wind-C (window-frame wind-C)))
         ;; on wide display, do things in one frame
         (force-one-frame 
-         (ediff-eval-in-buffer control-buf ediff-wide-display-p))
+         (ediff-with-current-buffer control-buf ediff-wide-display-p))
         ;; this lets us have local versions of ediff-split-window-function
         (split-window-function 
-         (ediff-eval-in-buffer control-buf ediff-split-window-function))
+         (ediff-with-current-buffer control-buf ediff-split-window-function))
         (orig-wind (selected-window))
         (orig-frame (selected-frame))
         (use-same-frame (or force-one-frame
@@ -454,7 +515,7 @@ into icons, regardless of the window manager.")
         ;; use-same-frame-for-AB implies wind A and B are ok for display
         (use-same-frame-for-AB (and (not use-same-frame)
                                     (eq frame-A frame-B)))
-        (merge-window-share (ediff-eval-in-buffer control-buf
+        (merge-window-share (ediff-with-current-buffer control-buf
                               ediff-merge-window-share))
         merge-window-lines
         designated-minibuffer-frame
@@ -512,8 +573,12 @@ into icons, regardless of the window manager.")
     
     (if use-same-frame
        (let ((window-min-height 1))
-         ;; avoid dedicated and non-splittable windows
-         (ediff-skip-unsuitable-frames)
+         (if (and (eq frame-A frame-B)
+                  (eq frame-B frame-C)
+                  (frame-live-p frame-A))
+             (select-frame frame-A)
+           ;; avoid dedicated and non-splittable windows
+           (ediff-skip-unsuitable-frames))
          (delete-other-windows)
          (setq merge-window-lines
                (max 2 (round (* (window-height) merge-window-share))))
@@ -572,7 +637,7 @@ into icons, regardless of the window manager.")
          (setq wind-C (selected-window))
          ))
     
-    (ediff-eval-in-buffer control-buf
+    (ediff-with-current-buffer control-buf
       (setq ediff-window-A wind-A
            ediff-window-B wind-B
            ediff-window-C wind-C)
@@ -591,7 +656,7 @@ into icons, regardless of the window manager.")
 ;;;    If it is not seen, use the current frame.
 ;;;    If both buffers are not seen, they share the current frame.  If one
 ;;;    of the buffers is not seen, it is placed in the current frame (where
-;;;    ediff started). If that frame is displaying the other buffer, it is
+;;;    ediff started).  If that frame is displaying the other buffer, it is
 ;;;    shared between the two buffers.
 ;;;    However, if we decide to put both buffers in one frame
 ;;;    and the selected frame isn't splittable, we create a new frame and
@@ -609,16 +674,16 @@ into icons, regardless of the window manager.")
         (frame-A (if wind-A (window-frame wind-A)))
         (frame-B (if wind-B (window-frame wind-B)))
         (frame-C (if wind-C (window-frame wind-C)))
-        (ctl-frame-exists-p (ediff-eval-in-buffer control-buf
+        (ctl-frame-exists-p (ediff-with-current-buffer control-buf
                               (frame-live-p ediff-control-frame)))
         ;; on wide display, do things in one frame
         (force-one-frame 
-         (ediff-eval-in-buffer control-buf ediff-wide-display-p))
+         (ediff-with-current-buffer control-buf ediff-wide-display-p))
         ;; this lets us have local versions of ediff-split-window-function
         (split-window-function 
-         (ediff-eval-in-buffer control-buf ediff-split-window-function))
+         (ediff-with-current-buffer control-buf ediff-split-window-function))
         (three-way-comparison
-         (ediff-eval-in-buffer control-buf ediff-3way-comparison-job))
+         (ediff-with-current-buffer control-buf ediff-3way-comparison-job))
         (orig-wind (selected-window))
         (use-same-frame (or force-one-frame
                             (eq frame-A frame-B)
@@ -641,7 +706,7 @@ into icons, regardless of the window manager.")
         designated-minibuffer-frame
         done-A done-B done-C)
     
-    (ediff-eval-in-buffer control-buf
+    (ediff-with-current-buffer control-buf
       (setq wind-A-start (ediff-overlay-start
                          (ediff-get-value-according-to-buffer-type
                           'A ediff-narrow-bounds))
@@ -675,8 +740,10 @@ into icons, regardless of the window manager.")
     
     (if use-same-frame
        (let (wind-width-or-height) ; this affects 3way setups only
-         ;; avoid dedicated and non-splittable windows
-         (ediff-skip-unsuitable-frames)
+         (if (and (eq frame-A frame-B) (frame-live-p frame-A))
+             (select-frame frame-A)
+           ;; avoid dedicated and non-splittable windows
+           (ediff-skip-unsuitable-frames))
          (delete-other-windows)
          (switch-to-buffer buf-A)
          (setq wind-A (selected-window))
@@ -740,7 +807,7 @@ into icons, regardless of the window manager.")
              (setq wind-C (selected-window))
              )))
     
-    (ediff-eval-in-buffer control-buf
+    (ediff-with-current-buffer control-buf
       (setq ediff-window-A wind-A
            ediff-window-B wind-B
            ediff-window-C wind-C)
@@ -750,7 +817,7 @@ into icons, regardless of the window manager.")
            (window-frame (minibuffer-window frame-A))))
     
     ;; It is unlikely that we'll implement a version of ediff-windows that
-    ;; 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.
     (if ediff-windows-job
        (progn
          (set-window-start wind-A wind-A-start)
@@ -768,8 +835,12 @@ into icons, regardless of the window manager.")
                    (or
                     (ediff-frame-has-dedicated-windows (selected-frame))
                     (ediff-frame-iconified-p (selected-frame))
+                    ;; skip small frames
                     (< (frame-height (selected-frame))
                        (* 3 window-min-height))
+                    ;; skip small windows
+                    (< (window-height (selected-window))
+                       (* 3 window-min-height))
                     (if ok-unsplittable
                         nil
                       (ediff-frame-unsplittable-p (selected-frame)))))
@@ -787,9 +858,8 @@ into icons, regardless of the window manager.")
        ans)
     (select-frame frame)
     (walk-windows 
-     (function (lambda (wind)
-                (if (window-dedicated-p wind)
-                    (setq ans t))))
+     (lambda (wind) (if (window-dedicated-p wind)
+                       (setq ans t)))
      'ignore-minibuffer
      frame)
     (select-frame cur-fr)
@@ -817,13 +887,13 @@ into icons, regardless of the window manager.")
        ;; user-grabbed-mouse
        fheight fwidth adjusted-parameters) 
        
-    (ediff-eval-in-buffer ctl-buffer
+    (ediff-with-current-buffer ctl-buffer
       (if ediff-xemacs-p (set-buffer-menubar nil))
       ;;(setq user-grabbed-mouse (ediff-user-grabbed-mouse))
       (run-hooks 'ediff-before-setup-control-frame-hook))
   
-    (setq old-ctl-frame (ediff-eval-in-buffer ctl-buffer ediff-control-frame))
-    (ediff-eval-in-buffer ctl-buffer
+    (setq old-ctl-frame (ediff-with-current-buffer ctl-buffer ediff-control-frame))
+    (ediff-with-current-buffer ctl-buffer
       (setq ctl-frame (if (frame-live-p old-ctl-frame)
                          old-ctl-frame
                        (make-frame ediff-control-frame-parameters))
@@ -838,7 +908,7 @@ into icons, regardless of the window manager.")
       
     ;; must be before ediff-setup-control-buffer
     ;; just a precaution--we should be in ctl-buffer already
-    (ediff-eval-in-buffer ctl-buffer
+    (ediff-with-current-buffer ctl-buffer
       (make-local-variable 'frame-title-format)
       (make-local-variable 'frame-icon-title-format)   ; XEmacs
       (make-local-variable 'icon-title-format))        ; Emacs
@@ -853,48 +923,50 @@ into icons, regardless of the window manager.")
     ;; 1 more line for the modeline
     (setq lines (1+ (count-lines (point-min) (point-max)))
          fheight lines
-         fwidth (+ (ediff-help-message-line-length) 2)
-         adjusted-parameters (append (list
-                                      ;; possibly change surrogate minibuffer
-                                      (cons 'minibuffer
-                                            (minibuffer-window
-                                             designated-minibuffer-frame))
-                                      (cons 'width fwidth)
-                                      (cons 'height fheight))
-                                     (funcall
-                                      ediff-control-frame-position-function
-                                      ctl-buffer fwidth fheight)))
+         fwidth (max (+ (ediff-help-message-line-length) 2)
+                     (ediff-compute-toolbar-width))
+         adjusted-parameters
+         (list
+          ;; possibly change surrogate minibuffer
+          (cons 'minibuffer
+                (minibuffer-window
+                 designated-minibuffer-frame))
+          (cons 'width fwidth)
+          (cons 'height fheight))
+         )
     (if ediff-use-long-help-message
        (setq adjusted-parameters
              (cons '(auto-raise . nil) adjusted-parameters)))
     
     ;; In XEmacs, buffer menubar needs to be killed before frame parameters
     ;; are changed. 
-    (if ediff-xemacs-p
+    (if (ediff-has-toolbar-support-p)
        (progn
+         (set-specifier top-toolbar-height (list ctl-frame 2))
+         (sit-for 0)
          (set-specifier top-toolbar-height (list ctl-frame 0))
-         (set-specifier bottom-toolbar-height (list ctl-frame 0))
+         ;;(set-specifier bottom-toolbar-height (list ctl-frame 0))
          (set-specifier left-toolbar-width (list ctl-frame 0))
          (set-specifier right-toolbar-width (list ctl-frame 0))
-         ;; XEmacs needed a redisplay, as it had trouble setting
-         ;; height correctly otherwise.
-         ;;(sit-for 0)
          ))
     
     ;; Under OS/2 (emx) we have to call modify frame parameters twice, in order
-    ;; 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
     ;; appears that in the OS/2 port of Emacs, one can't modify frame
-    ;; parameters of iconified frames. As a precaution, we do likewise for
+    ;; parameters of iconified frames.  As a precaution, we do likewise for
     ;; windows-nt.
     (if (memq system-type '(emx windows-nt windows-95))
        (modify-frame-parameters ctl-frame adjusted-parameters))
       
-    (goto-char (point-min))
+    ;; make or zap toolbar (if not requested)
+    (ediff-make-bottom-toolbar ctl-frame)
     
+    (goto-char (point-min))
+
     (modify-frame-parameters ctl-frame adjusted-parameters)
     (make-frame-visible ctl-frame)
     
-    ;; 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
     ;; iconified, the current buffer changes to that of the frame that
     ;; becomes exposed as a result of this iconification.
     ;; So, we make sure the current buffer doesn't change.
@@ -908,6 +980,12 @@ into icons, regardless of the window manager.")
           (raise-frame ctl-frame)))
     
     (set-window-dedicated-p (selected-window) t)
+
+    ;; Now move the frame.  We must do it separately due to an obscure bug in
+    ;; XEmacs
+    (modify-frame-parameters
+     ctl-frame
+     (funcall ediff-control-frame-position-function ctl-buffer fwidth fheight))
       
     ;; synchronize so the cursor will move to control frame
     ;; per RMS suggestion
@@ -925,17 +1003,18 @@ into icons, regardless of the window manager.")
                               (not (eq ediff-grab-mouse t)))))
        
     (if ediff-xemacs-p
-       (ediff-eval-in-buffer ctl-buffer
+       (ediff-with-current-buffer ctl-buffer
          (make-local-hook 'select-frame-hook)
          (add-hook 'select-frame-hook 'ediff-xemacs-select-frame-hook nil t)
          ))
        
-    (ediff-eval-in-buffer ctl-buffer
+    (ediff-with-current-buffer ctl-buffer
       (run-hooks 'ediff-after-setup-control-frame-hook))
     ))
+
     
 (defun ediff-destroy-control-frame (ctl-buffer)
-  (ediff-eval-in-buffer ctl-buffer
+  (ediff-with-current-buffer ctl-buffer
     (if (and (ediff-window-display-p) (frame-live-p ediff-control-frame))
        (let ((ctl-frame ediff-control-frame))
          (if ediff-xemacs-p
@@ -950,7 +1029,7 @@ into icons, regardless of the window manager.")
 
 ;; finds a good place to clip control frame
 (defun ediff-make-frame-position (ctl-buffer ctl-frame-width ctl-frame-height)
-  (ediff-eval-in-buffer ctl-buffer
+  (ediff-with-current-buffer ctl-buffer
     (let* ((frame-A (window-frame ediff-window-A))
           (frame-A-parameters (frame-parameters frame-A))
           (frame-A-top (eval (cdr (assoc 'top frame-A-parameters))))
@@ -961,7 +1040,7 @@ into icons, regardless of the window manager.")
           ctl-frame-top ctl-frame-left) 
       
       ;; Multiple control frames are clipped based on the value of
-      ;; ediff-control-buffer-number. This is done in order not to obscure
+      ;; ediff-control-buffer-number.  This is done in order not to obscure
       ;; other active control panels.
       (setq horizontal-adjustment (* 2 ediff-control-buffer-number)
            upward-adjustment (* -14 ediff-control-buffer-number))
@@ -1059,9 +1138,9 @@ It assumes that it is called from within the control buffer."
     
     ;; control buffer format
     (setq mode-line-format
-         (list (if (ediff-narrow-control-frame-p) "   " "-- ")
-               mode-line-buffer-identification
-               "      Quick Help"))
+         (if (ediff-narrow-control-frame-p)
+             (list "   " mode-line-buffer-identification)
+           (list "-- " mode-line-buffer-identification "        Quick Help")))
     ;; control buffer id
     (setq mode-line-buffer-identification 
          (if (ediff-narrow-control-frame-p)
@@ -1073,27 +1152,27 @@ It assumes that it is called from within the control buffer."
     (if (and (ediff-window-display-p) (frame-live-p ediff-control-frame))
        (ediff-refresh-control-frame))
     
-    (ediff-eval-in-buffer ediff-buffer-A
+    (ediff-with-current-buffer ediff-buffer-A
       (setq ediff-diff-status buf-A-state-diff)
       (ediff-strip-mode-line-format)
       (setq mode-line-format
            (list " A: " 'ediff-diff-status mode-line-format))
       (force-mode-line-update))
-    (ediff-eval-in-buffer ediff-buffer-B
+    (ediff-with-current-buffer ediff-buffer-B
       (setq ediff-diff-status buf-B-state-diff)
       (ediff-strip-mode-line-format)
       (setq mode-line-format
            (list " B: " 'ediff-diff-status mode-line-format))
       (force-mode-line-update))
     (if ediff-3way-job
-       (ediff-eval-in-buffer ediff-buffer-C
+       (ediff-with-current-buffer ediff-buffer-C
          (setq ediff-diff-status buf-C-state-diff)
          (ediff-strip-mode-line-format)
          (setq mode-line-format
                (list " C: " 'ediff-diff-status mode-line-format))
          (force-mode-line-update)))
     (if (ediff-buffer-live-p ediff-ancestor-buffer)
-       (ediff-eval-in-buffer ediff-ancestor-buffer
+       (ediff-with-current-buffer ediff-ancestor-buffer
          (ediff-strip-mode-line-format)
          ;; we keep the second dummy string in the mode line format of the
          ;; ancestor, since for other buffers Ediff prepends 2 strings and
@@ -1172,7 +1251,7 @@ It assumes that it is called from within the control buffer."
 (defun ediff-keep-window-config (control-buf)
   (and (eq control-buf (current-buffer))
        (/= (buffer-size) 0)
-       (ediff-eval-in-buffer control-buf
+       (ediff-with-current-buffer control-buf
         (let ((ctl-wind ediff-control-window)
               (A-wind ediff-window-A)
               (B-wind ediff-window-B)
@@ -1198,10 +1277,8 @@ It assumes that it is called from within the control buffer."
 
 ;;; Local Variables:
 ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun)
-;;; eval: (put 'ediff-eval-in-buffer 'lisp-indent-hook 1)
+;;; eval: (put 'ediff-with-current-buffer 'lisp-indent-hook 1)
+;;; eval: (put 'ediff-with-current-buffer 'edebug-form-spec '(form body))
 ;;; End:
 
-(provide 'ediff-wind)
-
-
 ;;; ediff-wind.el ends here