annotate lisp/keymap.el @ 5908:6174848f3e6c

Use parse_integer() in read_atom(); support bases with ratios like integers src/ChangeLog addition: 2015-05-08 Aidan Kehoe <kehoea@parhasard.net> * data.c (init_errors_once_early): Move the Qunsupported_type here from numbers.c, so it's available when the majority of our types are not supported. * general-slots.h: Add it here, too. * number.c: Remove the definition of Qunsupported_type from here. * lread.c (read_atom): Check if the first character could reflect a rational, if so, call parse_integer(), don't check the syntax of the other characters. This allows us to accept the non-ASCII digit characters too. If that worked partially, but not completely, and the next char is a slash, try to parse as a ratio. If that fails, try isfloat_string(), but only if the first character could plausibly be part of a float. Otherwise, treat as a symbol. * lread.c (read_rational): Rename from read_integer. Handle ratios with the same radix specification as was used for integers. * lread.c (read1): Rename read_integer in this function. Support the Common Lisp #NNNrMMM syntax for parsing a number MMM of arbitrary radix NNN. man/ChangeLog addition: 2015-05-08 Aidan Kehoe <kehoea@parhasard.net> * lispref/numbers.texi (Numbers): Describe the newly-supported arbitrary-base syntax for rationals (integers and ratios). Describe that ratios can take the same base specification as integers, something also new. tests/ChangeLog addition: 2015-05-08 Aidan Kehoe <kehoea@parhasard.net> * automated/lisp-reader-tests.el: Check the arbitrary-base integer reader syntax support, just added. Check the reader base support for ratios, just added. Check the non-ASCII-digit support in the reader, just added.
author Aidan Kehoe <kehoea@parhasard.net>
date Sat, 09 May 2015 00:40:57 +0100
parents c87b776ab0e1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 ;; keymap.el --- Keymap functions for XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 ;; Copyright (C) 1993-4, 1997 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 ;; Copyright (C) 1995 Tinker Systems and INS Engineering Corp.
1333
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
5 ;; Copyright (C) 2003 Ben Wing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 ;; Maintainer: XEmacs Development Team
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 ;; Keywords: internals, dumped
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 ;; This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 2828
diff changeset
12 ;; 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: 2828
diff changeset
13 ;; 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: 2828
diff changeset
14 ;; 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: 2828
diff changeset
15 ;; option) any later version.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 2828
diff changeset
17 ;; 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: 2828
diff changeset
18 ;; 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: 2828
diff changeset
19 ;; 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: 2828
diff changeset
20 ;; for more details.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 ;; 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: 2828
diff changeset
23 ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 ;;; Synched up with: FSF 19.28.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 ;;; Commentary:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 ;; This file is dumped with XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 ;;; Note: FSF does not have a file keymap.el. This stuff is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 ;;; in keymap.c.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 ;Prevent the \{...} documentation construct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 ;from mentioning keys that run this command.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 ;;; Code:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38
1333
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
39 ;; BEGIN SYNCHED WITH FSF 21.2.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 (defun undefined ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 (ding))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44
1333
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
45 ;Prevent the \{...} documentation construct
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
46 ;from mentioning keys that run this command.
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
47 (put 'undefined 'suppress-keymap t)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 (defun suppress-keymap (map &optional nodigits)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 "Make MAP override all normally self-inserting keys to be undefined.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 Normally, as an exception, digits and minus-sign are set to make prefix args,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 but optional second arg NODIGITS non-nil treats them like other chars."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 (substitute-key-definition 'self-insert-command 'undefined map global-map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 (or nodigits
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 (let ((string (make-string 1 ?0)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 (define-key map "-" 'negative-argument)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 ;; Make plain numbers do numeric args.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 (while (<= (aref string 0) ?9)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 (define-key map string 'digit-argument)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 (incf (aref string 0))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61
1333
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
62 ;Unneeded in XEmacs (defvar key-substitution-in-progress nil
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
63
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 (defun substitute-key-definition (olddef newdef keymap &optional oldmap prefix)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 "Replace OLDDEF with NEWDEF for any keys in KEYMAP now defined as OLDDEF.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 In other words, OLDDEF is replaced with NEWDEF wherever it appears.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 Prefix keymaps are checked recursively. If optional fourth argument OLDMAP
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 is specified, we redefine in KEYMAP as NEWDEF those chars which are defined
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
69 as OLDDEF in OLDMAP, unless that keybinding is already present in KEYMAP.
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
70 If optional fifth argument PREFIX is non-nil, then only those occurrences of
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 OLDDEF found in keymaps accessible through the keymap bound to PREFIX in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 KEYMAP are redefined. See also `accessible-keymaps'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 (let ((maps (accessible-keymaps (or oldmap keymap) prefix))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 (shadowing (not (null oldmap)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 prefix map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 (while maps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 (setq prefix (car (car maps))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 map (cdr (car maps))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 maps (cdr maps))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 ;; Substitute in this keymap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 (map-keymap #'(lambda (key binding)
1333
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
82 (if (or (eq binding olddef)
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
83 ;; Compare with equal if definition is a key
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
84 ;; sequence. That is useful for operating on
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
85 ;; function-key-map.
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
86 (and (or (stringp binding) (vectorp binding))
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
87 (equal binding olddef)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 ;; The new bindings always go in KEYMAP even if we
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 ;; found them in OLDMAP or one of its children.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 ;; If KEYMAP will be shadowing OLDMAP, then do not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 ;; redefine the key if there is another binding
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 ;; in KEYMAP that will shadow OLDDEF.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 (or (and shadowing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 (lookup-key keymap key))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 ;; define-key will give an error if a prefix
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 ;; of the key is already defined. Otherwise
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 ;; it will define the key in the map.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 ;; #### - Perhaps this should be protected?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 (define-key
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 keymap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 (vconcat prefix (list key))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 newdef))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 )))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105
1333
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
106 ;; FSF garbage. They misguidedly tried to put menu entries into keymaps,
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
107 ;; and needed stuff like the following. Eventually they admitted defeat
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
108 ;; and switched to our method.
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
109
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
110 ; (defun define-key-after (keymap key definition &optional after)
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
111 ; "Add binding in KEYMAP for KEY => DEFINITION, right after AFTER's binding.
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
112 ; This is like `define-key' except that the binding for KEY is placed
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
113 ; just after the binding for the event AFTER, instead of at the beginning
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
114 ; of the map. Note that AFTER must be an event type (like KEY), NOT a command
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
115 ; \(like DEFINITION).
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
116 ;
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
117 ; If AFTER is t or omitted, the new binding goes at the end of the keymap.
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
118 ;
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
119 ; KEY must contain just one event type--that is to say, it must be a
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
120 ; string or vector of length 1, but AFTER should be a single event
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
121 ; type--a symbol or a character, not a sequence.
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
122 ;
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
123 ; Bindings are always added before any inherited map.
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
124 ;
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
125 ; The order of bindings in a keymap matters when it is used as a menu."
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
126
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
127 (defmacro kbd (keys)
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
128 "Convert KEYS to the internal Emacs key representation.
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
129 KEYS should be a string constant in the format used for
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
130 saving keyboard macros (see `insert-kbd-macro')."
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
131 (if (or (stringp keys)
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
132 (vectorp keys))
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
133 ;; #### need to move xemacs-base into the core!!!!!!
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
134 (declare-fboundp (read-kbd-macro keys))
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
135 `(declare-fboundp (read-kbd-macro ,keys))))
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
136
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 776
diff changeset
137 ;; END SYNCHED WITH FSF 21.2.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 ;; This used to wrap forms into an interactive lambda. It is unclear
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 ;; to me why this is needed in this function. Anyway,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 ;; `key-or-menu-binding' doesn't do it, so this function no longer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 ;; does it, either.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 (defun insert-key-binding (key) ; modeled after describe-key
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 "Insert the command bound to KEY."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 (interactive "kInsert command bound to key: ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 (let ((defn (key-or-menu-binding key)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 (if (or (null defn) (integerp defn))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 (error "%s is undefined" (key-description key))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 (if (or (stringp defn) (vectorp defn))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 (setq defn (key-binding defn))) ;; a keyboard macro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 (insert (format "%s" defn)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 (defun read-command-or-command-sexp (prompt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 "Read a command symbol or command sexp.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 A command sexp is wrapped in an interactive lambda if needed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 Prompts with PROMPT."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 ;; Todo: it would be better if we could reject symbols that are not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 ;; commandp (as does 'read-command') but that is not easy to do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 ;; because we must supply arg4 = require-match = nil for sexp case.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 (let ((result (car (read-from-string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 (completing-read prompt obarray 'commandp)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 (if (and (consp result)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 (not (eq (car result) 'lambda)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 `(lambda ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 ,result)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 result)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
169 (defun local-key-binding (keys &optional accept-defaults)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 "Return the binding for command KEYS in current local keymap only.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 KEYS is a string, a vector of events, or a vector of key-description lists
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 as described in the documentation for the `define-key' function.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 The binding is probably a symbol with a function definition; see
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 the documentation for `lookup-key' for more information."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 (let ((map (current-local-map)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 (if map
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
177 (lookup-key map keys accept-defaults)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
180 (defun global-key-binding (keys &optional accept-defaults)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 "Return the binding for command KEYS in current global keymap only.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 KEYS is a string or vector of events, a sequence of keystrokes.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 The binding is probably a symbol with a function definition; see
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 the documentation for `lookup-key' for more information."
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
185 (lookup-key (current-global-map) keys accept-defaults))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 (defun global-set-key (key command)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 "Give KEY a global binding as COMMAND.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 COMMAND is a symbol naming an interactively-callable function.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 KEY is a string, a vector of events, or a vector of key-description lists
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 as described in the documentation for the `define-key' function.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 Note that if KEY has a local binding in the current buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 that local binding will continue to shadow any global binding."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 ;;(interactive "KSet key globally: \nCSet key %s to command: ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 (interactive (list (setq key (read-key-sequence "Set key globally: "))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 ;; Command sexps are allowed here so that this arg
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 ;; may be supplied interactively via insert-key-binding.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 (read-command-or-command-sexp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 (format "Set key %s to command: "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 (key-description key)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 (define-key (current-global-map) key command)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 (defun local-set-key (key command)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 "Give KEY a local binding as COMMAND.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 COMMAND is a symbol naming an interactively-callable function.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 KEY is a string, a vector of events, or a vector of key-description lists
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 as described in the documentation for the `define-key' function.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 The binding goes in the current buffer's local map,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 which is shared with other buffers in the same major mode."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 ;;(interactive "KSet key locally: \nCSet key %s locally to command: ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 (interactive (list (setq key (read-key-sequence "Set key locally: "))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 ;; Command sexps are allowed here so that this arg
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 ;; may be supplied interactively via insert-key-binding.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 (read-command-or-command-sexp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 (format "Set key %s locally to command: "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 (key-description key)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 (if (null (current-local-map))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 (use-local-map (make-sparse-keymap)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 (define-key (current-local-map) key command)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 (defun global-unset-key (key)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 "Remove global binding of KEY.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 KEY is a string, a vector of events, or a vector of key-description lists
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 as described in the documentation for the `define-key' function."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 (interactive "kUnset key globally: ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 (global-set-key key nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 (defun local-unset-key (key)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 "Remove local binding of KEY.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 KEY is a string, a vector of events, or a vector of key-description lists
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 as described in the documentation for the `define-key' function."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 (interactive "kUnset key locally: ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 (if (current-local-map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 (define-key (current-local-map) key nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 ;; FSF-inherited brain-death.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 (defun minor-mode-key-binding (key &optional accept-default)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 "Find the visible minor mode bindings of KEY.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 Return an alist of pairs (MODENAME . BINDING), where MODENAME is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 the symbol which names the minor mode binding KEY, and BINDING is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 KEY's definition in that mode. In particular, if KEY has no
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 minor-mode bindings, return nil. If the first binding is a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 non-prefix, all subsequent bindings will be omitted, since they would
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 be ignored. Similarly, the list doesn't include non-prefix bindings
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 that come after prefix bindings.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 If optional argument ACCEPT-DEFAULT is non-nil, recognize default
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 bindings; see the description of `lookup-key' for more details about this."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 (let ((tail minor-mode-map-alist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 a s v)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 (while tail
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 (setq a (car tail)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 tail (cdr tail))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 (and (consp a)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 (symbolp (setq s (car a)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 (boundp s)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 (symbol-value s)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 ;; indirect-function deals with autoloadable keymaps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 (setq v (indirect-function (cdr a)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 (setq v (lookup-key v key accept-default))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 ;; Terminate loop, with v set to non-nil value
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 (setq tail nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 v))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 (defun current-minor-mode-maps ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 "Return a list of keymaps for the minor modes of the current buffer."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 (let ((l '())
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 (tail minor-mode-map-alist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 a s v)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 (while tail
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 (setq a (car tail)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 tail (cdr tail))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 (and (consp a)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 (symbolp (setq s (car a)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 (boundp s)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 (symbol-value s)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 ;; indirect-function deals with autoloadable keymaps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 (setq v (indirect-function (cdr a)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 (setq l (cons v l))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 (nreverse l)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 ;;#### What a crock
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 (defun define-prefix-command (name &optional mapvar)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 "Define COMMAND as a prefix command.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 A new sparse keymap is stored as COMMAND's function definition.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 If second optional argument MAPVAR is not specified,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 COMMAND's value (as well as its function definition) is set to the keymap.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 If a second optional argument MAPVAR is given and is not `t',
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 the map is stored as its value.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 Regardless of MAPVAR, COMMAND's function-value is always set to the keymap."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 (let ((map (make-sparse-keymap name)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 (fset name map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 (cond ((not mapvar)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 (set name map))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 ((eq mapvar 't)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 (set mapvar map)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 ;;; Converting vectors of events to a read-equivalent form.
5745
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
308 (defun events-to-keys (events &optional no-mice)
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
309 "Given a vector of event objects, return a vector of key descriptors.
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
310
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
311 If all events can be represented unambiguously as characters, return a
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
312 string. Both the string and the vector will be equivalent to the events, if
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
313 the elements are passed to `character-to-event'.
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
314
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
315 If an event represents a key press of a printable ASCII character between ?@
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
316 and ?_, with the control modifier and only the control modifier, it is
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
317 returned as a character between ?\x00 and ?\x1f, inclusive. ?\\C-i, ?\\C-j,
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
318 ?\\C-m are returned as the symbols `tab', `linefeed' and `return',
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
319 respectively.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320
5745
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
321 There is a similar equivalence between ASCII characters with the meta
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
322 modifier and Latin 1 characters, but this function does not use that
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
323 equivalence.
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
324
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
325 Obsolete optional argument NO-MICE means that mouse events are not allowed.
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
326 These are actually never allowed, since `character-to-event' never accepts
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
327 them.
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
328
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
329 EVENTS can be a string, and will be treated as a vector of the events
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
330 corresponding to those characters."
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
331 ;; This is only used in packages. There were some contexts where it was
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
332 ;; used in core, but those dated from before #'lookup-key accepted events
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
333 ;; in KEYS; it conses less and is more accurate to use the events directly,
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
334 ;; rather than calling this function. It'd be nice to move this to
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
335 ;; xemacs-base and add an autoload, there's no need for it to be dumped.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 (if (and events (symbolp events)) (setq events (vector events)))
5745
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
337 (check-type events array)
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
338 (cond ((let* ((length (length events))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 (string (make-string length 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 c ce
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 (i 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 (while (< i length)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 (setq ce (aref events i))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 (or (eventp ce) (setq ce (character-to-event ce)))
5745
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
345 ;; Normalize `c' to `?c' and `(control k)' to `?\C-k' We don't
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
346 ;; "normalize" Latin 1 to the corresponding meta characters, or
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
347 ;; vice-versa.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 (setq c (event-to-character ce))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 (if (and c
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 (key-press-event-p ce))
5745
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
351 (if (symbolp (event-key ce))
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
352 (if (get (event-key ce) 'character-of-keysym)
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
353 ;; Don't use a string `tab' to avoid that unpleasant
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
354 ;; little ambiguity.
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
355 (setq c nil))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 (if c
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 (aset string i c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 (setq i length string nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 (setq i (1+ i)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 string))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 (let* ((length (length events))
5745
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
363 (new (vconcat events nil))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 event mods key
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 (i 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 (while (< i length)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 (setq event (aref events i))
5745
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
368 (or (eventp event) (setq event (character-to-event event)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 (cond ((key-press-event-p event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 (setq mods (event-modifiers event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 key (event-key event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 (aset new i (if mods
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 (nconc mods (cons key nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 key)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 ((or (and event (symbolp event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 (and (consp event) (symbolp (car event))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 (aset new i event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 (t
5745
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
379 (signal 'wrong-type-argument
f9e4d44504a4 Document #'events-to-keys some more, use it less.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5576
diff changeset
380 (list 'key-press-event-p event))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 (setq i (1+ i)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 new))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383
5801
0e9f791cc655 Support `function-key-map' in #'read-char{,-exclusive}, sync API with GNU
Aidan Kehoe <kehoea@parhasard.net>
parents: 5745
diff changeset
384 (defun next-key-event (&optional event prompt)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 "Return the next available keyboard event."
5801
0e9f791cc655 Support `function-key-map' in #'read-char{,-exclusive}, sync API with GNU
Aidan Kehoe <kehoea@parhasard.net>
parents: 5745
diff changeset
386 (while (not (key-press-event-p
0e9f791cc655 Support `function-key-map' in #'read-char{,-exclusive}, sync API with GNU
Aidan Kehoe <kehoea@parhasard.net>
parents: 5745
diff changeset
387 (setq event (next-command-event event prompt))))
0e9f791cc655 Support `function-key-map' in #'read-char{,-exclusive}, sync API with GNU
Aidan Kehoe <kehoea@parhasard.net>
parents: 5745
diff changeset
388 (dispatch-event event))
0e9f791cc655 Support `function-key-map' in #'read-char{,-exclusive}, sync API with GNU
Aidan Kehoe <kehoea@parhasard.net>
parents: 5745
diff changeset
389 event)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 (defun key-sequence-list-description (keys)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 "Convert a key sequence KEYS to the full [(modifiers... key)...] form.
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
393 Argument KEYS can be in any form accepted by `define-key' function.
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
394 The output is always in a canonical form, meaning you can use this
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
395 function to determine if two key sequence specifications are equivalent
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
396 by comparing the respective outputs of this function using `equal'."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 (let ((vec
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
398 (cond ((vectorp keys)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
399 keys)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
400 ((stringp keys)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
401 (vconcat keys))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
402 (t
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
403 (vector keys)))))
5567
3bc58dc9d688 Replace #'flet by #'labels where appropriate, core code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5549
diff changeset
404 (labels ((event-to-list (ev)
3bc58dc9d688 Replace #'flet by #'labels where appropriate, core code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5549
diff changeset
405 (append (event-modifiers ev) (list (event-key ev)))))
5576
071b810ceb18 Declare labels as line where appropriate; use #'labels, not #'flet, tests.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5567
diff changeset
406 (declare (inline event-to-list))
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
407 (mapvector
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
408 #'(lambda (key)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
409 (let* ((full-key
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
410 (cond ((key-press-event-p key)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
411 (event-to-list key))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
412 ((characterp key)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
413 (event-to-list (character-to-event key)))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
414 ((listp key)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
415 (copy-sequence key))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
416 (t
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
417 (list key))))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
418 (keysym (car (last full-key))))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
419 (if (characterp keysym)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
420 (setcar (last full-key) (intern (char-to-string keysym))))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
421 full-key))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
422 vec))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 ;;; Support keyboard commands to turn on various modifiers.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 ;;; These functions -- which are not commands -- each add one modifier
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 ;;; to the following event.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 (defun event-apply-alt-modifier (ignore-prompt)
5549
493c487cbc3f Add #'event-apply-modifiers, implement #'event-apply-modifiers in terms of it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5529
diff changeset
431 (event-apply-modifiers '(alt)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 (defun event-apply-super-modifier (ignore-prompt)
5549
493c487cbc3f Add #'event-apply-modifiers, implement #'event-apply-modifiers in terms of it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5529
diff changeset
433 (event-apply-modifiers '(super)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 (defun event-apply-hyper-modifier (ignore-prompt)
5549
493c487cbc3f Add #'event-apply-modifiers, implement #'event-apply-modifiers in terms of it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5529
diff changeset
435 (event-apply-modifiers '(hyper)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 (defun event-apply-shift-modifier (ignore-prompt)
5549
493c487cbc3f Add #'event-apply-modifiers, implement #'event-apply-modifiers in terms of it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5529
diff changeset
437 (event-apply-modifiers '(shift)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 (defun event-apply-control-modifier (ignore-prompt)
5549
493c487cbc3f Add #'event-apply-modifiers, implement #'event-apply-modifiers in terms of it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5529
diff changeset
439 (event-apply-modifiers '(control)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 (defun event-apply-meta-modifier (ignore-prompt)
5549
493c487cbc3f Add #'event-apply-modifiers, implement #'event-apply-modifiers in terms of it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5529
diff changeset
441 (event-apply-modifiers '(meta)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 ;;; #### `key-translate-map' is ignored for now.
5549
493c487cbc3f Add #'event-apply-modifiers, implement #'event-apply-modifiers in terms of it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5529
diff changeset
444 (defun event-apply-modifiers (list)
493c487cbc3f Add #'event-apply-modifiers, implement #'event-apply-modifiers in terms of it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5529
diff changeset
445 "Return the next key event, with a list of modifiers applied.
493c487cbc3f Add #'event-apply-modifiers, implement #'event-apply-modifiers in terms of it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5529
diff changeset
446 LIST describes the names of these modifier, a list of symbols.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 `function-key-map' is scanned for prefix bindings."
5808
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
448 (let (events binding key-sequence-list-description symbol-name)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 ;; read keystrokes scanning `function-key-map'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 (while (keymapp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 (setq binding
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 (lookup-key
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 function-key-map
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 (vconcat
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 (setq events
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 (append events (list (next-key-event)))))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 (if binding ; found a binding
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 ;; allow for several modifiers
5801
0e9f791cc655 Support `function-key-map' in #'read-char{,-exclusive}, sync API with GNU
Aidan Kehoe <kehoea@parhasard.net>
parents: 5745
diff changeset
460 (if (functionp binding)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 (setq binding (funcall binding nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 (setq events (append binding nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 ;; put remaining keystrokes back into input queue
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 (setq unread-command-events
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 (mapcar 'character-to-event (cdr events))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 (setq unread-command-events (cdr events)))
5549
493c487cbc3f Add #'event-apply-modifiers, implement #'event-apply-modifiers in terms of it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5529
diff changeset
467 ;; add modifiers LIST to the first keystroke or event
5808
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
468 (setf key-sequence-list-description
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
469 (aref (key-sequence-list-description (car events)) 0))
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
470 (if (and (member 'shift list)
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
471 (symbolp (car (last key-sequence-list-description)))
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
472 (eql 1 (length
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
473 (setq symbol-name
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
474 (symbol-name
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
475 (car (last key-sequence-list-description))))))
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
476 (not (eql (aref symbol-name 0) (upcase (aref symbol-name 0)))))
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
477 (setf (car (last key-sequence-list-description))
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
478 (intern (upcase symbol-name))
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
479 list (remove* 'shift list)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 (vector
5549
493c487cbc3f Add #'event-apply-modifiers, implement #'event-apply-modifiers in terms of it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5529
diff changeset
481 (append list
5808
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
482 (set-difference key-sequence-list-description list :stable t)))))
5549
493c487cbc3f Add #'event-apply-modifiers, implement #'event-apply-modifiers in terms of it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5529
diff changeset
483
493c487cbc3f Add #'event-apply-modifiers, implement #'event-apply-modifiers in terms of it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5529
diff changeset
484 (defun event-apply-modifier (symbol)
493c487cbc3f Add #'event-apply-modifiers, implement #'event-apply-modifiers in terms of it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5529
diff changeset
485 "Return the next key event, with a single modifier applied.
493c487cbc3f Add #'event-apply-modifiers, implement #'event-apply-modifiers in terms of it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5529
diff changeset
486 See `event-apply-modifiers'."
493c487cbc3f Add #'event-apply-modifiers, implement #'event-apply-modifiers in terms of it.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5529
diff changeset
487 (event-apply-modifiers (list symbol)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 (defun synthesize-keysym (ignore-prompt)
5801
0e9f791cc655 Support `function-key-map' in #'read-char{,-exclusive}, sync API with GNU
Aidan Kehoe <kehoea@parhasard.net>
parents: 5745
diff changeset
490 "Read a sequence of characters, and return the corresponding keysym.
0e9f791cc655 Support `function-key-map' in #'read-char{,-exclusive}, sync API with GNU
Aidan Kehoe <kehoea@parhasard.net>
parents: 5745
diff changeset
491 The characters must be ?-, or ?_, or have word syntax. Reading is
0e9f791cc655 Support `function-key-map' in #'read-char{,-exclusive}, sync API with GNU
Aidan Kehoe <kehoea@parhasard.net>
parents: 5745
diff changeset
492 terminated by RET (which is discarded)."
5808
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
493 ;; This has the disadvantage that only X11 keysyms (and space, backspace
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
494 ;; and friends, together with the trivial one-character keysyms) are
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
495 ;; recognised, and then only on a build with X11 support which has had an
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
496 ;; X11 frame open at some point.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 (let ((continuep t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 event char list)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 (while continuep
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 (setq event (next-key-event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 (cond ((and (setq char (event-to-character event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 (or (memq char '(?- ?_))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 (eq ?w (char-syntax char (standard-syntax-table)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 ;; Advance a character.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 (push char list))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 ((or (memq char '(?\r ?\n))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 (memq (event-key event) '(return newline)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 ;; Legal termination.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 (setq continuep nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 (char
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 ;; Illegal character.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 (error "Illegal character in keysym: %c" char))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 ;; Illegal event.
5861
c87b776ab0e1 Create a new error for when a char is needed but event-to-character gives nil
Aidan Kehoe <kehoea@parhasard.net>
parents: 5808
diff changeset
515 (error 'no-character-typed event))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 (vector (intern (concat "" (nreverse list))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517
5808
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
518 (defun synthesize-unicode-codepoint (ignore-prompt)
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
519 "Read a sequence of hexadecimal digits and return a one-char keyboard macro.
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
520
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
521 The character has the Unicode code point corresponding to those hexadecimal
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
522 digits."
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
523 (symbol-macrolet ((first-prompt "Unicode hex input: u"))
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
524 (let* ((prompt first-prompt) (integer 0)
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
525 (extent (make-extent (1- (length first-prompt))
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
526 (length first-prompt) prompt))
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
527 character digit-char-p)
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
528 (setf (extent-face extent) 'underline
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
529 (extent-property extent 'duplicable) t)
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
530 (while (not (member (setq character
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
531 ;; Discard non-enter non-hex-digit characters,
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
532 ;; as GTK does.
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
533 (read-char-exclusive prompt))
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
534 '(?\r ?\n)))
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
535 (when (setq digit-char-p (digit-char-p character 16))
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
536 (setq integer (logior (lsh integer 4) digit-char-p)
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
537 prompt (concat prompt (list character)))
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
538 (if (>= integer #x110000)
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
539 (error 'args-out-of-range "Not a Unicode code point" integer))
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
540 (set-extent-endpoints extent (1- (length first-prompt))
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
541 (length prompt) prompt)))
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
542 (vector (list (decode-char 'ucs integer))))))
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
543
5529
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
544 (define-key function-key-map-parent [?\C-x ?@ ?h] 'event-apply-hyper-modifier)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
545 (define-key function-key-map-parent [?\C-x ?@ ?s] 'event-apply-super-modifier)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
546 (define-key function-key-map-parent [?\C-x ?@ ?m] 'event-apply-meta-modifier)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
547 (define-key function-key-map-parent [?\C-x ?@ ?S] 'event-apply-shift-modifier)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
548 (define-key function-key-map-parent [?\C-x ?@ ?c] 'event-apply-control-modifier)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
549 (define-key function-key-map-parent [?\C-x ?@ ?a] 'event-apply-alt-modifier)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
550 (define-key function-key-map-parent [?\C-x ?@ ?k] 'synthesize-keysym)
5808
1b984807a299 Support control shift u for Unicode input as does GTK.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5801
diff changeset
551 (define-key function-key-map-parent [(control U)] 'synthesize-unicode-codepoint)
5529
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
552
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
553 ;; The autoloads for the compose map, and their bindings in
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
554 ;; function-key-map-parent are used by GTK as well as X11. And Julian
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
555 ;; Bradfield, at least, uses x-compose on the TTY, it's reasonable to make
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
556 ;; them generally available.
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
557
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
558 (loop for map in '(compose-acute-map compose-breve-map compose-caron-map
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
559 compose-cedilla-map compose-circumflex-map
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
560 compose-diaeresis-map compose-dot-map
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
561 compose-doubleacute-map compose-grave-map
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
562 compose-hook-map compose-horn-map compose-macron-map
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
563 compose-map compose-ogonek-map compose-ring-map
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
564 compose-stroke-map compose-tilde-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
565 do (autoload map "x-compose" nil t 'keymap))
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
566
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
567 (loop
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
568 for (key map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
569 ;; The dead keys might really be called just about anything, depending
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
570 ;; on the vendor. MIT thinks that the prefixes are "SunFA_", "D", and
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
571 ;; "hpmute_" for Sun, DEC, and HP respectively. However, OpenWindows 3
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
572 ;; thinks that the prefixes are "SunXK_FA_", "DXK_", and "hpXK_mute_".
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
573 ;; And HP (who don't mention Sun and DEC at all) use "XK_mute_". Go
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
574 ;; figure.
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
575
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
576 ;; Presumably if someone is running OpenWindows, they won't be using the
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
577 ;; DEC or HP keysyms, but if they are defined then that is possible, so
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
578 ;; in that case we accept them all.
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
579
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
580 ;; If things seem not to be working, you might want to check your
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
581 ;; /usr/lib/X11/XKeysymDB file to see if your vendor has an equally
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
582 ;; mixed up view of what these keys should be called.
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
583
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
584 ;; Canonical names:
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
585 in '((acute compose-acute-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
586 (grave compose-grave-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
587 (cedilla compose-cedilla-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
588 (diaeresis compose-diaeresis-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
589 (circumflex compose-circumflex-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
590 (tilde compose-tilde-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
591 (degree compose-ring-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
592 (multi-key compose-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
593
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
594 ;; Sun according to MIT:
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
595 (SunFA_Acute compose-acute-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
596 (SunFA_Grave compose-grave-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
597 (SunFA_Cedilla compose-cedilla-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
598 (SunFA_Diaeresis compose-diaeresis-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
599 (SunFA_Circum compose-circumflex-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
600 (SunFA_Tilde compose-tilde-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
601
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
602 ;; Sun according to OpenWindows 2:
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
603 (Dead_Grave compose-grave-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
604 (Dead_Circum compose-circumflex-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
605 (Dead_Tilde compose-tilde-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
606
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
607 ;; Sun according to OpenWindows 3:
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
608 (SunXK_FA_Acute compose-acute-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
609 (SunXK_FA_Grave compose-grave-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
610 (SunXK_FA_Cedilla compose-cedilla-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
611 (SunXK_FA_Diaeresis compose-diaeresis-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
612 (SunXK_FA_Circum compose-circumflex-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
613 (SunXK_FA_Tilde compose-tilde-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
614
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
615 ;; DEC according to MIT:
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
616 (Dacute_accent compose-acute-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
617 (Dgrave_accent compose-grave-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
618 (Dcedilla_accent compose-cedilla-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
619 (Dcircumflex_accent compose-circumflex-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
620 (Dtilde compose-tilde-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
621 (Dring_accent compose-ring-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
622
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
623 ;; DEC according to OpenWindows 3:
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
624 (DXK_acute_accent compose-acute-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
625 (DXK_grave_accent compose-grave-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
626 (DXK_cedilla_accent compose-cedilla-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
627 (DXK_circumflex_accent compose-circumflex-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
628 (DXK_tilde compose-tilde-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
629 (DXK_ring_accent compose-ring-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
630
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
631 ;; HP according to MIT:
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
632 (hpmute_acute compose-acute-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
633 (hpmute_grave compose-grave-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
634 (hpmute_diaeresis compose-diaeresis-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
635 (hpmute_asciicircum compose-circumflex-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
636 (hpmute_asciitilde compose-tilde-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
637
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
638 ;; Empirically discovered on Linux XFree86 MetroX:
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
639 (usldead_acute compose-acute-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
640 (usldead_grave compose-grave-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
641 (usldead_diaeresis compose-diaeresis-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
642 (usldead_asciicircum compose-circumflex-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
643 (usldead_asciitilde compose-tilde-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
644
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
645 ;; HP according to OpenWindows 3:
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
646 (hpXK_mute_acute compose-acute-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
647 (hpXK_mute_grave compose-grave-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
648 (hpXK_mute_diaeresis compose-diaeresis-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
649 (hpXK_mute_asciicircum compose-circumflex-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
650 (hpXK_mute_asciitilde compose-tilde-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
651
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
652 ;; HP according to HP-UX 8.0:
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
653 (XK_mute_acute compose-acute-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
654 (XK_mute_grave compose-grave-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
655 (XK_mute_diaeresis compose-diaeresis-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
656 (XK_mute_asciicircum compose-circumflex-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
657 (XK_mute_asciitilde compose-tilde-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
658
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
659 ;; XFree86 uses lower case and an underscore. XEmacs converts the
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
660 ;; underscore to a hyphen in x_keysym_to_emacs_keysym because the
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
661 ;; keysym is in the "Keyboard" character set, which seems a very
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
662 ;; arbitrary approach.
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
663 (dead-acute compose-acute-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
664 (dead-grave compose-grave-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
665 (dead-cedilla compose-cedilla-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
666 (dead-diaeresis compose-diaeresis-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
667 (dead-circum compose-circumflex-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
668 (dead-circumflex compose-circumflex-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
669 (dead-tilde compose-tilde-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
670 (dead-abovering compose-ring-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
671 (dead-caron compose-caron-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
672 (dead-macron compose-macron-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
673 (dead-breve compose-breve-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
674 (dead-abovedot compose-dot-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
675 (dead-doubleacute compose-doubleacute-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
676 (dead-ogonek compose-ogonek-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
677 (dead-hook compose-hook-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
678 (dead-horn compose-horn-map)
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
679 (dead-stroke compose-stroke-map))
3d1f8f0e690f Add `function-key-map-parent', for non-console-specific `function-key-map' bindings
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
680 do (define-key function-key-map-parent (vector key) map))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 ;;; keymap.el ends here