]> code.delx.au - gnu-emacs/blobdiff - lisp/frame.el
(timezone-parse-date): Match forms 1 and 2 first.
[gnu-emacs] / lisp / frame.el
index 29d8c76f5aa7170fa05ed511895d2cd0b2c0490a..b08fdc2c4b5b43b85435a5dcc8b1ddfa9421a626 100644 (file)
 The window system startup file should set this to its frame creation
 function, which should take an alist of parameters as its argument.")
 
-;;; The initial value given here for this must ask for a minibuffer.
-;;; There must always exist a frame with a minibuffer, and after we
-;;; delete the terminal frame, this will be the only frame.
-(defvar initial-frame-alist '((minibuffer . t))
+;;; The initial value given here for used to ask for a minibuffer.
+;;; But that's not necessary, because the default is to have one.
+;;; By not specifying it here, we let an X resource specify it.
+(defvar initial-frame-alist nil
   "Alist of frame parameters for creating the initial X window frame.
 You can set this in your `.emacs' file; for example,
  (setq initial-frame-alist '((top . 1) (left . 1) (width . 80) (height . 55)))
@@ -152,7 +152,7 @@ These supersede the values given in `default-frame-alist'.")
 (defun frame-initialize ()
 
   ;; Are we actually running under a window system at all?
-  (if (and window-system (not noninteractive))
+  (if (and window-system (not noninteractive) (not (eq window-system 'pc)))
       (progn
        ;; Turn on special-display processing only if there's a window system.
        (setq special-display-function 'special-display-popup-frame)
@@ -191,13 +191,14 @@ These supersede the values given in `default-frame-alist'.")
 
     ;; No, we're not running a window system.  Use make-terminal-frame if
     ;; we support that feature, otherwise arrange to cause errors.
-    (setq frame-creation-function
-         (if (fboundp 'make-terminal-frame)
-             'make-terminal-frame
-           (function
-            (lambda (parameters)
-              (error
-               "Can't create multiple frames without a window system")))))))
+    (or (eq window-system 'pc)
+       (setq frame-creation-function
+             (if (fboundp 'make-terminal-frame)
+                 'make-terminal-frame
+               (function
+                (lambda (parameters)
+                  (error
+                   "Can't create multiple frames without a window system"))))))))
 
 ;;; startup.el calls this function after loading the user's init
 ;;; file.  Now default-frame-alist and initial-frame-alist contain
@@ -417,37 +418,48 @@ The optional second argument PARAMETERS specifies additional frame parameters."
   (interactive "sMake frame on display: ")
   (make-frame (cons (cons 'display display) parameters)))
 
+(defun make-frame-command ()
+  "Make a new frame, and select it if the terminal displays only one frame."
+  (interactive)
+  (if (and window-system (not (eq window-system 'pc)))
+      (make-frame)
+    (select-frame (make-frame))))
+
+(defvar before-make-frame-hook nil
+  "Functions to run before a frame is created.")
+
+(defvar after-make-frame-functions nil
+  "Functions to run after a frame is created.
+The functions are run with one arg, the newly created frame.")
+
 ;; Alias, kept temporarily.
 (defalias 'new-frame 'make-frame)
-(defun make-frame (&optional parameters)
-  "Create a new frame, displaying the current buffer.
 
-Optional argument PARAMETERS is an alist of parameters for the new
-frame.  Specifically, PARAMETERS is a list of pairs, each having
-the form (NAME . VALUE).
+(defun make-frame (&optional parameters)
+  "Return a newly created frame displaying the current buffer.
+Optional argument PARAMETERS is an alist of parameters for the new frame.
+Each element of PARAMETERS should have the form (NAME . VALUE), for example:
 
-Here are some of the parameters allowed (not a complete list):
+ (name . STRING)       The frame should be named STRING.
 
-\(name . STRING)       - The frame should be named STRING.
+ (width . NUMBER)      The frame should be NUMBER characters in width.
+ (height . NUMBER)     The frame should be NUMBER text lines high.
 
-\(height . NUMBER) - The frame should be NUMBER text lines high.  If
-       this parameter is present, the width parameter must also be
-       given.
+You cannot specify either `width' or `height', you must use neither or both.
 
-\(width . NUMBER) - The frame should be NUMBER characters in width.
-       If this parameter is present, the height parameter must also
-       be given.
+ (minibuffer . t)      The frame should have a minibuffer.
+ (minibuffer . nil)    The frame should have no minibuffer.
+ (minibuffer . only)   The frame should contain only a minibuffer.
+ (minibuffer . WINDOW) The frame should use WINDOW as its minibuffer window.
 
-\(minibuffer . t) - the frame should have a minibuffer
-\(minibuffer . nil) - the frame should have no minibuffer
-\(minibuffer . only) - the frame should contain only a minibuffer
-\(minibuffer . WINDOW) - the frame should use WINDOW as its minibuffer window."
+Before the frame is created (via `frame-creation-function'), functions on the
+hook `before-make-frame-hook' are run.  After the frame is created, functions
+on `after-make-frame-functions' are run with one arg, the newly created frame."
   (interactive)
-  (let ((nframe))
-    (run-hooks 'before-make-frame-hook)
-    (setq nframe (funcall frame-creation-function parameters))
-    (run-hooks 'after-make-frame-hook)
-    nframe))
+  (run-hooks 'before-make-frame-hook)
+  (let ((frame (funcall frame-creation-function parameters)))
+    (run-hook-with-args 'after-make-frame-functions frame)
+    frame))
 
 (defun filtered-frame-list (predicate)
   "Return a list of all live frames which satisfy PREDICATE."
@@ -506,9 +518,7 @@ 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)
-    (if (fboundp 'unfocus-frame)
-       (unfocus-frame))))
+    (set-mouse-position (selected-frame) (1- (frame-width)) 0)))
 \f
 ;;;; Frame configurations
 
@@ -567,6 +577,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."
@@ -577,9 +592,11 @@ If FRAME is omitted, describe the currently selected frame."
 If FRAME is omitted, describe the currently selected frame."
   (cdr (assq 'width (frame-parameters frame))))
 
-(defun set-default-font (font-name)
+(defalias 'set-default-font 'set-frame-font)
+(defun set-frame-font (font-name)
   "Set the font of the selected frame to FONT.
-When called interactively, prompt for the name of the font to use."
+When called interactively, prompt for the name of the font to use.
+To get the frame's current default font, use `frame-parameters'."
   (interactive "sFont name: ")
   (modify-frame-parameters (selected-frame)
                           (list (cons 'font font-name)))
@@ -588,7 +605,8 @@ When called interactively, prompt for the name of the font to use."
 
 (defun set-background-color (color-name)
   "Set the background color of the selected frame to COLOR.
-When called interactively, prompt for the name of the color to use."
+When called interactively, prompt for the name of the color to use.
+To get the frame's current background color, use `frame-parameters'."
   (interactive "sColor: ")
   (modify-frame-parameters (selected-frame)
                           (list (cons 'background-color color-name)))
@@ -596,7 +614,8 @@ When called interactively, prompt for the name of the color to use."
 
 (defun set-foreground-color (color-name)
   "Set the foreground color of the selected frame to COLOR.
-When called interactively, prompt for the name of the color to use."
+When called interactively, prompt for the name of the color to use.
+To get the frame's current foreground color, use `frame-parameters'."
   (interactive "sColor: ")
   (modify-frame-parameters (selected-frame)
                           (list (cons 'foreground-color color-name)))
@@ -604,21 +623,24 @@ When called interactively, prompt for the name of the color to use."
 
 (defun set-cursor-color (color-name)
   "Set the text cursor color of the selected frame to COLOR.
-When called interactively, prompt for the name of the color to use."
+When called interactively, prompt for the name of the color to use.
+To get the frame's current cursor color, use `frame-parameters'."
   (interactive "sColor: ")
   (modify-frame-parameters (selected-frame)
                           (list (cons 'cursor-color color-name))))
 
 (defun set-mouse-color (color-name)
   "Set the color of the mouse pointer of the selected frame to COLOR.
-When called interactively, prompt for the name of the color to use."
+When called interactively, prompt for the name of the color to use.
+To get the frame's current mouse color, use `frame-parameters'."
   (interactive "sColor: ")
   (modify-frame-parameters (selected-frame)
                           (list (cons 'mouse-color color-name))))
 
 (defun set-border-color (color-name)
   "Set the color of the border of the selected frame to COLOR.
-When called interactively, prompt for the name of the color to use."
+When called interactively, prompt for the name of the color to use.
+To get the frame's current border color, use `frame-parameters'."
   (interactive "sColor: ")
   (modify-frame-parameters (selected-frame)
                           (list (cons 'border-color color-name))))
@@ -653,6 +675,9 @@ that is beyond the control of Emacs and this command has no effect on it."
   (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."
@@ -663,7 +688,9 @@ With arg, turn vertical scroll bars on if and only if arg is positive."
                           (frame-parameters (selected-frame))))
                -1 1)))
   (modify-frame-parameters (selected-frame)
-                          (list (cons 'vertical-scroll-bars (> arg 0)))))
+                          (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.
@@ -690,7 +717,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)
@@ -700,12 +727,8 @@ should use `set-frame-width' instead."
 
 \f
 ;;;; Key bindings
-(defvar ctl-x-5-map (make-sparse-keymap)
-  "Keymap for frame commands.")
-(defalias 'ctl-x-5-prefix ctl-x-5-map)
-(define-key ctl-x-map "5" 'ctl-x-5-prefix)
 
-(define-key ctl-x-5-map "2" 'make-frame)
+(define-key ctl-x-5-map "2" 'make-frame-command)
 (define-key ctl-x-5-map "0" 'delete-frame)
 (define-key ctl-x-5-map "o" 'other-frame)