(setup-8-bit-environment):
[bpt/emacs.git] / lisp / frame.el
index 8bb59a9..3266773 100644 (file)
@@ -1,6 +1,6 @@
 ;;; frame.el --- multi-frame management independent of window systems.
 
-;; Copyright (C) 1993, 1994 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1994, 1996, 1997 Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: internal
@@ -72,7 +72,7 @@ These supersede the values given in `default-frame-alist'.")
       (function (lambda ()
                  (make-frame pop-up-frame-alist))))
 
-(defvar special-display-frame-alist
+(defcustom special-display-frame-alist
   '((height . 14) (width . 80) (unsplittable . t))
   "*Alist of frame parameters used when creating special frames.
 Special frames are used for buffers whose names are in
@@ -80,7 +80,11 @@ Special frames are used for buffers whose names are in
 one of the regular expressions in `special-display-regexps'.
 This variable can be set in your init file, like this:
   (setq special-display-frame-alist '((width . 80) (height . 20)))
-These supersede the values given in `default-frame-alist'.")
+These supersede the values given in `default-frame-alist'."
+  :type '(repeat (cons :format "%v"
+                        (symbol :tag "Parameter")
+                        (sexp :tag "Value")))
+  :group 'frames)
 
 ;; Display BUFFER in its own frame, reusing an existing window if any.
 ;; Return the window chosen.
@@ -165,19 +169,13 @@ These supersede the values given in `default-frame-alist'.")
            (progn
              (setq frame-initial-frame-alist
                    (append initial-frame-alist default-frame-alist))
-             ;; Record these with their default values
-             ;; if they don't have any values explicitly.
-             (or (assq 'vertical-scroll-bars frame-initial-frame-alist)
-                 (setq frame-initial-frame-alist
-                       (cons '(vertical-scroll-bars . t)
-                             frame-initial-frame-alist)))
              (or (assq 'horizontal-scroll-bars frame-initial-frame-alist)
                  (setq frame-initial-frame-alist
                        (cons '(horizontal-scroll-bars . t)
                              frame-initial-frame-alist)))
              (setq default-minibuffer-frame
                    (setq frame-initial-frame
-                         (make-frame initial-frame-alist)))
+                         (make-frame frame-initial-frame-alist)))
              ;; Delete any specifications for window geometry parameters
              ;; so that we won't reapply them in frame-notice-user-settings.
              ;; It would be wrong to reapply them then,
@@ -499,6 +497,12 @@ the user during startup."
   (cdr param-list))
 
 
+(defcustom focus-follows-mouse t
+  "*Non-nil if window system changes focus when you move the mouse."
+  :type 'boolean
+  :group 'frames
+  :version "20.3")
+
 (defun other-frame (arg)
   "Select the ARG'th different visible frame, and raise it.
 All frames are arranged in a cyclic order.
@@ -518,7 +522,44 @@ A negative ARG moves in the opposite order."
       (setq arg (1+ arg)))
     (raise-frame frame)
     (select-frame frame)
-    (set-mouse-position (selected-frame) (1- (frame-width)) 0)))
+    ;; Ensure, if possible, that frame gets input focus.
+    (if (eq window-system 'w32)
+       (w32-focus-frame frame)
+      (when focus-follows-mouse
+       (set-mouse-position (selected-frame) (1- (frame-width)) 0)))))
+
+(defun make-frame-names-alist ()
+  (let* ((current-frame (selected-frame))
+        (falist
+         (cons
+          (cons (frame-parameter current-frame 'name) current-frame) nil))
+        (frame (next-frame nil t)))
+    (while (not (eq frame current-frame))
+      (progn
+       (setq falist (cons (cons (frame-parameter frame 'name) frame) falist))
+       (setq frame (next-frame frame t))))
+    falist))
+
+(defvar frame-name-history nil)
+(defun select-frame-by-name (name)
+  "Select the frame whose name is NAME and raise it.
+If there is no frame by that name, signal an error."
+  (interactive
+   (let* ((frame-names-alist (make-frame-names-alist))
+          (default (car (car frame-names-alist)))
+          (input (completing-read
+                  (format "Select Frame (default %s): " default)
+                  frame-names-alist nil t nil 'frame-name-history)))
+     (if (= (length input) 0)
+        (list default)
+       (list input))))
+  (let* ((frame-names-alist (make-frame-names-alist))
+        (frame (cdr (assoc name frame-names-alist))))
+    (or frame
+       (error "There is no frame named `%s'" name))
+    (make-frame-visible frame)
+    (raise-frame frame)
+    (select-frame frame)))
 \f
 ;;;; Frame configurations
 
@@ -577,6 +618,11 @@ is given and non-nil, the unwanted frames are iconified instead."
 ;;;; Convenience functions for accessing and interactively changing
 ;;;; frame parameters.
 
+(defun frame-parameter (frame parameter)
+  "Return FRAME's value for parameter PARAMETER.
+If FRAME is omitted, describe the currently selected frame."
+  (cdr (assq parameter (frame-parameters frame))))
+
 (defun frame-height (&optional frame)
   "Return number of lines available for display on FRAME.
 If FRAME is omitted, describe the currently selected frame."
@@ -669,31 +715,14 @@ that is beyond the control of Emacs and this command has no effect on it."
                -1 1)))
   (modify-frame-parameters (selected-frame)
                           (list (cons 'auto-lower (> arg 0)))))
-
-(defvar scroll-bar-side 'left
-  "*Specify which side scroll bars should be on.  Value is `left' or `right'.")
-
-(defun toggle-scroll-bar (arg)
-  "Toggle whether or not the selected frame has vertical scroll bars.
-With arg, turn vertical scroll bars on if and only if arg is positive."
-  (interactive "P")
-  (if (null arg)
-      (setq arg
-           (if (cdr (assq 'vertical-scroll-bars
-                          (frame-parameters (selected-frame))))
-               -1 1)))
+(defun set-frame-name (name)
+  "Set the name of the selected frame to NAME.
+When called interactively, prompt for the name of the frame.
+The frame name is displayed on the modeline if the terminal displays only
+one frame, otherwise the name is displayed on the frame's caption bar."
+  (interactive "sFrame name: ")
   (modify-frame-parameters (selected-frame)
-                          (list (cons 'vertical-scroll-bars
-                                      (if (> arg 0)
-                                          scroll-bar-side)))))
-
-(defun toggle-horizontal-scroll-bar (arg)
-  "Toggle whether or not the selected frame has horizontal scroll bars.
-With arg, turn horizontal scroll bars on if and only if arg is positive.
-Horizontal scroll bars aren't implemented yet."
-  (interactive "P")
-  (error "Horizontal scroll bars aren't implemented yet"))
-
+                          (list (cons 'name name))))
 \f
 ;;;; Aliases for backward compatibility with Emacs 18.
 (defalias 'screen-height 'frame-height)
@@ -712,7 +741,7 @@ should use `set-frame-width instead'."
 Optional second arg non-nil means that redisplay should use LINES lines\n\
 but that the idea of the actual height of the screen should not be changed.\n\
 This function is provided only for compatibility with Emacs 18; new code\n\
-should use `set-frame-width' instead."
+should use `set-frame-height' instead."
   (set-frame-height (selected-frame) lines pretend))
 
 (make-obsolete 'screen-height 'frame-height)