annotate lisp/term/win32-win.el @ 318:afd57c14dfc8 r21-0b57

Import from CVS: tag r21-0b57
author cvs
date Mon, 13 Aug 2007 10:45:36 +0200
parents 376386a54a3c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; win32-win.el --- parse switches controlling interface with win32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; Copyright (C) 1993, 1994 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Author: Kevin Gallo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Keywords: terminals
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;; This file is part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;; along with GNU Emacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;; win32-win.el: this file is loaded from ../lisp/startup.el when it recognizes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; that win32 windows are to be used. Command line switches are parsed and those
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;; pertaining to win32 are processed and removed from the command line. The
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; win32 display is opened and hooks are set for popping up the initial window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; startup.el will then examine startup files, and eventually call the hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; which create the first window (s).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; These are the standard X switches from the Xt Initialize.c file of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; Release 4.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; Command line Resource Manager string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; +rv *reverseVideo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;; +synchronous *synchronous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;; -background *background
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;; -bd *borderColor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; -bg *background
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;; -bordercolor *borderColor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;; -borderwidth .borderWidth
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;; -bw .borderWidth
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;; -display .display
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;; -fg *foreground
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;; -fn *font
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;; -font *font
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;; -foreground *foreground
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;; -geometry .geometry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;; -i .iconType
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;; -itype .iconType
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; -iconic .iconic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;; -name .name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;; -reverse *reverseVideo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;; -rv *reverseVideo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;; -selectionTimeout .selectionTimeout
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;; -synchronous *synchronous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;; -xrm
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;; An alist of X options and the function which handles them. See
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;; ../startup.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (if (not (eq (console-type) 'win32))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (error "%s: Loading win32-win.el but not compiled for win32" (invocation-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (defvar x-invocation-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (defvar x-command-line-resources nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (defconst x-option-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 '(("-bw" . x-handle-numeric-switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ("-d" . x-handle-display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ("-display" . x-handle-display)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ("-name" . x-handle-name-rn-switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ("-rn" . x-handle-name-rn-switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ("-T" . x-handle-switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ("-r" . x-handle-switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ("-rv" . x-handle-switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ("-reverse" . x-handle-switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ("-fn" . x-handle-switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ("-font" . x-handle-switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ("-ib" . x-handle-numeric-switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ("-g" . x-handle-geometry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ("-geometry" . x-handle-geometry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ("-fg" . x-handle-switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ("-foreground". x-handle-switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ("-bg" . x-handle-switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ("-background". x-handle-switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ("-ms" . x-handle-switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ("-itype" . x-handle-switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ("-i" . x-handle-switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ("-iconic" . x-handle-iconic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ("-xrm" . x-handle-xrm-switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ("-cr" . x-handle-switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ("-vb" . x-handle-switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ("-hb" . x-handle-switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ("-bd" . x-handle-switch)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (defconst x-long-option-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 '(("--border-width" . "-bw")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ("--display" . "-d")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ("--name" . "-name")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ("--title" . "-T")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ("--reverse-video" . "-reverse")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ("--font" . "-font")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ("--internal-border" . "-ib")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ("--geometry" . "-geometry")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ("--foreground-color" . "-fg")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ("--background-color" . "-bg")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ("--mouse-color" . "-ms")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ("--icon-type" . "-itype")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ("--iconic" . "-iconic")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ("--xrm" . "-xrm")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ("--cursor-color" . "-cr")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ("--vertical-scroll-bars" . "-vb")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ("--border-color" . "-bd")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (defconst x-switch-definitions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 '(("-name" name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ("-T" name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ("-r" reverse t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ("-rv" reverse t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ("-reverse" reverse t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ("-fn" font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ("-font" font)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ("-ib" internal-border-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ("-fg" foreground-color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 ("-foreground" foreground-color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ("-bg" background-color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ("-background" background-color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ("-ms" mouse-color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ("-cr" cursor-color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ("-itype" icon-type t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ("-i" icon-type t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ("-vb" vertical-scroll-bars t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ("-hb" horizontal-scroll-bars t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ("-bd" border-color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 ("-bw" border-width)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ;; Handler for switches of the form "-switch value" or "-switch".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (defun x-handle-switch (switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (let ((aelt (assoc switch x-switch-definitions)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (if aelt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (if (nth 2 aelt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (setq default-frame-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (cons (cons (nth 1 aelt) (nth 2 aelt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 default-frame-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (setq default-frame-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (cons (cons (nth 1 aelt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (car x-invocation-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 default-frame-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 x-invocation-args (cdr x-invocation-args))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ;; Make -iconic apply only to the initial frame!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (defun x-handle-iconic (switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (setq initial-frame-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (cons '(visibility . icon) initial-frame-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ;; Handler for switches of the form "-switch n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (defun x-handle-numeric-switch (switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (let ((aelt (assoc switch x-switch-definitions)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (if aelt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (setq default-frame-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (cons (cons (nth 1 aelt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (string-to-int (car x-invocation-args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 default-frame-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 x-invocation-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (cdr x-invocation-args)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 ;; Handle the -xrm option.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (defun x-handle-xrm-switch (switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (or (consp x-invocation-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (error "%s: missing argument to `%s' option" (invocation-name) switch))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (setq x-command-line-resources (car x-invocation-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (setq x-invocation-args (cdr x-invocation-args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ;; Handle the geometry option
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (defun x-handle-geometry (switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (let ((geo (x-parse-geometry (car x-invocation-args))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (setq initial-frame-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (append initial-frame-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (if (or (assq 'left geo) (assq 'top geo))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 '((user-position . t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (if (or (assq 'height geo) (assq 'width geo))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 '((user-size . t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 geo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 x-invocation-args (cdr x-invocation-args))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 ;; Handle the -name and -rn options. Set the variable x-resource-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 ;; to the option's operand; if the switch was `-name', set the name of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 ;; the initial frame, too.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (defun x-handle-name-rn-switch (switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (or (consp x-invocation-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (error "%s: missing argument to `%s' option" (invocation-name) switch))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (setq x-resource-name (car x-invocation-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 x-invocation-args (cdr x-invocation-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (if (string= switch "-name")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (setq initial-frame-alist (cons (cons 'name x-resource-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 initial-frame-alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (defvar x-display-name nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 "The display name specifying server and frame.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (defun x-handle-display (switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (setq x-display-name (car x-invocation-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 x-invocation-args (cdr x-invocation-args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (defvar x-invocation-args nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (defun x-handle-args (args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 "Process the X-related command line options in ARGS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 This is done before the user's startup file is loaded. They are copied to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 x-invocation args from which the X-related things are extracted, first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 the switch (e.g., \"-fg\") in the following code, and possible values
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 \(e.g., \"black\") in the option handler code (e.g., x-handle-switch).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 This returns ARGS with the arguments that have been processed removed."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (message "%s" args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (setq x-invocation-args args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 args nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (while x-invocation-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (let* ((this-switch (car x-invocation-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (orig-this-switch this-switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 completion argval aelt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (setq x-invocation-args (cdr x-invocation-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 ;; Check for long options with attached arguments
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ;; and separate out the attached option argument into argval.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (if (string-match "^--[^=]*=" this-switch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (setq argval (substring this-switch (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 this-switch (substring this-switch 0 (1- (match-end 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (setq completion (try-completion this-switch x-long-option-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (if (eq completion t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 ;; Exact match for long option.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (setq this-switch (cdr (assoc this-switch x-long-option-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (if (stringp completion)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (let ((elt (assoc completion x-long-option-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 ;; Check for abbreviated long option.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (or elt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (error "Option `%s' is ambiguous" this-switch))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (setq this-switch (cdr elt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 ;; Check for a short option.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (setq argval nil this-switch orig-this-switch)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (setq aelt (assoc this-switch x-option-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (if aelt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (if argval
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (let ((x-invocation-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (cons argval x-invocation-args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (funcall (cdr aelt) this-switch))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (funcall (cdr aelt) this-switch))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (setq args (cons this-switch args)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (setq args (nreverse args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 ;; Available colors
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (defvar x-colors '("aquamarine"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 "Aquamarine"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 "medium aquamarine"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 "MediumAquamarine"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 "black"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 "Black"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 "blue"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 "Blue"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 "cadet blue"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 "CadetBlue"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 "cornflower blue"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 "CornflowerBlue"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 "dark slate blue"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 "DarkSlateBlue"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 "light blue"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 "LightBlue"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 "light steel blue"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 "LightSteelBlue"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 "medium blue"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 "MediumBlue"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 "medium slate blue"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 "MediumSlateBlue"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 "midnight blue"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 "MidnightBlue"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 "navy blue"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 "NavyBlue"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 "navy"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 "Navy"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 "sky blue"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 "SkyBlue"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 "slate blue"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 "SlateBlue"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 "steel blue"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 "SteelBlue"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 "coral"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 "Coral"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 "cyan"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 "Cyan"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 "firebrick"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 "Firebrick"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 "brown"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 "Brown"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 "gold"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 "Gold"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 "goldenrod"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 "Goldenrod"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 "green"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 "Green"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 "dark green"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 "DarkGreen"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 "dark olive green"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 "DarkOliveGreen"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 "forest green"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 "ForestGreen"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 "lime green"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 "LimeGreen"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 "medium sea green"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 "MediumSeaGreen"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 "medium spring green"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 "MediumSpringGreen"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 "pale green"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 "PaleGreen"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 "sea green"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 "SeaGreen"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 "spring green"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 "SpringGreen"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 "yellow green"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 "YellowGreen"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 "dark slate grey"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 "DarkSlateGrey"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 "dark slate gray"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 "DarkSlateGray"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 "dim grey"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 "DimGrey"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 "dim gray"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 "DimGray"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 "light grey"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 "LightGrey"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 "light gray"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 "LightGray"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 "gray"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 "grey"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 "Gray"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 "Grey"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 "khaki"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 "Khaki"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 "magenta"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 "Magenta"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 "maroon"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 "Maroon"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 "orange"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 "Orange"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 "orchid"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 "Orchid"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 "dark orchid"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 "DarkOrchid"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 "medium orchid"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 "MediumOrchid"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 "pink"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 "Pink"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 "plum"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 "Plum"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 "red"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 "Red"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 "indian red"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 "IndianRed"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 "medium violet red"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 "MediumVioletRed"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 "orange red"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 "OrangeRed"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 "violet red"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 "VioletRed"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 "salmon"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 "Salmon"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 "sienna"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 "Sienna"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 "tan"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 "Tan"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 "thistle"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 "Thistle"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 "turquoise"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 "Turquoise"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 "dark turquoise"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 "DarkTurquoise"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 "medium turquoise"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 "MediumTurquoise"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 "violet"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 "Violet"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 "blue violet"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 "BlueViolet"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 "wheat"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 "Wheat"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 "white"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 "White"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 "yellow"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 "Yellow"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 "green yellow"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 "GreenYellow")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 "The full list of X colors from the `rgb.text' file.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (defun x-defined-colors (&optional frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 "Return a list of colors supported for a particular frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 The argument FRAME specifies which frame to try.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 The value may be different for frames on different X displays."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (or frame (setq frame (selected-frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (let ((all-colors x-colors)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (this-color nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (defined-colors nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (while all-colors
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (setq this-color (car all-colors)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 all-colors (cdr all-colors))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (and (face-color-supported-p frame this-color t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (setq defined-colors (cons this-color defined-colors))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 defined-colors))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 ;;;; Function keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (defun iconify-or-deiconify-frame ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 "Iconify the selected frame, or deiconify if it's currently an icon."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (if (eq (cdr (assq 'visibility (frame-parameters))) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (iconify-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (make-frame-visible)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (substitute-key-definition 'suspend-emacs 'iconify-or-deiconify-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 global-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 ;; Map certain keypad keys into ASCII characters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 ;; that people usually expect.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (define-key function-key-map [backspace] [127])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (define-key function-key-map [delete] [127])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (define-key function-key-map [tab] [?\t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (define-key function-key-map [linefeed] [?\n])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (define-key function-key-map [clear] [11])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (define-key function-key-map [return] [13])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (define-key function-key-map [escape] [?\e])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (define-key function-key-map [M-backspace] [?\M-\d])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (define-key function-key-map [M-delete] [?\M-\d])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (define-key function-key-map [M-tab] [?\M-\t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (define-key function-key-map [M-linefeed] [?\M-\n])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (define-key function-key-map [M-clear] [?\M-\013])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (define-key function-key-map [M-return] [?\M-\015])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (define-key function-key-map [M-escape] [?\M-\e])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 ;; These tell read-char how to convert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 ;; these special chars to ASCII.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (put 'backspace 'ascii-character 127)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (put 'delete 'ascii-character 127)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (put 'tab 'ascii-character ?\t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (put 'linefeed 'ascii-character ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (put 'clear 'ascii-character 12)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (put 'return 'ascii-character 13)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (put 'escape 'ascii-character ?\e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 ;;;; Selections and cut buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 ;;; We keep track of the last text selected here, so we can check the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 ;;; current selection against it, and avoid passing back our own text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 ;;; from x-cut-buffer-or-selection-value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (defvar x-last-selected-text nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 ;;; It is said that overlarge strings are slow to put into the cut buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 ;;; Note this value is overridden below.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (defvar x-cut-buffer-max 20000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 "Max number of characters to put in the cut buffer.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (defvar x-select-enable-clipboard t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 "Non-nil means cutting and pasting uses the clipboard.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 This is in addition to the primary selection.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (defun x-select-text (text &optional push)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (if x-select-enable-clipboard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (win32-set-clipboard-data text)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 ;;; Return the value of the current selection.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 ;;; Consult the selection, then the cut buffer. Treat empty strings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 ;;; as if they were unset.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (defun x-get-selection-value ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (if x-select-enable-clipboard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (let (text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 ;; Don't die if x-get-selection signals an error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (condition-case c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (setq text (win32-get-clipboard-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (error (message "win32-get-clipboard-data:%s" c)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (if (string= text "") (setq text nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 text)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 ;;; Do the actual Windows setup here; the above code just defines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 ;;; functions and variables that we use now.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (setq command-line-args (x-handle-args command-line-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 ;;; Make sure we have a valid resource name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (or (stringp x-resource-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (let (i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (setq x-resource-name (invocation-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 ;; Change any . or * characters in x-resource-name to hyphens,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 ;; so as not to choke when we use it in X resource queries.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (while (setq i (string-match "[.*]" x-resource-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (aset x-resource-name i ?-))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 ;; For the benefit of older Emacses (19.27 and earlier) that are sharing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 ;; the same lisp directory, don't pass the third argument unless we seem
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 ;; to have the multi-display support.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (if (fboundp 'x-close-connection)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (x-open-connection ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 x-command-line-resources
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 ;; Exit Emacs with fatal error if this fails.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (x-open-connection ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 x-command-line-resources))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (setq frame-creation-function 'x-create-frame-with-faces)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (setq x-cut-buffer-max (min (- (/ (x-server-max-request-size) 2) 100)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 x-cut-buffer-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 ;; Win32 expects the menu bar cut and paste commands to use the clipboard.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 ;; This has ,? to match both on Sunos and on Solaris.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (menu-bar-enable-clipboard)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 ;; Apply a geometry resource to the initial frame. Put it at the end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 ;; of the alist, so that anything specified on the command line takes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 ;; precedence.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (let* ((res-geometry (x-get-resource "geometry" "Geometry"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 parsed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (if res-geometry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (setq parsed (x-parse-geometry res-geometry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 ;; If the resource specifies a position,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 ;; call the position and size "user-specified".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (if (or (assq 'top parsed) (assq 'left parsed))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (setq parsed (cons '(user-position . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (cons '(user-size . t) parsed))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 ;; All geometry parms apply to the initial frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (setq initial-frame-alist (append initial-frame-alist parsed))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 ;; The size parms apply to all frames.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (if (assq 'height parsed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (setq default-frame-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (cons (cons 'height (cdr (assq 'height parsed)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 default-frame-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (if (assq 'width parsed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (setq default-frame-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (cons (cons 'width (cdr (assq 'width parsed)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 default-frame-alist))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 ;; Check the reverseVideo resource.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (let ((case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (let ((rv (x-get-resource "reverseVideo" "ReverseVideo")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (if (and rv
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (string-match "^\\(true\\|yes\\|on\\)$" rv))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (setq default-frame-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (cons '(reverse . t) default-frame-alist)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 ;; Set x-selection-timeout, measured in milliseconds.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (let ((res-selection-timeout
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (x-get-resource "selectionTimeout" "SelectionTimeout")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (setq x-selection-timeout 20000)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (if res-selection-timeout
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (setq x-selection-timeout (string-to-number res-selection-timeout))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (defun x-win-suspend-error ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (error "Suspending an emacs running under Win32 makes no sense"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (add-hook 'suspend-hook 'x-win-suspend-error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 ;;; Arrange for the kill and yank functions to set and check the clipboard.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (setq interprogram-cut-function 'x-select-text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (setq interprogram-paste-function 'x-get-selection-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 ;;; Turn off window-splitting optimization; win32 is usually fast enough
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 ;;; that this is only annoying.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (setq split-window-keep-point t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 ;; Don't show the frame name; that's redundant.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (setq-default mode-line-buffer-identification '("Emacs: %12b"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 ;;; Set to a system sound if you want a fancy bell.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (set-message-beep 'ok)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 ;; Remap some functions to call win32 common dialogs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (defun internal-face-interactive (what &optional bool)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (let* ((fn (intern (concat "face-" what)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (prompt (concat "Set " what " of face"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (face (read-face-name (concat prompt ": ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 (default (if (fboundp fn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (or (funcall fn face (selected-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (funcall fn 'default (selected-frame)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (fn-win (intern (concat (symbol-name window-system) "-select-" what)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (if (fboundp fn-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (funcall fn-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (if bool
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (y-or-n-p (concat "Should face " (symbol-name face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 " be " bool "? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (read-string (concat prompt " " (symbol-name face) " to: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 default)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (list face (if (equal value "") nil value))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 ;; Redefine the font selection to use the Win32 dialog
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (defun mouse-set-font (&rest fonts)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (set-default-font (win32-select-font)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 ;;; win32-win.el ends here