comparison lisp/frame.el @ 25139:fde300f58ed8

Change comments to doc strings and other doc fixes. (frame-delete-all): Moved to subr.el as `assoc-delete-all'. Callers changed. (set-background-color, set-foreground-color, set-cursor-color) (set-mouse-color, set-border-color): Offer completion of colours. (cursor): Add :version to defgroup.
author Dave Love <fx@gnu.org>
date Fri, 30 Jul 1999 18:39:32 +0000
parents 98d218afbb10
children 1bae87a16cdf
comparison
equal deleted inserted replaced
25138:b005bf702615 25139:fde300f58ed8
97 :type '(repeat (cons :format "%v" 97 :type '(repeat (cons :format "%v"
98 (symbol :tag "Parameter") 98 (symbol :tag "Parameter")
99 (sexp :tag "Value"))) 99 (sexp :tag "Value")))
100 :group 'frames) 100 :group 'frames)
101 101
102 ;; Display BUFFER in its own frame, reusing an existing window if any.
103 ;; Return the window chosen.
104 ;; Currently we do not insist on selecting the window within its frame.
105 ;; If ARGS is an alist, use it as a list of frame parameter specs.
106 ;; If ARGS is a list whose car is a symbol,
107 ;; use (car ARGS) as a function to do the work.
108 ;; Pass it BUFFER as first arg, and (cdr ARGS) gives the rest of the args.
109 (defun special-display-popup-frame (buffer &optional args) 102 (defun special-display-popup-frame (buffer &optional args)
103 "Display BUFFER in its own frame, reusing an existing window if any.
104 Return the window chosen.
105 Currently we do not insist on selecting the window within its frame.
106 If ARGS is an alist, use it as a list of frame parameter specs.
107 If ARGS is a list whose car is a symbol,
108 use (car ARGS) as a function to do the work.
109 Pass it BUFFER as first arg, and (cdr ARGS) gives the rest of the args."
110 (if (and args (symbolp (car args))) 110 (if (and args (symbolp (car args)))
111 (apply (car args) buffer (cdr args)) 111 (apply (car args) buffer (cdr args))
112 (let ((window (get-buffer-window buffer t))) 112 (let ((window (get-buffer-window buffer t)))
113 (if window 113 (if window
114 ;; If we have a window already, make it visible. 114 ;; If we have a window already, make it visible.
120 (let ((frame (make-frame (append args special-display-frame-alist)))) 120 (let ((frame (make-frame (append args special-display-frame-alist))))
121 (set-window-buffer (frame-selected-window frame) buffer) 121 (set-window-buffer (frame-selected-window frame) buffer)
122 (set-window-dedicated-p (frame-selected-window frame) t) 122 (set-window-dedicated-p (frame-selected-window frame) t)
123 (frame-selected-window frame)))))) 123 (frame-selected-window frame))))))
124 124
125 ;; Handle delete-frame events from the X server.
126 (defun handle-delete-frame (event) 125 (defun handle-delete-frame (event)
126 "Handle delete-frame events from the X server."
127 (interactive "e") 127 (interactive "e")
128 (let ((frame (posn-window (event-start event))) 128 (let ((frame (posn-window (event-start event)))
129 (i 0) 129 (i 0)
130 (tail (frame-list))) 130 (tail (frame-list)))
131 (while tail 131 (while tail
165 165
166 ;;; startup.el calls this function before loading the user's init 166 ;;; startup.el calls this function before loading the user's init
167 ;;; file - if there is no frame with a minibuffer open now, create 167 ;;; file - if there is no frame with a minibuffer open now, create
168 ;;; one to display messages while loading the init file. 168 ;;; one to display messages while loading the init file.
169 (defun frame-initialize () 169 (defun frame-initialize ()
170 170 "Create an in initial frame if necessary."
171 ;; Are we actually running under a window system at all? 171 ;; Are we actually running under a window system at all?
172 (if (and window-system (not noninteractive) (not (eq window-system 'pc))) 172 (if (and window-system (not noninteractive) (not (eq window-system 'pc)))
173 (progn 173 (progn
174 ;; Turn on special-display processing only if there's a window system. 174 ;; Turn on special-display processing only if there's a window system.
175 (setq special-display-function 'special-display-popup-frame) 175 (setq special-display-function 'special-display-popup-frame)
213 213
214 ;;; startup.el calls this function after loading the user's init 214 ;;; startup.el calls this function after loading the user's init
215 ;;; file. Now default-frame-alist and initial-frame-alist contain 215 ;;; file. Now default-frame-alist and initial-frame-alist contain
216 ;;; information to which we must react; do what needs to be done. 216 ;;; information to which we must react; do what needs to be done.
217 (defun frame-notice-user-settings () 217 (defun frame-notice-user-settings ()
218 218 "Act on user's init file settings of frame parameters.
219 React to settings of `default-frame-alist', `initial-frame-alist' there."
219 ;; Make menu-bar-mode and default-frame-alist consistent. 220 ;; Make menu-bar-mode and default-frame-alist consistent.
220 (if (boundp 'menu-bar-mode) 221 (if (boundp 'menu-bar-mode)
221 (let ((default (assq 'menu-bar-lines default-frame-alist))) 222 (let ((default (assq 'menu-bar-lines default-frame-alist)))
222 (if default 223 (if default
223 (setq menu-bar-mode (not (eq (cdr default) 0))) 224 (setq menu-bar-mode (not (eq (cdr default) 0)))
270 nil)) 271 nil))
271 ;; Get rid of `reverse', because that was handled 272 ;; Get rid of `reverse', because that was handled
272 ;; when we first made the frame. 273 ;; when we first made the frame.
273 (setq parms (cons '(reverse) (delq (assq 'reverse parms) parms))) 274 (setq parms (cons '(reverse) (delq (assq 'reverse parms) parms)))
274 (if (assq 'height frame-initial-geometry-arguments) 275 (if (assq 'height frame-initial-geometry-arguments)
275 (setq parms (frame-delete-all 'height parms))) 276 (setq parms (assoc-delete-all 'height parms)))
276 (if (assq 'width frame-initial-geometry-arguments) 277 (if (assq 'width frame-initial-geometry-arguments)
277 (setq parms (frame-delete-all 'width parms))) 278 (setq parms (assoc-delete-all 'width parms)))
278 (if (assq 'left frame-initial-geometry-arguments) 279 (if (assq 'left frame-initial-geometry-arguments)
279 (setq parms (frame-delete-all 'left parms))) 280 (setq parms (assoc-delete-all 'left parms)))
280 (if (assq 'top frame-initial-geometry-arguments) 281 (if (assq 'top frame-initial-geometry-arguments)
281 (setq parms (frame-delete-all 'top parms))) 282 (setq parms (assoc-delete-all 'top parms)))
282 (setq new 283 (setq new
283 (make-frame 284 (make-frame
284 ;; Use the geometry args that created the existing 285 ;; Use the geometry args that created the existing
285 ;; frame, rather than the parms we get for it. 286 ;; frame, rather than the parms we get for it.
286 (append frame-initial-geometry-arguments 287 (append frame-initial-geometry-arguments
342 ;; the new parameters. 343 ;; the new parameters.
343 (let (newparms allparms tail) 344 (let (newparms allparms tail)
344 (setq allparms (append initial-frame-alist 345 (setq allparms (append initial-frame-alist
345 default-frame-alist)) 346 default-frame-alist))
346 (if (assq 'height frame-initial-geometry-arguments) 347 (if (assq 'height frame-initial-geometry-arguments)
347 (setq allparms (frame-delete-all 'height allparms))) 348 (setq allparms (assoc-delete-all 'height allparms)))
348 (if (assq 'width frame-initial-geometry-arguments) 349 (if (assq 'width frame-initial-geometry-arguments)
349 (setq allparms (frame-delete-all 'width allparms))) 350 (setq allparms (assoc-delete-all 'width allparms)))
350 (if (assq 'left frame-initial-geometry-arguments) 351 (if (assq 'left frame-initial-geometry-arguments)
351 (setq allparms (frame-delete-all 'left allparms))) 352 (setq allparms (assoc-delete-all 'left allparms)))
352 (if (assq 'top frame-initial-geometry-arguments) 353 (if (assq 'top frame-initial-geometry-arguments)
353 (setq allparms (frame-delete-all 'top allparms))) 354 (setq allparms (assoc-delete-all 'top allparms)))
354 (setq tail allparms) 355 (setq tail allparms)
355 ;; Find just the parms that have changed since we first 356 ;; Find just the parms that have changed since we first
356 ;; made this frame. Those are the ones actually set by 357 ;; made this frame. Those are the ones actually set by
357 ;; the init file. For those parms whose values we already knew 358 ;; the init file. For those parms whose values we already knew
358 ;; (such as those spec'd by command line options) 359 ;; (such as those spec'd by command line options)
392 (let ((parms (append minibuffer-frame-alist '((minibuffer . only))))) 393 (let ((parms (append minibuffer-frame-alist '((minibuffer . only)))))
393 (if display 394 (if display
394 (make-frame-on-display display parms) 395 (make-frame-on-display display parms)
395 (make-frame parms)))) 396 (make-frame parms))))
396 397
397 ;; Delete from ALIST all elements whose car is KEY.
398 ;; Return the modified alist.
399 (defun frame-delete-all (key alist)
400 (setq alist (copy-sequence alist))
401 (let ((tail alist))
402 (while tail
403 (if (eq (car (car tail)) key)
404 (setq alist (delq (car tail) alist)))
405 (setq tail (cdr tail)))
406 alist))
407
408 ;;;; Creation of additional frames, and other frame miscellanea 398 ;;;; Creation of additional frames, and other frame miscellanea
409 399
410 ;;; Return some frame other than the current frame, creating one if
411 ;;; necessary. Note that the minibuffer frame, if separate, is not
412 ;;; considered (see next-frame).
413 (defun get-other-frame () 400 (defun get-other-frame ()
401 "Return some frame other than the current frame.
402 Create one if necessary. Note that the minibuffer frame, if separate,
403 is not considered (see `next-frame')."
414 (let ((s (if (equal (next-frame (selected-frame)) (selected-frame)) 404 (let ((s (if (equal (next-frame (selected-frame)) (selected-frame))
415 (make-frame) 405 (make-frame)
416 (next-frame (selected-frame))))) 406 (next-frame (selected-frame)))))
417 s)) 407 s))
418 408
663 If FRAME is omitted, describe the currently selected frame." 653 If FRAME is omitted, describe the currently selected frame."
664 (cdr (assq 'width (frame-parameters frame)))) 654 (cdr (assq 'width (frame-parameters frame))))
665 655
666 (defalias 'set-default-font 'set-frame-font) 656 (defalias 'set-default-font 'set-frame-font)
667 (defun set-frame-font (font-name) 657 (defun set-frame-font (font-name)
668 "Set the font of the selected frame to FONT. 658 "Set the font of the selected frame to FONT-NAME.
669 When called interactively, prompt for the name of the font to use. 659 When called interactively, prompt for the name of the font to use.
670 To get the frame's current default font, use `frame-parameters'." 660 To get the frame's current default font, use `frame-parameters'."
671 (interactive "sFont name: ") 661 (interactive "sFont name: ")
672 (modify-frame-parameters (selected-frame) 662 (modify-frame-parameters (selected-frame)
673 (list (cons 'font font-name))) 663 (list (cons 'font font-name)))
674 ;; Update faces that want a bold or italic version of the default font. 664 ;; Update faces that want a bold or italic version of the default font.
675 (frame-update-faces (selected-frame)) 665 (frame-update-faces (selected-frame))
676 (run-hooks 'after-setting-font-hooks)) 666 (run-hooks 'after-setting-font-hooks))
677 667
678 (defun set-background-color (color-name) 668 (defun set-background-color (color-name)
679 "Set the background color of the selected frame to COLOR. 669 "Set the background color of the selected frame to COLOR-NAME.
680 When called interactively, prompt for the name of the color to use. 670 When called interactively, prompt for the name of the color to use.
681 To get the frame's current background color, use `frame-parameters'." 671 To get the frame's current background color, use `frame-parameters'."
682 (interactive "sColor: ") 672 (interactive (list (facemenu-read-color)))
683 (modify-frame-parameters (selected-frame) 673 (modify-frame-parameters (selected-frame)
684 (list (cons 'background-color color-name))) 674 (list (cons 'background-color color-name)))
685 (frame-update-face-colors (selected-frame))) 675 (frame-update-face-colors (selected-frame)))
686 676
687 (defun set-foreground-color (color-name) 677 (defun set-foreground-color (color-name)
688 "Set the foreground color of the selected frame to COLOR. 678 "Set the foreground color of the selected frame to COLOR-NAME.
689 When called interactively, prompt for the name of the color to use. 679 When called interactively, prompt for the name of the color to use.
690 To get the frame's current foreground color, use `frame-parameters'." 680 To get the frame's current foreground color, use `frame-parameters'."
691 (interactive "sColor: ") 681 (interactive (list (facemenu-read-color)))
692 (modify-frame-parameters (selected-frame) 682 (modify-frame-parameters (selected-frame)
693 (list (cons 'foreground-color color-name))) 683 (list (cons 'foreground-color color-name)))
694 (frame-update-face-colors (selected-frame))) 684 (frame-update-face-colors (selected-frame)))
695 685
696 (defun set-cursor-color (color-name) 686 (defun set-cursor-color (color-name)
697 "Set the text cursor color of the selected frame to COLOR. 687 "Set the text cursor color of the selected frame to COLOR-NAME.
698 When called interactively, prompt for the name of the color to use. 688 When called interactively, prompt for the name of the color to use.
699 To get the frame's current cursor color, use `frame-parameters'." 689 To get the frame's current cursor color, use `frame-parameters'."
700 (interactive "sColor: ") 690 (interactive (list (facemenu-read-color)))
701 (modify-frame-parameters (selected-frame) 691 (modify-frame-parameters (selected-frame)
702 (list (cons 'cursor-color color-name)))) 692 (list (cons 'cursor-color color-name))))
703 693
704 (defun set-mouse-color (color-name) 694 (defun set-mouse-color (color-name)
705 "Set the color of the mouse pointer of the selected frame to COLOR. 695 "Set the color of the mouse pointer of the selected frame to COLOR-NAME.
706 When called interactively, prompt for the name of the color to use. 696 When called interactively, prompt for the name of the color to use.
707 To get the frame's current mouse color, use `frame-parameters'." 697 To get the frame's current mouse color, use `frame-parameters'."
708 (interactive "sColor: ") 698 (interactive (list (facemenu-read-color)))
709 (modify-frame-parameters (selected-frame) 699 (modify-frame-parameters (selected-frame)
710 (list (cons 'mouse-color 700 (list (cons 'mouse-color
711 (or color-name 701 (or color-name
712 (cdr (assq 'mouse-color 702 (cdr (assq 'mouse-color
713 (frame-parameters)))))))) 703 (frame-parameters))))))))
714 704
715 (defun set-border-color (color-name) 705 (defun set-border-color (color-name)
716 "Set the color of the border of the selected frame to COLOR. 706 "Set the color of the border of the selected frame to COLOR-NAME.
717 When called interactively, prompt for the name of the color to use. 707 When called interactively, prompt for the name of the color to use.
718 To get the frame's current border color, use `frame-parameters'." 708 To get the frame's current border color, use `frame-parameters'."
719 (interactive "sColor: ") 709 (interactive (list (facemenu-read-color)))
720 (modify-frame-parameters (selected-frame) 710 (modify-frame-parameters (selected-frame)
721 (list (cons 'border-color color-name)))) 711 (list (cons 'border-color color-name))))
722 712
723 (defun auto-raise-mode (arg) 713 (defun auto-raise-mode (arg)
724 "Toggle whether or not the selected frame should auto-raise. 714 "Toggle whether or not the selected frame should auto-raise.
761 ;;;; Aliases for backward compatibility with Emacs 18. 751 ;;;; Aliases for backward compatibility with Emacs 18.
762 (defalias 'screen-height 'frame-height) 752 (defalias 'screen-height 'frame-height)
763 (defalias 'screen-width 'frame-width) 753 (defalias 'screen-width 'frame-width)
764 754
765 (defun set-screen-width (cols &optional pretend) 755 (defun set-screen-width (cols &optional pretend)
766 "Obsolete function to change the size of the screen to COLS columns.\n\ 756 "Obsolete function to change the size of the screen to COLS columns.
767 Optional second arg non-nil means that redisplay should use COLS columns\n\ 757 Optional second arg non-nil means that redisplay should use COLS columns
768 but that the idea of the actual width of the frame should not be changed.\n\ 758 but that the idea of the actual width of the frame should not be changed.
769 This function is provided only for compatibility with Emacs 18; new code\n\ 759 This function is provided only for compatibility with Emacs 18; new code
770 should use `set-frame-width instead'." 760 should use `set-frame-width instead'."
771 (set-frame-width (selected-frame) cols pretend)) 761 (set-frame-width (selected-frame) cols pretend))
772 762
773 (defun set-screen-height (lines &optional pretend) 763 (defun set-screen-height (lines &optional pretend)
774 "Obsolete function to change the height of the screen to LINES lines.\n\ 764 "Obsolete function to change the height of the screen to LINES lines.
775 Optional second arg non-nil means that redisplay should use LINES lines\n\ 765 Optional second arg non-nil means that redisplay should use LINES lines
776 but that the idea of the actual height of the screen should not be changed.\n\ 766 but that the idea of the actual height of the screen should not be changed.
777 This function is provided only for compatibility with Emacs 18; new code\n\ 767 This function is provided only for compatibility with Emacs 18; new code
778 should use `set-frame-height' instead." 768 should use `set-frame-height' instead."
779 (set-frame-height (selected-frame) lines pretend)) 769 (set-frame-height (selected-frame) lines pretend))
780 770
781 (make-obsolete 'screen-height 'frame-height) 771 (make-obsolete 'screen-height 'frame-height)
782 (make-obsolete 'screen-width 'frame-width) 772 (make-obsolete 'screen-width 'frame-width)
799 789
800 ;;; Blinking cursor 790 ;;; Blinking cursor
801 791
802 (defgroup cursor nil 792 (defgroup cursor nil
803 "Cursor on frames." 793 "Cursor on frames."
794 :version "21.1"
804 :group 'frames) 795 :group 'frames)
805 796
806 (defcustom blink-cursor-delay 0.5 797 (defcustom blink-cursor-delay 0.5
807 "*Seconds of Emacs idle time after which cursor starts to blink." 798 "*Seconds of Emacs idle time after which cursor starts to blink."
808 :tag "Delay in seconds." 799 :tag "Delay in seconds."
904 (define-key ctl-x-5-map "o" 'other-frame) 895 (define-key ctl-x-5-map "o" 'other-frame)
905 896
906 (provide 'frame) 897 (provide 'frame)
907 898
908 ;;; frame.el ends here 899 ;;; frame.el ends here
900 (frame-notice-user-settings):