annotate lisp/keymap.el @ 872:79c6ff3eef26

[xemacs-hg @ 2002-06-20 21:18:01 by ben] font changes etc.; some 21.4 changes mule/mule-msw-init-late.el: Specify charset->windows-registry conversion. mule/mule-x-init.el: Delete extra mule font additions here. Put them in faces.c. cl-macs.el: Document better. font-lock.el: Move Lisp function regexp to lisp-mode.el. lisp-mode.el: Various indentation fixes: Handle flet functions better. Handle argument lists in defuns and flets. Handle quoted lists, e.g. property lists -- don't indent like function calls. Distinguish between lambdas and other lists. lisp-mode.el: Handle this form. faces.el, font-menu.el, font.el, gtk-faces.el, msw-faces.el, msw-font-menu.el, x-faces.el, x-init.el: Major overhaul of face-handling code: -- Fix lots of bogus code in msw-faces.el, msw-font-menu.el, font-menu.el that was "truenaming" font specs -- i.e. in the process of frobbing a particular field in a general user-specified font spec with wildcarded fields, sticking in particular values for all the remaining wildcarded fields. This bug was rampant everywhere except in x-faces.el (the oldest and only correctly written code). This also means that we need to work with font names at all times and not font instances, because a font instance is essentially a truenamed font. -- Total rewrite of extremely junky code in msw-faces.el. Work with names as well as font instances, and return names; stop truenaming when canonicalizing and frobbing; fix handling of the combined style field, i.e. weight/slant (also fixed in font.el). -- Totally rewrite the frobbing functions in faces.el. This time, we frob all the instantiators rather than just computing a single instance value and working backwards. That way, e.g., `bold' will work for all charsets that have bold available, rather than only for whatever charset was part of the computed font instance (another example of the truename virus). Also fix up code to look at the fallbacks (all of them) when no global value present, so we don't need to put something in the global value. Intelligently handle a request to frob a buffer locale, rather than signalling an error. When frobbing instantiators, try hard to figure out what device type is associated with them, and frob each according to its own proper device type. Correctly handle inheritance vectors given as instantiators. Preserve existing tags when putting back frobbed instantiators. Extract out general specifier-frobbing code into specifier.el. Document everything cleanly. Do lots of other things better, etc. -- Don't duplicatively set a global specification for the default font -- it's already in the fallback and we no longer need a default global specification present. Delete various code in x-faces.el and msw-faces.el that duplicated the lists of fonts in faces.c. -- init-global-faces was not being called at all under MS Windows! Major bogosity. That caused device-specific values to get stuck into all the fonts, making it very hard to change them -- setting global specs caused nothing to happen. -- Correct weight names in font.el. -- Lots more font fixups in objects*.c. Printer.el: Warning fix. specifier.el: Add more args to map-specifier. Add various "heuristic" specifier functions to aid in creation of specifier-munging code such as in faces.el. subr.el: New functions. lwlib.c: Fix warning. config.inc.samp: Clean up, add args to control fastcall (not yet supported! the changes needed are in another ws of mine), profile support, vc6 support, union-type. xemacs.dsp, xemacs.mak: Semi-major overhaul. Fix bug where dump-id was always getting recomputed, forcing a redump even when nothing changed. Add support for fastcall. Support edit-and-continue (on by default) with vc6. Use incremental linking when doing a debug compilation. Add support for profiling. Consolidate the various debug flags. Partial support for "batch-compiling" -- compiling many files on a single invocation of the compiler. Doesn't seem to help that much for me, so it's not finished or enabled by default. Remove HAVE_MSW_C_DIRED, we always do. Correct some sloppy use of directories. s/cygwin32.h: Allow pdump to work under Cygwin (mmap is broken, so need to undefine HAVE_MMAP). s/win32-common.h, s/windowsnt.h: Support for fastcall. Add WIN32_ANY for identifying all Win32 variants (Cygwin, native, MinGW). Both of these are properly used in another ws. alloc.c, balloon-x.c, buffer.c, bytecode.c, callint.c, cm.c, cmdloop.c, cmds.c, console-gtk.c, console-gtk.h, console-msw.c, console-msw.h, console-stream.c, console-stream.h, console-tty.c, console-tty.h, console-x.c, console-x.h, console.c, console.h, device-gtk.c, device-msw.c, device-tty.c, device-x.c, device.c, device.h, devslots.h, dialog-gtk.c, dialog-msw.c, dialog-x.c, dialog.c, dired-msw.c, editfns.c, emacs.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, event-tty.c, event-unixoid.c, events.c, extents.c, extents.h, faces.c, fileio.c, fns.c, frame-gtk.c, frame-msw.c, frame-tty.c, frame-x.c, frame.c, frame.h, glyphs-eimage.c, glyphs-gtk.c, glyphs-msw.c, glyphs-widget.c, glyphs-x.c, glyphs.c, glyphs.h, gui-gtk.c, gui-msw.c, gui-x.c, gui.c, gutter.c, input-method-xlib.c, intl-encap-win32.c, intl-win32.c, keymap.c, lisp.h, macros.c, menubar-gtk.c, menubar-msw.c, menubar-x.c, menubar.c, menubar.h, minibuf.c, mule-charset.c, nt.c, objects-gtk.c, objects-gtk.h, objects-msw.c, objects-msw.h, objects-tty.c, objects-tty.h, objects-x.c, objects-x.h, objects.c, objects.h, postgresql.c, print.c, process.h, redisplay-gtk.c, redisplay-msw.c, redisplay-output.c, redisplay-tty.c, redisplay-x.c, redisplay.c, redisplay.h, scrollbar-gtk.c, scrollbar-msw.c, scrollbar-x.c, scrollbar.c, select-gtk.c, select-msw.c, select-x.c, select.c, signal.c, sound.c, specifier.c, symbols.c, syntax.c, sysdep.c, syssignal.h, syswindows.h, toolbar-common.c, toolbar-gtk.c, toolbar-msw.c, toolbar-x.c, toolbar.c, unicode.c, window.c, window.h: The following are the major changes made: (1) Separation of various header files into an external and an internal version, similar to the existing separation of process.h and procimpl.h. Eventually this should be done for all Lisp objects. The external version has the same name as currently; the internal adds -impl. The external file has XFOO() macros for objects, but the structure is opaque and defined only in the internal file. It's now reasonable to move all prototypes in lisp.h into the appropriate external file, and this should be done. Currently, separation has been done on extents.h, objects*.h, console.h, device.h, frame.h, and window.h. For c/d/f/w, the most basic properties are available in the external header file, with the macros resolving to functions. In the internal header file, the macros are redefined to directly access the structure. Also, the global MARK_FOO_CHANGED macros have been made into functions so that they can be accessed without needing to include lots of -impl headers -- they are used in almost exclusively in non-time-critical functions, and take up enough time that the function overhead will be negligible. Similarly, the function overhead from making the basic properties mentioned above into functions is negligible, and code that does heavy accessing of c/d/f/w structures inevitably ends up needing the internal header files, anyway. (2) More face changes. -- Major rewrite of objects-msw.c. Now handles wildcard specs properly, rather than "truenaming" (or even worse, signalling an error, which previously happened with some of the fallbacks if you tried to use them in make-font-instance!). -- Split charset matching of fonts into two stages -- one to find a font specifically designed for a particular charset (by examining its registry), the second to find a Unicode font that can support the charset. This needs to proceed as two complete, separate instantiations in order to work properly (otherwise many of the fonts in the HELLO page look wrong). This should also make it easy to support iso10646 (Unicode) fonts under X. -- All default values for fonts are now completely specified in the fallbacks. Stuff from mule-x-init.el has all been moved here, merged with the existing specs, and totally rethought so you get sensible results. (HELLO now looks much better!). -- Generalize the "default X/GTK device" stuff into a per-device-type "default device". -- Add mswindows-{set-}charset-registry. In time, charset<->code-page conversion functions will be removed. -- Wrap protective code around calls to compute device specifier tags, and do this computation before calling the face initialization code because the latter may need these tags to be correctly updated. (3) Other changes. EmacsFrame.c, glyphs-msw.c, eval.c, gui-x.c, intl-encap-win32.c, search.c, signal.c, toolbar-msw.c, unicode.c: Warning fixes. config.h.in: #undefs meant to be frobbed by configure *MUST* go inside of #ifndef WIN32_NO_CONFIGURE, and everything else *MUST* go outside! eval.c: Let detailed backtraces be detailed. specifier.c: Don't override user's print-string-length/print-length settings. glyphs.c: New function image-instance-instantiator. config.h.in, sysdep.c: Changes for fastcall. sysdep.c, nt.c: Fix up a previous botched patch that tried to add support for both EEXIST and EACCES. IF THE BOTCHED PATCH WENT INTO 21.4, THIS FIXUP NEEDS TO GO IN, TOO. search.c: Fix *evil* crash due to incorrect synching of syntax-cache code with 21.1. THIS SHOULD GO INTO 21.4.
author ben
date Thu, 20 Jun 2002 21:19:10 +0000
parents 79940b592197
children 1b0339b048ce
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.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 ;; Maintainer: XEmacs Development Team
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 ;; Keywords: internals, dumped
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 ;; This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 ;; XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 ;; under the terms of the GNU General Public License as published by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 ;; any later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 ;; General Public License for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 ;; along with XEmacs; see the file COPYING. If not, write to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 ;; Free Software Foundation, 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 ;;; Synched up with: FSF 19.28.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 ;;; Commentary:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 ;; This file is dumped with XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 ;;; Note: FSF does not have a file keymap.el. This stuff is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 ;;; in keymap.c.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 ;Prevent the \{...} documentation construct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 ;from mentioning keys that run this command.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 ;;; Code:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 (put 'undefined 'suppress-keymap t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 (defun undefined ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 (ding))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 (defmacro kbd (keys)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 "Convert KEYS to the internal Emacs key representation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 KEYS should be a string in the format used for saving keyboard macros
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 \(see `insert-kbd-macro')."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 (if (or (stringp keys)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 (vectorp keys))
776
79940b592197 [xemacs-hg @ 2002-03-15 07:43:14 by ben]
ben
parents: 502
diff changeset
52 ;; #### need to move xemacs-base into the core!!!!!!
79940b592197 [xemacs-hg @ 2002-03-15 07:43:14 by ben]
ben
parents: 502
diff changeset
53 (declare-fboundp (read-kbd-macro keys))
79940b592197 [xemacs-hg @ 2002-03-15 07:43:14 by ben]
ben
parents: 502
diff changeset
54 `(declare-fboundp (read-kbd-macro ,keys))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 (defun suppress-keymap (map &optional nodigits)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 "Make MAP override all normally self-inserting keys to be undefined.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 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
59 but optional second arg NODIGITS non-nil treats them like other chars."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 (substitute-key-definition 'self-insert-command 'undefined map global-map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 (or nodigits
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 (let ((string (make-string 1 ?0)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 (define-key map "-" 'negative-argument)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 ;; Make plain numbers do numeric args.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 (while (<= (aref string 0) ?9)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 (define-key map string 'digit-argument)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 (incf (aref string 0))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 (defun substitute-key-definition (olddef newdef keymap &optional oldmap prefix)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 "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
71 In other words, OLDDEF is replaced with NEWDEF wherever it appears.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 Prefix keymaps are checked recursively. If optional fourth argument OLDMAP
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 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
74 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
75 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
76 OLDDEF found in keymaps accessible through the keymap bound to PREFIX in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 KEYMAP are redefined. See also `accessible-keymaps'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 (let ((maps (accessible-keymaps (or oldmap keymap) prefix))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 (shadowing (not (null oldmap)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 prefix map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 (while maps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 (setq prefix (car (car maps))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 map (cdr (car maps))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 maps (cdr maps))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 ;; Substitute in this keymap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 (map-keymap #'(lambda (key binding)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 (if (eq binding olddef)
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 ;; This used to wrap forms into an interactive lambda. It is unclear
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 ;; to me why this is needed in this function. Anyway,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 ;; `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
110 ;; does it, either.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 (defun insert-key-binding (key) ; modeled after describe-key
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 "Insert the command bound to KEY."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 (interactive "kInsert command bound to key: ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 (let ((defn (key-or-menu-binding key)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 (if (or (null defn) (integerp defn))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 (error "%s is undefined" (key-description key))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 (if (or (stringp defn) (vectorp defn))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 (setq defn (key-binding defn))) ;; a keyboard macro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 (insert (format "%s" defn)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 (defun read-command-or-command-sexp (prompt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 "Read a command symbol or command sexp.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 A command sexp is wrapped in an interactive lambda if needed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 Prompts with PROMPT."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 ;; 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
126 ;; commandp (as does 'read-command') but that is not easy to do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 ;; because we must supply arg4 = require-match = nil for sexp case.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 (let ((result (car (read-from-string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 (completing-read prompt obarray 'commandp)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 (if (and (consp result)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 (not (eq (car result) 'lambda)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 `(lambda ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 ,result)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 result)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
137 (defun local-key-binding (keys &optional accept-defaults)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 "Return the binding for command KEYS in current local keymap only.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 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
140 as described in the documentation for the `define-key' function.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 The binding is probably a symbol with a function definition; see
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 the documentation for `lookup-key' for more information."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 (let ((map (current-local-map)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 (if map
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
145 (lookup-key map keys accept-defaults)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
148 (defun global-key-binding (keys &optional accept-defaults)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 "Return the binding for command KEYS in current global keymap only.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 KEYS is a string or vector of events, a sequence of keystrokes.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 The binding is probably a symbol with a function definition; see
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 the documentation for `lookup-key' for more information."
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 428
diff changeset
153 (lookup-key (current-global-map) keys accept-defaults))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 (defun global-set-key (key command)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 "Give KEY a global binding as COMMAND.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 COMMAND is a symbol naming an interactively-callable function.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 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
159 as described in the documentation for the `define-key' function.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 Note that if KEY has a local binding in the current buffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 that local binding will continue to shadow any global binding."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 ;;(interactive "KSet key globally: \nCSet key %s to command: ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 (interactive (list (setq key (read-key-sequence "Set key globally: "))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 ;; Command sexps are allowed here so that this arg
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 ;; may be supplied interactively via insert-key-binding.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 (read-command-or-command-sexp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 (format "Set key %s to command: "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 (key-description key)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 (define-key (current-global-map) key command)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 (defun local-set-key (key command)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 "Give KEY a local binding as COMMAND.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 COMMAND is a symbol naming an interactively-callable function.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 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
176 as described in the documentation for the `define-key' function.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 The binding goes in the current buffer's local map,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 which is shared with other buffers in the same major mode."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 ;;(interactive "KSet key locally: \nCSet key %s locally to command: ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 (interactive (list (setq key (read-key-sequence "Set key locally: "))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 ;; Command sexps are allowed here so that this arg
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 ;; may be supplied interactively via insert-key-binding.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 (read-command-or-command-sexp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 (format "Set key %s locally to command: "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 (key-description key)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 (if (null (current-local-map))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 (use-local-map (make-sparse-keymap)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 (define-key (current-local-map) key command)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 (defun global-unset-key (key)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 "Remove global binding of KEY.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 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
194 as described in the documentation for the `define-key' function."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 (interactive "kUnset key globally: ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 (global-set-key key nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 (defun local-unset-key (key)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 "Remove local binding of KEY.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 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
201 as described in the documentation for the `define-key' function."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 (interactive "kUnset key locally: ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 (if (current-local-map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 (define-key (current-local-map) key nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 ;; FSF-inherited brain-death.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 (defun minor-mode-key-binding (key &optional accept-default)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 "Find the visible minor mode bindings of KEY.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 Return an alist of pairs (MODENAME . BINDING), where MODENAME is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 the symbol which names the minor mode binding KEY, and BINDING is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 KEY's definition in that mode. In particular, if KEY has no
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 minor-mode bindings, return nil. If the first binding is a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 non-prefix, all subsequent bindings will be omitted, since they would
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 be ignored. Similarly, the list doesn't include non-prefix bindings
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 that come after prefix bindings.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 If optional argument ACCEPT-DEFAULT is non-nil, recognize default
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 bindings; see the description of `lookup-key' for more details about this."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 (let ((tail minor-mode-map-alist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 a s v)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 (while tail
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 (setq a (car tail)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 tail (cdr tail))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 (and (consp a)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 (symbolp (setq s (car a)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 (boundp s)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 (symbol-value s)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 ;; indirect-function deals with autoloadable keymaps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 (setq v (indirect-function (cdr a)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 (setq v (lookup-key v key accept-default))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 ;; Terminate loop, with v set to non-nil value
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 (setq tail nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 v))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 (defun current-minor-mode-maps ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 "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
239 (let ((l '())
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 (tail minor-mode-map-alist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 a s v)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 (while tail
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 (setq a (car tail)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 tail (cdr tail))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 (and (consp a)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 (symbolp (setq s (car a)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 (boundp s)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 (symbol-value s)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 ;; indirect-function deals with autoloadable keymaps
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 (setq v (indirect-function (cdr a)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 (setq l (cons v l))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 (nreverse l)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 ;;#### What a crock
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 (defun define-prefix-command (name &optional mapvar)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 "Define COMMAND as a prefix command.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 A new sparse keymap is stored as COMMAND's function definition.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 If second optional argument MAPVAR is not specified,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 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
261 If a second optional argument MAPVAR is given and is not `t',
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 the map is stored as its value.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 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
264 (let ((map (make-sparse-keymap name)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 (fset name map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 (cond ((not mapvar)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 (set name map))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 ((eq mapvar 't)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 (set mapvar map)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 ;;; Converting vectors of events to a read-equivalent form.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 ;;; This is used both by call-interactively (for the command history)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 ;;; and by macros.el (for saving keyboard macros to a file).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 ;; #### why does (events-to-keys [backspace]) return "\C-h"?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 ;; BTW, this function is a mess, and macros.el does *not* use it, in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 ;; spite of the above comment. `format-kbd-macro' is used to save
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 ;; keyboard macros to a file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 (defun events-to-keys (events &optional no-mice)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 "Given a vector of event objects, returns a vector of key descriptors,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 or a string (if they all fit in the ASCII range).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 Optional arg NO-MICE means that button events are not allowed."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 (if (and events (symbolp events)) (setq events (vector events)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 (cond ((stringp events)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 events)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 ((not (vectorp events))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 (signal 'wrong-type-argument (list 'vectorp events)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 ((let* ((length (length events))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 (string (make-string length 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 c ce
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 (i 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 (while (< i length)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 (setq ce (aref events i))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 (or (eventp ce) (setq ce (character-to-event ce)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 ;; Normalize `c' to `?c' and `(control k)' to `?\C-k'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 ;; By passing t for the `allow-meta' arg we could get kbd macros
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 ;; with meta in them to translate to the string form instead of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 ;; the list/symbol form; but I expect that would cause confusion,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 ;; so let's use the list/symbol form whenever there's
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 ;; any ambiguity.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 (setq c (event-to-character ce))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 (if (and c
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 character-set-property
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 (key-press-event-p ce))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 (cond ((symbolp (event-key ce))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 (if (get (event-key ce) character-set-property)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 ;; Don't use a string for `backspace' and `tab' to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 ;; avoid that unpleasant little ambiguity.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 (setq c nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 ((and (= (event-modifier-bits ce) 1) ;control
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 (integerp (event-key ce)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 (let* ((te (character-to-event c)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 (if (and (symbolp (event-key te))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 (get (event-key te) character-set-property))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 ;; Don't "normalize" (control i) to tab
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 ;; to avoid the ambiguity in the other direction
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 (setq c nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 (deallocate-event te)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 (if c
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 (aset string i c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 (setq i length string nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 (setq i (1+ i)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 string))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 (let* ((length (length events))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 (new (copy-sequence events))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 event mods key
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 (i 0))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 (while (< i length)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 (setq event (aref events i))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 (cond ((key-press-event-p event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 (setq mods (event-modifiers event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 key (event-key event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 (if (numberp key)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 (setq key (intern (make-string 1 key))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 (aset new i (if mods
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 (nconc mods (cons key nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 key)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 ((misc-user-event-p event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 (aset new i (list 'menu-selection
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 (event-function event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 (event-object event))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 ((or (button-press-event-p event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 (button-release-event-p event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 (if no-mice
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 (error
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 "Mouse events can't be saved in keyboard macros."))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 (setq mods (event-modifiers event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 key (intern (format "button%d%s"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 (event-button event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 (if (button-release-event-p event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 "up" ""))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 (aset new i (if mods
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 (nconc mods (cons key nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 key)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 ((or (and event (symbolp event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 (and (consp event) (symbolp (car event))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 (aset new i event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 (signal 'wrong-type-argument (list 'eventp event))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 (setq i (1+ i)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 new))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 (defun next-key-event ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 "Return the next available keyboard event."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 (let (event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 (while (not (key-press-event-p (setq event (next-command-event))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 (dispatch-event event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 (defun key-sequence-list-description (keys)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 "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
378 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
379 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
380 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
381 by comparing the respective outputs of this function using `equal'."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 (let ((vec
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
383 (cond ((vectorp keys)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
384 keys)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
385 ((stringp keys)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
386 (vconcat keys))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
387 (t
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
388 (vector keys)))))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
389 (flet ((event-to-list (ev)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
390 (append (event-modifiers ev) (list (event-key ev)))))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
391 (mapvector
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
392 #'(lambda (key)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
393 (let* ((full-key
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
394 (cond ((key-press-event-p key)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
395 (event-to-list key))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
396 ((characterp key)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
397 (event-to-list (character-to-event key)))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
398 ((listp key)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
399 (copy-sequence key))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
400 (t
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
401 (list key))))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
402 (keysym (car (last full-key))))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
403 (if (characterp keysym)
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
404 (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
405 full-key))
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 444
diff changeset
406 vec))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 ;;; Support keyboard commands to turn on various modifiers.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 ;;; These functions -- which are not commands -- each add one modifier
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 ;;; to the following event.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 (defun event-apply-alt-modifier (ignore-prompt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 (event-apply-modifier 'alt))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 (defun event-apply-super-modifier (ignore-prompt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 (event-apply-modifier 'super))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 (defun event-apply-hyper-modifier (ignore-prompt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 (event-apply-modifier 'hyper))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 (defun event-apply-shift-modifier (ignore-prompt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 (event-apply-modifier 'shift))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 (defun event-apply-control-modifier (ignore-prompt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 (event-apply-modifier 'control))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 (defun event-apply-meta-modifier (ignore-prompt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 (event-apply-modifier 'meta))
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 ;;; #### `key-translate-map' is ignored for now.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 (defun event-apply-modifier (symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 "Return the next key event, with a modifier flag applied.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 SYMBOL is the name of this modifier, as a symbol.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 `function-key-map' is scanned for prefix bindings."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 (let (events binding)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 ;; read keystrokes scanning `function-key-map'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 (while (keymapp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 (setq binding
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 (lookup-key
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 function-key-map
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 (vconcat
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 (setq events
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 (append events (list (next-key-event)))))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 (if binding ; found a binding
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 ;; allow for several modifiers
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 (if (and (symbolp binding) (fboundp binding))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 (setq binding (funcall binding nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 (setq events (append binding nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 ;; put remaining keystrokes back into input queue
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 (setq unread-command-events
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 (mapcar 'character-to-event (cdr events))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 (setq unread-command-events (cdr events)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 ;; add a modifier SYMBOL to the first keystroke or event
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 (vector
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 (append (list symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 (delq symbol
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 (aref (key-sequence-list-description (car events)) 0))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 (defun synthesize-keysym (ignore-prompt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 "Read a sequence of keys, and returned the corresponding key symbol.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 The characters must be from the [-_a-zA-Z0-9]. Reading is terminated
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 by RET (which is discarded)."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 (let ((continuep t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 event char list)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 (while continuep
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 (setq event (next-key-event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 (cond ((and (setq char (event-to-character event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 (or (memq char '(?- ?_))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 (eq ?w (char-syntax char (standard-syntax-table)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 ;; Advance a character.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 (push char list))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 ((or (memq char '(?\r ?\n))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 (memq (event-key event) '(return newline)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 ;; Legal termination.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 (setq continuep nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 (char
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 ;; Illegal character.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 (error "Illegal character in keysym: %c" char))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 ;; Illegal event.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 (error "Event has no character equivalent: %s" event))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 (vector (intern (concat "" (nreverse list))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 ;; This looks dirty. The following code should maybe go to another
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 ;; file, and `create-console-hook' should maybe default to nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 (add-hook
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 'create-console-hook
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 #'(lambda (console)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 (letf (((selected-console) console))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 (define-key function-key-map [?\C-x ?@ ?h] 'event-apply-hyper-modifier)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 (define-key function-key-map [?\C-x ?@ ?s] 'event-apply-super-modifier)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 (define-key function-key-map [?\C-x ?@ ?m] 'event-apply-meta-modifier)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 (define-key function-key-map [?\C-x ?@ ?S] 'event-apply-shift-modifier)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 (define-key function-key-map [?\C-x ?@ ?c] 'event-apply-control-modifier)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 (define-key function-key-map [?\C-x ?@ ?a] 'event-apply-alt-modifier)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 (define-key function-key-map [?\C-x ?@ ?k] 'synthesize-keysym))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 ;;; keymap.el ends here