comparison lisp/frame.el @ 39846:2e4007551cfd

(special-display-popup-frame): Obey new specs `same-window' and `same-frame'.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Fri, 12 Oct 2001 20:39:54 +0000
parents b7d5e9ab6f93
children e9c66842eb07
comparison
equal deleted inserted replaced
39845:e7ed51a0fc32 39846:2e4007551cfd
30 (defvar frame-creation-function nil 30 (defvar frame-creation-function nil
31 "Window-system dependent function to call to create a new frame. 31 "Window-system dependent function to call to create a new frame.
32 The window system startup file should set this to its frame creation 32 The window system startup file should set this to its frame creation
33 function, which should take an alist of parameters as its argument.") 33 function, which should take an alist of parameters as its argument.")
34 34
35 ;;; The initial value given here for used to ask for a minibuffer. 35 ;; The initial value given here used to ask for a minibuffer.
36 ;;; But that's not necessary, because the default is to have one. 36 ;; But that's not necessary, because the default is to have one.
37 ;;; By not specifying it here, we let an X resource specify it. 37 ;; By not specifying it here, we let an X resource specify it.
38 (defcustom initial-frame-alist nil 38 (defcustom initial-frame-alist nil
39 "*Alist of frame parameters for creating the initial X window frame. 39 "*Alist of frame parameters for creating the initial X window frame.
40 You can set this in your `.emacs' file; for example, 40 You can set this in your `.emacs' file; for example,
41 (setq initial-frame-alist '((top . 1) (left . 1) (width . 80) (height . 55))) 41 (setq initial-frame-alist '((top . 1) (left . 1) (width . 80) (height . 55)))
42 Parameters specified here supersede the values given in `default-frame-alist'. 42 Parameters specified here supersede the values given in `default-frame-alist'.
111 use (car ARGS) as a function to do the work. 111 use (car ARGS) as a function to do the work.
112 Pass it BUFFER as first arg, and (cdr ARGS) gives the rest of the args." 112 Pass it BUFFER as first arg, and (cdr ARGS) gives the rest of the args."
113 (if (and args (symbolp (car args))) 113 (if (and args (symbolp (car args)))
114 (apply (car args) buffer (cdr args)) 114 (apply (car args) buffer (cdr args))
115 (let ((window (get-buffer-window buffer t))) 115 (let ((window (get-buffer-window buffer t)))
116 (if window 116 (or
117 ;; If we have a window already, make it visible. 117 ;; If we have a window already, make it visible.
118 (let ((frame (window-frame window))) 118 (when window
119 (make-frame-visible frame) 119 (let ((frame (window-frame window)))
120 (raise-frame frame) 120 (make-frame-visible frame)
121 window) 121 (raise-frame frame)
122 ;; If no window yet, make one in a new frame. 122 window))
123 (let ((frame (make-frame (append args special-display-frame-alist)))) 123 ;; Reuse the current window if the user requested it.
124 (set-window-buffer (frame-selected-window frame) buffer) 124 (when (cdr (assq 'same-window args))
125 (set-window-dedicated-p (frame-selected-window frame) t) 125 (condition-case nil
126 (frame-selected-window frame)))))) 126 (progn (switch-to-buffer buffer) (selected-window))
127 (error nil)))
128 ;; Stay on the same frame if requested.
129 (when (or (cdr (assq 'same-frame args)) (cdr (assq 'same-window args)))
130 (let* ((pop-up-frames nil) (pop-up-windows t)
131 special-display-regexps special-display-buffer-names
132 (window (display-buffer buffer)))
133 ;; (set-window-dedicated-p window t)
134 window))
135 ;; If no window yet, make one in a new frame.
136 (let ((frame (make-frame (append args special-display-frame-alist))))
137 (set-window-buffer (frame-selected-window frame) buffer)
138 (set-window-dedicated-p (frame-selected-window frame) t)
139 (frame-selected-window frame))))))
127 140
128 (defun handle-delete-frame (event) 141 (defun handle-delete-frame (event)
129 "Handle delete-frame events from the X server." 142 "Handle delete-frame events from the X server."
130 (interactive "e") 143 (interactive "e")
131 (let ((frame (posn-window (event-start event))) 144 (let ((frame (posn-window (event-start event)))
141 ;; Gildea@x.org says it is ok to ask questions before terminating. 154 ;; Gildea@x.org says it is ok to ask questions before terminating.
142 (save-buffers-kill-emacs)))) 155 (save-buffers-kill-emacs))))
143 156
144 ;;;; Arrangement of frames at startup 157 ;;;; Arrangement of frames at startup
145 158
146 ;;; 1) Load the window system startup file from the lisp library and read the 159 ;; 1) Load the window system startup file from the lisp library and read the
147 ;;; high-priority arguments (-q and the like). The window system startup 160 ;; high-priority arguments (-q and the like). The window system startup
148 ;;; file should create any frames specified in the window system defaults. 161 ;; file should create any frames specified in the window system defaults.
149 ;;; 162 ;;
150 ;;; 2) If no frames have been opened, we open an initial text frame. 163 ;; 2) If no frames have been opened, we open an initial text frame.
151 ;;; 164 ;;
152 ;;; 3) Once the init file is done, we apply any newly set parameters 165 ;; 3) Once the init file is done, we apply any newly set parameters
153 ;;; in initial-frame-alist to the frame. 166 ;; in initial-frame-alist to the frame.
154 167
155 ;; These are now called explicitly at the proper times, 168 ;; These are now called explicitly at the proper times,
156 ;; since that is easier to understand. 169 ;; since that is easier to understand.
157 ;; Actually using hooks within Emacs is bad for future maintenance. --rms. 170 ;; Actually using hooks within Emacs is bad for future maintenance. --rms.
158 ;; (add-hook 'before-init-hook 'frame-initialize) 171 ;; (add-hook 'before-init-hook 'frame-initialize)
159 ;; (add-hook 'window-setup-hook 'frame-notice-user-settings) 172 ;; (add-hook 'window-setup-hook 'frame-notice-user-settings)
160 173
161 ;;; If we create the initial frame, this is it. 174 ;; If we create the initial frame, this is it.
162 (defvar frame-initial-frame nil) 175 (defvar frame-initial-frame nil)
163 176
164 ;; Record the parameters used in frame-initialize to make the initial frame. 177 ;; Record the parameters used in frame-initialize to make the initial frame.
165 (defvar frame-initial-frame-alist) 178 (defvar frame-initial-frame-alist)
166 179
167 (defvar frame-initial-geometry-arguments nil) 180 (defvar frame-initial-geometry-arguments nil)
168 181
169 ;;; startup.el calls this function before loading the user's init 182 ;; startup.el calls this function before loading the user's init
170 ;;; file - if there is no frame with a minibuffer open now, create 183 ;; file - if there is no frame with a minibuffer open now, create
171 ;;; one to display messages while loading the init file. 184 ;; one to display messages while loading the init file.
172 (defun frame-initialize () 185 (defun frame-initialize ()
173 "Create an initial frame if necessary." 186 "Create an initial frame if necessary."
174 ;; Are we actually running under a window system at all? 187 ;; Are we actually running under a window system at all?
175 (if (and window-system (not noninteractive) (not (eq window-system 'pc))) 188 (if (and window-system (not noninteractive) (not (eq window-system 'pc)))
176 (progn 189 (progn
215 "Can't create multiple frames without a window system")))))))) 228 "Can't create multiple frames without a window system"))))))))
216 229
217 (defvar frame-notice-user-settings t 230 (defvar frame-notice-user-settings t
218 "Non-nil means function `frame-notice-user-settings' wasn't run yet.") 231 "Non-nil means function `frame-notice-user-settings' wasn't run yet.")
219 232
220 ;;; startup.el calls this function after loading the user's init 233 ;; startup.el calls this function after loading the user's init
221 ;;; file. Now default-frame-alist and initial-frame-alist contain 234 ;; file. Now default-frame-alist and initial-frame-alist contain
222 ;;; information to which we must react; do what needs to be done. 235 ;; information to which we must react; do what needs to be done.
223 (defun frame-notice-user-settings () 236 (defun frame-notice-user-settings ()
224 "Act on user's init file settings of frame parameters. 237 "Act on user's init file settings of frame parameters.
225 React to settings of `default-frame-alist', `initial-frame-alist' there." 238 React to settings of `default-frame-alist', `initial-frame-alist' there."
226 ;; Make menu-bar-mode and default-frame-alist consistent. 239 ;; Make menu-bar-mode and default-frame-alist consistent.
227 (when (boundp 'menu-bar-mode) 240 (when (boundp 'menu-bar-mode)
785 ;; if this frame doesn't support fonts. 798 ;; if this frame doesn't support fonts.
786 (x-list-fonts "*" nil (selected-frame))))))) 799 (x-list-fonts "*" nil (selected-frame)))))))
787 (modify-frame-parameters (selected-frame) 800 (modify-frame-parameters (selected-frame)
788 (list (cons 'font font-name))) 801 (list (cons 'font font-name)))
789 (run-hooks 'after-setting-font-hook 'after-setting-font-hooks)) 802 (run-hooks 'after-setting-font-hook 'after-setting-font-hooks))
803
804 (defun set-frame-parameter (frame parameter value)
805 (modify-frame-parameters frame (list (cons parameter value))))
790 806
791 (defun set-background-color (color-name) 807 (defun set-background-color (color-name)
792 "Set the background color of the selected frame to COLOR-NAME. 808 "Set the background color of the selected frame to COLOR-NAME.
793 When called interactively, prompt for the name of the color to use. 809 When called interactively, prompt for the name of the color to use.
794 To get the frame's current background color, use `frame-parameters'." 810 To get the frame's current background color, use `frame-parameters'."
1086 (make-obsolete 'screen-width 'frame-width) ;before 19.15 1102 (make-obsolete 'screen-width 'frame-width) ;before 19.15
1087 (make-obsolete 'set-screen-width 'set-frame-width) ;before 19.15 1103 (make-obsolete 'set-screen-width 'set-frame-width) ;before 19.15
1088 (make-obsolete 'set-screen-height 'set-frame-height) ;before 19.15 1104 (make-obsolete 'set-screen-height 'set-frame-height) ;before 19.15
1089 1105
1090 1106
1091 ;;; Highlighting trailing whitespace. 1107 ;; Highlighting trailing whitespace.
1092 1108
1093 (make-variable-buffer-local 'show-trailing-whitespace) 1109 (make-variable-buffer-local 'show-trailing-whitespace)
1094 1110
1095 (defcustom show-trailing-whitespace nil 1111 (defcustom show-trailing-whitespace nil
1096 "*Non-nil means highlight trailing whitespace in face `trailing-whitespace'. 1112 "*Non-nil means highlight trailing whitespace in face `trailing-whitespace'.
1101 :type 'boolean 1117 :type 'boolean
1102 :group 'font-lock) 1118 :group 'font-lock)
1103 1119
1104 1120
1105 1121
1106 ;;; Scrolling 1122 ;; Scrolling
1107 1123
1108 (defgroup scrolling nil 1124 (defgroup scrolling nil
1109 "Scrolling windows." 1125 "Scrolling windows."
1110 :version "21.1" 1126 :version "21.1"
1111 :group 'frames) 1127 :group 'frames)
1117 :version "21.1" 1133 :version "21.1"
1118 :type 'boolean 1134 :type 'boolean
1119 :group 'scrolling) 1135 :group 'scrolling)
1120 1136
1121 1137
1122 ;;; Blinking cursor 1138 ;; Blinking cursor
1123 1139
1124 (defgroup cursor nil 1140 (defgroup cursor nil
1125 "Displaying text cursors." 1141 "Displaying text cursors."
1126 :version "21.1" 1142 :version "21.1"
1127 :group 'frames) 1143 :group 'frames)
1213 (cancel-timer blink-cursor-timer) 1229 (cancel-timer blink-cursor-timer)
1214 (setq blink-cursor-timer nil)) 1230 (setq blink-cursor-timer nil))
1215 1231
1216 1232
1217 1233
1218 ;;; Hourglass pointer 1234 ;; Hourglass pointer
1219 1235
1220 (defcustom display-hourglass t 1236 (defcustom display-hourglass t
1221 "*Non-nil means show an hourglass pointer when running under a window system." 1237 "*Non-nil means show an hourglass pointer when running under a window system."
1222 :tag "Hourglass pointer" 1238 :tag "Hourglass pointer"
1223 :type 'boolean 1239 :type 'boolean