]> code.delx.au - gnu-emacs/blobdiff - lisp/vc/ediff-wind.el
Update copyright year to 2016
[gnu-emacs] / lisp / vc / ediff-wind.el
index 5a7fa0bf9505a1c0b95ce1670a2c9cee71ab171a..8dbb2f8219873a8c625fabd4279098e1d429d9a8 100644 (file)
@@ -1,6 +1,6 @@
 ;;; ediff-wind.el --- window manipulation utilities
 
-;; Copyright (C) 1994-1997, 2000-201 Free Software Foundation, Inc.
+;; Copyright (C) 1994-1997, 2000-2016 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
 ;; Package: ediff
 
 ;; declare-function does not exist in XEmacs
 (eval-and-compile
-  (unless (fboundp 'declare-function) (defmacro declare-function (&rest  r))))
+  (unless (fboundp 'declare-function) (defmacro declare-function (&rest  _r))))
 
-(eval-when-compile
-  (require 'ediff-util)
-  (require 'ediff-help))
+(require 'ediff-init)
+(require 'ediff-help)
 ;; end pacifier
 
-(require 'ediff-init)
 
 ;; be careful with ediff-tbar
-(if (featurep 'xemacs)
-    (require 'ediff-tbar)
-  (defun ediff-compute-toolbar-width () 0))
+(eval-and-compile
+  (if (featurep 'xemacs)
+      (require 'ediff-tbar)
+    (defun ediff-compute-toolbar-width () 0)))
 
 (defgroup ediff-window nil
   "Ediff window manipulation."
 
 ;; Determine which window setup function to use based on current window system.
 (defun ediff-choose-window-setup-function-automatically ()
+  (declare (obsolete ediff-setup-windows-default "24.3"))
   (if (ediff-window-display-p)
       'ediff-setup-windows-multiframe
     'ediff-setup-windows-plain))
 
-(defcustom ediff-window-setup-function (ediff-choose-window-setup-function-automatically)
+(defcustom ediff-window-setup-function 'ediff-setup-windows-default
   "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. By default, the appropriate function is
-chosen automatically depending on the current window system.
-However, `ediff-toggle-multiframe' can be used to toggle between the multiframe
-display and the single frame display.
-If the multiframe 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.
+Ediff provides a choice of three functions:
+ (1) `ediff-setup-windows-multiframe', which sets the control panel
+     in a separate frame.
+ (2) `ediff-setup-windows-plain', which does everything in one frame
+ (3) `ediff-setup-windows-default' (the default), which does (1)
+     on a graphical display and (2) on a text terminal.
+
+The command \\[ediff-toggle-multiframe] can be used to toggle
+between the multiframe display and the single frame display.  If
+the multiframe 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.
 
 If you don't like any of the two provided functions, write your own one.
 The basic guidelines:
@@ -90,10 +94,12 @@ The basic guidelines:
        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."
-  :type '(choice (const :tag "Multi Frame" ediff-setup-windows-multiframe)
+  :type '(choice (const :tag "Choose Automatically" ediff-setup-windows-default)
+                (const :tag "Multi Frame" ediff-setup-windows-multiframe)
                 (const :tag "Single Frame" ediff-setup-windows-plain)
                 (function :tag "Other function"))
-  :group 'ediff-window)
+  :group 'ediff-window
+  :version "24.3")
 
 ;; indicates if we are in a multiframe setup
 (ediff-defvar-local ediff-multiframe nil "")
@@ -195,7 +201,7 @@ Used internally---not a user option.")
 
 (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
+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."
   :type 'boolean
@@ -205,7 +211,7 @@ responsibility."
   "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 form \((top . <position>) \(left . <position>))"
   :type 'function
   :group 'ediff-window)
 
@@ -274,7 +280,7 @@ into icons, regardless of the window manager."
 
 ;;; Functions
 
-(defun ediff-get-window-by-clicking (wind prev-wind wind-number)
+(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)
@@ -283,9 +289,9 @@ into icons, regardless of the window manager."
          (beep 1))
       (message "Please click on Window %d " wind-number))
     (ediff-read-event) ; discard event
-    (setq wind (if (featurep 'xemacs)
-                  (event-window event)
-                (posn-window (event-start event))))))
+    (if (featurep 'xemacs)
+        (event-window event)
+      (posn-window (event-start event)))))
 
 
 ;; Select the lowest window on the frame.
@@ -333,6 +339,12 @@ into icons, regardless of the window manager."
        buffer-A buffer-B buffer-C control-buffer))
   (run-hooks 'ediff-after-setup-windows-hook))
 
+(defun ediff-setup-windows-default (buffer-A buffer-B buffer-C control-buffer)
+  (funcall (if (display-graphic-p)
+              'ediff-setup-windows-multiframe
+            'ediff-setup-windows-plain)
+          buffer-A buffer-B buffer-C control-buffer))
+
 ;; Just set up 3 windows.
 ;; Usually used without windowing systems
 ;; With windowing, we want to use dedicated frames.
@@ -345,6 +357,8 @@ into icons, regardless of the window manager."
     (ediff-setup-windows-plain-compare
      buffer-A buffer-B buffer-C control-buffer)))
 
+(autoload 'ediff-setup-control-buffer "ediff-util")
+
 (defun ediff-setup-windows-plain-merge (buf-A buf-B buf-C control-buffer)
   ;; skip dedicated and unsplittable frames
   (ediff-destroy-control-frame control-buffer)
@@ -418,7 +432,7 @@ into icons, regardless of the window manager."
            three-way-comparison ediff-3way-comparison-job))
     ;; if in minibuffer go somewhere else
     (if (save-match-data
-         (string-match "\*Minibuf-" (buffer-name (window-buffer))))
+         (string-match "\\*Minibuf-" (buffer-name (window-buffer))))
        (select-window (next-window nil 'ignore-minibuf)))
     (delete-other-windows)
     (set-window-dedicated-p (selected-window) nil)
@@ -847,7 +861,7 @@ into icons, regardless of the window manager."
 ;; create a new splittable frame if none is found
 (defun ediff-skip-unsuitable-frames (&optional ok-unsplittable)
   (if (ediff-window-display-p)
-      (let ((wind-frame (window-frame (selected-window)))
+      (let ((wind-frame (window-frame))
             seen-windows)
        (while (and (not (memq (selected-window) seen-windows))
                    (or
@@ -863,7 +877,7 @@ into icons, regardless of the window manager."
          (setq seen-windows (cons (selected-window) seen-windows))
          ;; try new window
          (other-window 1 t)
-         (setq wind-frame (window-frame (selected-window)))
+         (setq wind-frame (window-frame))
          )
        (if (memq (selected-window) seen-windows)
            ;; fed up, no appropriate frames
@@ -895,6 +909,8 @@ into icons, regardless of the window manager."
     (not (ediff-frame-has-dedicated-windows (window-frame wind)))
     )))
 
+(declare-function ediff-make-bottom-toolbar "ediff-util" (&optional frame))
+
 ;; Prepare or refresh control frame
 (defun ediff-setup-control-frame (ctl-buffer designated-minibuffer-frame)
   (let ((window-min-height 1)
@@ -923,7 +939,7 @@ into icons, regardless of the window manager."
 
     (setq ctl-frame-iconified-p (ediff-frame-iconified-p ctl-frame))
     (select-frame ctl-frame)
-    (if (window-dedicated-p (selected-window))
+    (if (window-dedicated-p)
        ()
       (delete-other-windows)
       (switch-to-buffer ctl-buffer))
@@ -942,7 +958,7 @@ into icons, regardless of the window manager."
          (and (eq this-command 'ediff-toggle-help)
               dont-iconify-ctl-frame))
 
-    ;; 1 more line for the modeline
+    ;; 1 more line for the mode line
     (setq lines (1+ (count-lines (point-min) (point-max)))
          fheight lines
          fwidth (max (+ (ediff-help-message-line-length) 2)
@@ -1126,8 +1142,8 @@ It assumes that it is called from within the control buffer."
 
 
 ;; Revise the mode line to display which difference we have selected
-;; Also resets modelines of buffers A/B, since they may be clobbered by
-;; anothe invocations of Ediff.
+;; Also resets mode lines of buffers A/B, since they may be clobbered by
+;; other invocations of Ediff.
 (defun ediff-refresh-mode-lines ()
   (let (buf-A-state-diff buf-B-state-diff buf-C-state-diff buf-C-state-merge)