annotate lisp/gtk-init.el @ 5553:62edcc6a11ec

Add an assertion about argument order to #'apply-partially compiler macro lisp/ChangeLog addition: 2011-08-24 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (apply-partially): Add an assertion to this compiler macro, requiring that the order of the placeholders corresponding to the arguments in the constants vector of the constructed compiled function be the same as the order of the arguments to #'apply-partially. tests/ChangeLog addition: 2011-08-24 Aidan Kehoe <kehoea@parhasard.net> * automated/lisp-tests.el: Add a test of apply partially that depends on the relative order of its arguments.
author Aidan Kehoe <kehoea@parhasard.net>
date Wed, 24 Aug 2011 11:06:41 +0100
parents 3d1f8f0e690f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1 ;;; gtk-init.el --- initialization code for mswindows
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2 ;; Copyright (C) 1990, 1993, 1994 Free Software Foundation, Inc.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
3 ;; Copyright (C) 1995 Board of Trustees, University of Illinois.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
4 ;; Copyright (C) 1995, 1996 Ben Wing.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
5
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
6 ;; Author: various
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
7 ;; Rewritten for Gtk by: William Perry
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
8
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
9 ;; This file is part of XEmacs.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
10
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4477
diff changeset
11 ;; XEmacs is free software: you can redistribute it and/or modify it
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4477
diff changeset
12 ;; under the terms of the GNU General Public License as published by the
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4477
diff changeset
13 ;; Free Software Foundation, either version 3 of the License, or (at your
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4477
diff changeset
14 ;; option) any later version.
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
15
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4477
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4477
diff changeset
17 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4477
diff changeset
18 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4477
diff changeset
19 ;; for more details.
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
20
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4477
diff changeset
22 ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>.
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
23
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 487
diff changeset
24 (globally-declare-boundp
4477
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
25 '(gtk-initial-argv-list gtk-initial-geometry))
506
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 502
diff changeset
26
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 502
diff changeset
27 (globally-declare-fboundp
39ccc7dd8077 [xemacs-hg @ 2001-05-05 08:39:59 by ben]
ben
parents: 502
diff changeset
28 '(gtk-keysym-on-keyboard-p))
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 487
diff changeset
29
4477
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
30 (defvar gtk-early-lisp-options-file "~/.xemacs/gtk-options.el"
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
31 "Path where GTK-specific early options should be stored.
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
32
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
33 This allows the user to set initial geometry without using GNOME and session
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
34 management, and, since it is read before GTK is initialized, it avoids
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
35 window flicker on resizing.
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
36
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
37 It is normally not useful to change without recompiling XEmacs.")
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
38
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
39 (defvar gtk-command-switch-alist
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
40 '(
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
41 ;; GNOME Options
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
42 ("--disable-sound" . nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
43 ("--enable-sound" . nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
44 ("--espeaker" . t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
45
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
46 ;; GTK Options
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
47 ("--gdk-debug" . t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
48 ("--gdk-no-debug" . t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
49 ("--display" . t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
50 ("--sync" . nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
51 ("--no-xshm" . nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
52 ("--name" . t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
53 ("--class" . t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
54 ("--gxid_host" . t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
55 ("--gxid_port" . t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
56 ("--xim-preedit" . t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
57 ("--xim-status" . t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
58 ("--gtk-debug" . t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
59 ("--gtk-no-debug" . t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
60 ("--gtk-module" . t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
61
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
62 ;; Glib options
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
63 ("--g-fatal-warnings" . nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
64
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
65 ;; Session management options
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
66 ("--sm-client-id" . t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
67 ("--sm-config-prefix" . t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
68 ("--sm-disable" . t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
69 )
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
70
4477
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
71 "An assoc list of command line args that should be in gtk-initial-argv-list.
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
72 This is necessary because GTK and GNOME consider it a fatal error if they
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
73 receive unknown command line arguments (perfectly reasonable). But this
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
74 means that if the user specifies a file name on the command line they will
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
75 be unable to start. So we filter the command line and allow only items in
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
76 this list in.
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
77
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
78 The CDR of the assoc list is whether it accepts an argument. For the
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
79 moment, all options are in GNU long form.")
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
80
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
81 (defvar make-device-early-gtk-entry-point-called-p nil
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
82 "Whether `make-device-early-gtk-entry-point' has been called, at least once.
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
83
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
84 Much of the GTK-specific Lisp init code should only be called the first time
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
85 a GTK device is created; this variable allows for that.")
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
86
4477
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
87 (defvar make-device-late-gtk-entry-point-called-p nil
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
88 "Whether `make-device-late-gtk-entry-point' has been called, at least once.
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
89
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
90 Much of the GTK-specific Lisp init code should only be called the first time
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
91 a GTK device is created; this variable allows for that.")
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
92
4477
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
93 (defun make-device-early-gtk-entry-point ()
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
94 "Entry point to set up the Lisp environment before GTK device creation."
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
95 (unless make-device-early-gtk-entry-point-called-p
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
96 (setq initial-frame-plist
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
97 (and initial-frame-unmapped-p '(initially-unmapped t))
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
98 gtk-initial-argv-list
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
99 (cons (car command-line-args) (gtk-filter-arguments))
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
100 gtk-initial-geometry
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
101 (nth 1 (member "-geometry" command-line-args-left))
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
102 make-device-early-gtk-entry-point-called-p t)
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
103 (unless vanilla-inhibiting
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
104 (load gtk-early-lisp-options-file t t t))))
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
105
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
106 (defun gtk-init-handle-geometry (arg)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
107 "Set up initial geometry info for GTK devices."
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
108 (setq gtk-initial-geometry (pop command-line-args-left)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
109
4477
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
110 (defun make-device-late-gtk-entry-point (device)
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
111 "Entry-Point to do any Lisp-level GTK device-specific initialization."
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
112 (unless make-device-late-gtk-entry-point-called-p
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
113 (setq make-device-late-gtk-entry-point-called-p t)))
e34711681f30 Don't determine whether to call general device-type code at startup,
Aidan Kehoe <kehoea@parhasard.net>
parents: 4380
diff changeset
114
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
115 (defun gtk-filter-arguments ()
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
116 (let ((accepted nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
117 (rejected nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
118 (todo nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
119 (setq todo (mapcar (lambda (argdesc)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
120 (if (cdr argdesc)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
121 ;; Need to look for --foo=bar
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
122 (concat "^" (car argdesc) "=")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
123 ;; Just a simple arg
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
124 (concat "^" (regexp-quote (car argdesc)) "$")))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
125 gtk-command-switch-alist))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
126
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
127 (while command-line-args-left
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
128 (if (catch 'found
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
129 (mapc (lambda (r)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
130 (if (string-match r (car command-line-args-left))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
131 (throw 'found t))) todo)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
132 (mapc (lambda (argdesc)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
133 (if (cdr argdesc)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
134 ;; This time we only care about argument items
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
135 ;; that take an argument. We'll check to see if
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
136 ;; someone used --foo bar instead of --foo=bar
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
137 (if (string-match (concat "^" (car argdesc) "$") (car command-line-args-left))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
138 ;; Yup! Need to push
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
139 (progn
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
140 (push (pop command-line-args-left) accepted)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
141 (throw 'found t)))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
142 gtk-command-switch-alist)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
143 nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
144 (push (pop command-line-args-left) accepted)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
145 (push (pop command-line-args-left) rejected)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
146 (setq command-line-args-left (nreverse rejected))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
147 (nreverse accepted)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
148
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
149 (push '("-geometry" . gtk-init-handle-geometry) command-switch-alist)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
150