annotate src/keymap.c @ 32889:673e3ef1f7f6

(where_is_cache, where_is_cache_keymaps): New vars. (Fset_keymap_parent, store_in_keymap): Flush the where-is cache. (where_is_internal): Renamed from Fwhere_is_internal. Don't DEFUN any more. Arg `xkeymap' replaced by `keymaps'. (Fwhere_is_internal): New function wrapping where_is_internal. (where_is_internal_1): Handle the case where we're filling the cache. (syms_of_keymap): Init and gcpro the where_is_cache(|_keymaps).
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 25 Oct 2000 23:35:21 +0000
parents c1b3ab2a1ccc
children c3435dc00ed7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1 /* Manipulation of keymaps
32818
f915f46d067c Update copyright.
Gerd Moellmann <gerd@gnu.org>
parents: 32739
diff changeset
2 Copyright (C) 1985, 86,87,88,93,94,95,98,99, 2000
f915f46d067c Update copyright.
Gerd Moellmann <gerd@gnu.org>
parents: 32739
diff changeset
3 Free Software Foundation, Inc.
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5 This file is part of GNU Emacs.
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
7 GNU Emacs is free software; you can redistribute it and/or modify
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
8 it under the terms of the GNU General Public License as published by
647
529171c8b71c entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 517
diff changeset
9 the Free Software Foundation; either version 2, or (at your option)
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10 any later version.
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 GNU Emacs is distributed in the hope that it will be useful,
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15 GNU General Public License for more details.
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 along with GNU Emacs; see the file COPYING. If not, write to
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 14129
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 14129
diff changeset
20 Boston, MA 02111-1307, USA. */
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22
4696
1fc792473491 Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents: 4575
diff changeset
23 #include <config.h>
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 #include <stdio.h>
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25 #include "lisp.h"
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26 #include "commands.h"
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27 #include "buffer.h"
17036
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
28 #include "charset.h"
517
2f2206ac3dba *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
29 #include "keyboard.h"
2059
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
30 #include "termhooks.h"
2439
b6c62e4abf59 Put interrupt input blocking in a separate file from xterm.h.
Jim Blandy <jimb@redhat.com>
parents: 2358
diff changeset
31 #include "blockinput.h"
13771
28790743a5a3 (Fkey_binding): Handle text-property keymaps.
Karl Heuer <kwzh@gnu.org>
parents: 13343
diff changeset
32 #include "puresize.h"
29282
59f2b30d577b Include intervals.h.
Dave Love <fx@gnu.org>
parents: 29013
diff changeset
33 #include "intervals.h"
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 #define min(a, b) ((a) < (b) ? (a) : (b))
31208
442d40fce0db (store_in_keymap, fix_submap_inheritance): New prototypes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30780
diff changeset
36 #define KEYMAPP(m) (!NILP (Fkeymapp (m)))
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
38 /* The number of elements in keymap vectors. */
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39 #define DENSE_TABLE_SIZE (0200)
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41 /* Actually allocate storage for these variables */
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43 Lisp_Object current_global_map; /* Current global keymap */
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45 Lisp_Object global_map; /* default global key bindings */
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47 Lisp_Object meta_map; /* The keymap used for globally bound
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 ESC-prefixed default commands */
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 Lisp_Object control_x_map; /* The keymap used for globally bound
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 C-x-prefixed default commands */
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 /* was MinibufLocalMap */
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 Lisp_Object Vminibuffer_local_map;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55 /* The keymap used by the minibuf for local
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56 bindings when spaces are allowed in the
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57 minibuf */
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
58
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 /* was MinibufLocalNSMap */
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 Lisp_Object Vminibuffer_local_ns_map;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 /* The keymap used by the minibuf for local
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62 bindings when spaces are not encouraged
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63 in the minibuf */
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65 /* keymap used for minibuffers when doing completion */
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66 /* was MinibufLocalCompletionMap */
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67 Lisp_Object Vminibuffer_local_completion_map;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 /* keymap used for minibuffers when doing completion and require a match */
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 /* was MinibufLocalMustMatchMap */
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 Lisp_Object Vminibuffer_local_must_match_map;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
73 /* Alist of minor mode variables and keymaps. */
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
74 Lisp_Object Vminor_mode_map_alist;
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
75
20517
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
76 /* Alist of major-mode-specific overrides for
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
77 minor mode variables and keymaps. */
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
78 Lisp_Object Vminor_mode_overriding_map_alist;
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
79
517
2f2206ac3dba *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
80 /* Keymap mapping ASCII function key sequences onto their preferred forms.
2f2206ac3dba *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
81 Initialized by the terminal-specific lisp files. See DEFVAR for more
2f2206ac3dba *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
82 documentation. */
2f2206ac3dba *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
83 Lisp_Object Vfunction_key_map;
2f2206ac3dba *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
84
12710
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
85 /* Keymap mapping ASCII function key sequences onto their preferred forms. */
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
86 Lisp_Object Vkey_translation_map;
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
87
12297
fe458a8ecfa2 (Vdefine_key_rebound_commands): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 12262
diff changeset
88 /* A list of all commands given new bindings since a certain time
fe458a8ecfa2 (Vdefine_key_rebound_commands): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 12262
diff changeset
89 when nil was stored here.
fe458a8ecfa2 (Vdefine_key_rebound_commands): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 12262
diff changeset
90 This is used to speed up recomputation of menu key equivalents
fe458a8ecfa2 (Vdefine_key_rebound_commands): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 12262
diff changeset
91 when Emacs starts up. t means don't record anything here. */
fe458a8ecfa2 (Vdefine_key_rebound_commands): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 12262
diff changeset
92 Lisp_Object Vdefine_key_rebound_commands;
fe458a8ecfa2 (Vdefine_key_rebound_commands): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 12262
diff changeset
93
21241
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
94 Lisp_Object Qkeymapp, Qkeymap, Qnon_ascii, Qmenu_item;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95
2886
ad36d1481295 Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 2790
diff changeset
96 /* A char with the CHAR_META bit set in a vector or the 0200 bit set
ad36d1481295 Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 2790
diff changeset
97 in a string key sequence is equivalent to prefixing with this
ad36d1481295 Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 2790
diff changeset
98 character. */
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99 extern Lisp_Object meta_prefix_char;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100
5613
cad51b2de6cd (Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents: 5551
diff changeset
101 extern Lisp_Object Voverriding_local_map;
cad51b2de6cd (Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents: 5551
diff changeset
102
32889
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
103 /* Hash table used to cache a reverse-map to speed up calls to where-is. */
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
104 static Lisp_Object where_is_cache;
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
105 /* Which keymaps are reverse-stored in the cache. */
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
106 static Lisp_Object where_is_cache_keymaps;
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
107
31208
442d40fce0db (store_in_keymap, fix_submap_inheritance): New prototypes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30780
diff changeset
108 static Lisp_Object store_in_keymap P_ ((Lisp_Object, Lisp_Object, Lisp_Object));
442d40fce0db (store_in_keymap, fix_submap_inheritance): New prototypes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30780
diff changeset
109 static void fix_submap_inheritance P_ ((Lisp_Object, Lisp_Object, Lisp_Object));
442d40fce0db (store_in_keymap, fix_submap_inheritance): New prototypes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30780
diff changeset
110
442d40fce0db (store_in_keymap, fix_submap_inheritance): New prototypes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30780
diff changeset
111 static Lisp_Object define_as_prefix P_ ((Lisp_Object, Lisp_Object));
442d40fce0db (store_in_keymap, fix_submap_inheritance): New prototypes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30780
diff changeset
112 static Lisp_Object describe_buffer_bindings P_ ((Lisp_Object));
442d40fce0db (store_in_keymap, fix_submap_inheritance): New prototypes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30780
diff changeset
113 static void describe_command P_ ((Lisp_Object));
442d40fce0db (store_in_keymap, fix_submap_inheritance): New prototypes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30780
diff changeset
114 static void describe_translation P_ ((Lisp_Object));
442d40fce0db (store_in_keymap, fix_submap_inheritance): New prototypes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30780
diff changeset
115 static void describe_map P_ ((Lisp_Object, Lisp_Object,
442d40fce0db (store_in_keymap, fix_submap_inheritance): New prototypes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30780
diff changeset
116 void (*) P_ ((Lisp_Object)),
442d40fce0db (store_in_keymap, fix_submap_inheritance): New prototypes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30780
diff changeset
117 int, Lisp_Object, Lisp_Object*, int));
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
118
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
119 /* Keymap object support - constructors and predicates. */
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
120
1095
6578f07e9eb8 (Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 647
diff changeset
121 DEFUN ("make-keymap", Fmake_keymap, Smake_keymap, 0, 1, 0,
23758
e6bdd4559dc7 (Fmake_keymap): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 23734
diff changeset
122 "Construct and return a new keymap, of the form (keymap CHARTABLE . ALIST).\n\
e6bdd4559dc7 (Fmake_keymap): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 23734
diff changeset
123 CHARTABLE is a char-table that holds the bindings for the ASCII\n\
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124 characters. ALIST is an assoc-list which holds bindings for function keys,\n\
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
125 mouse events, and any other things that appear in the input stream.\n\
1095
6578f07e9eb8 (Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 647
diff changeset
126 All entries in it are initially nil, meaning \"command undefined\".\n\n\
6578f07e9eb8 (Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 647
diff changeset
127 The optional arg STRING supplies a menu name for the keymap\n\
6578f07e9eb8 (Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 647
diff changeset
128 in case you use it as a menu with `x-popup-menu'.")
6578f07e9eb8 (Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 647
diff changeset
129 (string)
6578f07e9eb8 (Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 647
diff changeset
130 Lisp_Object string;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
131 {
1095
6578f07e9eb8 (Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 647
diff changeset
132 Lisp_Object tail;
6578f07e9eb8 (Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 647
diff changeset
133 if (!NILP (string))
6578f07e9eb8 (Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 647
diff changeset
134 tail = Fcons (string, Qnil);
6578f07e9eb8 (Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 647
diff changeset
135 else
6578f07e9eb8 (Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 647
diff changeset
136 tail = Qnil;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
137 return Fcons (Qkeymap,
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
138 Fcons (Fmake_char_table (Qkeymap, Qnil), tail));
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
140
1095
6578f07e9eb8 (Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 647
diff changeset
141 DEFUN ("make-sparse-keymap", Fmake_sparse_keymap, Smake_sparse_keymap, 0, 1, 0,
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
142 "Construct and return a new sparse keymap.\n\
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143 Its car is `keymap' and its cdr is an alist of (CHAR . DEFINITION),\n\
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144 which binds the character CHAR to DEFINITION, or (SYMBOL . DEFINITION),\n\
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145 which binds the function key or mouse event SYMBOL to DEFINITION.\n\
1095
6578f07e9eb8 (Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 647
diff changeset
146 Initially the alist is nil.\n\n\
6578f07e9eb8 (Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 647
diff changeset
147 The optional arg STRING supplies a menu name for the keymap\n\
6578f07e9eb8 (Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 647
diff changeset
148 in case you use it as a menu with `x-popup-menu'.")
6578f07e9eb8 (Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 647
diff changeset
149 (string)
6578f07e9eb8 (Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 647
diff changeset
150 Lisp_Object string;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
151 {
1095
6578f07e9eb8 (Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 647
diff changeset
152 if (!NILP (string))
6578f07e9eb8 (Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 647
diff changeset
153 return Fcons (Qkeymap, Fcons (string, Qnil));
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154 return Fcons (Qkeymap, Qnil);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157 /* This function is used for installing the standard key bindings
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158 at initialization time.
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
159
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
160 For example:
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
161
1388
02226bff1476 * keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents: 1315
diff changeset
162 initial_define_key (control_x_map, Ctl('X'), "exchange-point-and-mark"); */
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
164 void
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165 initial_define_key (keymap, key, defname)
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
166 Lisp_Object keymap;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
167 int key;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
168 char *defname;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
169 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
170 store_in_keymap (keymap, make_number (key), intern (defname));
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
171 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
172
1388
02226bff1476 * keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents: 1315
diff changeset
173 void
02226bff1476 * keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents: 1315
diff changeset
174 initial_define_lispy_key (keymap, keyname, defname)
02226bff1476 * keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents: 1315
diff changeset
175 Lisp_Object keymap;
02226bff1476 * keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents: 1315
diff changeset
176 char *keyname;
02226bff1476 * keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents: 1315
diff changeset
177 char *defname;
02226bff1476 * keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents: 1315
diff changeset
178 {
02226bff1476 * keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents: 1315
diff changeset
179 store_in_keymap (keymap, intern (keyname), intern (defname));
02226bff1476 * keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents: 1315
diff changeset
180 }
02226bff1476 * keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents: 1315
diff changeset
181
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
182 DEFUN ("keymapp", Fkeymapp, Skeymapp, 1, 1, 0,
14080
439185f0ef37 (Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents: 13947
diff changeset
183 "Return t if OBJECT is a keymap.\n\
362
d1e5cf833d37 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 250
diff changeset
184 \n\
2790
cf431814ce6a (access_keymap): Handle any length vector.
Richard M. Stallman <rms@gnu.org>
parents: 2755
diff changeset
185 A keymap is a list (keymap . ALIST),\n\
6457
13aa19ca4b4f (Fkeymapp): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 6456
diff changeset
186 or a symbol whose function definition is itself a keymap.\n\
362
d1e5cf833d37 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 250
diff changeset
187 ALIST elements look like (CHAR . DEFN) or (SYMBOL . DEFN);\n\
2790
cf431814ce6a (access_keymap): Handle any length vector.
Richard M. Stallman <rms@gnu.org>
parents: 2755
diff changeset
188 a vector of densely packed bindings for small character codes\n\
cf431814ce6a (access_keymap): Handle any length vector.
Richard M. Stallman <rms@gnu.org>
parents: 2755
diff changeset
189 is also allowed as an element.")
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
190 (object)
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
191 Lisp_Object object;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
192 {
31208
442d40fce0db (store_in_keymap, fix_submap_inheritance): New prototypes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30780
diff changeset
193 /* FIXME: Maybe this should return t for autoloaded keymaps? -sm */
1517
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
194 return (NILP (get_keymap_1 (object, 0, 0)) ? Qnil : Qt);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
195 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
197 /* Check that OBJECT is a keymap (after dereferencing through any
1517
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
198 symbols). If it is, return it.
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
199
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
200 If AUTOLOAD is non-zero and OBJECT is a symbol whose function value
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
201 is an autoload form, do the autoload and try again.
7998
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
202 If AUTOLOAD is nonzero, callers must assume GC is possible.
1517
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
203
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
204 ERROR controls how we respond if OBJECT isn't a keymap.
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
205 If ERROR is non-zero, signal an error; otherwise, just return Qnil.
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
206
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
207 Note that most of the time, we don't want to pursue autoloads.
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
208 Functions like Faccessible_keymaps which scan entire keymap trees
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
209 shouldn't load every autoloaded keymap. I'm not sure about this,
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
210 but it seems to me that only read_key_sequence, Flookup_key, and
30134
784ef95b020b (get_keymap_1): Add comment that this function can GC.
Gerd Moellmann <gerd@gnu.org>
parents: 30030
diff changeset
211 Fdefine_key should cause keymaps to be autoloaded.
784ef95b020b (get_keymap_1): Add comment that this function can GC.
Gerd Moellmann <gerd@gnu.org>
parents: 30030
diff changeset
212
784ef95b020b (get_keymap_1): Add comment that this function can GC.
Gerd Moellmann <gerd@gnu.org>
parents: 30030
diff changeset
213 This function can GC when AUTOLOAD is non-zero, because it calls
784ef95b020b (get_keymap_1): Add comment that this function can GC.
Gerd Moellmann <gerd@gnu.org>
parents: 30030
diff changeset
214 do_autoload which can GC. */
1517
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
215
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216 Lisp_Object
1517
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
217 get_keymap_1 (object, error, autoload)
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218 Lisp_Object object;
1517
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
219 int error, autoload;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220 {
1517
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
221 Lisp_Object tem;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
222
1517
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
223 autoload_retry:
25128
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
224 if (NILP (object))
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
225 goto end;
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
226 if (CONSP (object) && EQ (XCAR (object), Qkeymap))
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
227 return object;
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
228 else
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
229 {
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
230 tem = indirect_function (object);
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
231 if (CONSP (tem) && EQ (XCAR (tem), Qkeymap))
25128
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
232 return tem;
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
233 }
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
234
1566
892c9f61217a * keymap.c (get_keymap_1): Don't try to autoload OBJECT's function
Jim Blandy <jimb@redhat.com>
parents: 1517
diff changeset
235 /* Should we do an autoload? Autoload forms for keymaps have
892c9f61217a * keymap.c (get_keymap_1): Don't try to autoload OBJECT's function
Jim Blandy <jimb@redhat.com>
parents: 1517
diff changeset
236 Qkeymap as their fifth element. */
1517
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
237 if (autoload
8866
48a0ea73a9d7 (Fkey_description): Give error if KEYS not an array.
Richard M. Stallman <rms@gnu.org>
parents: 8731
diff changeset
238 && SYMBOLP (object)
1517
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
239 && CONSP (tem)
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
240 && EQ (XCAR (tem), Qautoload))
1517
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
241 {
1566
892c9f61217a * keymap.c (get_keymap_1): Don't try to autoload OBJECT's function
Jim Blandy <jimb@redhat.com>
parents: 1517
diff changeset
242 Lisp_Object tail;
892c9f61217a * keymap.c (get_keymap_1): Don't try to autoload OBJECT's function
Jim Blandy <jimb@redhat.com>
parents: 1517
diff changeset
243
892c9f61217a * keymap.c (get_keymap_1): Don't try to autoload OBJECT's function
Jim Blandy <jimb@redhat.com>
parents: 1517
diff changeset
244 tail = Fnth (make_number (4), tem);
892c9f61217a * keymap.c (get_keymap_1): Don't try to autoload OBJECT's function
Jim Blandy <jimb@redhat.com>
parents: 1517
diff changeset
245 if (EQ (tail, Qkeymap))
892c9f61217a * keymap.c (get_keymap_1): Don't try to autoload OBJECT's function
Jim Blandy <jimb@redhat.com>
parents: 1517
diff changeset
246 {
892c9f61217a * keymap.c (get_keymap_1): Don't try to autoload OBJECT's function
Jim Blandy <jimb@redhat.com>
parents: 1517
diff changeset
247 struct gcpro gcpro1, gcpro2;
1517
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
248
3691
49ce2242f5c1 (get_keymap_1): Add missing semicolon.
Richard M. Stallman <rms@gnu.org>
parents: 3674
diff changeset
249 GCPRO2 (tem, object);
49ce2242f5c1 (get_keymap_1): Add missing semicolon.
Richard M. Stallman <rms@gnu.org>
parents: 3674
diff changeset
250 do_autoload (tem, object);
1566
892c9f61217a * keymap.c (get_keymap_1): Don't try to autoload OBJECT's function
Jim Blandy <jimb@redhat.com>
parents: 1517
diff changeset
251 UNGCPRO;
1517
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
252
1566
892c9f61217a * keymap.c (get_keymap_1): Don't try to autoload OBJECT's function
Jim Blandy <jimb@redhat.com>
parents: 1517
diff changeset
253 goto autoload_retry;
892c9f61217a * keymap.c (get_keymap_1): Don't try to autoload OBJECT's function
Jim Blandy <jimb@redhat.com>
parents: 1517
diff changeset
254 }
1517
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
255 }
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
256
25128
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
257 end:
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
258 if (error)
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
259 wrong_type_argument (Qkeymapp, object);
31829
43566b0aec59 Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents: 31496
diff changeset
260 return Qnil;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
261 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
262
1517
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
263
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
264 /* Follow any symbol chaining, and return the keymap denoted by OBJECT.
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
265 If OBJECT doesn't denote a keymap at all, signal an error. */
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
266 Lisp_Object
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
267 get_keymap (object)
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
268 Lisp_Object object;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
269 {
6774
a29237d1fdca (get_keymap): Pass 1 as ERROR to get_keymap_1.
Richard M. Stallman <rms@gnu.org>
parents: 6695
diff changeset
270 return get_keymap_1 (object, 1, 0);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
271 }
15344
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
272
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
273 /* Return the parent map of the keymap MAP, or nil if it has none.
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
274 We assume that MAP is a valid keymap. */
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
275
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
276 DEFUN ("keymap-parent", Fkeymap_parent, Skeymap_parent, 1, 1, 0,
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
277 "Return the parent keymap of KEYMAP.")
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
278 (keymap)
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
279 Lisp_Object keymap;
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
280 {
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
281 Lisp_Object list;
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
282
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
283 keymap = get_keymap_1 (keymap, 1, 1);
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
284
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
285 /* Skip past the initial element `keymap'. */
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
286 list = XCDR (keymap);
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
287 for (; CONSP (list); list = XCDR (list))
15344
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
288 {
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
289 /* See if there is another `keymap'. */
31208
442d40fce0db (store_in_keymap, fix_submap_inheritance): New prototypes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30780
diff changeset
290 if (KEYMAPP (list))
15344
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
291 return list;
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
292 }
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
293
32478
a7703eb49693 (Fkeymap_parent): Undefined autoload -> 1.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32476
diff changeset
294 return get_keymap_1(list, 0, 1);
15344
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
295 }
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
296
31496
946e1ba42cc9 (Fset_keymap_parent): Check for cycles in keymap
Gerd Moellmann <gerd@gnu.org>
parents: 31232
diff changeset
297
32038
0cb9cab990cb (keymap_memberp): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31989
diff changeset
298 /* Check whether MAP is one of MAPS parents. */
0cb9cab990cb (keymap_memberp): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31989
diff changeset
299 int
0cb9cab990cb (keymap_memberp): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31989
diff changeset
300 keymap_memberp (map, maps)
0cb9cab990cb (keymap_memberp): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31989
diff changeset
301 Lisp_Object map, maps;
0cb9cab990cb (keymap_memberp): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31989
diff changeset
302 {
32559
bc60bd171784 (keymap_memberp): Ensure that nil is not a member.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32478
diff changeset
303 if (NILP (map)) return 0;
32038
0cb9cab990cb (keymap_memberp): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31989
diff changeset
304 while (KEYMAPP (maps) && !EQ (map, maps))
0cb9cab990cb (keymap_memberp): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31989
diff changeset
305 maps = Fkeymap_parent (maps);
0cb9cab990cb (keymap_memberp): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31989
diff changeset
306 return (EQ (map, maps));
0cb9cab990cb (keymap_memberp): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31989
diff changeset
307 }
0cb9cab990cb (keymap_memberp): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31989
diff changeset
308
15344
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
309 /* Set the parent keymap of MAP to PARENT. */
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
310
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
311 DEFUN ("set-keymap-parent", Fset_keymap_parent, Sset_keymap_parent, 2, 2, 0,
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
312 "Modify KEYMAP to set its parent map to PARENT.\n\
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
313 PARENT should be nil or another keymap.")
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
314 (keymap, parent)
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
315 Lisp_Object keymap, parent;
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
316 {
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
317 Lisp_Object list, prev;
30134
784ef95b020b (get_keymap_1): Add comment that this function can GC.
Gerd Moellmann <gerd@gnu.org>
parents: 30030
diff changeset
318 struct gcpro gcpro1;
15344
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
319 int i;
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
320
32889
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
321 /* Force a keymap flush for the next call to where-is.
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
322 Since this can be called from within where-is, we don't set where_is_cache
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
323 directly but only where_is_cache_keymaps, since where_is_cache shouldn't
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
324 be changed during where-is, while where_is_cache_keymaps is only used at
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
325 the very beginning of where-is and can thus be changed here without any
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
326 adverse effect.
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
327 This is a very minor correctness (rather than safety) issue. */
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
328 where_is_cache_keymaps = Qt;
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
329
15344
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
330 keymap = get_keymap_1 (keymap, 1, 1);
30134
784ef95b020b (get_keymap_1): Add comment that this function can GC.
Gerd Moellmann <gerd@gnu.org>
parents: 30030
diff changeset
331 GCPRO1 (keymap);
784ef95b020b (get_keymap_1): Add comment that this function can GC.
Gerd Moellmann <gerd@gnu.org>
parents: 30030
diff changeset
332
15344
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
333 if (!NILP (parent))
31496
946e1ba42cc9 (Fset_keymap_parent): Check for cycles in keymap
Gerd Moellmann <gerd@gnu.org>
parents: 31232
diff changeset
334 {
946e1ba42cc9 (Fset_keymap_parent): Check for cycles in keymap
Gerd Moellmann <gerd@gnu.org>
parents: 31232
diff changeset
335 parent = get_keymap_1 (parent, 1, 1);
946e1ba42cc9 (Fset_keymap_parent): Check for cycles in keymap
Gerd Moellmann <gerd@gnu.org>
parents: 31232
diff changeset
336
946e1ba42cc9 (Fset_keymap_parent): Check for cycles in keymap
Gerd Moellmann <gerd@gnu.org>
parents: 31232
diff changeset
337 /* Check for cycles. */
32038
0cb9cab990cb (keymap_memberp): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31989
diff changeset
338 if (keymap_memberp (keymap, parent))
31496
946e1ba42cc9 (Fset_keymap_parent): Check for cycles in keymap
Gerd Moellmann <gerd@gnu.org>
parents: 31232
diff changeset
339 error ("Cyclic keymap inheritance");
946e1ba42cc9 (Fset_keymap_parent): Check for cycles in keymap
Gerd Moellmann <gerd@gnu.org>
parents: 31232
diff changeset
340 }
15344
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
341
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
342 /* Skip past the initial element `keymap'. */
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
343 prev = keymap;
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
344 while (1)
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
345 {
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
346 list = XCDR (prev);
15344
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
347 /* If there is a parent keymap here, replace it.
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
348 If we came to the end, add the parent in PREV. */
31208
442d40fce0db (store_in_keymap, fix_submap_inheritance): New prototypes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30780
diff changeset
349 if (! CONSP (list) || KEYMAPP (list))
15344
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
350 {
15422
dd639432a55a (Fset_keymap_parent): Return early if KEYMAP already has the proper parent.
Richard M. Stallman <rms@gnu.org>
parents: 15378
diff changeset
351 /* If we already have the right parent, return now
dd639432a55a (Fset_keymap_parent): Return early if KEYMAP already has the proper parent.
Richard M. Stallman <rms@gnu.org>
parents: 15378
diff changeset
352 so that we avoid the loops below. */
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
353 if (EQ (XCDR (prev), parent))
30134
784ef95b020b (get_keymap_1): Add comment that this function can GC.
Gerd Moellmann <gerd@gnu.org>
parents: 30030
diff changeset
354 RETURN_UNGCPRO (parent);
15422
dd639432a55a (Fset_keymap_parent): Return early if KEYMAP already has the proper parent.
Richard M. Stallman <rms@gnu.org>
parents: 15378
diff changeset
355
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
356 XCDR (prev) = parent;
15344
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
357 break;
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
358 }
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
359 prev = list;
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
360 }
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
361
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
362 /* Scan through for submaps, and set their parents too. */
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
363
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
364 for (list = XCDR (keymap); CONSP (list); list = XCDR (list))
15344
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
365 {
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
366 /* Stop the scan when we come to the parent. */
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
367 if (EQ (XCAR (list), Qkeymap))
15344
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
368 break;
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
369
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
370 /* If this element holds a prefix map, deal with it. */
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
371 if (CONSP (XCAR (list))
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
372 && CONSP (XCDR (XCAR (list))))
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
373 fix_submap_inheritance (keymap, XCAR (XCAR (list)),
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
374 XCDR (XCAR (list)));
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
375
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
376 if (VECTORP (XCAR (list)))
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
377 for (i = 0; i < XVECTOR (XCAR (list))->size; i++)
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
378 if (CONSP (XVECTOR (XCAR (list))->contents[i]))
15344
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
379 fix_submap_inheritance (keymap, make_number (i),
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
380 XVECTOR (XCAR (list))->contents[i]);
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
381
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
382 if (CHAR_TABLE_P (XCAR (list)))
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
383 {
20076
374e09781f08 (Faccessible_keymaps): Avoid alloca for fixed-size array.
Karl Heuer <kwzh@gnu.org>
parents: 20070
diff changeset
384 Lisp_Object indices[3];
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
385
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
386 map_char_table (fix_submap_inheritance, Qnil, XCAR (list),
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
387 keymap, 0, indices);
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
388 }
15344
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
389 }
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
390
30134
784ef95b020b (get_keymap_1): Add comment that this function can GC.
Gerd Moellmann <gerd@gnu.org>
parents: 30030
diff changeset
391 RETURN_UNGCPRO (parent);
15344
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
392 }
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
393
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
394 /* EVENT is defined in MAP as a prefix, and SUBMAP is its definition.
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
395 if EVENT is also a prefix in MAP's parent,
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
396 make sure that SUBMAP inherits that definition as its own parent. */
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
397
31208
442d40fce0db (store_in_keymap, fix_submap_inheritance): New prototypes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30780
diff changeset
398 static void
15344
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
399 fix_submap_inheritance (map, event, submap)
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
400 Lisp_Object map, event, submap;
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
401 {
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
402 Lisp_Object map_parent, parent_entry;
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
403
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
404 /* SUBMAP is a cons that we found as a key binding.
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
405 Discard the other things found in a menu key binding. */
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
406
32038
0cb9cab990cb (keymap_memberp): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31989
diff changeset
407 submap = get_keymap_1 (get_keyelt (submap, 0), 0, 0);
15344
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
408
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
409 /* If it isn't a keymap now, there's no work to do. */
32038
0cb9cab990cb (keymap_memberp): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31989
diff changeset
410 if (NILP (submap))
15344
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
411 return;
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
412
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
413 map_parent = Fkeymap_parent (map);
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
414 if (! NILP (map_parent))
32844
5aa0846c2995 (fix_submap_inheritance): Use get_keymap_1 on parent_entry
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32818
diff changeset
415 parent_entry =
5aa0846c2995 (fix_submap_inheritance): Use get_keymap_1 on parent_entry
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32818
diff changeset
416 get_keymap_1 (access_keymap (map_parent, event, 0, 0, 0), 0, 0);
15344
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
417 else
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
418 parent_entry = Qnil;
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
419
15378
ecfc288350ab (fix_submap_inheritance): If parent_entry is not a keymap, use nil instead.
Richard M. Stallman <rms@gnu.org>
parents: 15344
diff changeset
420 /* If MAP's parent has something other than a keymap,
32739
5ce157b2eaa9 (fix_submap_inheritance): Don't do anything if parent_entry
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32615
diff changeset
421 our own submap shadows it completely. */
32844
5aa0846c2995 (fix_submap_inheritance): Use get_keymap_1 on parent_entry
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32818
diff changeset
422 if (NILP (parent_entry))
32739
5ce157b2eaa9 (fix_submap_inheritance): Don't do anything if parent_entry
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32615
diff changeset
423 return;
15378
ecfc288350ab (fix_submap_inheritance): If parent_entry is not a keymap, use nil instead.
Richard M. Stallman <rms@gnu.org>
parents: 15344
diff changeset
424
15344
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
425 if (! EQ (parent_entry, submap))
25600
6cea4c28fc1c (fix_submap_inheritance): Do nothing if the proper parent is an
Richard M. Stallman <rms@gnu.org>
parents: 25128
diff changeset
426 {
6cea4c28fc1c (fix_submap_inheritance): Do nothing if the proper parent is an
Richard M. Stallman <rms@gnu.org>
parents: 25128
diff changeset
427 Lisp_Object submap_parent;
6cea4c28fc1c (fix_submap_inheritance): Do nothing if the proper parent is an
Richard M. Stallman <rms@gnu.org>
parents: 25128
diff changeset
428 submap_parent = submap;
6cea4c28fc1c (fix_submap_inheritance): Do nothing if the proper parent is an
Richard M. Stallman <rms@gnu.org>
parents: 25128
diff changeset
429 while (1)
6cea4c28fc1c (fix_submap_inheritance): Do nothing if the proper parent is an
Richard M. Stallman <rms@gnu.org>
parents: 25128
diff changeset
430 {
6cea4c28fc1c (fix_submap_inheritance): Do nothing if the proper parent is an
Richard M. Stallman <rms@gnu.org>
parents: 25128
diff changeset
431 Lisp_Object tem;
32739
5ce157b2eaa9 (fix_submap_inheritance): Don't do anything if parent_entry
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32615
diff changeset
432
25600
6cea4c28fc1c (fix_submap_inheritance): Do nothing if the proper parent is an
Richard M. Stallman <rms@gnu.org>
parents: 25128
diff changeset
433 tem = Fkeymap_parent (submap_parent);
32739
5ce157b2eaa9 (fix_submap_inheritance): Don't do anything if parent_entry
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32615
diff changeset
434
5ce157b2eaa9 (fix_submap_inheritance): Don't do anything if parent_entry
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32615
diff changeset
435 if (KEYMAPP (tem))
5ce157b2eaa9 (fix_submap_inheritance): Don't do anything if parent_entry
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32615
diff changeset
436 {
5ce157b2eaa9 (fix_submap_inheritance): Don't do anything if parent_entry
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32615
diff changeset
437 if (keymap_memberp (tem, parent_entry))
5ce157b2eaa9 (fix_submap_inheritance): Don't do anything if parent_entry
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32615
diff changeset
438 /* Fset_keymap_parent could create a cycle. */
5ce157b2eaa9 (fix_submap_inheritance): Don't do anything if parent_entry
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32615
diff changeset
439 return;
5ce157b2eaa9 (fix_submap_inheritance): Don't do anything if parent_entry
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32615
diff changeset
440 submap_parent = tem;
5ce157b2eaa9 (fix_submap_inheritance): Don't do anything if parent_entry
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32615
diff changeset
441 }
25600
6cea4c28fc1c (fix_submap_inheritance): Do nothing if the proper parent is an
Richard M. Stallman <rms@gnu.org>
parents: 25128
diff changeset
442 else
6cea4c28fc1c (fix_submap_inheritance): Do nothing if the proper parent is an
Richard M. Stallman <rms@gnu.org>
parents: 25128
diff changeset
443 break;
6cea4c28fc1c (fix_submap_inheritance): Do nothing if the proper parent is an
Richard M. Stallman <rms@gnu.org>
parents: 25128
diff changeset
444 }
6cea4c28fc1c (fix_submap_inheritance): Do nothing if the proper parent is an
Richard M. Stallman <rms@gnu.org>
parents: 25128
diff changeset
445 Fset_keymap_parent (submap_parent, parent_entry);
6cea4c28fc1c (fix_submap_inheritance): Do nothing if the proper parent is an
Richard M. Stallman <rms@gnu.org>
parents: 25128
diff changeset
446 }
15344
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
447 }
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
448
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
449 /* Look up IDX in MAP. IDX may be any sort of event.
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
450 Note that this does only one level of lookup; IDX must be a single
1388
02226bff1476 * keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents: 1315
diff changeset
451 event, not a sequence.
02226bff1476 * keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents: 1315
diff changeset
452
02226bff1476 * keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents: 1315
diff changeset
453 If T_OK is non-zero, bindings for Qt are treated as default
02226bff1476 * keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents: 1315
diff changeset
454 bindings; any key left unmentioned by other tables and bindings is
02226bff1476 * keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents: 1315
diff changeset
455 given the binding of Qt.
02226bff1476 * keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents: 1315
diff changeset
456
3735
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
457 If T_OK is zero, bindings for Qt are not treated specially.
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
458
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
459 If NOINHERIT, don't accept a subkeymap found in an inherited keymap. */
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
460
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
461 Lisp_Object
32476
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
462 access_keymap (map, idx, t_ok, noinherit, autoload)
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
463 Lisp_Object map;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
464 Lisp_Object idx;
1388
02226bff1476 * keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents: 1315
diff changeset
465 int t_ok;
3735
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
466 int noinherit;
32476
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
467 int autoload;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
468 {
3735
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
469 int noprefix = 0;
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
470 Lisp_Object val;
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
471
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
472 /* If idx is a list (some sort of mouse click, perhaps?),
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
473 the index we want to use is the car of the list, which
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
474 ought to be a symbol. */
1315
884c3d7e7172 * keymap.c (access_keymap, store_in_keymap,
Jim Blandy <jimb@redhat.com>
parents: 1264
diff changeset
475 idx = EVENT_HEAD (idx);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
476
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
477 /* If idx is a symbol, it might have modifiers, which need to
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
478 be put in the canonical order. */
8866
48a0ea73a9d7 (Fkey_description): Give error if KEYS not an array.
Richard M. Stallman <rms@gnu.org>
parents: 8731
diff changeset
479 if (SYMBOLP (idx))
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
480 idx = reorder_modifiers (idx);
3515
9d0af0f2dc0d (access_keymap, store_in_keymap): Discard meaningless
Richard M. Stallman <rms@gnu.org>
parents: 3425
diff changeset
481 else if (INTEGERP (idx))
9d0af0f2dc0d (access_keymap, store_in_keymap): Discard meaningless
Richard M. Stallman <rms@gnu.org>
parents: 3425
diff changeset
482 /* Clobber the high bits that can be present on a machine
9d0af0f2dc0d (access_keymap, store_in_keymap): Discard meaningless
Richard M. Stallman <rms@gnu.org>
parents: 3425
diff changeset
483 with more than 24 bits of integer. */
9312
dfaf1d41e53d (synkey, access_keymap, store_in_keymap, Faccessible_keymaps,
Karl Heuer <kwzh@gnu.org>
parents: 9273
diff changeset
484 XSETFASTINT (idx, XINT (idx) & (CHAR_META | (CHAR_META - 1)));
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
485
32476
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
486 /* Handle the special meta -> esc mapping. */
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
487 if (INTEGERP (idx) && XUINT (idx) & meta_modifier)
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
488 {
32615
5f6178a60e6b (access_keymap): If IDX has a meta prefix, and there's
Gerd Moellmann <gerd@gnu.org>
parents: 32559
diff changeset
489 /* See if there is a meta-map. If there's none, there is
5f6178a60e6b (access_keymap): If IDX has a meta prefix, and there's
Gerd Moellmann <gerd@gnu.org>
parents: 32559
diff changeset
490 no binding for IDX, unless a default binding exists in MAP. */
32739
5ce157b2eaa9 (fix_submap_inheritance): Don't do anything if parent_entry
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32615
diff changeset
491 Lisp_Object meta_map =
32818
f915f46d067c Update copyright.
Gerd Moellmann <gerd@gnu.org>
parents: 32739
diff changeset
492 get_keymap_1 (access_keymap (map, meta_prefix_char,
f915f46d067c Update copyright.
Gerd Moellmann <gerd@gnu.org>
parents: 32739
diff changeset
493 t_ok, noinherit, autoload),
32739
5ce157b2eaa9 (fix_submap_inheritance): Don't do anything if parent_entry
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32615
diff changeset
494 0, autoload);
5ce157b2eaa9 (fix_submap_inheritance): Don't do anything if parent_entry
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32615
diff changeset
495 if (!NILP (meta_map))
32615
5f6178a60e6b (access_keymap): If IDX has a meta prefix, and there's
Gerd Moellmann <gerd@gnu.org>
parents: 32559
diff changeset
496 {
32739
5ce157b2eaa9 (fix_submap_inheritance): Don't do anything if parent_entry
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32615
diff changeset
497 map = meta_map;
32615
5f6178a60e6b (access_keymap): If IDX has a meta prefix, and there's
Gerd Moellmann <gerd@gnu.org>
parents: 32559
diff changeset
498 idx = make_number (XUINT (idx) & ~meta_modifier);
5f6178a60e6b (access_keymap): If IDX has a meta prefix, and there's
Gerd Moellmann <gerd@gnu.org>
parents: 32559
diff changeset
499 }
5f6178a60e6b (access_keymap): If IDX has a meta prefix, and there's
Gerd Moellmann <gerd@gnu.org>
parents: 32559
diff changeset
500 else if (t_ok)
5f6178a60e6b (access_keymap): If IDX has a meta prefix, and there's
Gerd Moellmann <gerd@gnu.org>
parents: 32559
diff changeset
501 /* Set IDX to t, so that we only find a default binding. */
5f6178a60e6b (access_keymap): If IDX has a meta prefix, and there's
Gerd Moellmann <gerd@gnu.org>
parents: 32559
diff changeset
502 idx = Qt;
5f6178a60e6b (access_keymap): If IDX has a meta prefix, and there's
Gerd Moellmann <gerd@gnu.org>
parents: 32559
diff changeset
503 else
5f6178a60e6b (access_keymap): If IDX has a meta prefix, and there's
Gerd Moellmann <gerd@gnu.org>
parents: 32559
diff changeset
504 /* We know there is no binding. */
5f6178a60e6b (access_keymap): If IDX has a meta prefix, and there's
Gerd Moellmann <gerd@gnu.org>
parents: 32559
diff changeset
505 return Qnil;
32476
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
506 }
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
507
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
508 {
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
509 Lisp_Object tail;
6502
18dfda644bc0 (access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents: 6475
diff changeset
510 Lisp_Object t_binding;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
511
6502
18dfda644bc0 (access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents: 6475
diff changeset
512 t_binding = Qnil;
32476
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
513 for (tail = XCDR (map);
32615
5f6178a60e6b (access_keymap): If IDX has a meta prefix, and there's
Gerd Moellmann <gerd@gnu.org>
parents: 32559
diff changeset
514 (CONSP (tail)
5f6178a60e6b (access_keymap): If IDX has a meta prefix, and there's
Gerd Moellmann <gerd@gnu.org>
parents: 32559
diff changeset
515 || (tail = get_keymap_1 (tail, 0, autoload),
5f6178a60e6b (access_keymap): If IDX has a meta prefix, and there's
Gerd Moellmann <gerd@gnu.org>
parents: 32559
diff changeset
516 CONSP (tail)));
32476
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
517 tail = XCDR (tail))
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
518 {
6502
18dfda644bc0 (access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents: 6475
diff changeset
519 Lisp_Object binding;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
520
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
521 binding = XCAR (tail);
9973
1d5a908f201e (access_keymap): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9957
diff changeset
522 if (SYMBOLP (binding))
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
523 {
3735
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
524 /* If NOINHERIT, stop finding prefix definitions
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
525 after we pass a second occurrence of the `keymap' symbol. */
32476
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
526 if (noinherit && EQ (binding, Qkeymap))
3735
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
527 noprefix = 1;
9973
1d5a908f201e (access_keymap): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9957
diff changeset
528 }
1d5a908f201e (access_keymap): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9957
diff changeset
529 else if (CONSP (binding))
1d5a908f201e (access_keymap): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9957
diff changeset
530 {
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
531 if (EQ (XCAR (binding), idx))
3735
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
532 {
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
533 val = XCDR (binding);
32038
0cb9cab990cb (keymap_memberp): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31989
diff changeset
534 if (noprefix && KEYMAPP (val))
3735
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
535 return Qnil;
15344
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
536 if (CONSP (val))
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
537 fix_submap_inheritance (map, idx, val);
32476
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
538 return get_keyelt (val, autoload);
3735
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
539 }
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
540 if (t_ok && EQ (XCAR (binding), Qt))
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
541 t_binding = XCDR (binding);
9973
1d5a908f201e (access_keymap): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9957
diff changeset
542 }
1d5a908f201e (access_keymap): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9957
diff changeset
543 else if (VECTORP (binding))
1d5a908f201e (access_keymap): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9957
diff changeset
544 {
9957
940847846909 (access_keymap, store_in_keymap): Use NATNUMP instead of its expansion.
Karl Heuer <kwzh@gnu.org>
parents: 9946
diff changeset
545 if (NATNUMP (idx) && XFASTINT (idx) < XVECTOR (binding)->size)
3735
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
546 {
9973
1d5a908f201e (access_keymap): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9957
diff changeset
547 val = XVECTOR (binding)->contents[XFASTINT (idx)];
32038
0cb9cab990cb (keymap_memberp): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31989
diff changeset
548 if (noprefix && KEYMAPP (val))
3735
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
549 return Qnil;
15344
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
550 if (CONSP (val))
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
551 fix_submap_inheritance (map, idx, val);
32476
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
552 return get_keyelt (val, autoload);
3735
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
553 }
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
554 }
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
555 else if (CHAR_TABLE_P (binding))
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
556 {
17932
78a128b99e05 (access_keymap, store_in_keymap): Don't look in a char-table
Richard M. Stallman <rms@gnu.org>
parents: 17861
diff changeset
557 /* Character codes with modifiers
78a128b99e05 (access_keymap, store_in_keymap): Don't look in a char-table
Richard M. Stallman <rms@gnu.org>
parents: 17861
diff changeset
558 are not included in a char-table.
78a128b99e05 (access_keymap, store_in_keymap): Don't look in a char-table
Richard M. Stallman <rms@gnu.org>
parents: 17861
diff changeset
559 All character codes without modifiers are included. */
78a128b99e05 (access_keymap, store_in_keymap): Don't look in a char-table
Richard M. Stallman <rms@gnu.org>
parents: 17861
diff changeset
560 if (NATNUMP (idx)
78a128b99e05 (access_keymap, store_in_keymap): Don't look in a char-table
Richard M. Stallman <rms@gnu.org>
parents: 17861
diff changeset
561 && ! (XFASTINT (idx)
78a128b99e05 (access_keymap, store_in_keymap): Don't look in a char-table
Richard M. Stallman <rms@gnu.org>
parents: 17861
diff changeset
562 & (CHAR_ALT | CHAR_SUPER | CHAR_HYPER
78a128b99e05 (access_keymap, store_in_keymap): Don't look in a char-table
Richard M. Stallman <rms@gnu.org>
parents: 17861
diff changeset
563 | CHAR_SHIFT | CHAR_CTL | CHAR_META)))
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
564 {
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
565 val = Faref (binding, idx);
32038
0cb9cab990cb (keymap_memberp): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31989
diff changeset
566 if (noprefix && KEYMAPP (val))
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
567 return Qnil;
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
568 if (CONSP (val))
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
569 fix_submap_inheritance (map, idx, val);
32476
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
570 return get_keyelt (val, autoload);
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
571 }
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
572 }
1264
6ba9d5aaace6 * keymap.c (access_keymap): Don't forget to QUIT while scanning
Jim Blandy <jimb@redhat.com>
parents: 1236
diff changeset
573
6ba9d5aaace6 * keymap.c (access_keymap): Don't forget to QUIT while scanning
Jim Blandy <jimb@redhat.com>
parents: 1236
diff changeset
574 QUIT;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
575 }
1388
02226bff1476 * keymap.c (initial_define_lispy_key): New function, for defining
Jim Blandy <jimb@redhat.com>
parents: 1315
diff changeset
576
32476
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
577 return get_keyelt (t_binding, autoload);
1236
5e8c234e5f03 * keymap.c (access_keymap): Remove code to notice bindings for
Jim Blandy <jimb@redhat.com>
parents: 1209
diff changeset
578 }
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
579 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
580
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
581 /* Given OBJECT which was found in a slot in a keymap,
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
582 trace indirect definitions to get the actual definition of that slot.
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
583 An indirect definition is a list of the form
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
584 (KEYMAP . INDEX), where KEYMAP is a keymap or a symbol defined as one
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
585 and INDEX is the object to look up in KEYMAP to yield the definition.
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
586
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
587 Also if OBJECT has a menu string as the first element,
6774
a29237d1fdca (get_keymap): Pass 1 as ERROR to get_keymap_1.
Richard M. Stallman <rms@gnu.org>
parents: 6695
diff changeset
588 remove that. Also remove a menu help string as second element.
a29237d1fdca (get_keymap): Pass 1 as ERROR to get_keymap_1.
Richard M. Stallman <rms@gnu.org>
parents: 6695
diff changeset
589
a29237d1fdca (get_keymap): Pass 1 as ERROR to get_keymap_1.
Richard M. Stallman <rms@gnu.org>
parents: 6695
diff changeset
590 If AUTOLOAD is nonzero, load autoloadable keymaps
a29237d1fdca (get_keymap): Pass 1 as ERROR to get_keymap_1.
Richard M. Stallman <rms@gnu.org>
parents: 6695
diff changeset
591 that are referred to with indirection. */
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
592
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
593 Lisp_Object
6774
a29237d1fdca (get_keymap): Pass 1 as ERROR to get_keymap_1.
Richard M. Stallman <rms@gnu.org>
parents: 6695
diff changeset
594 get_keyelt (object, autoload)
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
595 register Lisp_Object object;
6774
a29237d1fdca (get_keymap): Pass 1 as ERROR to get_keymap_1.
Richard M. Stallman <rms@gnu.org>
parents: 6695
diff changeset
596 int autoload;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
597 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
598 while (1)
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
599 {
25128
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
600 if (!(CONSP (object)))
21241
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
601 /* This is really the value. */
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
602 return object;
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
603
25128
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
604 /* If the keymap contents looks like (keymap ...) or (lambda ...)
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
605 then use itself. */
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
606 else if (EQ (XCAR (object), Qkeymap) || EQ (XCAR (object), Qlambda))
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
607 return object;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
608
21241
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
609 /* If the keymap contents looks like (menu-item name . DEFN)
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
610 or (menu-item name DEFN ...) then use DEFN.
29941
0c77254c90b8 (get_keyelt): For menu-items containing a `:filter
Gerd Moellmann <gerd@gnu.org>
parents: 29726
diff changeset
611 This is a new format menu item. */
25128
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
612 else if (EQ (XCAR (object), Qmenu_item))
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
613 {
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
614 if (CONSP (XCDR (object)))
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
615 {
29941
0c77254c90b8 (get_keyelt): For menu-items containing a `:filter
Gerd Moellmann <gerd@gnu.org>
parents: 29726
diff changeset
616 Lisp_Object tem;
0c77254c90b8 (get_keyelt): For menu-items containing a `:filter
Gerd Moellmann <gerd@gnu.org>
parents: 29726
diff changeset
617
25128
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
618 object = XCDR (XCDR (object));
29941
0c77254c90b8 (get_keyelt): For menu-items containing a `:filter
Gerd Moellmann <gerd@gnu.org>
parents: 29726
diff changeset
619 tem = object;
25128
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
620 if (CONSP (object))
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
621 object = XCAR (object);
29941
0c77254c90b8 (get_keyelt): For menu-items containing a `:filter
Gerd Moellmann <gerd@gnu.org>
parents: 29726
diff changeset
622
0c77254c90b8 (get_keyelt): For menu-items containing a `:filter
Gerd Moellmann <gerd@gnu.org>
parents: 29726
diff changeset
623 /* If there's a `:filter FILTER', apply FILTER to the
0c77254c90b8 (get_keyelt): For menu-items containing a `:filter
Gerd Moellmann <gerd@gnu.org>
parents: 29726
diff changeset
624 menu-item's definition to get the real definition to
30030
94dcb1b07998 (get_keyelt): Temporarily inhibit GC while evaluating
Gerd Moellmann <gerd@gnu.org>
parents: 29941
diff changeset
625 use. Temporarily inhibit GC while evaluating FILTER,
94dcb1b07998 (get_keyelt): Temporarily inhibit GC while evaluating
Gerd Moellmann <gerd@gnu.org>
parents: 29941
diff changeset
626 because not functions calling get_keyelt are prepared
94dcb1b07998 (get_keyelt): Temporarily inhibit GC while evaluating
Gerd Moellmann <gerd@gnu.org>
parents: 29941
diff changeset
627 for a GC. */
29941
0c77254c90b8 (get_keyelt): For menu-items containing a `:filter
Gerd Moellmann <gerd@gnu.org>
parents: 29726
diff changeset
628 for (; CONSP (tem) && CONSP (XCDR (tem)); tem = XCDR (tem))
0c77254c90b8 (get_keyelt): For menu-items containing a `:filter
Gerd Moellmann <gerd@gnu.org>
parents: 29726
diff changeset
629 if (EQ (XCAR (tem), QCfilter))
0c77254c90b8 (get_keyelt): For menu-items containing a `:filter
Gerd Moellmann <gerd@gnu.org>
parents: 29726
diff changeset
630 {
30030
94dcb1b07998 (get_keyelt): Temporarily inhibit GC while evaluating
Gerd Moellmann <gerd@gnu.org>
parents: 29941
diff changeset
631 int count = inhibit_garbage_collection ();
29941
0c77254c90b8 (get_keyelt): For menu-items containing a `:filter
Gerd Moellmann <gerd@gnu.org>
parents: 29726
diff changeset
632 Lisp_Object filter;
0c77254c90b8 (get_keyelt): For menu-items containing a `:filter
Gerd Moellmann <gerd@gnu.org>
parents: 29726
diff changeset
633 filter = XCAR (XCDR (tem));
0c77254c90b8 (get_keyelt): For menu-items containing a `:filter
Gerd Moellmann <gerd@gnu.org>
parents: 29726
diff changeset
634 filter = list2 (filter, list2 (Qquote, object));
0c77254c90b8 (get_keyelt): For menu-items containing a `:filter
Gerd Moellmann <gerd@gnu.org>
parents: 29726
diff changeset
635 object = menu_item_eval_property (filter);
30030
94dcb1b07998 (get_keyelt): Temporarily inhibit GC while evaluating
Gerd Moellmann <gerd@gnu.org>
parents: 29941
diff changeset
636 unbind_to (count, Qnil);
29941
0c77254c90b8 (get_keyelt): For menu-items containing a `:filter
Gerd Moellmann <gerd@gnu.org>
parents: 29726
diff changeset
637 break;
0c77254c90b8 (get_keyelt): For menu-items containing a `:filter
Gerd Moellmann <gerd@gnu.org>
parents: 29726
diff changeset
638 }
25128
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
639 }
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
640 else
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
641 /* Invalid keymap */
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
642 return object;
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
643 }
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
644
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
645 /* If the keymap contents looks like (STRING . DEFN), use DEFN.
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
646 Keymap alist elements like (CHAR MENUSTRING . DEFN)
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
647 will be used by HierarKey menus. */
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
648 else if (STRINGP (XCAR (object)))
21241
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
649 {
25128
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
650 object = XCDR (object);
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
651 /* Also remove a menu help string, if any,
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
652 following the menu item name. */
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
653 if (CONSP (object) && STRINGP (XCAR (object)))
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
654 object = XCDR (object);
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
655 /* Also remove the sublist that caches key equivalences, if any. */
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
656 if (CONSP (object) && CONSP (XCAR (object)))
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
657 {
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
658 Lisp_Object carcar;
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
659 carcar = XCAR (XCAR (object));
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
660 if (NILP (carcar) || VECTORP (carcar))
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
661 object = XCDR (object);
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
662 }
21241
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
663 }
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
664
25128
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
665 /* If the contents are (KEYMAP . ELEMENT), go indirect. */
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
666 else
25128
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
667 {
30134
784ef95b020b (get_keymap_1): Add comment that this function can GC.
Gerd Moellmann <gerd@gnu.org>
parents: 30030
diff changeset
668 Lisp_Object map;
25128
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
669 map = get_keymap_1 (Fcar_safe (object), 0, autoload);
32476
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
670 return (NILP (map) ? object /* Invalid keymap */
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
671 : access_keymap (map, Fcdr (object), 0, 0, autoload));
25128
2563b35e613f (get_keymap_1, get_keyelt): Check the type of OBJECT
Karl Heuer <kwzh@gnu.org>
parents: 24572
diff changeset
672 }
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
673 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
674 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
675
31232
5213900983ed (store_in_keymap): Add `static' to declaration.
Dave Love <fx@gnu.org>
parents: 31208
diff changeset
676 static Lisp_Object
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
677 store_in_keymap (keymap, idx, def)
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
678 Lisp_Object keymap;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
679 register Lisp_Object idx;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
680 register Lisp_Object def;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
681 {
32889
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
682 /* Flush any reverse-map cache. */
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
683 where_is_cache = Qnil;
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
684 where_is_cache_keymaps = Qt;
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
685
10367
e1c7a3f0c15f (store_in_keymap): Copy a cons only if car is a string.
Richard M. Stallman <rms@gnu.org>
parents: 10305
diff changeset
686 /* If we are preparing to dump, and DEF is a menu element
21241
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
687 with a menu item indicator, copy it to ensure it is not pure. */
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
688 if (CONSP (def) && PURE_P (def)
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
689 && (EQ (XCAR (def), Qmenu_item) || STRINGP (XCAR (def))))
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
690 def = Fcons (XCAR (def), XCDR (def));
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
691
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
692 if (!CONSP (keymap) || ! EQ (XCAR (keymap), Qkeymap))
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
693 error ("attempt to define a key in a non-keymap");
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
694
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
695 /* If idx is a list (some sort of mouse click, perhaps?),
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
696 the index we want to use is the car of the list, which
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
697 ought to be a symbol. */
1315
884c3d7e7172 * keymap.c (access_keymap, store_in_keymap,
Jim Blandy <jimb@redhat.com>
parents: 1264
diff changeset
698 idx = EVENT_HEAD (idx);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
699
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
700 /* If idx is a symbol, it might have modifiers, which need to
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
701 be put in the canonical order. */
9123
c225137ddefb (get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents: 8922
diff changeset
702 if (SYMBOLP (idx))
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
703 idx = reorder_modifiers (idx);
3515
9d0af0f2dc0d (access_keymap, store_in_keymap): Discard meaningless
Richard M. Stallman <rms@gnu.org>
parents: 3425
diff changeset
704 else if (INTEGERP (idx))
9d0af0f2dc0d (access_keymap, store_in_keymap): Discard meaningless
Richard M. Stallman <rms@gnu.org>
parents: 3425
diff changeset
705 /* Clobber the high bits that can be present on a machine
9d0af0f2dc0d (access_keymap, store_in_keymap): Discard meaningless
Richard M. Stallman <rms@gnu.org>
parents: 3425
diff changeset
706 with more than 24 bits of integer. */
9312
dfaf1d41e53d (synkey, access_keymap, store_in_keymap, Faccessible_keymaps,
Karl Heuer <kwzh@gnu.org>
parents: 9273
diff changeset
707 XSETFASTINT (idx, XINT (idx) & (CHAR_META | (CHAR_META - 1)));
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
708
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
709 /* Scan the keymap for a binding of idx. */
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
710 {
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
711 Lisp_Object tail;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
712
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
713 /* The cons after which we should insert new bindings. If the
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
714 keymap has a table element, we record its position here, so new
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
715 bindings will go after it; this way, the table will stay
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
716 towards the front of the alist and character lookups in dense
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
717 keymaps will remain fast. Otherwise, this just points at the
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
718 front of the keymap. */
6502
18dfda644bc0 (access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents: 6475
diff changeset
719 Lisp_Object insertion_point;
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
720
6502
18dfda644bc0 (access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents: 6475
diff changeset
721 insertion_point = keymap;
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
722 for (tail = XCDR (keymap); CONSP (tail); tail = XCDR (tail))
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
723 {
6502
18dfda644bc0 (access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents: 6475
diff changeset
724 Lisp_Object elt;
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
725
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
726 elt = XCAR (tail);
9973
1d5a908f201e (access_keymap): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9957
diff changeset
727 if (VECTORP (elt))
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
728 {
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
729 if (NATNUMP (idx) && XFASTINT (idx) < ASIZE (elt))
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
730 {
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
731 ASET (elt, XFASTINT (idx), def);
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
732 return def;
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
733 }
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
734 insertion_point = tail;
9973
1d5a908f201e (access_keymap): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9957
diff changeset
735 }
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
736 else if (CHAR_TABLE_P (elt))
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
737 {
17932
78a128b99e05 (access_keymap, store_in_keymap): Don't look in a char-table
Richard M. Stallman <rms@gnu.org>
parents: 17861
diff changeset
738 /* Character codes with modifiers
78a128b99e05 (access_keymap, store_in_keymap): Don't look in a char-table
Richard M. Stallman <rms@gnu.org>
parents: 17861
diff changeset
739 are not included in a char-table.
78a128b99e05 (access_keymap, store_in_keymap): Don't look in a char-table
Richard M. Stallman <rms@gnu.org>
parents: 17861
diff changeset
740 All character codes without modifiers are included. */
78a128b99e05 (access_keymap, store_in_keymap): Don't look in a char-table
Richard M. Stallman <rms@gnu.org>
parents: 17861
diff changeset
741 if (NATNUMP (idx)
78a128b99e05 (access_keymap, store_in_keymap): Don't look in a char-table
Richard M. Stallman <rms@gnu.org>
parents: 17861
diff changeset
742 && ! (XFASTINT (idx)
78a128b99e05 (access_keymap, store_in_keymap): Don't look in a char-table
Richard M. Stallman <rms@gnu.org>
parents: 17861
diff changeset
743 & (CHAR_ALT | CHAR_SUPER | CHAR_HYPER
78a128b99e05 (access_keymap, store_in_keymap): Don't look in a char-table
Richard M. Stallman <rms@gnu.org>
parents: 17861
diff changeset
744 | CHAR_SHIFT | CHAR_CTL | CHAR_META)))
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
745 {
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
746 Faset (elt, idx, def);
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
747 return def;
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
748 }
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
749 insertion_point = tail;
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
750 }
9973
1d5a908f201e (access_keymap): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9957
diff changeset
751 else if (CONSP (elt))
1d5a908f201e (access_keymap): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9957
diff changeset
752 {
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
753 if (EQ (idx, XCAR (elt)))
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
754 {
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
755 XCDR (elt) = def;
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
756 return def;
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
757 }
9973
1d5a908f201e (access_keymap): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9957
diff changeset
758 }
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
759 else if (EQ (elt, Qkeymap))
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
760 /* If we find a 'keymap' symbol in the spine of KEYMAP,
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
761 then we must have found the start of a second keymap
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
762 being used as the tail of KEYMAP, and a binding for IDX
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
763 should be inserted before it. */
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
764 goto keymap_end;
1441
929409595312 * keymap.c (store_in_keymap): Don't forget to QUIT in the
Jim Blandy <jimb@redhat.com>
parents: 1388
diff changeset
765
929409595312 * keymap.c (store_in_keymap): Don't forget to QUIT in the
Jim Blandy <jimb@redhat.com>
parents: 1388
diff changeset
766 QUIT;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
767 }
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
768
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
769 keymap_end:
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
770 /* We have scanned the entire keymap, and not found a binding for
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
771 IDX. Let's add one. */
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
772 XCDR (insertion_point)
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
773 = Fcons (Fcons (idx, def), XCDR (insertion_point));
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
774 }
32038
0cb9cab990cb (keymap_memberp): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31989
diff changeset
775
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
776 return def;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
777 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
778
20319
81424cf4d446 (copy_keymap_1): Fix return type.
Andreas Schwab <schwab@suse.de>
parents: 20076
diff changeset
779 void
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
780 copy_keymap_1 (chartable, idx, elt)
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
781 Lisp_Object chartable, idx, elt;
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
782 {
17861
f84a12392eab (copy_keymap_1): Do nothing if ELT isn't a keymap.
Richard M. Stallman <rms@gnu.org>
parents: 17832
diff changeset
783 if (!SYMBOLP (elt) && ! NILP (Fkeymapp (elt)))
f84a12392eab (copy_keymap_1): Do nothing if ELT isn't a keymap.
Richard M. Stallman <rms@gnu.org>
parents: 17832
diff changeset
784 Faset (chartable, idx, Fcopy_keymap (elt));
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
785 }
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
786
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
787 DEFUN ("copy-keymap", Fcopy_keymap, Scopy_keymap, 1, 1, 0,
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
788 "Return a copy of the keymap KEYMAP.\n\
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
789 The copy starts out with the same definitions of KEYMAP,\n\
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
790 but changing either the copy or KEYMAP does not affect the other.\n\
362
d1e5cf833d37 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 250
diff changeset
791 Any key definitions that are subkeymaps are recursively copied.\n\
d1e5cf833d37 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 250
diff changeset
792 However, a key definition which is a symbol whose definition is a keymap\n\
d1e5cf833d37 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 250
diff changeset
793 is not copied.")
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
794 (keymap)
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
795 Lisp_Object keymap;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
796 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
797 register Lisp_Object copy, tail;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
798
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
799 copy = Fcopy_alist (get_keymap (keymap));
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
800
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
801 for (tail = copy; CONSP (tail); tail = XCDR (tail))
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
802 {
6502
18dfda644bc0 (access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents: 6475
diff changeset
803 Lisp_Object elt;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
804
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
805 elt = XCAR (tail);
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
806 if (CHAR_TABLE_P (elt))
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
807 {
20076
374e09781f08 (Faccessible_keymaps): Avoid alloca for fixed-size array.
Karl Heuer <kwzh@gnu.org>
parents: 20070
diff changeset
808 Lisp_Object indices[3];
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
809
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
810 elt = Fcopy_sequence (elt);
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
811 XCAR (tail) = elt;
18142
c9bd973ca168 (Fcopy_keymap): After copying a sub-char-table, do store the copy.
Richard M. Stallman <rms@gnu.org>
parents: 17932
diff changeset
812
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
813 map_char_table (copy_keymap_1, Qnil, elt, elt, 0, indices);
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
814 }
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
815 else if (VECTORP (elt))
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
816 {
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
817 int i;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
818
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
819 elt = Fcopy_sequence (elt);
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
820 XCAR (tail) = elt;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
821
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
822 for (i = 0; i < ASIZE (elt); i++)
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
823 if (!SYMBOLP (AREF (elt, i))
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
824 && ! NILP (Fkeymapp (AREF (elt, i))))
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
825 ASET (elt, i, Fcopy_keymap (AREF (elt, i)));
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
826 }
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
827 else if (CONSP (elt) && CONSP (XCDR (elt)))
6456
9854df0e91e1 (Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents: 6021
diff changeset
828 {
21241
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
829 Lisp_Object tem;
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
830 tem = XCDR (elt);
21241
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
831
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
832 /* Is this a new format menu item. */
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
833 if (EQ (XCAR (tem),Qmenu_item))
6456
9854df0e91e1 (Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents: 6021
diff changeset
834 {
21241
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
835 /* Copy cell with menu-item marker. */
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
836 XCDR (elt)
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
837 = Fcons (XCAR (tem), XCDR (tem));
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
838 elt = XCDR (elt);
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
839 tem = XCDR (elt);
21241
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
840 if (CONSP (tem))
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
841 {
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
842 /* Copy cell with menu-item name. */
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
843 XCDR (elt)
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
844 = Fcons (XCAR (tem), XCDR (tem));
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
845 elt = XCDR (elt);
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
846 tem = XCDR (elt);
21241
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
847 };
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
848 if (CONSP (tem))
6456
9854df0e91e1 (Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents: 6021
diff changeset
849 {
21241
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
850 /* Copy cell with binding and if the binding is a keymap,
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
851 copy that. */
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
852 XCDR (elt)
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
853 = Fcons (XCAR (tem), XCDR (tem));
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
854 elt = XCDR (elt);
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
855 tem = XCAR (elt);
21241
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
856 if (!(SYMBOLP (tem) || NILP (Fkeymapp (tem))))
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
857 XCAR (elt) = Fcopy_keymap (tem);
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
858 tem = XCDR (elt);
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
859 if (CONSP (tem) && CONSP (XCAR (tem)))
21241
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
860 /* Delete cache for key equivalences. */
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
861 XCDR (elt) = XCDR (tem);
6456
9854df0e91e1 (Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents: 6021
diff changeset
862 }
9854df0e91e1 (Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents: 6021
diff changeset
863 }
21241
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
864 else
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
865 {
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
866 /* It may be an old fomat menu item.
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
867 Skip the optional menu string.
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
868 */
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
869 if (STRINGP (XCAR (tem)))
21241
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
870 {
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
871 /* Copy the cell, since copy-alist didn't go this deep. */
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
872 XCDR (elt)
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
873 = Fcons (XCAR (tem), XCDR (tem));
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
874 elt = XCDR (elt);
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
875 tem = XCDR (elt);
21241
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
876 /* Also skip the optional menu help string. */
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
877 if (CONSP (tem) && STRINGP (XCAR (tem)))
21241
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
878 {
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
879 XCDR (elt)
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
880 = Fcons (XCAR (tem), XCDR (tem));
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
881 elt = XCDR (elt);
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
882 tem = XCDR (elt);
21241
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
883 }
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
884 /* There may also be a list that caches key equivalences.
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
885 Just delete it for the new keymap. */
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
886 if (CONSP (tem)
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
887 && CONSP (XCAR (tem))
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
888 && (NILP (XCAR (XCAR (tem)))
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
889 || VECTORP (XCAR (XCAR (tem)))))
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
890 XCDR (elt) = XCDR (tem);
21241
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
891 }
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
892 if (CONSP (elt)
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
893 && ! SYMBOLP (XCDR (elt))
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
894 && ! NILP (Fkeymapp (XCDR (elt))))
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
895 XCDR (elt) = Fcopy_keymap (XCDR (elt));
21241
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
896 }
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
897
6456
9854df0e91e1 (Fcopy_keymap): Account for menus and equiv-key cache.
Karl Heuer <kwzh@gnu.org>
parents: 6021
diff changeset
898 }
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
899 }
21241
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
900
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
901 return copy;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
902 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
903
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
904 /* Simple Keymap mutators and accessors. */
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
905
7998
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
906 /* GC is possible in this function if it autoloads a keymap. */
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
907
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
908 DEFUN ("define-key", Fdefine_key, Sdefine_key, 3, 3, 0,
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
909 "Args KEYMAP, KEY, DEF. Define key sequence KEY, in KEYMAP, as DEF.\n\
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
910 KEYMAP is a keymap. KEY is a string or a vector of symbols and characters\n\
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
911 meaning a sequence of keystrokes and events.\n\
5100
33de23a28204 Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5055
diff changeset
912 Non-ASCII characters with codes above 127 (such as ISO Latin-1)\n\
33de23a28204 Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5055
diff changeset
913 can be included if you use a vector.\n\
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
914 DEF is anything that can be a key's definition:\n\
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
915 nil (means key is undefined in this keymap),\n\
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
916 a command (a Lisp function suitable for interactive calling)\n\
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
917 a string (treated as a keyboard macro),\n\
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
918 a keymap (to define a prefix key),\n\
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
919 a symbol. When the key is looked up, the symbol will stand for its\n\
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
920 function definition, which should at that time be one of the above,\n\
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
921 or another symbol whose function definition is used, etc.\n\
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
922 a cons (STRING . DEFN), meaning that DEFN is the definition\n\
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
923 (DEFN should be a valid definition in its own right),\n\
368
d04df545062f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 362
diff changeset
924 or a cons (KEYMAP . CHAR), meaning use definition of CHAR in map KEYMAP.\n\
d04df545062f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 362
diff changeset
925 \n\
d04df545062f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 362
diff changeset
926 If KEYMAP is a sparse keymap, the pair binding KEY to DEF is added at\n\
d04df545062f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 362
diff changeset
927 the front of KEYMAP.")
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
928 (keymap, key, def)
1517
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
929 Lisp_Object keymap;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
930 Lisp_Object key;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
931 Lisp_Object def;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
932 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
933 register int idx;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
934 register Lisp_Object c;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
935 register Lisp_Object cmd;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
936 int metized = 0;
2059
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
937 int meta_bit;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
938 int length;
1517
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
939 struct gcpro gcpro1, gcpro2, gcpro3;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
940
6774
a29237d1fdca (get_keymap): Pass 1 as ERROR to get_keymap_1.
Richard M. Stallman <rms@gnu.org>
parents: 6695
diff changeset
941 keymap = get_keymap_1 (keymap, 1, 1);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
942
9123
c225137ddefb (get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents: 8922
diff changeset
943 if (!VECTORP (key) && !STRINGP (key))
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
944 key = wrong_type_argument (Qarrayp, key);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
945
1517
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
946 length = XFASTINT (Flength (key));
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
947 if (length == 0)
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
948 return Qnil;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
949
12297
fe458a8ecfa2 (Vdefine_key_rebound_commands): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 12262
diff changeset
950 if (SYMBOLP (def) && !EQ (Vdefine_key_rebound_commands, Qt))
fe458a8ecfa2 (Vdefine_key_rebound_commands): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 12262
diff changeset
951 Vdefine_key_rebound_commands = Fcons (def, Vdefine_key_rebound_commands);
fe458a8ecfa2 (Vdefine_key_rebound_commands): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 12262
diff changeset
952
1517
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
953 GCPRO3 (keymap, key, def);
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
954
9123
c225137ddefb (get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents: 8922
diff changeset
955 if (VECTORP (key))
2059
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
956 meta_bit = meta_modifier;
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
957 else
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
958 meta_bit = 0x80;
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
959
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
960 idx = 0;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
961 while (1)
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
962 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
963 c = Faref (key, make_number (idx));
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
964
10840
3a7336f191b9 (Fdefine_key): Handle Lucid-style (crtl backspace) etc.
Richard M. Stallman <rms@gnu.org>
parents: 10810
diff changeset
965 if (CONSP (c) && lucid_event_type_list_p (c))
12151
43b030e896eb (Flookup_key, Fdefine_key): Use Fevent_convert_list.
Karl Heuer <kwzh@gnu.org>
parents: 11973
diff changeset
966 c = Fevent_convert_list (c);
10840
3a7336f191b9 (Fdefine_key): Handle Lucid-style (crtl backspace) etc.
Richard M. Stallman <rms@gnu.org>
parents: 10810
diff changeset
967
9123
c225137ddefb (get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents: 8922
diff changeset
968 if (INTEGERP (c)
2059
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
969 && (XINT (c) & meta_bit)
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
970 && !metized)
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
971 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
972 c = meta_prefix_char;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
973 metized = 1;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
974 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
975 else
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
976 {
9123
c225137ddefb (get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents: 8922
diff changeset
977 if (INTEGERP (c))
2093
ce8bad247b1a (Fdefine_key): Use proper meta-bit to clear.
Richard M. Stallman <rms@gnu.org>
parents: 2059
diff changeset
978 XSETINT (c, XINT (c) & ~meta_bit);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
979
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
980 metized = 0;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
981 idx++;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
982 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
983
6473
76bb655df959 (Fdefine_key): Check for non-events in keyvector.
Karl Heuer <kwzh@gnu.org>
parents: 6457
diff changeset
984 if (! INTEGERP (c) && ! SYMBOLP (c) && ! CONSP (c))
8517
a7fe53588b6f (Fdefine_key): Fix error message.
Richard M. Stallman <rms@gnu.org>
parents: 8473
diff changeset
985 error ("Key sequence contains invalid events");
6473
76bb655df959 (Fdefine_key): Check for non-events in keyvector.
Karl Heuer <kwzh@gnu.org>
parents: 6457
diff changeset
986
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
987 if (idx == length)
1517
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
988 RETURN_UNGCPRO (store_in_keymap (keymap, c, def));
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
989
32476
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
990 cmd = access_keymap (keymap, c, 0, 1, 1);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
991
3735
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
992 /* If this key is undefined, make it a prefix. */
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
993 if (NILP (cmd))
3735
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
994 cmd = define_as_prefix (keymap, c);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
995
1517
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
996 keymap = get_keymap_1 (cmd, 0, 1);
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
997 if (NILP (keymap))
6502
18dfda644bc0 (access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents: 6475
diff changeset
998 /* We must use Fkey_description rather than just passing key to
18dfda644bc0 (access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents: 6475
diff changeset
999 error; key might be a vector, not a string. */
18dfda644bc0 (access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents: 6475
diff changeset
1000 error ("Key sequence %s uses invalid prefix characters",
18dfda644bc0 (access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents: 6475
diff changeset
1001 XSTRING (Fkey_description (key))->data);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1002 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1003 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1004
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1005 /* Value is number if KEY is too long; NIL if valid but has no definition. */
7998
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1006 /* GC is possible in this function if it autoloads a keymap. */
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1007
1871
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1008 DEFUN ("lookup-key", Flookup_key, Slookup_key, 2, 3, 0,
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1009 "In keymap KEYMAP, look up key sequence KEY. Return the definition.\n\
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1010 nil means undefined. See doc of `define-key' for kinds of definitions.\n\
1871
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1011 \n\
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1012 A number as value means KEY is \"too long\";\n\
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1013 that is, characters or symbols in it except for the last one\n\
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1014 fail to be a valid sequence of prefix characters in KEYMAP.\n\
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1015 The number is how many characters at the front of KEY\n\
1871
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1016 it takes to reach a non-prefix command.\n\
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1017 \n\
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1018 Normally, `lookup-key' ignores bindings for t, which act as default\n\
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1019 bindings, used when nothing else in the keymap applies; this makes it\n\
13947
65488aa49b87 (Flookup_key): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 13771
diff changeset
1020 usable as a general function for probing keymaps. However, if the\n\
1871
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1021 third optional argument ACCEPT-DEFAULT is non-nil, `lookup-key' will\n\
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1022 recognize the default bindings, just as `read-key-sequence' does.")
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1023 (keymap, key, accept_default)
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1024 register Lisp_Object keymap;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1025 Lisp_Object key;
1871
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1026 Lisp_Object accept_default;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1027 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1028 register int idx;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1029 register Lisp_Object cmd;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1030 register Lisp_Object c;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1031 int length;
1871
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1032 int t_ok = ! NILP (accept_default);
7998
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1033 struct gcpro gcpro1;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1034
6774
a29237d1fdca (get_keymap): Pass 1 as ERROR to get_keymap_1.
Richard M. Stallman <rms@gnu.org>
parents: 6695
diff changeset
1035 keymap = get_keymap_1 (keymap, 1, 1);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1036
9123
c225137ddefb (get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents: 8922
diff changeset
1037 if (!VECTORP (key) && !STRINGP (key))
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1038 key = wrong_type_argument (Qarrayp, key);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1039
1517
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
1040 length = XFASTINT (Flength (key));
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1041 if (length == 0)
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1042 return keymap;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1043
7998
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1044 GCPRO1 (key);
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1045
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1046 idx = 0;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1047 while (1)
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1048 {
32476
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
1049 c = Faref (key, make_number (idx++));
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1050
10840
3a7336f191b9 (Fdefine_key): Handle Lucid-style (crtl backspace) etc.
Richard M. Stallman <rms@gnu.org>
parents: 10810
diff changeset
1051 if (CONSP (c) && lucid_event_type_list_p (c))
12151
43b030e896eb (Flookup_key, Fdefine_key): Use Fevent_convert_list.
Karl Heuer <kwzh@gnu.org>
parents: 11973
diff changeset
1052 c = Fevent_convert_list (c);
10840
3a7336f191b9 (Fdefine_key): Handle Lucid-style (crtl backspace) etc.
Richard M. Stallman <rms@gnu.org>
parents: 10810
diff changeset
1053
32476
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
1054 /* Turn the 8th bit of string chars into a meta modifier. */
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
1055 if (XINT (c) & 0x80 && STRINGP (key))
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
1056 XSETINT (c, (XINT (c) | meta_modifier) & ~0x80);
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
1057
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
1058 cmd = access_keymap (keymap, c, t_ok, 0, 1);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1059 if (idx == length)
7998
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1060 RETURN_UNGCPRO (cmd);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1061
6774
a29237d1fdca (get_keymap): Pass 1 as ERROR to get_keymap_1.
Richard M. Stallman <rms@gnu.org>
parents: 6695
diff changeset
1062 keymap = get_keymap_1 (cmd, 0, 1);
1517
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
1063 if (NILP (keymap))
7998
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1064 RETURN_UNGCPRO (make_number (idx));
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1065
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1066 QUIT;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1067 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1068 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1069
3735
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
1070 /* Make KEYMAP define event C as a keymap (i.e., as a prefix).
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
1071 Assume that currently it does not define C at all.
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
1072 Return the keymap. */
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
1073
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
1074 static Lisp_Object
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
1075 define_as_prefix (keymap, c)
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
1076 Lisp_Object keymap, c;
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
1077 {
32476
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
1078 Lisp_Object cmd;
3735
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
1079
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
1080 cmd = Fmake_sparse_keymap (Qnil);
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
1081 /* If this key is defined as a prefix in an inherited keymap,
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
1082 make it a prefix in this map, and make its definition
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
1083 inherit the other prefix definition. */
32476
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
1084 cmd = nconc2 (cmd, access_keymap (keymap, c, 0, 0, 0));
3735
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
1085 store_in_keymap (keymap, c, cmd);
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
1086
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
1087 return cmd;
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
1088 }
7193a99a87c1 Make prefix keys work with keymap inheritance
Richard M. Stallman <rms@gnu.org>
parents: 3691
diff changeset
1089
2093
ce8bad247b1a (Fdefine_key): Use proper meta-bit to clear.
Richard M. Stallman <rms@gnu.org>
parents: 2059
diff changeset
1090 /* Append a key to the end of a key sequence. We always make a vector. */
ce8bad247b1a (Fdefine_key): Use proper meta-bit to clear.
Richard M. Stallman <rms@gnu.org>
parents: 2059
diff changeset
1091
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1092 Lisp_Object
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1093 append_key (key_sequence, key)
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1094 Lisp_Object key_sequence, key;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1095 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1096 Lisp_Object args[2];
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1097
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1098 args[0] = key_sequence;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1099
2093
ce8bad247b1a (Fdefine_key): Use proper meta-bit to clear.
Richard M. Stallman <rms@gnu.org>
parents: 2059
diff changeset
1100 args[1] = Fcons (key, Qnil);
ce8bad247b1a (Fdefine_key): Use proper meta-bit to clear.
Richard M. Stallman <rms@gnu.org>
parents: 2059
diff changeset
1101 return Fvconcat (2, args);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1102 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1103
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1104
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1105 /* Global, local, and minor mode keymap stuff. */
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1106
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
1107 /* We can't put these variables inside current_minor_maps, since under
517
2f2206ac3dba *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
1108 some systems, static gets macro-defined to be the empty string.
2f2206ac3dba *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
1109 Ickypoo. */
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
1110 static Lisp_Object *cmm_modes, *cmm_maps;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
1111 static int cmm_size;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
1112
12542
f86a10208f7e (current_minor_maps): Catch errors in Findirect_function.
Karl Heuer <kwzh@gnu.org>
parents: 12297
diff changeset
1113 /* Error handler used in current_minor_maps. */
f86a10208f7e (current_minor_maps): Catch errors in Findirect_function.
Karl Heuer <kwzh@gnu.org>
parents: 12297
diff changeset
1114 static Lisp_Object
f86a10208f7e (current_minor_maps): Catch errors in Findirect_function.
Karl Heuer <kwzh@gnu.org>
parents: 12297
diff changeset
1115 current_minor_maps_error ()
f86a10208f7e (current_minor_maps): Catch errors in Findirect_function.
Karl Heuer <kwzh@gnu.org>
parents: 12297
diff changeset
1116 {
f86a10208f7e (current_minor_maps): Catch errors in Findirect_function.
Karl Heuer <kwzh@gnu.org>
parents: 12297
diff changeset
1117 return Qnil;
f86a10208f7e (current_minor_maps): Catch errors in Findirect_function.
Karl Heuer <kwzh@gnu.org>
parents: 12297
diff changeset
1118 }
f86a10208f7e (current_minor_maps): Catch errors in Findirect_function.
Karl Heuer <kwzh@gnu.org>
parents: 12297
diff changeset
1119
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1120 /* Store a pointer to an array of the keymaps of the currently active
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1121 minor modes in *buf, and return the number of maps it contains.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1122
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1123 This function always returns a pointer to the same buffer, and may
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1124 free or reallocate it, so if you want to keep it for a long time or
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1125 hand it out to lisp code, copy it. This procedure will be called
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1126 for every key sequence read, so the nice lispy approach (return a
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1127 new assoclist, list, what have you) for each invocation would
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1128 result in a lot of consing over time.
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1129
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1130 If we used xrealloc/xmalloc and ran out of memory, they would throw
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1131 back to the command loop, which would try to read a key sequence,
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1132 which would call this function again, resulting in an infinite
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1133 loop. Instead, we'll use realloc/malloc and silently truncate the
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1134 list, let the key sequence be read, and hope some other piece of
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1135 code signals the error. */
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1136 int
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1137 current_minor_maps (modeptr, mapptr)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1138 Lisp_Object **modeptr, **mapptr;
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1139 {
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1140 int i = 0;
20517
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1141 int list_number = 0;
517
2f2206ac3dba *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
1142 Lisp_Object alist, assoc, var, val;
20517
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1143 Lisp_Object lists[2];
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1144
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1145 lists[0] = Vminor_mode_overriding_map_alist;
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1146 lists[1] = Vminor_mode_map_alist;
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1147
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1148 for (list_number = 0; list_number < 2; list_number++)
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1149 for (alist = lists[list_number];
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1150 CONSP (alist);
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
1151 alist = XCDR (alist))
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
1152 if ((assoc = XCAR (alist), CONSP (assoc))
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
1153 && (var = XCAR (assoc), SYMBOLP (var))
20517
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1154 && (val = find_symbol_value (var), ! EQ (val, Qunbound))
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1155 && ! NILP (val))
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1156 {
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1157 Lisp_Object temp;
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1158
20576
b916d29222a3 (current_minor_maps):
Richard M. Stallman <rms@gnu.org>
parents: 20517
diff changeset
1159 /* If a variable has an entry in Vminor_mode_overriding_map_alist,
b916d29222a3 (current_minor_maps):
Richard M. Stallman <rms@gnu.org>
parents: 20517
diff changeset
1160 and also an entry in Vminor_mode_map_alist,
b916d29222a3 (current_minor_maps):
Richard M. Stallman <rms@gnu.org>
parents: 20517
diff changeset
1161 ignore the latter. */
b916d29222a3 (current_minor_maps):
Richard M. Stallman <rms@gnu.org>
parents: 20517
diff changeset
1162 if (list_number == 1)
b916d29222a3 (current_minor_maps):
Richard M. Stallman <rms@gnu.org>
parents: 20517
diff changeset
1163 {
b916d29222a3 (current_minor_maps):
Richard M. Stallman <rms@gnu.org>
parents: 20517
diff changeset
1164 val = assq_no_quit (var, lists[0]);
b916d29222a3 (current_minor_maps):
Richard M. Stallman <rms@gnu.org>
parents: 20517
diff changeset
1165 if (!NILP (val))
b916d29222a3 (current_minor_maps):
Richard M. Stallman <rms@gnu.org>
parents: 20517
diff changeset
1166 break;
b916d29222a3 (current_minor_maps):
Richard M. Stallman <rms@gnu.org>
parents: 20517
diff changeset
1167 }
b916d29222a3 (current_minor_maps):
Richard M. Stallman <rms@gnu.org>
parents: 20517
diff changeset
1168
20517
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1169 if (i >= cmm_size)
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1170 {
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1171 Lisp_Object *newmodes, *newmaps;
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1172
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1173 if (cmm_maps)
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1174 {
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1175 BLOCK_INPUT;
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1176 cmm_size *= 2;
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1177 newmodes
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1178 = (Lisp_Object *) realloc (cmm_modes,
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1179 cmm_size * sizeof (Lisp_Object));
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1180 newmaps
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1181 = (Lisp_Object *) realloc (cmm_maps,
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1182 cmm_size * sizeof (Lisp_Object));
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1183 UNBLOCK_INPUT;
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1184 }
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1185 else
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1186 {
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1187 BLOCK_INPUT;
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1188 cmm_size = 30;
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1189 newmodes
30609
6e37e9488e49 (current_minor_maps): Use xmalloc instead of malloc.
Gerd Moellmann <gerd@gnu.org>
parents: 30559
diff changeset
1190 = (Lisp_Object *) xmalloc (cmm_size * sizeof (Lisp_Object));
20517
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1191 newmaps
30609
6e37e9488e49 (current_minor_maps): Use xmalloc instead of malloc.
Gerd Moellmann <gerd@gnu.org>
parents: 30559
diff changeset
1192 = (Lisp_Object *) xmalloc (cmm_size * sizeof (Lisp_Object));
20517
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1193 UNBLOCK_INPUT;
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1194 }
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1195
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1196 if (newmaps && newmodes)
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1197 {
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1198 cmm_modes = newmodes;
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1199 cmm_maps = newmaps;
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1200 }
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1201 else
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1202 break;
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1203 }
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1204
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1205 /* Get the keymap definition--or nil if it is not defined. */
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1206 temp = internal_condition_case_1 (Findirect_function,
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
1207 XCDR (assoc),
20517
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1208 Qerror, current_minor_maps_error);
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1209 if (!NILP (temp))
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1210 {
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1211 cmm_modes[i] = var;
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1212 cmm_maps [i] = temp;
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1213 i++;
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1214 }
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
1215 }
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1216
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
1217 if (modeptr) *modeptr = cmm_modes;
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
1218 if (mapptr) *mapptr = cmm_maps;
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1219 return i;
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1220 }
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1221
7998
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1222 /* GC is possible in this function if it autoloads a keymap. */
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1223
1871
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1224 DEFUN ("key-binding", Fkey_binding, Skey_binding, 1, 2, 0,
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1225 "Return the binding for command KEY in current keymaps.\n\
1871
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1226 KEY is a string or vector, a sequence of keystrokes.\n\
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1227 The binding is probably a symbol with a function definition.\n\
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1228 \n\
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1229 Normally, `key-binding' ignores bindings for t, which act as default\n\
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1230 bindings, used when nothing else in the keymap applies; this makes it\n\
5055
bbe5bba17b10 (Fkey_binding): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 4696
diff changeset
1231 usable as a general function for probing keymaps. However, if the\n\
bbe5bba17b10 (Fkey_binding): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 4696
diff changeset
1232 optional second argument ACCEPT-DEFAULT is non-nil, `key-binding' does\n\
1871
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1233 recognize the default bindings, just as `read-key-sequence' does.")
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1234 (key, accept_default)
6834
6a77fcbb5d44 (Fkey_binding): Declare accept_default.
Richard M. Stallman <rms@gnu.org>
parents: 6774
diff changeset
1235 Lisp_Object key, accept_default;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1236 {
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1237 Lisp_Object *maps, value;
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1238 int nmaps, i;
7998
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1239 struct gcpro gcpro1;
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1240
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1241 GCPRO1 (key);
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1242
12262
a7d5578ebb25 (Fkey_binding, describe_buffer_bindings):
Karl Heuer <kwzh@gnu.org>
parents: 12151
diff changeset
1243 if (!NILP (current_kboard->Voverriding_terminal_local_map))
a7d5578ebb25 (Fkey_binding, describe_buffer_bindings):
Karl Heuer <kwzh@gnu.org>
parents: 12151
diff changeset
1244 {
a7d5578ebb25 (Fkey_binding, describe_buffer_bindings):
Karl Heuer <kwzh@gnu.org>
parents: 12151
diff changeset
1245 value = Flookup_key (current_kboard->Voverriding_terminal_local_map,
a7d5578ebb25 (Fkey_binding, describe_buffer_bindings):
Karl Heuer <kwzh@gnu.org>
parents: 12151
diff changeset
1246 key, accept_default);
a7d5578ebb25 (Fkey_binding, describe_buffer_bindings):
Karl Heuer <kwzh@gnu.org>
parents: 12151
diff changeset
1247 if (! NILP (value) && !INTEGERP (value))
a7d5578ebb25 (Fkey_binding, describe_buffer_bindings):
Karl Heuer <kwzh@gnu.org>
parents: 12151
diff changeset
1248 RETURN_UNGCPRO (value);
a7d5578ebb25 (Fkey_binding, describe_buffer_bindings):
Karl Heuer <kwzh@gnu.org>
parents: 12151
diff changeset
1249 }
a7d5578ebb25 (Fkey_binding, describe_buffer_bindings):
Karl Heuer <kwzh@gnu.org>
parents: 12151
diff changeset
1250 else if (!NILP (Voverriding_local_map))
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1251 {
5613
cad51b2de6cd (Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents: 5551
diff changeset
1252 value = Flookup_key (Voverriding_local_map, key, accept_default);
9123
c225137ddefb (get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents: 8922
diff changeset
1253 if (! NILP (value) && !INTEGERP (value))
7998
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1254 RETURN_UNGCPRO (value);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1255 }
5613
cad51b2de6cd (Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents: 5551
diff changeset
1256 else
cad51b2de6cd (Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents: 5551
diff changeset
1257 {
13771
28790743a5a3 (Fkey_binding): Handle text-property keymaps.
Karl Heuer <kwzh@gnu.org>
parents: 13343
diff changeset
1258 Lisp_Object local;
28790743a5a3 (Fkey_binding): Handle text-property keymaps.
Karl Heuer <kwzh@gnu.org>
parents: 13343
diff changeset
1259
5613
cad51b2de6cd (Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents: 5551
diff changeset
1260 nmaps = current_minor_maps (0, &maps);
7998
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1261 /* Note that all these maps are GCPRO'd
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1262 in the places where we found them. */
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1263
5613
cad51b2de6cd (Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents: 5551
diff changeset
1264 for (i = 0; i < nmaps; i++)
cad51b2de6cd (Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents: 5551
diff changeset
1265 if (! NILP (maps[i]))
cad51b2de6cd (Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents: 5551
diff changeset
1266 {
cad51b2de6cd (Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents: 5551
diff changeset
1267 value = Flookup_key (maps[i], key, accept_default);
9123
c225137ddefb (get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents: 8922
diff changeset
1268 if (! NILP (value) && !INTEGERP (value))
7998
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1269 RETURN_UNGCPRO (value);
5613
cad51b2de6cd (Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents: 5551
diff changeset
1270 }
cad51b2de6cd (Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents: 5551
diff changeset
1271
29282
59f2b30d577b Include intervals.h.
Dave Love <fx@gnu.org>
parents: 29013
diff changeset
1272 local = get_local_map (PT, current_buffer, keymap);
59f2b30d577b Include intervals.h.
Dave Love <fx@gnu.org>
parents: 29013
diff changeset
1273 if (! NILP (local))
59f2b30d577b Include intervals.h.
Dave Love <fx@gnu.org>
parents: 29013
diff changeset
1274 {
59f2b30d577b Include intervals.h.
Dave Love <fx@gnu.org>
parents: 29013
diff changeset
1275 value = Flookup_key (local, key, accept_default);
59f2b30d577b Include intervals.h.
Dave Love <fx@gnu.org>
parents: 29013
diff changeset
1276 if (! NILP (value) && !INTEGERP (value))
59f2b30d577b Include intervals.h.
Dave Love <fx@gnu.org>
parents: 29013
diff changeset
1277 RETURN_UNGCPRO (value);
59f2b30d577b Include intervals.h.
Dave Love <fx@gnu.org>
parents: 29013
diff changeset
1278 }
59f2b30d577b Include intervals.h.
Dave Love <fx@gnu.org>
parents: 29013
diff changeset
1279
59f2b30d577b Include intervals.h.
Dave Love <fx@gnu.org>
parents: 29013
diff changeset
1280 local = get_local_map (PT, current_buffer, local_map);
13771
28790743a5a3 (Fkey_binding): Handle text-property keymaps.
Karl Heuer <kwzh@gnu.org>
parents: 13343
diff changeset
1281
28790743a5a3 (Fkey_binding): Handle text-property keymaps.
Karl Heuer <kwzh@gnu.org>
parents: 13343
diff changeset
1282 if (! NILP (local))
5613
cad51b2de6cd (Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents: 5551
diff changeset
1283 {
13771
28790743a5a3 (Fkey_binding): Handle text-property keymaps.
Karl Heuer <kwzh@gnu.org>
parents: 13343
diff changeset
1284 value = Flookup_key (local, key, accept_default);
9123
c225137ddefb (get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents: 8922
diff changeset
1285 if (! NILP (value) && !INTEGERP (value))
7998
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1286 RETURN_UNGCPRO (value);
5613
cad51b2de6cd (Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents: 5551
diff changeset
1287 }
cad51b2de6cd (Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents: 5551
diff changeset
1288 }
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1289
1871
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1290 value = Flookup_key (current_global_map, key, accept_default);
7998
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1291 UNGCPRO;
9123
c225137ddefb (get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents: 8922
diff changeset
1292 if (! NILP (value) && !INTEGERP (value))
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1293 return value;
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1294
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1295 return Qnil;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1296 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1297
7998
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1298 /* GC is possible in this function if it autoloads a keymap. */
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1299
1871
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1300 DEFUN ("local-key-binding", Flocal_key_binding, Slocal_key_binding, 1, 2, 0,
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1301 "Return the binding for command KEYS in current local keymap only.\n\
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1302 KEYS is a string, a sequence of keystrokes.\n\
1871
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1303 The binding is probably a symbol with a function definition.\n\
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1304 \n\
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1305 If optional argument ACCEPT-DEFAULT is non-nil, recognize default\n\
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1306 bindings; see the description of `lookup-key' for more details about this.")
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1307 (keys, accept_default)
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1308 Lisp_Object keys, accept_default;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1309 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1310 register Lisp_Object map;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1311 map = current_buffer->keymap;
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
1312 if (NILP (map))
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1313 return Qnil;
1871
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1314 return Flookup_key (map, keys, accept_default);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1315 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1316
7998
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1317 /* GC is possible in this function if it autoloads a keymap. */
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1318
1871
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1319 DEFUN ("global-key-binding", Fglobal_key_binding, Sglobal_key_binding, 1, 2, 0,
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1320 "Return the binding for command KEYS in current global keymap only.\n\
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1321 KEYS is a string, a sequence of keystrokes.\n\
517
2f2206ac3dba *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
1322 The binding is probably a symbol with a function definition.\n\
2f2206ac3dba *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
1323 This function's return values are the same as those of lookup-key\n\
7998
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1324 \(which see).\n\
1871
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1325 \n\
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1326 If optional argument ACCEPT-DEFAULT is non-nil, recognize default\n\
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1327 bindings; see the description of `lookup-key' for more details about this.")
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1328 (keys, accept_default)
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1329 Lisp_Object keys, accept_default;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1330 {
1871
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1331 return Flookup_key (current_global_map, keys, accept_default);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1332 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1333
7998
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1334 /* GC is possible in this function if it autoloads a keymap. */
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1335
1871
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1336 DEFUN ("minor-mode-key-binding", Fminor_mode_key_binding, Sminor_mode_key_binding, 1, 2, 0,
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1337 "Find the visible minor mode bindings of KEY.\n\
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1338 Return an alist of pairs (MODENAME . BINDING), where MODENAME is the\n\
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1339 the symbol which names the minor mode binding KEY, and BINDING is\n\
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1340 KEY's definition in that mode. In particular, if KEY has no\n\
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1341 minor-mode bindings, return nil. If the first binding is a\n\
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1342 non-prefix, all subsequent bindings will be omitted, since they would\n\
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1343 be ignored. Similarly, the list doesn't include non-prefix bindings\n\
1871
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1344 that come after prefix bindings.\n\
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1345 \n\
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1346 If optional argument ACCEPT-DEFAULT is non-nil, recognize default\n\
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1347 bindings; see the description of `lookup-key' for more details about this.")
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1348 (key, accept_default)
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1349 Lisp_Object key, accept_default;
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1350 {
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1351 Lisp_Object *modes, *maps;
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1352 int nmaps;
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1353 Lisp_Object binding;
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1354 int i, j;
7998
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1355 struct gcpro gcpro1, gcpro2;
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1356
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1357 nmaps = current_minor_maps (&modes, &maps);
7998
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1358 /* Note that all these maps are GCPRO'd
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1359 in the places where we found them. */
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1360
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1361 binding = Qnil;
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1362 GCPRO2 (key, binding);
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1363
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1364 for (i = j = 0; i < nmaps; i++)
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
1365 if (! NILP (maps[i])
1871
00bee181f7ed * keymap.c (Flookup_key, Fkey_binding, Flocal_key_binding,
Jim Blandy <jimb@redhat.com>
parents: 1821
diff changeset
1366 && ! NILP (binding = Flookup_key (maps[i], key, accept_default))
9123
c225137ddefb (get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents: 8922
diff changeset
1367 && !INTEGERP (binding))
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1368 {
1517
72b7bbcaf7d8 * keymap.c (Fdefine_key, Flookup_key, describe_map): Don't assume
Jim Blandy <jimb@redhat.com>
parents: 1441
diff changeset
1369 if (! NILP (get_keymap (binding)))
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1370 maps[j++] = Fcons (modes[i], binding);
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1371 else if (j == 0)
7998
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1372 RETURN_UNGCPRO (Fcons (Fcons (modes[i], binding), Qnil));
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1373 }
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1374
7998
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1375 UNGCPRO;
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1376 return Flist (j, maps);
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1377 }
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1378
23968
4c423f69142b (Fdefine_prefix_command): Accept a third argument NAME
Eli Zaretskii <eliz@gnu.org>
parents: 23953
diff changeset
1379 DEFUN ("define-prefix-command", Fdefine_prefix_command, Sdefine_prefix_command, 1, 3, 0,
2652
90485f37bfc3 * keymap.c (Fdefine_prefix_command): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 2439
diff changeset
1380 "Define COMMAND as a prefix command. COMMAND should be a symbol.\n\
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1381 A new sparse keymap is stored as COMMAND's function definition and its value.\n\
362
d1e5cf833d37 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 250
diff changeset
1382 If a second optional argument MAPVAR is given, the map is stored as\n\
d1e5cf833d37 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 250
diff changeset
1383 its value instead of as COMMAND's value; but COMMAND is still defined\n\
23968
4c423f69142b (Fdefine_prefix_command): Accept a third argument NAME
Eli Zaretskii <eliz@gnu.org>
parents: 23953
diff changeset
1384 as a function.\n\
4c423f69142b (Fdefine_prefix_command): Accept a third argument NAME
Eli Zaretskii <eliz@gnu.org>
parents: 23953
diff changeset
1385 The third optional argument NAME, if given, supplies a menu name\n\
4c423f69142b (Fdefine_prefix_command): Accept a third argument NAME
Eli Zaretskii <eliz@gnu.org>
parents: 23953
diff changeset
1386 string for the map. This is required to use the keymap as a menu.")
4c423f69142b (Fdefine_prefix_command): Accept a third argument NAME
Eli Zaretskii <eliz@gnu.org>
parents: 23953
diff changeset
1387 (command, mapvar, name)
4c423f69142b (Fdefine_prefix_command): Accept a third argument NAME
Eli Zaretskii <eliz@gnu.org>
parents: 23953
diff changeset
1388 Lisp_Object command, mapvar, name;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1389 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1390 Lisp_Object map;
23968
4c423f69142b (Fdefine_prefix_command): Accept a third argument NAME
Eli Zaretskii <eliz@gnu.org>
parents: 23953
diff changeset
1391 map = Fmake_sparse_keymap (name);
14080
439185f0ef37 (Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents: 13947
diff changeset
1392 Ffset (command, map);
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
1393 if (!NILP (mapvar))
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1394 Fset (mapvar, map);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1395 else
14080
439185f0ef37 (Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents: 13947
diff changeset
1396 Fset (command, map);
439185f0ef37 (Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents: 13947
diff changeset
1397 return command;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1398 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1399
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1400 DEFUN ("use-global-map", Fuse_global_map, Suse_global_map, 1, 1, 0,
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1401 "Select KEYMAP as the global keymap.")
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1402 (keymap)
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1403 Lisp_Object keymap;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1404 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1405 keymap = get_keymap (keymap);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1406 current_global_map = keymap;
8464
edbb014c600a (Fuse_global_map, Fuse_local_map): Call record_asynch_buffer_change.
Richard M. Stallman <rms@gnu.org>
parents: 8431
diff changeset
1407
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1408 return Qnil;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1409 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1410
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1411 DEFUN ("use-local-map", Fuse_local_map, Suse_local_map, 1, 1, 0,
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1412 "Select KEYMAP as the local keymap.\n\
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1413 If KEYMAP is nil, that means no local keymap.")
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1414 (keymap)
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1415 Lisp_Object keymap;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1416 {
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
1417 if (!NILP (keymap))
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1418 keymap = get_keymap (keymap);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1419
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1420 current_buffer->keymap = keymap;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1421
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1422 return Qnil;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1423 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1424
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1425 DEFUN ("current-local-map", Fcurrent_local_map, Scurrent_local_map, 0, 0, 0,
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1426 "Return current buffer's local keymap, or nil if it has none.")
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1427 ()
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1428 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1429 return current_buffer->keymap;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1430 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1431
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1432 DEFUN ("current-global-map", Fcurrent_global_map, Scurrent_global_map, 0, 0, 0,
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1433 "Return the current global keymap.")
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1434 ()
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1435 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1436 return current_global_map;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1437 }
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1438
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1439 DEFUN ("current-minor-mode-maps", Fcurrent_minor_mode_maps, Scurrent_minor_mode_maps, 0, 0, 0,
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1440 "Return a list of keymaps for the minor modes of the current buffer.")
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1441 ()
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1442 {
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1443 Lisp_Object *maps;
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1444 int nmaps = current_minor_maps (0, &maps);
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1445
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1446 return Flist (nmaps, maps);
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1447 }
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1448
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1449 /* Help functions for describing and documenting keymaps. */
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
1450
20319
81424cf4d446 (copy_keymap_1): Fix return type.
Andreas Schwab <schwab@suse.de>
parents: 20076
diff changeset
1451 static void accessible_keymaps_char_table ();
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
1452
7998
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1453 /* This function cannot GC. */
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1454
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1455 DEFUN ("accessible-keymaps", Faccessible_keymaps, Saccessible_keymaps,
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
1456 1, 2, 0,
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1457 "Find all keymaps accessible via prefix characters from KEYMAP.\n\
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1458 Returns a list of elements of the form (KEYS . MAP), where the sequence\n\
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1459 KEYS starting from KEYMAP gets you to MAP. These elements are ordered\n\
14304
57194b6a555d (Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
1460 so that the KEYS increase in length. The first element is ([] . KEYMAP).\n\
3962
38041a5069a8 (Faccessible_keymaps): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 3952
diff changeset
1461 An optional argument PREFIX, if non-nil, should be a key sequence;\n\
38041a5069a8 (Faccessible_keymaps): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 3952
diff changeset
1462 then the value includes only maps for prefixes that start with PREFIX.")
14080
439185f0ef37 (Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents: 13947
diff changeset
1463 (keymap, prefix)
439185f0ef37 (Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents: 13947
diff changeset
1464 Lisp_Object keymap, prefix;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1465 {
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
1466 Lisp_Object maps, good_maps, tail;
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
1467 int prefixlen = 0;
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
1468
7998
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1469 /* no need for gcpro because we don't autoload any keymaps. */
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1470
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
1471 if (!NILP (prefix))
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
1472 prefixlen = XINT (Flength (prefix));
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1473
8431
b4138573c00f (Faccessible_keymaps): Use PREFIX to set loop starting
Richard M. Stallman <rms@gnu.org>
parents: 7998
diff changeset
1474 if (!NILP (prefix))
b4138573c00f (Faccessible_keymaps): Use PREFIX to set loop starting
Richard M. Stallman <rms@gnu.org>
parents: 7998
diff changeset
1475 {
b4138573c00f (Faccessible_keymaps): Use PREFIX to set loop starting
Richard M. Stallman <rms@gnu.org>
parents: 7998
diff changeset
1476 /* If a prefix was specified, start with the keymap (if any) for
b4138573c00f (Faccessible_keymaps): Use PREFIX to set loop starting
Richard M. Stallman <rms@gnu.org>
parents: 7998
diff changeset
1477 that prefix, so we don't waste time considering other prefixes. */
b4138573c00f (Faccessible_keymaps): Use PREFIX to set loop starting
Richard M. Stallman <rms@gnu.org>
parents: 7998
diff changeset
1478 Lisp_Object tem;
14080
439185f0ef37 (Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents: 13947
diff changeset
1479 tem = Flookup_key (keymap, prefix, Qt);
8473
c285c3b0ea54 (Faccessible_keymaps): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 8464
diff changeset
1480 /* Flookup_key may give us nil, or a number,
c285c3b0ea54 (Faccessible_keymaps): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 8464
diff changeset
1481 if the prefix is not defined in this particular map.
c285c3b0ea54 (Faccessible_keymaps): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 8464
diff changeset
1482 It might even give us a list that isn't a keymap. */
c285c3b0ea54 (Faccessible_keymaps): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 8464
diff changeset
1483 tem = get_keymap_1 (tem, 0, 0);
8431
b4138573c00f (Faccessible_keymaps): Use PREFIX to set loop starting
Richard M. Stallman <rms@gnu.org>
parents: 7998
diff changeset
1484 if (!NILP (tem))
17510
2da99276d613 (Faccessible_keymaps): Convert PREFIX to a vector
Richard M. Stallman <rms@gnu.org>
parents: 17327
diff changeset
1485 {
2da99276d613 (Faccessible_keymaps): Convert PREFIX to a vector
Richard M. Stallman <rms@gnu.org>
parents: 17327
diff changeset
1486 /* Convert PREFIX to a vector now, so that later on
2da99276d613 (Faccessible_keymaps): Convert PREFIX to a vector
Richard M. Stallman <rms@gnu.org>
parents: 17327
diff changeset
1487 we don't have to deal with the possibility of a string. */
2da99276d613 (Faccessible_keymaps): Convert PREFIX to a vector
Richard M. Stallman <rms@gnu.org>
parents: 17327
diff changeset
1488 if (STRINGP (prefix))
2da99276d613 (Faccessible_keymaps): Convert PREFIX to a vector
Richard M. Stallman <rms@gnu.org>
parents: 17327
diff changeset
1489 {
20624
9ac0b485cf60 (describe_vector): Unconditionally handle multibyte chars.
Richard M. Stallman <rms@gnu.org>
parents: 20576
diff changeset
1490 int i, i_byte, c;
17510
2da99276d613 (Faccessible_keymaps): Convert PREFIX to a vector
Richard M. Stallman <rms@gnu.org>
parents: 17327
diff changeset
1491 Lisp_Object copy;
2da99276d613 (Faccessible_keymaps): Convert PREFIX to a vector
Richard M. Stallman <rms@gnu.org>
parents: 17327
diff changeset
1492
2da99276d613 (Faccessible_keymaps): Convert PREFIX to a vector
Richard M. Stallman <rms@gnu.org>
parents: 17327
diff changeset
1493 copy = Fmake_vector (make_number (XSTRING (prefix)->size), Qnil);
24572
9fb4096c5f77 (Faccessible_keymaps): Really initialize i_byte.
Richard M. Stallman <rms@gnu.org>
parents: 24396
diff changeset
1494 for (i = 0, i_byte = 0; i < XSTRING (prefix)->size;)
17510
2da99276d613 (Faccessible_keymaps): Convert PREFIX to a vector
Richard M. Stallman <rms@gnu.org>
parents: 17327
diff changeset
1495 {
20624
9ac0b485cf60 (describe_vector): Unconditionally handle multibyte chars.
Richard M. Stallman <rms@gnu.org>
parents: 20576
diff changeset
1496 int i_before = i;
29013
b9565b4bcdf8 (Fsingle_key_description): Use SPLIT_CHAR instead of
Kenichi Handa <handa@m17n.org>
parents: 26864
diff changeset
1497
b9565b4bcdf8 (Fsingle_key_description): Use SPLIT_CHAR instead of
Kenichi Handa <handa@m17n.org>
parents: 26864
diff changeset
1498 FETCH_STRING_CHAR_ADVANCE (c, prefix, i, i_byte);
b9565b4bcdf8 (Fsingle_key_description): Use SPLIT_CHAR instead of
Kenichi Handa <handa@m17n.org>
parents: 26864
diff changeset
1499 if (SINGLE_BYTE_CHAR_P (c) && (c & 0200))
b9565b4bcdf8 (Fsingle_key_description): Use SPLIT_CHAR instead of
Kenichi Handa <handa@m17n.org>
parents: 26864
diff changeset
1500 c ^= 0200 | meta_modifier;
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
1501 ASET (copy, i_before, make_number (c));
17510
2da99276d613 (Faccessible_keymaps): Convert PREFIX to a vector
Richard M. Stallman <rms@gnu.org>
parents: 17327
diff changeset
1502 }
2da99276d613 (Faccessible_keymaps): Convert PREFIX to a vector
Richard M. Stallman <rms@gnu.org>
parents: 17327
diff changeset
1503 prefix = copy;
2da99276d613 (Faccessible_keymaps): Convert PREFIX to a vector
Richard M. Stallman <rms@gnu.org>
parents: 17327
diff changeset
1504 }
2da99276d613 (Faccessible_keymaps): Convert PREFIX to a vector
Richard M. Stallman <rms@gnu.org>
parents: 17327
diff changeset
1505 maps = Fcons (Fcons (prefix, tem), Qnil);
2da99276d613 (Faccessible_keymaps): Convert PREFIX to a vector
Richard M. Stallman <rms@gnu.org>
parents: 17327
diff changeset
1506 }
8431
b4138573c00f (Faccessible_keymaps): Use PREFIX to set loop starting
Richard M. Stallman <rms@gnu.org>
parents: 7998
diff changeset
1507 else
b4138573c00f (Faccessible_keymaps): Use PREFIX to set loop starting
Richard M. Stallman <rms@gnu.org>
parents: 7998
diff changeset
1508 return Qnil;
b4138573c00f (Faccessible_keymaps): Use PREFIX to set loop starting
Richard M. Stallman <rms@gnu.org>
parents: 7998
diff changeset
1509 }
b4138573c00f (Faccessible_keymaps): Use PREFIX to set loop starting
Richard M. Stallman <rms@gnu.org>
parents: 7998
diff changeset
1510 else
b4138573c00f (Faccessible_keymaps): Use PREFIX to set loop starting
Richard M. Stallman <rms@gnu.org>
parents: 7998
diff changeset
1511 maps = Fcons (Fcons (Fmake_vector (make_number (0), Qnil),
14080
439185f0ef37 (Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents: 13947
diff changeset
1512 get_keymap (keymap)),
8431
b4138573c00f (Faccessible_keymaps): Use PREFIX to set loop starting
Richard M. Stallman <rms@gnu.org>
parents: 7998
diff changeset
1513 Qnil);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1514
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1515 /* For each map in the list maps,
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1516 look at any other maps it points to,
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1517 and stick them at the end if they are not already in the list.
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1518
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1519 This is a breadth-first traversal, where tail is the queue of
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1520 nodes, and maps accumulates a list of all nodes visited. */
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1521
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
1522 for (tail = maps; CONSP (tail); tail = XCDR (tail))
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1523 {
6502
18dfda644bc0 (access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents: 6475
diff changeset
1524 register Lisp_Object thisseq, thismap;
18dfda644bc0 (access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents: 6475
diff changeset
1525 Lisp_Object last;
18dfda644bc0 (access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents: 6475
diff changeset
1526 /* Does the current sequence end in the meta-prefix-char? */
18dfda644bc0 (access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents: 6475
diff changeset
1527 int is_metized;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1528
6502
18dfda644bc0 (access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents: 6475
diff changeset
1529 thisseq = Fcar (Fcar (tail));
18dfda644bc0 (access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents: 6475
diff changeset
1530 thismap = Fcdr (Fcar (tail));
18dfda644bc0 (access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents: 6475
diff changeset
1531 last = make_number (XINT (Flength (thisseq)) - 1);
18dfda644bc0 (access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents: 6475
diff changeset
1532 is_metized = (XINT (last) >= 0
17264
fad065a280dc (Faccessible_keymaps): When metizing, convert a
Richard M. Stallman <rms@gnu.org>
parents: 17189
diff changeset
1533 /* Don't metize the last char of PREFIX. */
fad065a280dc (Faccessible_keymaps): When metizing, convert a
Richard M. Stallman <rms@gnu.org>
parents: 17189
diff changeset
1534 && XINT (last) >= prefixlen
6502
18dfda644bc0 (access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents: 6475
diff changeset
1535 && EQ (Faref (thisseq, last), meta_prefix_char));
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1536
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
1537 for (; CONSP (thismap); thismap = XCDR (thismap))
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
1538 {
6502
18dfda644bc0 (access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents: 6475
diff changeset
1539 Lisp_Object elt;
18dfda644bc0 (access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents: 6475
diff changeset
1540
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
1541 elt = XCAR (thismap);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1542
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
1543 QUIT;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1544
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
1545 if (CHAR_TABLE_P (elt))
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
1546 {
20076
374e09781f08 (Faccessible_keymaps): Avoid alloca for fixed-size array.
Karl Heuer <kwzh@gnu.org>
parents: 20070
diff changeset
1547 Lisp_Object indices[3];
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
1548
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
1549 map_char_table (accessible_keymaps_char_table, Qnil,
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
1550 elt, Fcons (maps, Fcons (tail, thisseq)),
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
1551 0, indices);
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
1552 }
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
1553 else if (VECTORP (elt))
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1554 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1555 register int i;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1556
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1557 /* Vector keymap. Scan all the elements. */
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
1558 for (i = 0; i < ASIZE (elt); i++)
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1559 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1560 register Lisp_Object tem;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1561 register Lisp_Object cmd;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1562
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
1563 cmd = get_keyelt (AREF (elt, i), 0);
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
1564 if (NILP (cmd)) continue;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1565 tem = Fkeymapp (cmd);
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
1566 if (!NILP (tem))
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1567 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1568 cmd = get_keymap (cmd);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1569 /* Ignore keymaps that are already added to maps. */
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1570 tem = Frassq (cmd, maps);
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
1571 if (NILP (tem))
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1572 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1573 /* If the last key in thisseq is meta-prefix-char,
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1574 turn it into a meta-ized keystroke. We know
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1575 that the event we're about to append is an
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
1576 ascii keystroke since we're processing a
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
1577 keymap table. */
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1578 if (is_metized)
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1579 {
2093
ce8bad247b1a (Fdefine_key): Use proper meta-bit to clear.
Richard M. Stallman <rms@gnu.org>
parents: 2059
diff changeset
1580 int meta_bit = meta_modifier;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1581 tem = Fcopy_sequence (thisseq);
2093
ce8bad247b1a (Fdefine_key): Use proper meta-bit to clear.
Richard M. Stallman <rms@gnu.org>
parents: 2059
diff changeset
1582
ce8bad247b1a (Fdefine_key): Use proper meta-bit to clear.
Richard M. Stallman <rms@gnu.org>
parents: 2059
diff changeset
1583 Faset (tem, last, make_number (i | meta_bit));
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1584
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1585 /* This new sequence is the same length as
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1586 thisseq, so stick it in the list right
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1587 after this one. */
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
1588 XCDR (tail)
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
1589 = Fcons (Fcons (tem, cmd), XCDR (tail));
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1590 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1591 else
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1592 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1593 tem = append_key (thisseq, make_number (i));
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1594 nconc2 (tail, Fcons (Fcons (tem, cmd), Qnil));
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1595 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1596 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1597 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1598 }
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
1599 }
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
1600 else if (CONSP (elt))
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1601 {
25785
0d701c4484e3 (Flookup_key, Faccessible_keymaps, describe_vector,
Gerd Moellmann <gerd@gnu.org>
parents: 25662
diff changeset
1602 register Lisp_Object cmd, tem;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1603
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
1604 cmd = get_keyelt (XCDR (elt), 0);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1605 /* Ignore definitions that aren't keymaps themselves. */
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1606 tem = Fkeymapp (cmd);
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
1607 if (!NILP (tem))
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1608 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1609 /* Ignore keymaps that have been seen already. */
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1610 cmd = get_keymap (cmd);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1611 tem = Frassq (cmd, maps);
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
1612 if (NILP (tem))
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1613 {
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
1614 /* Let elt be the event defined by this map entry. */
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
1615 elt = XCAR (elt);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1616
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1617 /* If the last key in thisseq is meta-prefix-char, and
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1618 this entry is a binding for an ascii keystroke,
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1619 turn it into a meta-ized keystroke. */
9123
c225137ddefb (get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents: 8922
diff changeset
1620 if (is_metized && INTEGERP (elt))
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1621 {
17264
fad065a280dc (Faccessible_keymaps): When metizing, convert a
Richard M. Stallman <rms@gnu.org>
parents: 17189
diff changeset
1622 Lisp_Object element;
fad065a280dc (Faccessible_keymaps): When metizing, convert a
Richard M. Stallman <rms@gnu.org>
parents: 17189
diff changeset
1623
fad065a280dc (Faccessible_keymaps): When metizing, convert a
Richard M. Stallman <rms@gnu.org>
parents: 17189
diff changeset
1624 element = thisseq;
fad065a280dc (Faccessible_keymaps): When metizing, convert a
Richard M. Stallman <rms@gnu.org>
parents: 17189
diff changeset
1625 tem = Fvconcat (1, &element);
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
1626 XSETFASTINT (AREF (tem, XINT (last)),
18613
614b916ff5bf Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents: 18142
diff changeset
1627 XINT (elt) | meta_modifier);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1628
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1629 /* This new sequence is the same length as
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1630 thisseq, so stick it in the list right
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1631 after this one. */
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
1632 XCDR (tail)
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
1633 = Fcons (Fcons (tem, cmd), XCDR (tail));
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1634 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1635 else
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1636 nconc2 (tail,
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1637 Fcons (Fcons (append_key (thisseq, elt), cmd),
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1638 Qnil));
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1639 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1640 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1641 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1642 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1643 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1644
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
1645 if (NILP (prefix))
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
1646 return maps;
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
1647
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
1648 /* Now find just the maps whose access prefixes start with PREFIX. */
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
1649
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
1650 good_maps = Qnil;
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
1651 for (; CONSP (maps); maps = XCDR (maps))
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
1652 {
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
1653 Lisp_Object elt, thisseq;
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
1654 elt = XCAR (maps);
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
1655 thisseq = XCAR (elt);
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
1656 /* The access prefix must be at least as long as PREFIX,
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
1657 and the first elements must match those of PREFIX. */
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
1658 if (XINT (Flength (thisseq)) >= prefixlen)
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
1659 {
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
1660 int i;
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
1661 for (i = 0; i < prefixlen; i++)
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
1662 {
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
1663 Lisp_Object i1;
9312
dfaf1d41e53d (synkey, access_keymap, store_in_keymap, Faccessible_keymaps,
Karl Heuer <kwzh@gnu.org>
parents: 9273
diff changeset
1664 XSETFASTINT (i1, i);
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
1665 if (!EQ (Faref (thisseq, i1), Faref (prefix, i1)))
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
1666 break;
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
1667 }
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
1668 if (i == prefixlen)
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
1669 good_maps = Fcons (elt, good_maps);
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
1670 }
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
1671 }
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
1672
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
1673 return Fnreverse (good_maps);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1674 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1675
20319
81424cf4d446 (copy_keymap_1): Fix return type.
Andreas Schwab <schwab@suse.de>
parents: 20076
diff changeset
1676 static void
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
1677 accessible_keymaps_char_table (args, index, cmd)
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
1678 Lisp_Object args, index, cmd;
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
1679 {
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
1680 Lisp_Object tem;
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
1681 Lisp_Object maps, tail, thisseq;
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
1682
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
1683 if (NILP (cmd))
20319
81424cf4d446 (copy_keymap_1): Fix return type.
Andreas Schwab <schwab@suse.de>
parents: 20076
diff changeset
1684 return;
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
1685
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
1686 maps = XCAR (args);
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
1687 tail = XCAR (XCDR (args));
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
1688 thisseq = XCDR (XCDR (args));
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
1689
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
1690 tem = Fkeymapp (cmd);
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
1691 if (!NILP (tem))
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
1692 {
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
1693 cmd = get_keymap (cmd);
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
1694 /* Ignore keymaps that are already added to maps. */
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
1695 tem = Frassq (cmd, maps);
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
1696 if (NILP (tem))
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
1697 {
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
1698 tem = append_key (thisseq, index);
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
1699 nconc2 (tail, Fcons (Fcons (tem, cmd), Qnil));
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
1700 }
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
1701 }
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
1702 }
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
1703
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1704 Lisp_Object Qsingle_key_description, Qkey_description;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1705
7998
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1706 /* This function cannot GC. */
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1707
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1708 DEFUN ("key-description", Fkey_description, Skey_description, 1, 1, 0,
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1709 "Return a pretty description of key-sequence KEYS.\n\
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1710 Control characters turn into \"C-foo\" sequences, meta into \"M-foo\"\n\
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1711 spaces are put between sequence elements, etc.")
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1712 (keys)
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1713 Lisp_Object keys;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1714 {
31829
43566b0aec59 Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents: 31496
diff changeset
1715 int len = 0;
20624
9ac0b485cf60 (describe_vector): Unconditionally handle multibyte chars.
Richard M. Stallman <rms@gnu.org>
parents: 20576
diff changeset
1716 int i, i_byte;
7809
cf23573fa6fb (Fkey_description): Avoid using Fmapconcat--do it directly.
Richard M. Stallman <rms@gnu.org>
parents: 7669
diff changeset
1717 Lisp_Object sep;
31829
43566b0aec59 Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents: 31496
diff changeset
1718 Lisp_Object *args = NULL;
7809
cf23573fa6fb (Fkey_description): Avoid using Fmapconcat--do it directly.
Richard M. Stallman <rms@gnu.org>
parents: 7669
diff changeset
1719
8866
48a0ea73a9d7 (Fkey_description): Give error if KEYS not an array.
Richard M. Stallman <rms@gnu.org>
parents: 8731
diff changeset
1720 if (STRINGP (keys))
2059
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1721 {
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1722 Lisp_Object vector;
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1723 vector = Fmake_vector (Flength (keys), Qnil);
24572
9fb4096c5f77 (Faccessible_keymaps): Really initialize i_byte.
Richard M. Stallman <rms@gnu.org>
parents: 24396
diff changeset
1724 for (i = 0, i_byte = 0; i < XSTRING (keys)->size; )
2059
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1725 {
20624
9ac0b485cf60 (describe_vector): Unconditionally handle multibyte chars.
Richard M. Stallman <rms@gnu.org>
parents: 20576
diff changeset
1726 int c;
20641
a48d24f8726c (push_key_description): If C >= 128, always use octal representation.
Kenichi Handa <handa@m17n.org>
parents: 20624
diff changeset
1727 int i_before = i;
20624
9ac0b485cf60 (describe_vector): Unconditionally handle multibyte chars.
Richard M. Stallman <rms@gnu.org>
parents: 20576
diff changeset
1728
29013
b9565b4bcdf8 (Fsingle_key_description): Use SPLIT_CHAR instead of
Kenichi Handa <handa@m17n.org>
parents: 26864
diff changeset
1729 FETCH_STRING_CHAR_ADVANCE (c, keys, i, i_byte);
b9565b4bcdf8 (Fsingle_key_description): Use SPLIT_CHAR instead of
Kenichi Handa <handa@m17n.org>
parents: 26864
diff changeset
1730 if (SINGLE_BYTE_CHAR_P (c) && (c & 0200))
b9565b4bcdf8 (Fsingle_key_description): Use SPLIT_CHAR instead of
Kenichi Handa <handa@m17n.org>
parents: 26864
diff changeset
1731 c ^= 0200 | meta_modifier;
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
1732 XSETFASTINT (AREF (vector, i_before), c);
2059
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1733 }
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1734 keys = vector;
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1735 }
23953
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1736
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1737 if (VECTORP (keys))
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1738 {
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1739 /* In effect, this computes
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1740 (mapconcat 'single-key-description keys " ")
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1741 but we shouldn't use mapconcat because it can do GC. */
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1742
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1743 len = XVECTOR (keys)->size;
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1744 sep = build_string (" ");
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1745 /* This has one extra element at the end that we don't pass to Fconcat. */
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1746 args = (Lisp_Object *) alloca (len * 2 * sizeof (Lisp_Object));
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1747
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1748 for (i = 0; i < len; i++)
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1749 {
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
1750 args[i * 2] = Fsingle_key_description (AREF (keys, i), Qnil);
23953
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1751 args[i * 2 + 1] = sep;
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1752 }
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1753 }
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1754 else if (CONSP (keys))
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1755 {
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1756 /* In effect, this computes
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1757 (mapconcat 'single-key-description keys " ")
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1758 but we shouldn't use mapconcat because it can do GC. */
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1759
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1760 len = XFASTINT (Flength (keys));
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1761 sep = build_string (" ");
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1762 /* This has one extra element at the end that we don't pass to Fconcat. */
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1763 args = (Lisp_Object *) alloca (len * 2 * sizeof (Lisp_Object));
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1764
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1765 for (i = 0; i < len; i++)
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1766 {
30559
16a291eedbd8 (Fsingle_key_description): Add parameter NO_ANGLES.
Gerd Moellmann <gerd@gnu.org>
parents: 30134
diff changeset
1767 args[i * 2] = Fsingle_key_description (XCAR (keys), Qnil);
23953
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1768 args[i * 2 + 1] = sep;
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
1769 keys = XCDR (keys);
23953
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1770 }
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1771 }
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1772 else
8866
48a0ea73a9d7 (Fkey_description): Give error if KEYS not an array.
Richard M. Stallman <rms@gnu.org>
parents: 8731
diff changeset
1773 keys = wrong_type_argument (Qarrayp, keys);
7809
cf23573fa6fb (Fkey_description): Avoid using Fmapconcat--do it directly.
Richard M. Stallman <rms@gnu.org>
parents: 7669
diff changeset
1774
cf23573fa6fb (Fkey_description): Avoid using Fmapconcat--do it directly.
Richard M. Stallman <rms@gnu.org>
parents: 7669
diff changeset
1775 return Fconcat (len * 2 - 1, args);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1776 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1777
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1778 char *
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1779 push_key_description (c, p)
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1780 register unsigned int c;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1781 register char *p;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1782 {
30780
b4fcea50ee82 (push_key_description): If C without modifiers is < 32,
Gerd Moellmann <gerd@gnu.org>
parents: 30609
diff changeset
1783 unsigned c2;
b4fcea50ee82 (push_key_description): If C without modifiers is < 32,
Gerd Moellmann <gerd@gnu.org>
parents: 30609
diff changeset
1784
2343
ddb30eaf2f56 (push_key_description): Ignore bits above meta_modifier.
Richard M. Stallman <rms@gnu.org>
parents: 2093
diff changeset
1785 /* Clear all the meaningless bits above the meta bit. */
ddb30eaf2f56 (push_key_description): Ignore bits above meta_modifier.
Richard M. Stallman <rms@gnu.org>
parents: 2093
diff changeset
1786 c &= meta_modifier | ~ - meta_modifier;
30780
b4fcea50ee82 (push_key_description): If C without modifiers is < 32,
Gerd Moellmann <gerd@gnu.org>
parents: 30609
diff changeset
1787 c2 = c & ~(alt_modifier | ctrl_modifier | hyper_modifier
b4fcea50ee82 (push_key_description): If C without modifiers is < 32,
Gerd Moellmann <gerd@gnu.org>
parents: 30609
diff changeset
1788 | meta_modifier | shift_modifier | super_modifier);
2343
ddb30eaf2f56 (push_key_description): Ignore bits above meta_modifier.
Richard M. Stallman <rms@gnu.org>
parents: 2093
diff changeset
1789
2059
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1790 if (c & alt_modifier)
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1791 {
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1792 *p++ = 'A';
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1793 *p++ = '-';
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1794 c -= alt_modifier;
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1795 }
30780
b4fcea50ee82 (push_key_description): If C without modifiers is < 32,
Gerd Moellmann <gerd@gnu.org>
parents: 30609
diff changeset
1796 if ((c & ctrl_modifier) != 0
b4fcea50ee82 (push_key_description): If C without modifiers is < 32,
Gerd Moellmann <gerd@gnu.org>
parents: 30609
diff changeset
1797 || (c2 < ' ' && c2 != 27 && c2 != '\t' && c2 != Ctl ('M')))
2059
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1798 {
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1799 *p++ = 'C';
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1800 *p++ = '-';
30780
b4fcea50ee82 (push_key_description): If C without modifiers is < 32,
Gerd Moellmann <gerd@gnu.org>
parents: 30609
diff changeset
1801 c &= ~ctrl_modifier;
2059
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1802 }
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1803 if (c & hyper_modifier)
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1804 {
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1805 *p++ = 'H';
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1806 *p++ = '-';
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1807 c -= hyper_modifier;
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1808 }
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1809 if (c & meta_modifier)
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1810 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1811 *p++ = 'M';
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1812 *p++ = '-';
2059
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1813 c -= meta_modifier;
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1814 }
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1815 if (c & shift_modifier)
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1816 {
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1817 *p++ = 'S';
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1818 *p++ = '-';
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1819 c -= shift_modifier;
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1820 }
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1821 if (c & super_modifier)
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1822 {
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1823 *p++ = 's';
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1824 *p++ = '-';
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1825 c -= super_modifier;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1826 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1827 if (c < 040)
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1828 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1829 if (c == 033)
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1830 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1831 *p++ = 'E';
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1832 *p++ = 'S';
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1833 *p++ = 'C';
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1834 }
2059
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1835 else if (c == '\t')
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1836 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1837 *p++ = 'T';
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1838 *p++ = 'A';
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1839 *p++ = 'B';
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1840 }
16875
d9956cf6699b (push_key_description): Print C-j, not TAB.
Richard M. Stallman <rms@gnu.org>
parents: 16465
diff changeset
1841 else if (c == Ctl ('M'))
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1842 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1843 *p++ = 'R';
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1844 *p++ = 'E';
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1845 *p++ = 'T';
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1846 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1847 else
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1848 {
30780
b4fcea50ee82 (push_key_description): If C without modifiers is < 32,
Gerd Moellmann <gerd@gnu.org>
parents: 30609
diff changeset
1849 /* `C-' already added above. */
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1850 if (c > 0 && c <= Ctl ('Z'))
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1851 *p++ = c + 0140;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1852 else
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1853 *p++ = c + 0100;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1854 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1855 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1856 else if (c == 0177)
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1857 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1858 *p++ = 'D';
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1859 *p++ = 'E';
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1860 *p++ = 'L';
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1861 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1862 else if (c == ' ')
24394
8159c8cb33cc (push_key_description): If enable-multibyte-characters
Kenichi Handa <handa@m17n.org>
parents: 23968
diff changeset
1863 {
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1864 *p++ = 'S';
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1865 *p++ = 'P';
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1866 *p++ = 'C';
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1867 }
24396
340189fd508f (push_key_description): If enable-multibyte-characters
Kenichi Handa <handa@m17n.org>
parents: 24394
diff changeset
1868 else if (c < 128
340189fd508f (push_key_description): If enable-multibyte-characters
Kenichi Handa <handa@m17n.org>
parents: 24394
diff changeset
1869 || (NILP (current_buffer->enable_multibyte_characters)
340189fd508f (push_key_description): If enable-multibyte-characters
Kenichi Handa <handa@m17n.org>
parents: 24394
diff changeset
1870 && SINGLE_BYTE_CHAR_P (c)))
17189
7c008ec99e97 (describe_vector): Adjusted for the change of CHAR_TABLE_ORDINARY_SLOTS.
Kenichi Handa <handa@m17n.org>
parents: 17111
diff changeset
1871 *p++ = c;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1872 else
2059
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1873 {
24394
8159c8cb33cc (push_key_description): If enable-multibyte-characters
Kenichi Handa <handa@m17n.org>
parents: 23968
diff changeset
1874 if (! NILP (current_buffer->enable_multibyte_characters))
8159c8cb33cc (push_key_description): If enable-multibyte-characters
Kenichi Handa <handa@m17n.org>
parents: 23968
diff changeset
1875 c = unibyte_char_to_multibyte (c);
8159c8cb33cc (push_key_description): If enable-multibyte-characters
Kenichi Handa <handa@m17n.org>
parents: 23968
diff changeset
1876
8159c8cb33cc (push_key_description): If enable-multibyte-characters
Kenichi Handa <handa@m17n.org>
parents: 23968
diff changeset
1877 if (NILP (current_buffer->enable_multibyte_characters)
8159c8cb33cc (push_key_description): If enable-multibyte-characters
Kenichi Handa <handa@m17n.org>
parents: 23968
diff changeset
1878 || SINGLE_BYTE_CHAR_P (c)
8159c8cb33cc (push_key_description): If enable-multibyte-characters
Kenichi Handa <handa@m17n.org>
parents: 23968
diff changeset
1879 || ! char_valid_p (c, 0))
8159c8cb33cc (push_key_description): If enable-multibyte-characters
Kenichi Handa <handa@m17n.org>
parents: 23968
diff changeset
1880 {
8159c8cb33cc (push_key_description): If enable-multibyte-characters
Kenichi Handa <handa@m17n.org>
parents: 23968
diff changeset
1881 int bit_offset;
8159c8cb33cc (push_key_description): If enable-multibyte-characters
Kenichi Handa <handa@m17n.org>
parents: 23968
diff changeset
1882 *p++ = '\\';
8159c8cb33cc (push_key_description): If enable-multibyte-characters
Kenichi Handa <handa@m17n.org>
parents: 23968
diff changeset
1883 /* The biggest character code uses 19 bits. */
8159c8cb33cc (push_key_description): If enable-multibyte-characters
Kenichi Handa <handa@m17n.org>
parents: 23968
diff changeset
1884 for (bit_offset = 18; bit_offset >= 0; bit_offset -= 3)
8159c8cb33cc (push_key_description): If enable-multibyte-characters
Kenichi Handa <handa@m17n.org>
parents: 23968
diff changeset
1885 {
8159c8cb33cc (push_key_description): If enable-multibyte-characters
Kenichi Handa <handa@m17n.org>
parents: 23968
diff changeset
1886 if (c >= (1 << bit_offset))
8159c8cb33cc (push_key_description): If enable-multibyte-characters
Kenichi Handa <handa@m17n.org>
parents: 23968
diff changeset
1887 *p++ = ((c & (7 << bit_offset)) >> bit_offset) + '0';
8159c8cb33cc (push_key_description): If enable-multibyte-characters
Kenichi Handa <handa@m17n.org>
parents: 23968
diff changeset
1888 }
8159c8cb33cc (push_key_description): If enable-multibyte-characters
Kenichi Handa <handa@m17n.org>
parents: 23968
diff changeset
1889 }
8159c8cb33cc (push_key_description): If enable-multibyte-characters
Kenichi Handa <handa@m17n.org>
parents: 23968
diff changeset
1890 else
8159c8cb33cc (push_key_description): If enable-multibyte-characters
Kenichi Handa <handa@m17n.org>
parents: 23968
diff changeset
1891 {
26864
b89eb8bbaff1 (push_key_description): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 26481
diff changeset
1892 p += CHAR_STRING (c, p);
24394
8159c8cb33cc (push_key_description): If enable-multibyte-characters
Kenichi Handa <handa@m17n.org>
parents: 23968
diff changeset
1893 }
2059
3eaba0d9797c Include termhooks.h.
Richard M. Stallman <rms@gnu.org>
parents: 1922
diff changeset
1894 }
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1895
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1896 return p;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1897 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1898
7998
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1899 /* This function cannot GC. */
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1900
30559
16a291eedbd8 (Fsingle_key_description): Add parameter NO_ANGLES.
Gerd Moellmann <gerd@gnu.org>
parents: 30134
diff changeset
1901 DEFUN ("single-key-description", Fsingle_key_description,
16a291eedbd8 (Fsingle_key_description): Add parameter NO_ANGLES.
Gerd Moellmann <gerd@gnu.org>
parents: 30134
diff changeset
1902 Ssingle_key_description, 1, 2, 0,
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1903 "Return a pretty description of command character KEY.\n\
30559
16a291eedbd8 (Fsingle_key_description): Add parameter NO_ANGLES.
Gerd Moellmann <gerd@gnu.org>
parents: 30134
diff changeset
1904 Control characters turn into C-whatever, etc.\n\
16a291eedbd8 (Fsingle_key_description): Add parameter NO_ANGLES.
Gerd Moellmann <gerd@gnu.org>
parents: 30134
diff changeset
1905 Optional argument NO-ANGLES non-nil means don't put angle brackets\n\
16a291eedbd8 (Fsingle_key_description): Add parameter NO_ANGLES.
Gerd Moellmann <gerd@gnu.org>
parents: 30134
diff changeset
1906 around function keys and event symbols.")
16a291eedbd8 (Fsingle_key_description): Add parameter NO_ANGLES.
Gerd Moellmann <gerd@gnu.org>
parents: 30134
diff changeset
1907 (key, no_angles)
16a291eedbd8 (Fsingle_key_description): Add parameter NO_ANGLES.
Gerd Moellmann <gerd@gnu.org>
parents: 30134
diff changeset
1908 Lisp_Object key, no_angles;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1909 {
23953
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1910 if (CONSP (key) && lucid_event_type_list_p (key))
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1911 key = Fevent_convert_list (key);
c8cdb4e487cb (Fsingle_key_description): Handle (control ?x) etc.
Richard M. Stallman <rms@gnu.org>
parents: 23776
diff changeset
1912
1315
884c3d7e7172 * keymap.c (access_keymap, store_in_keymap,
Jim Blandy <jimb@redhat.com>
parents: 1264
diff changeset
1913 key = EVENT_HEAD (key);
517
2f2206ac3dba *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
1914
10008
b83150a8020d (Fsingle_key_description): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9973
diff changeset
1915 if (INTEGERP (key)) /* Normal character */
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1916 {
23734
44546fc7faad (Fsingle_key_description): Handle generic characters.
Richard M. Stallman <rms@gnu.org>
parents: 22841
diff changeset
1917 unsigned int charset, c1, c2;
23776
529965d3c653 (Fsingle_key_description): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 23758
diff changeset
1918 int without_bits = XINT (key) & ~((-1) << CHARACTERBITS);
529965d3c653 (Fsingle_key_description): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 23758
diff changeset
1919
529965d3c653 (Fsingle_key_description): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 23758
diff changeset
1920 if (SINGLE_BYTE_CHAR_P (without_bits))
23734
44546fc7faad (Fsingle_key_description): Handle generic characters.
Richard M. Stallman <rms@gnu.org>
parents: 22841
diff changeset
1921 charset = 0;
44546fc7faad (Fsingle_key_description): Handle generic characters.
Richard M. Stallman <rms@gnu.org>
parents: 22841
diff changeset
1922 else
29013
b9565b4bcdf8 (Fsingle_key_description): Use SPLIT_CHAR instead of
Kenichi Handa <handa@m17n.org>
parents: 26864
diff changeset
1923 SPLIT_CHAR (without_bits, charset, c1, c2);
23734
44546fc7faad (Fsingle_key_description): Handle generic characters.
Richard M. Stallman <rms@gnu.org>
parents: 22841
diff changeset
1924
44546fc7faad (Fsingle_key_description): Handle generic characters.
Richard M. Stallman <rms@gnu.org>
parents: 22841
diff changeset
1925 if (charset
24394
8159c8cb33cc (push_key_description): If enable-multibyte-characters
Kenichi Handa <handa@m17n.org>
parents: 23968
diff changeset
1926 && CHARSET_DEFINED_P (charset)
23734
44546fc7faad (Fsingle_key_description): Handle generic characters.
Richard M. Stallman <rms@gnu.org>
parents: 22841
diff changeset
1927 && ((c1 >= 0 && c1 < 32)
44546fc7faad (Fsingle_key_description): Handle generic characters.
Richard M. Stallman <rms@gnu.org>
parents: 22841
diff changeset
1928 || (c2 >= 0 && c2 < 32)))
44546fc7faad (Fsingle_key_description): Handle generic characters.
Richard M. Stallman <rms@gnu.org>
parents: 22841
diff changeset
1929 {
44546fc7faad (Fsingle_key_description): Handle generic characters.
Richard M. Stallman <rms@gnu.org>
parents: 22841
diff changeset
1930 /* Handle a generic character. */
44546fc7faad (Fsingle_key_description): Handle generic characters.
Richard M. Stallman <rms@gnu.org>
parents: 22841
diff changeset
1931 Lisp_Object name;
44546fc7faad (Fsingle_key_description): Handle generic characters.
Richard M. Stallman <rms@gnu.org>
parents: 22841
diff changeset
1932 name = CHARSET_TABLE_INFO (charset, CHARSET_LONG_NAME_IDX);
44546fc7faad (Fsingle_key_description): Handle generic characters.
Richard M. Stallman <rms@gnu.org>
parents: 22841
diff changeset
1933 CHECK_STRING (name, 0);
44546fc7faad (Fsingle_key_description): Handle generic characters.
Richard M. Stallman <rms@gnu.org>
parents: 22841
diff changeset
1934 return concat2 (build_string ("Character set "), name);
44546fc7faad (Fsingle_key_description): Handle generic characters.
Richard M. Stallman <rms@gnu.org>
parents: 22841
diff changeset
1935 }
44546fc7faad (Fsingle_key_description): Handle generic characters.
Richard M. Stallman <rms@gnu.org>
parents: 22841
diff changeset
1936 else
44546fc7faad (Fsingle_key_description): Handle generic characters.
Richard M. Stallman <rms@gnu.org>
parents: 22841
diff changeset
1937 {
26481
70d85ae6dfee (Fsingle_key_description): Use KEY_DESCRIPTION_SIZE to
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
1938 char tem[KEY_DESCRIPTION_SIZE];
23734
44546fc7faad (Fsingle_key_description): Handle generic characters.
Richard M. Stallman <rms@gnu.org>
parents: 22841
diff changeset
1939
44546fc7faad (Fsingle_key_description): Handle generic characters.
Richard M. Stallman <rms@gnu.org>
parents: 22841
diff changeset
1940 *push_key_description (XUINT (key), tem) = 0;
44546fc7faad (Fsingle_key_description): Handle generic characters.
Richard M. Stallman <rms@gnu.org>
parents: 22841
diff changeset
1941 return build_string (tem);
44546fc7faad (Fsingle_key_description): Handle generic characters.
Richard M. Stallman <rms@gnu.org>
parents: 22841
diff changeset
1942 }
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1943 }
10008
b83150a8020d (Fsingle_key_description): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9973
diff changeset
1944 else if (SYMBOLP (key)) /* Function key or event-symbol */
29651
31099bb76b6e (Fsingle_key_description): Enclose function key and
Gerd Moellmann <gerd@gnu.org>
parents: 29282
diff changeset
1945 {
30559
16a291eedbd8 (Fsingle_key_description): Add parameter NO_ANGLES.
Gerd Moellmann <gerd@gnu.org>
parents: 30134
diff changeset
1946 if (NILP (no_angles))
16a291eedbd8 (Fsingle_key_description): Add parameter NO_ANGLES.
Gerd Moellmann <gerd@gnu.org>
parents: 30134
diff changeset
1947 {
16a291eedbd8 (Fsingle_key_description): Add parameter NO_ANGLES.
Gerd Moellmann <gerd@gnu.org>
parents: 30134
diff changeset
1948 char *buffer
16a291eedbd8 (Fsingle_key_description): Add parameter NO_ANGLES.
Gerd Moellmann <gerd@gnu.org>
parents: 30134
diff changeset
1949 = (char *) alloca (STRING_BYTES (XSYMBOL (key)->name) + 5);
16a291eedbd8 (Fsingle_key_description): Add parameter NO_ANGLES.
Gerd Moellmann <gerd@gnu.org>
parents: 30134
diff changeset
1950 sprintf (buffer, "<%s>", XSYMBOL (key)->name->data);
16a291eedbd8 (Fsingle_key_description): Add parameter NO_ANGLES.
Gerd Moellmann <gerd@gnu.org>
parents: 30134
diff changeset
1951 return build_string (buffer);
16a291eedbd8 (Fsingle_key_description): Add parameter NO_ANGLES.
Gerd Moellmann <gerd@gnu.org>
parents: 30134
diff changeset
1952 }
16a291eedbd8 (Fsingle_key_description): Add parameter NO_ANGLES.
Gerd Moellmann <gerd@gnu.org>
parents: 30134
diff changeset
1953 else
16a291eedbd8 (Fsingle_key_description): Add parameter NO_ANGLES.
Gerd Moellmann <gerd@gnu.org>
parents: 30134
diff changeset
1954 return Fsymbol_name (key);
29651
31099bb76b6e (Fsingle_key_description): Enclose function key and
Gerd Moellmann <gerd@gnu.org>
parents: 29282
diff changeset
1955 }
10008
b83150a8020d (Fsingle_key_description): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9973
diff changeset
1956 else if (STRINGP (key)) /* Buffer names in the menubar. */
b83150a8020d (Fsingle_key_description): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9973
diff changeset
1957 return Fcopy_sequence (key);
b83150a8020d (Fsingle_key_description): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9973
diff changeset
1958 else
b83150a8020d (Fsingle_key_description): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents: 9973
diff changeset
1959 error ("KEY must be an integer, cons, symbol, or string");
31829
43566b0aec59 Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents: 31496
diff changeset
1960 return Qnil;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1961 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1962
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1963 char *
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1964 push_text_char_description (c, p)
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1965 register unsigned int c;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1966 register char *p;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1967 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1968 if (c >= 0200)
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1969 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1970 *p++ = 'M';
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1971 *p++ = '-';
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1972 c -= 0200;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1973 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1974 if (c < 040)
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1975 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1976 *p++ = '^';
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1977 *p++ = c + 64; /* 'A' - 1 */
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1978 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1979 else if (c == 0177)
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1980 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1981 *p++ = '^';
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1982 *p++ = '?';
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1983 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1984 else
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1985 *p++ = c;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1986 return p;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1987 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1988
7998
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1989 /* This function cannot GC. */
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
1990
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1991 DEFUN ("text-char-description", Ftext_char_description, Stext_char_description, 1, 1, 0,
14080
439185f0ef37 (Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents: 13947
diff changeset
1992 "Return a pretty description of file-character CHARACTER.\n\
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1993 Control characters turn into \"^char\", etc.")
14080
439185f0ef37 (Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents: 13947
diff changeset
1994 (character)
439185f0ef37 (Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents: 13947
diff changeset
1995 Lisp_Object character;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1996 {
26864
b89eb8bbaff1 (push_key_description): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 26481
diff changeset
1997 /* Currently MAX_MULTIBYTE_LENGTH is 4 (< 6). */
b89eb8bbaff1 (push_key_description): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 26481
diff changeset
1998 unsigned char str[6];
b89eb8bbaff1 (push_key_description): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 26481
diff changeset
1999 int c;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2000
14080
439185f0ef37 (Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents: 13947
diff changeset
2001 CHECK_NUMBER (character, 0);
439185f0ef37 (Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents: 13947
diff changeset
2002
26864
b89eb8bbaff1 (push_key_description): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 26481
diff changeset
2003 c = XINT (character);
b89eb8bbaff1 (push_key_description): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 26481
diff changeset
2004 if (!SINGLE_BYTE_CHAR_P (c))
17036
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
2005 {
26864
b89eb8bbaff1 (push_key_description): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 26481
diff changeset
2006 int len = CHAR_STRING (c, str);
17036
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
2007
20624
9ac0b485cf60 (describe_vector): Unconditionally handle multibyte chars.
Richard M. Stallman <rms@gnu.org>
parents: 20576
diff changeset
2008 return make_multibyte_string (str, 1, len);
17036
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
2009 }
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
2010
26864
b89eb8bbaff1 (push_key_description): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 26481
diff changeset
2011 *push_text_char_description (c & 0377, str) = 0;
b89eb8bbaff1 (push_key_description): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 26481
diff changeset
2012
b89eb8bbaff1 (push_key_description): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 26481
diff changeset
2013 return build_string (str);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2014 }
2727
b8911c8b9700 * keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents: 2652
diff changeset
2015
b8911c8b9700 * keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents: 2652
diff changeset
2016 /* Return non-zero if SEQ contains only ASCII characters, perhaps with
b8911c8b9700 * keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents: 2652
diff changeset
2017 a meta bit. */
b8911c8b9700 * keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents: 2652
diff changeset
2018 static int
b8911c8b9700 * keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents: 2652
diff changeset
2019 ascii_sequence_p (seq)
b8911c8b9700 * keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents: 2652
diff changeset
2020 Lisp_Object seq;
b8911c8b9700 * keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents: 2652
diff changeset
2021 {
9312
dfaf1d41e53d (synkey, access_keymap, store_in_keymap, Faccessible_keymaps,
Karl Heuer <kwzh@gnu.org>
parents: 9273
diff changeset
2022 int i;
2727
b8911c8b9700 * keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents: 2652
diff changeset
2023 int len = XINT (Flength (seq));
6008
d3ccce72be00 (get_keyelt): Discard keyboard equivalents
Richard M. Stallman <rms@gnu.org>
parents: 5785
diff changeset
2024
9312
dfaf1d41e53d (synkey, access_keymap, store_in_keymap, Faccessible_keymaps,
Karl Heuer <kwzh@gnu.org>
parents: 9273
diff changeset
2025 for (i = 0; i < len; i++)
2727
b8911c8b9700 * keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents: 2652
diff changeset
2026 {
9312
dfaf1d41e53d (synkey, access_keymap, store_in_keymap, Faccessible_keymaps,
Karl Heuer <kwzh@gnu.org>
parents: 9273
diff changeset
2027 Lisp_Object ii, elt;
6008
d3ccce72be00 (get_keyelt): Discard keyboard equivalents
Richard M. Stallman <rms@gnu.org>
parents: 5785
diff changeset
2028
9312
dfaf1d41e53d (synkey, access_keymap, store_in_keymap, Faccessible_keymaps,
Karl Heuer <kwzh@gnu.org>
parents: 9273
diff changeset
2029 XSETFASTINT (ii, i);
dfaf1d41e53d (synkey, access_keymap, store_in_keymap, Faccessible_keymaps,
Karl Heuer <kwzh@gnu.org>
parents: 9273
diff changeset
2030 elt = Faref (seq, ii);
2727
b8911c8b9700 * keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents: 2652
diff changeset
2031
9123
c225137ddefb (get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents: 8922
diff changeset
2032 if (!INTEGERP (elt)
2727
b8911c8b9700 * keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents: 2652
diff changeset
2033 || (XUINT (elt) & ~CHAR_META) >= 0x80)
b8911c8b9700 * keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents: 2652
diff changeset
2034 return 0;
b8911c8b9700 * keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents: 2652
diff changeset
2035 }
b8911c8b9700 * keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents: 2652
diff changeset
2036
b8911c8b9700 * keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents: 2652
diff changeset
2037 return 1;
b8911c8b9700 * keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents: 2652
diff changeset
2038 }
b8911c8b9700 * keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents: 2652
diff changeset
2039
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2040
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
2041 /* where-is - finding a command in a set of keymaps. */
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
2042
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2043 static Lisp_Object where_is_internal_1 ();
20319
81424cf4d446 (copy_keymap_1): Fix return type.
Andreas Schwab <schwab@suse.de>
parents: 20076
diff changeset
2044 static void where_is_internal_2 ();
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2045
32476
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
2046 static INLINE int
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
2047 menu_item_p (item)
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
2048 Lisp_Object item;
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
2049 {
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
2050 return (CONSP (item)
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
2051 && (EQ (XCAR (item),Qmenu_item)
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
2052 || STRINGP (XCAR (item))));
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
2053 }
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
2054
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2055 /* Like Flookup_key, but uses a list of keymaps SHADOW instead of a single map.
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2056 Returns the first non-nil binding found in any of those maps. */
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2057
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2058 static Lisp_Object
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2059 shadow_lookup (shadow, key, flag)
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2060 Lisp_Object shadow, key, flag;
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2061 {
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2062 Lisp_Object tail, value;
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2063
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2064 for (tail = shadow; CONSP (tail); tail = XCDR (tail))
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2065 {
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2066 value = Flookup_key (XCAR (tail), key, flag);
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2067 if (!NILP (value) && !NATNUMP (value))
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2068 return value;
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2069 }
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2070 return Qnil;
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2071 }
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2072
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2073 /* This function can GC if Flookup_key autoloads any keymaps. */
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2074
32889
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2075 static Lisp_Object
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2076 where_is_internal (definition, keymaps, firstonly, noindirect)
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2077 Lisp_Object definition, keymaps;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2078 Lisp_Object firstonly, noindirect;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2079 {
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2080 Lisp_Object maps = Qnil;
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2081 Lisp_Object found, sequences;
7998
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
2082 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
10810
9b418bde9fcf (Fwhere_is_internal): If FIRSTONLY is not nil or non-ascii,
Richard M. Stallman <rms@gnu.org>
parents: 10541
diff changeset
2083 /* 1 means ignore all menu bindings entirely. */
9b418bde9fcf (Fwhere_is_internal): If FIRSTONLY is not nil or non-ascii,
Richard M. Stallman <rms@gnu.org>
parents: 10541
diff changeset
2084 int nomenus = !NILP (firstonly) && !EQ (firstonly, Qnon_ascii);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2085
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2086 found = keymaps;
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2087 while (CONSP (found))
29282
59f2b30d577b Include intervals.h.
Dave Love <fx@gnu.org>
parents: 29013
diff changeset
2088 {
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2089 maps =
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2090 nconc2 (maps, Faccessible_keymaps (get_keymap (XCAR (found)), Qnil));
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2091 found = XCDR (found);
29282
59f2b30d577b Include intervals.h.
Dave Love <fx@gnu.org>
parents: 29013
diff changeset
2092 }
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2093
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2094 GCPRO5 (definition, keymaps, maps, found, sequences);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2095 found = Qnil;
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2096 sequences = Qnil;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2097
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
2098 for (; !NILP (maps); maps = Fcdr (maps))
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2099 {
6502
18dfda644bc0 (access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents: 6475
diff changeset
2100 /* Key sequence to reach map, and the map that it reaches */
18dfda644bc0 (access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents: 6475
diff changeset
2101 register Lisp_Object this, map;
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2102
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2103 /* In order to fold [META-PREFIX-CHAR CHAR] sequences into
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2104 [M-CHAR] sequences, check if last character of the sequence
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2105 is the meta-prefix char. */
6502
18dfda644bc0 (access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents: 6475
diff changeset
2106 Lisp_Object last;
18dfda644bc0 (access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents: 6475
diff changeset
2107 int last_is_meta;
18dfda644bc0 (access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents: 6475
diff changeset
2108
18dfda644bc0 (access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents: 6475
diff changeset
2109 this = Fcar (Fcar (maps));
18dfda644bc0 (access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents: 6475
diff changeset
2110 map = Fcdr (Fcar (maps));
18dfda644bc0 (access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents: 6475
diff changeset
2111 last = make_number (XINT (Flength (this)) - 1);
18dfda644bc0 (access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents: 6475
diff changeset
2112 last_is_meta = (XINT (last) >= 0
18dfda644bc0 (access_keymap, store_in_keymap, Fcopy_keymap, Fdefine_key,
Karl Heuer <kwzh@gnu.org>
parents: 6475
diff changeset
2113 && EQ (Faref (this, last), meta_prefix_char));
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2114
32145
a48fcf036df1 (Fwhere_is_internal): Ignore `menu-bar' and `tool-bar'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32038
diff changeset
2115 if (nomenus && XINT (last) >= 0)
a48fcf036df1 (Fwhere_is_internal): Ignore `menu-bar' and `tool-bar'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32038
diff changeset
2116 { /* If no menu entries should be returned, skip over the
a48fcf036df1 (Fwhere_is_internal): Ignore `menu-bar' and `tool-bar'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32038
diff changeset
2117 keymaps bound to `menu-bar' and `tool-bar'. */
a48fcf036df1 (Fwhere_is_internal): Ignore `menu-bar' and `tool-bar'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32038
diff changeset
2118 Lisp_Object tem = Faref (this, 0);
a48fcf036df1 (Fwhere_is_internal): Ignore `menu-bar' and `tool-bar'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32038
diff changeset
2119 if (EQ (tem, Qmenu_bar) || EQ (tem, Qtool_bar))
a48fcf036df1 (Fwhere_is_internal): Ignore `menu-bar' and `tool-bar'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32038
diff changeset
2120 continue;
a48fcf036df1 (Fwhere_is_internal): Ignore `menu-bar' and `tool-bar'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32038
diff changeset
2121 }
a48fcf036df1 (Fwhere_is_internal): Ignore `menu-bar' and `tool-bar'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32038
diff changeset
2122
1236
5e8c234e5f03 * keymap.c (access_keymap): Remove code to notice bindings for
Jim Blandy <jimb@redhat.com>
parents: 1209
diff changeset
2123 QUIT;
5e8c234e5f03 * keymap.c (access_keymap): Remove code to notice bindings for
Jim Blandy <jimb@redhat.com>
parents: 1209
diff changeset
2124
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2125 while (CONSP (map))
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2126 {
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2127 /* Because the code we want to run on each binding is rather
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2128 large, we don't want to have two separate loop bodies for
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2129 sparse keymap bindings and tables; we want to iterate one
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2130 loop body over both keymap and vector bindings.
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2131
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2132 For this reason, if Fcar (map) is a vector, we don't
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2133 advance map to the next element until i indicates that we
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2134 have finished off the vector. */
7998
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
2135 Lisp_Object elt, key, binding;
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
2136 elt = XCAR (map);
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
2137 map = XCDR (map);
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2138
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2139 sequences = Qnil;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2140
1236
5e8c234e5f03 * keymap.c (access_keymap): Remove code to notice bindings for
Jim Blandy <jimb@redhat.com>
parents: 1209
diff changeset
2141 QUIT;
5e8c234e5f03 * keymap.c (access_keymap): Remove code to notice bindings for
Jim Blandy <jimb@redhat.com>
parents: 1209
diff changeset
2142
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2143 /* Set key and binding to the current key and binding, and
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2144 advance map and i to the next binding. */
9123
c225137ddefb (get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents: 8922
diff changeset
2145 if (VECTORP (elt))
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2146 {
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2147 Lisp_Object sequence;
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2148 int i;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2149 /* In a vector, look at each element. */
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2150 for (i = 0; i < XVECTOR (elt)->size; i++)
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2151 {
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2152 binding = AREF (elt, i);
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2153 XSETFASTINT (key, i);
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2154 sequence = where_is_internal_1 (binding, key, definition,
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2155 noindirect, this,
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2156 last, nomenus, last_is_meta);
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2157 if (!NILP (sequence))
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2158 sequences = Fcons (sequence, sequences);
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2159 }
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2160 }
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2161 else if (CHAR_TABLE_P (elt))
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2162 {
20076
374e09781f08 (Faccessible_keymaps): Avoid alloca for fixed-size array.
Karl Heuer <kwzh@gnu.org>
parents: 20070
diff changeset
2163 Lisp_Object indices[3];
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2164 Lisp_Object args;
20076
374e09781f08 (Faccessible_keymaps): Avoid alloca for fixed-size array.
Karl Heuer <kwzh@gnu.org>
parents: 20070
diff changeset
2165
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2166 args = Fcons (Fcons (Fcons (definition, noindirect),
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2167 Qnil), /* Result accumulator. */
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2168 Fcons (Fcons (this, last),
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2169 Fcons (make_number (nomenus),
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2170 make_number (last_is_meta))));
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2171 map_char_table (where_is_internal_2, Qnil, elt, args,
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2172 0, indices);
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2173 sequences = XCDR (XCAR (args));
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2174 }
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2175 else if (CONSP (elt))
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2176 {
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2177 Lisp_Object sequence;
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2178
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
2179 key = XCAR (elt);
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
2180 binding = XCDR (elt);
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2181
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2182 sequence = where_is_internal_1 (binding, key, definition,
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2183 noindirect, this,
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2184 last, nomenus, last_is_meta);
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2185 if (!NILP (sequence))
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2186 sequences = Fcons (sequence, sequences);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2187 }
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2188
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2189
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
2190 for (; ! NILP (sequences); sequences = XCDR (sequences))
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2191 {
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2192 Lisp_Object sequence;
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2193
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
2194 sequence = XCAR (sequences);
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2195
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2196 /* Verify that this key binding is not shadowed by another
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2197 binding for the same key, before we say it exists.
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2198
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2199 Mechanism: look for local definition of this key and if
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2200 it is defined and does not match what we found then
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2201 ignore this key.
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2202
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2203 Either nil or number as value from Flookup_key
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2204 means undefined. */
32889
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2205 if (!EQ (shadow_lookup (keymaps, sequence, Qnil), definition))
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2206 continue;
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2207
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2208 /* It is a true unshadowed match. Record it, unless it's already
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2209 been seen (as could happen when inheriting keymaps). */
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2210 if (NILP (Fmember (sequence, found)))
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2211 found = Fcons (sequence, found);
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2212
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2213 /* If firstonly is Qnon_ascii, then we can return the first
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2214 binding we find. If firstonly is not Qnon_ascii but not
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2215 nil, then we should return the first ascii-only binding
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2216 we find. */
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2217 if (EQ (firstonly, Qnon_ascii))
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2218 RETURN_UNGCPRO (sequence);
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2219 else if (! NILP (firstonly) && ascii_sequence_p (sequence))
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2220 RETURN_UNGCPRO (sequence);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2221 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2222 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2223 }
2727
b8911c8b9700 * keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents: 2652
diff changeset
2224
7998
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
2225 UNGCPRO;
d4b5f4dd9c51 (Flookup_key): Add gcpro.
Richard M. Stallman <rms@gnu.org>
parents: 7894
diff changeset
2226
2727
b8911c8b9700 * keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents: 2652
diff changeset
2227 found = Fnreverse (found);
b8911c8b9700 * keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents: 2652
diff changeset
2228
b8911c8b9700 * keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents: 2652
diff changeset
2229 /* firstonly may have been t, but we may have gone all the way through
b8911c8b9700 * keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents: 2652
diff changeset
2230 the keymaps without finding an all-ASCII key sequence. So just
b8911c8b9700 * keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents: 2652
diff changeset
2231 return the best we could find. */
b8911c8b9700 * keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents: 2652
diff changeset
2232 if (! NILP (firstonly))
b8911c8b9700 * keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents: 2652
diff changeset
2233 return Fcar (found);
b8911c8b9700 * keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents: 2652
diff changeset
2234
b8911c8b9700 * keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents: 2652
diff changeset
2235 return found;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2236 }
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2237
32889
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2238 DEFUN ("where-is-internal", Fwhere_is_internal, Swhere_is_internal, 1, 4, 0,
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2239 "Return list of keys that invoke DEFINITION.\n\
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2240 If KEYMAP is non-nil, search only KEYMAP and the global keymap.\n\
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2241 If KEYMAP is nil, search all the currently active keymaps.\n\
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2242 If KEYMAP is a list of keymaps, search only those keymaps.\n\
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2243 \n\
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2244 If optional 3rd arg FIRSTONLY is non-nil, return the first key sequence found,\n\
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2245 rather than a list of all possible key sequences.\n\
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2246 If FIRSTONLY is the symbol `non-ascii', return the first binding found,\n\
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2247 no matter what it is.\n\
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2248 If FIRSTONLY has another non-nil value, prefer sequences of ASCII characters,\n\
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2249 and entirely reject menu bindings.\n\
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2250 \n\
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2251 If optional 4th arg NOINDIRECT is non-nil, don't follow indirections\n\
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2252 to other keymaps or slots. This makes it possible to search for an\n\
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2253 indirect definition itself.")
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2254 (definition, xkeymap, firstonly, noindirect)
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2255 Lisp_Object definition, xkeymap;
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2256 Lisp_Object firstonly, noindirect;
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2257 {
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2258 Lisp_Object sequences, keymaps;
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2259 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2260 /* 1 means ignore all menu bindings entirely. */
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2261 int nomenus = !NILP (firstonly) && !EQ (firstonly, Qnon_ascii);
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2262
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2263 /* Find the relevant keymaps. */
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2264 if (CONSP (xkeymap) && KEYMAPP (XCAR (xkeymap)))
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2265 keymaps = xkeymap;
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2266 else if (! NILP (xkeymap))
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2267 keymaps = Fcons (xkeymap, Fcons (current_global_map, Qnil));
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2268 else
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2269 keymaps =
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2270 Fdelq (Qnil,
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2271 nconc2 (Fcurrent_minor_mode_maps (),
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2272 Fcons (get_local_map (PT, current_buffer, keymap),
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2273 Fcons (get_local_map (PT, current_buffer, local_map),
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2274 Fcons (current_global_map, Qnil)))));
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2275
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2276 /* Only use caching for the menubar (i.e. called with (def nil t nil).
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2277 We don't really need to check `xkeymap'. */
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2278 if (nomenus && NILP (noindirect) && NILP (xkeymap))
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2279 {
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2280 /* Check heuristic-consistency of the cache. */
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2281 if (NILP (Fequal (keymaps, where_is_cache_keymaps)))
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2282 where_is_cache = Qnil;
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2283
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2284 if (NILP (where_is_cache))
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2285 {
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2286 /* We need to create the cache. */
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2287 Lisp_Object args[2];
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2288 where_is_cache = Fmake_hash_table (0, args);
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2289 where_is_cache_keymaps = Qt;
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2290
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2291 /* Fill in the cache. */
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2292 GCPRO4 (definition, keymaps, firstonly, noindirect);
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2293 where_is_internal (definition, keymaps, firstonly, noindirect);
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2294 UNGCPRO;
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2295
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2296 where_is_cache_keymaps = keymaps;
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2297 }
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2298
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2299 sequences = Fgethash (definition, where_is_cache, Qnil);
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2300 /* Verify that the key bindings are not shadowed. */
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2301 /* key-binding can GC. */
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2302 GCPRO3 (definition, sequences, keymaps);
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2303 for (sequences = Fnreverse (sequences);
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2304 CONSP (sequences);
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2305 sequences = XCDR (sequences))
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2306 if (EQ (shadow_lookup (keymaps, XCAR (sequences), Qnil), definition))
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2307 RETURN_UNGCPRO (XCAR (sequences));
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2308 RETURN_UNGCPRO (Qnil);
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2309 }
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2310 else
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2311 {
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2312 /* Kill the cache so that where_is_internal_1 doesn't think
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2313 we're filling it up. */
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2314 where_is_cache = Qnil;
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2315 return where_is_internal (definition, keymaps, firstonly, noindirect);
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2316 }
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2317 }
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2318
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2319 /* This is the function that Fwhere_is_internal calls using map_char_table.
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2320 ARGS has the form
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2321 (((DEFINITION . NOINDIRECT) . (KEYMAP . RESULT))
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2322 .
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2323 ((THIS . LAST) . (NOMENUS . LAST_IS_META)))
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2324 Since map_char_table doesn't really use the return value from this function,
30134
784ef95b020b (get_keymap_1): Add comment that this function can GC.
Gerd Moellmann <gerd@gnu.org>
parents: 30030
diff changeset
2325 we the result append to RESULT, the slot in ARGS.
784ef95b020b (get_keymap_1): Add comment that this function can GC.
Gerd Moellmann <gerd@gnu.org>
parents: 30030
diff changeset
2326
784ef95b020b (get_keymap_1): Add comment that this function can GC.
Gerd Moellmann <gerd@gnu.org>
parents: 30030
diff changeset
2327 This function can GC because it calls where_is_internal_1 which can
784ef95b020b (get_keymap_1): Add comment that this function can GC.
Gerd Moellmann <gerd@gnu.org>
parents: 30030
diff changeset
2328 GC. */
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2329
20319
81424cf4d446 (copy_keymap_1): Fix return type.
Andreas Schwab <schwab@suse.de>
parents: 20076
diff changeset
2330 static void
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2331 where_is_internal_2 (args, key, binding)
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2332 Lisp_Object args, key, binding;
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2333 {
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2334 Lisp_Object definition, noindirect, this, last;
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2335 Lisp_Object result, sequence;
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2336 int nomenus, last_is_meta;
30134
784ef95b020b (get_keymap_1): Add comment that this function can GC.
Gerd Moellmann <gerd@gnu.org>
parents: 30030
diff changeset
2337 struct gcpro gcpro1, gcpro2, gcpro3;
784ef95b020b (get_keymap_1): Add comment that this function can GC.
Gerd Moellmann <gerd@gnu.org>
parents: 30030
diff changeset
2338
784ef95b020b (get_keymap_1): Add comment that this function can GC.
Gerd Moellmann <gerd@gnu.org>
parents: 30030
diff changeset
2339 GCPRO3 (args, key, binding);
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2340 result = XCDR (XCAR (args));
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
2341 definition = XCAR (XCAR (XCAR (args)));
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
2342 noindirect = XCDR (XCAR (XCAR (args)));
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
2343 this = XCAR (XCAR (XCDR (args)));
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
2344 last = XCDR (XCAR (XCDR (args)));
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
2345 nomenus = XFASTINT (XCAR (XCDR (XCDR (args))));
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
2346 last_is_meta = XFASTINT (XCDR (XCDR (XCDR (args))));
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2347
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2348 sequence = where_is_internal_1 (binding, key, definition, noindirect,
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2349 this, last, nomenus, last_is_meta);
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2350
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2351 if (!NILP (sequence))
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2352 XCDR (XCAR (args)) = Fcons (sequence, result);
30134
784ef95b020b (get_keymap_1): Add comment that this function can GC.
Gerd Moellmann <gerd@gnu.org>
parents: 30030
diff changeset
2353
784ef95b020b (get_keymap_1): Add comment that this function can GC.
Gerd Moellmann <gerd@gnu.org>
parents: 30030
diff changeset
2354 UNGCPRO;
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2355 }
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2356
30134
784ef95b020b (get_keymap_1): Add comment that this function can GC.
Gerd Moellmann <gerd@gnu.org>
parents: 30030
diff changeset
2357
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2358 /* This function cannot GC. */
30134
784ef95b020b (get_keymap_1): Add comment that this function can GC.
Gerd Moellmann <gerd@gnu.org>
parents: 30030
diff changeset
2359
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2360 static Lisp_Object
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2361 where_is_internal_1 (binding, key, definition, noindirect, this, last,
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2362 nomenus, last_is_meta)
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2363 Lisp_Object binding, key, definition, noindirect, this, last;
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2364 int nomenus, last_is_meta;
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2365 {
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2366 Lisp_Object sequence;
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2367
32476
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
2368 /* Skip left-over menu-items.
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
2369 These can appear in a keymap bound to a mouse click, for example. */
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
2370 if (nomenus && menu_item_p (binding))
9b2a0dc393a4 * keymap.c (access_keymap): Add AUTOLOAD parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32145
diff changeset
2371 return Qnil;
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2372 /* Search through indirections unless that's not wanted. */
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2373 if (NILP (noindirect))
32145
a48fcf036df1 (Fwhere_is_internal): Ignore `menu-bar' and `tool-bar'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32038
diff changeset
2374 binding = get_keyelt (binding, 0);
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2375
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2376 /* End this iteration if this element does not match
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2377 the target. */
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2378
32889
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2379 if (!(!NILP (where_is_cache) /* everything "matches" during cache-fill. */
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2380 || EQ (binding, definition)
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2381 || (CONSP (definition) && !NILP (Fequal (binding, definition)))))
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2382 /* Doesn't match. */
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2383 return Qnil;
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2384
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2385 /* We have found a match. Construct the key sequence where we found it. */
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2386 if (INTEGERP (key) && last_is_meta)
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2387 {
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2388 sequence = Fcopy_sequence (this);
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2389 Faset (sequence, last, make_number (XINT (key) | meta_modifier));
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2390 }
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2391 else
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2392 sequence = append_key (this, key);
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2393
32889
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2394 if (!NILP (where_is_cache))
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2395 {
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2396 Lisp_Object sequences = Fgethash (binding, where_is_cache, Qnil);
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2397 Fputhash (binding, Fcons (sequence, sequences), where_is_cache);
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2398 return Qnil;
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2399 }
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2400 else
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
2401 return sequence;
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2402 }
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2403
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
2404 /* describe-bindings - summarizing all the bindings in a set of keymaps. */
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
2405
20850
ffbaaba0bf76 (Fdescribe_bindings_internal):
Richard M. Stallman <rms@gnu.org>
parents: 20708
diff changeset
2406 DEFUN ("describe-bindings-internal", Fdescribe_bindings_internal, Sdescribe_bindings_internal, 0, 2, "",
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2407 "Show a list of all defined keys, and their definitions.\n\
20850
ffbaaba0bf76 (Fdescribe_bindings_internal):
Richard M. Stallman <rms@gnu.org>
parents: 20708
diff changeset
2408 We put that list in a buffer, and display the buffer.\n\
ffbaaba0bf76 (Fdescribe_bindings_internal):
Richard M. Stallman <rms@gnu.org>
parents: 20708
diff changeset
2409 \n\
ffbaaba0bf76 (Fdescribe_bindings_internal):
Richard M. Stallman <rms@gnu.org>
parents: 20708
diff changeset
2410 The optional argument MENUS, if non-nil, says to mention menu bindings.\n\
ffbaaba0bf76 (Fdescribe_bindings_internal):
Richard M. Stallman <rms@gnu.org>
parents: 20708
diff changeset
2411 \(Ordinarily these are omitted from the output.)\n\
ffbaaba0bf76 (Fdescribe_bindings_internal):
Richard M. Stallman <rms@gnu.org>
parents: 20708
diff changeset
2412 The optional argument PREFIX, if non-nil, should be a key sequence;\n\
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2413 then we display only bindings that start with that prefix.")
20850
ffbaaba0bf76 (Fdescribe_bindings_internal):
Richard M. Stallman <rms@gnu.org>
parents: 20708
diff changeset
2414 (menus, prefix)
ffbaaba0bf76 (Fdescribe_bindings_internal):
Richard M. Stallman <rms@gnu.org>
parents: 20708
diff changeset
2415 Lisp_Object menus, prefix;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2416 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2417 register Lisp_Object thisbuf;
9273
129621997564 (synkey, Fdescribe_bindings, describe_command): Use new accessor macros
Karl Heuer <kwzh@gnu.org>
parents: 9123
diff changeset
2418 XSETBUFFER (thisbuf, current_buffer);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2419 internal_with_output_to_temp_buffer ("*Help*",
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2420 describe_buffer_bindings,
20850
ffbaaba0bf76 (Fdescribe_bindings_internal):
Richard M. Stallman <rms@gnu.org>
parents: 20708
diff changeset
2421 list3 (thisbuf, prefix, menus));
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2422 return Qnil;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2423 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2424
20850
ffbaaba0bf76 (Fdescribe_bindings_internal):
Richard M. Stallman <rms@gnu.org>
parents: 20708
diff changeset
2425 /* ARG is (BUFFER PREFIX MENU-FLAG). */
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2426
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2427 static Lisp_Object
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2428 describe_buffer_bindings (arg)
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2429 Lisp_Object arg;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2430 {
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2431 Lisp_Object descbuf, prefix, shadow;
20850
ffbaaba0bf76 (Fdescribe_bindings_internal):
Richard M. Stallman <rms@gnu.org>
parents: 20708
diff changeset
2432 int nomenu;
7186
092688f7ebbb (describe_buffer_bindings): gcpro stuff. Delete some unused code.
Karl Heuer <kwzh@gnu.org>
parents: 7184
diff changeset
2433 register Lisp_Object start1;
092688f7ebbb (describe_buffer_bindings): gcpro stuff. Delete some unused code.
Karl Heuer <kwzh@gnu.org>
parents: 7184
diff changeset
2434 struct gcpro gcpro1;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2435
1120
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2436 char *alternate_heading
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2437 = "\
20850
ffbaaba0bf76 (Fdescribe_bindings_internal):
Richard M. Stallman <rms@gnu.org>
parents: 20708
diff changeset
2438 Keyboard translations:\n\n\
ffbaaba0bf76 (Fdescribe_bindings_internal):
Richard M. Stallman <rms@gnu.org>
parents: 20708
diff changeset
2439 You type Translation\n\
ffbaaba0bf76 (Fdescribe_bindings_internal):
Richard M. Stallman <rms@gnu.org>
parents: 20708
diff changeset
2440 -------- -----------\n";
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2441
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
2442 descbuf = XCAR (arg);
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
2443 arg = XCDR (arg);
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
2444 prefix = XCAR (arg);
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
2445 arg = XCDR (arg);
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
2446 nomenu = NILP (XCAR (arg));
20850
ffbaaba0bf76 (Fdescribe_bindings_internal):
Richard M. Stallman <rms@gnu.org>
parents: 20708
diff changeset
2447
4575
bf0f07186369 (describe_buffer_bindings): Declare shadow just once.
Richard M. Stallman <rms@gnu.org>
parents: 4138
diff changeset
2448 shadow = Qnil;
7186
092688f7ebbb (describe_buffer_bindings): gcpro stuff. Delete some unused code.
Karl Heuer <kwzh@gnu.org>
parents: 7184
diff changeset
2449 GCPRO1 (shadow);
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2450
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2451 Fset_buffer (Vstandard_output);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2452
1120
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2453 /* Report on alternates for keys. */
12710
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2454 if (STRINGP (Vkeyboard_translate_table) && !NILP (prefix))
1120
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2455 {
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2456 int c;
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2457 unsigned char *translate = XSTRING (Vkeyboard_translate_table)->data;
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2458 int translate_len = XSTRING (Vkeyboard_translate_table)->size;
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2459
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2460 for (c = 0; c < translate_len; c++)
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2461 if (translate[c] != c)
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2462 {
26481
70d85ae6dfee (Fsingle_key_description): Use KEY_DESCRIPTION_SIZE to
Kenichi Handa <handa@m17n.org>
parents: 26404
diff changeset
2463 char buf[KEY_DESCRIPTION_SIZE];
1120
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2464 char *bufend;
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2465
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2466 if (alternate_heading)
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2467 {
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2468 insert_string (alternate_heading);
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2469 alternate_heading = 0;
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2470 }
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2471
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2472 bufend = push_key_description (translate[c], buf);
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2473 insert (buf, bufend - buf);
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2474 Findent_to (make_number (16), make_number (1));
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2475 bufend = push_key_description (c, buf);
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2476 insert (buf, bufend - buf);
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2477
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2478 insert ("\n", 1);
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2479 }
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2480
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2481 insert ("\n", 1);
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2482 }
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2483
12710
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2484 if (!NILP (Vkey_translation_map))
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2485 describe_map_tree (Vkey_translation_map, 0, Qnil, prefix,
20850
ffbaaba0bf76 (Fdescribe_bindings_internal):
Richard M. Stallman <rms@gnu.org>
parents: 20708
diff changeset
2486 "Key translations", nomenu, 1, 0);
12710
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2487
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
2488 {
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
2489 int i, nmaps;
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
2490 Lisp_Object *modes, *maps;
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
2491
1120
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2492 /* Temporarily switch to descbuf, so that we can get that buffer's
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2493 minor modes correctly. */
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2494 Fset_buffer (descbuf);
12710
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2495
12262
a7d5578ebb25 (Fkey_binding, describe_buffer_bindings):
Karl Heuer <kwzh@gnu.org>
parents: 12151
diff changeset
2496 if (!NILP (current_kboard->Voverriding_terminal_local_map)
a7d5578ebb25 (Fkey_binding, describe_buffer_bindings):
Karl Heuer <kwzh@gnu.org>
parents: 12151
diff changeset
2497 || !NILP (Voverriding_local_map))
5613
cad51b2de6cd (Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents: 5551
diff changeset
2498 nmaps = 0;
cad51b2de6cd (Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents: 5551
diff changeset
2499 else
cad51b2de6cd (Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents: 5551
diff changeset
2500 nmaps = current_minor_maps (&modes, &maps);
1120
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2501 Fset_buffer (Vstandard_output);
0a486e1a45bc * keymap.c (describe_buffer_bindings): Adjust key_heading to match
Jim Blandy <jimb@redhat.com>
parents: 1095
diff changeset
2502
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2503 /* Print the minor mode maps. */
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
2504 for (i = 0; i < nmaps; i++)
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
2505 {
6695
c66bed2f25af (describe_buffer_bindings): Move XSYMBOL to after SYMBOLP.
Karl Heuer <kwzh@gnu.org>
parents: 6524
diff changeset
2506 /* The title for a minor mode keymap
4023
5e4f918d5d44 (describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents: 3962
diff changeset
2507 is constructed at run time.
5e4f918d5d44 (describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents: 3962
diff changeset
2508 We let describe_map_tree do the actual insertion
5e4f918d5d44 (describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents: 3962
diff changeset
2509 because it takes care of other features when doing so. */
6695
c66bed2f25af (describe_buffer_bindings): Move XSYMBOL to after SYMBOLP.
Karl Heuer <kwzh@gnu.org>
parents: 6524
diff changeset
2510 char *title, *p;
4023
5e4f918d5d44 (describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents: 3962
diff changeset
2511
9123
c225137ddefb (get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents: 8922
diff changeset
2512 if (!SYMBOLP (modes[i]))
7186
092688f7ebbb (describe_buffer_bindings): gcpro stuff. Delete some unused code.
Karl Heuer <kwzh@gnu.org>
parents: 7184
diff changeset
2513 abort();
092688f7ebbb (describe_buffer_bindings): gcpro stuff. Delete some unused code.
Karl Heuer <kwzh@gnu.org>
parents: 7184
diff changeset
2514
29695
5201e6953968 (describe_buffer_bindings): Add `\f\n' in front of titles.
Gerd Moellmann <gerd@gnu.org>
parents: 29651
diff changeset
2515 p = title = (char *) alloca (42 + XSYMBOL (modes[i])->name->size);
5201e6953968 (describe_buffer_bindings): Add `\f\n' in front of titles.
Gerd Moellmann <gerd@gnu.org>
parents: 29651
diff changeset
2516 *p++ = '\f';
5201e6953968 (describe_buffer_bindings): Add `\f\n' in front of titles.
Gerd Moellmann <gerd@gnu.org>
parents: 29651
diff changeset
2517 *p++ = '\n';
7186
092688f7ebbb (describe_buffer_bindings): gcpro stuff. Delete some unused code.
Karl Heuer <kwzh@gnu.org>
parents: 7184
diff changeset
2518 *p++ = '`';
092688f7ebbb (describe_buffer_bindings): gcpro stuff. Delete some unused code.
Karl Heuer <kwzh@gnu.org>
parents: 7184
diff changeset
2519 bcopy (XSYMBOL (modes[i])->name->data, p,
092688f7ebbb (describe_buffer_bindings): gcpro stuff. Delete some unused code.
Karl Heuer <kwzh@gnu.org>
parents: 7184
diff changeset
2520 XSYMBOL (modes[i])->name->size);
092688f7ebbb (describe_buffer_bindings): gcpro stuff. Delete some unused code.
Karl Heuer <kwzh@gnu.org>
parents: 7184
diff changeset
2521 p += XSYMBOL (modes[i])->name->size;
092688f7ebbb (describe_buffer_bindings): gcpro stuff. Delete some unused code.
Karl Heuer <kwzh@gnu.org>
parents: 7184
diff changeset
2522 *p++ = '\'';
6695
c66bed2f25af (describe_buffer_bindings): Move XSYMBOL to after SYMBOLP.
Karl Heuer <kwzh@gnu.org>
parents: 6524
diff changeset
2523 bcopy (" Minor Mode Bindings", p, sizeof (" Minor Mode Bindings") - 1);
c66bed2f25af (describe_buffer_bindings): Move XSYMBOL to after SYMBOLP.
Karl Heuer <kwzh@gnu.org>
parents: 6524
diff changeset
2524 p += sizeof (" Minor Mode Bindings") - 1;
4023
5e4f918d5d44 (describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents: 3962
diff changeset
2525 *p = 0;
5e4f918d5d44 (describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents: 3962
diff changeset
2526
20850
ffbaaba0bf76 (Fdescribe_bindings_internal):
Richard M. Stallman <rms@gnu.org>
parents: 20708
diff changeset
2527 describe_map_tree (maps[i], 1, shadow, prefix, title, nomenu, 0, 0);
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2528 shadow = Fcons (maps[i], shadow);
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
2529 }
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
2530 }
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
2531
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2532 /* Print the (major mode) local map. */
12262
a7d5578ebb25 (Fkey_binding, describe_buffer_bindings):
Karl Heuer <kwzh@gnu.org>
parents: 12151
diff changeset
2533 if (!NILP (current_kboard->Voverriding_terminal_local_map))
a7d5578ebb25 (Fkey_binding, describe_buffer_bindings):
Karl Heuer <kwzh@gnu.org>
parents: 12151
diff changeset
2534 start1 = current_kboard->Voverriding_terminal_local_map;
a7d5578ebb25 (Fkey_binding, describe_buffer_bindings):
Karl Heuer <kwzh@gnu.org>
parents: 12151
diff changeset
2535 else if (!NILP (Voverriding_local_map))
5613
cad51b2de6cd (Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents: 5551
diff changeset
2536 start1 = Voverriding_local_map;
cad51b2de6cd (Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents: 5551
diff changeset
2537 else
cad51b2de6cd (Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents: 5551
diff changeset
2538 start1 = XBUFFER (descbuf)->keymap;
cad51b2de6cd (Fkey_binding): Handle Voverriding_local_map.
Richard M. Stallman <rms@gnu.org>
parents: 5551
diff changeset
2539
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
2540 if (!NILP (start1))
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2541 {
16465
398e3995162d (describe_buffer_bindings): Pass 1 for PARTIAL
Richard M. Stallman <rms@gnu.org>
parents: 16227
diff changeset
2542 describe_map_tree (start1, 1, shadow, prefix,
29695
5201e6953968 (describe_buffer_bindings): Add `\f\n' in front of titles.
Gerd Moellmann <gerd@gnu.org>
parents: 29651
diff changeset
2543 "\f\nMajor Mode Bindings", nomenu, 0, 0);
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2544 shadow = Fcons (start1, shadow);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2545 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2546
16465
398e3995162d (describe_buffer_bindings): Pass 1 for PARTIAL
Richard M. Stallman <rms@gnu.org>
parents: 16227
diff changeset
2547 describe_map_tree (current_global_map, 1, shadow, prefix,
29695
5201e6953968 (describe_buffer_bindings): Add `\f\n' in front of titles.
Gerd Moellmann <gerd@gnu.org>
parents: 29651
diff changeset
2548 "\f\nGlobal Bindings", nomenu, 0, 1);
12710
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2549
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2550 /* Print the function-key-map translations under this prefix. */
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2551 if (!NILP (Vfunction_key_map))
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2552 describe_map_tree (Vfunction_key_map, 0, Qnil, prefix,
29695
5201e6953968 (describe_buffer_bindings): Add `\f\n' in front of titles.
Gerd Moellmann <gerd@gnu.org>
parents: 29651
diff changeset
2553 "\f\nFunction key map translations", nomenu, 1, 0);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2554
9862
d35ed70c84d4 (describe_buffer_bindings): Set help-mode in *Help* buffer.
Karl Heuer <kwzh@gnu.org>
parents: 9312
diff changeset
2555 call0 (intern ("help-mode"));
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2556 Fset_buffer (descbuf);
7186
092688f7ebbb (describe_buffer_bindings): gcpro stuff. Delete some unused code.
Karl Heuer <kwzh@gnu.org>
parents: 7184
diff changeset
2557 UNGCPRO;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2558 return Qnil;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2559 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2560
13947
65488aa49b87 (Flookup_key): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 13771
diff changeset
2561 /* Insert a description of the key bindings in STARTMAP,
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2562 followed by those of all maps reachable through STARTMAP.
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2563 If PARTIAL is nonzero, omit certain "uninteresting" commands
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2564 (such as `undefined').
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2565 If SHADOW is non-nil, it is a list of maps;
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2566 don't mention keys which would be shadowed by any of them.
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2567 PREFIX, if non-nil, says mention only keys that start with PREFIX.
4023
5e4f918d5d44 (describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents: 3962
diff changeset
2568 TITLE, if not 0, is a string to insert at the beginning.
5551
2b8f405f5103 (describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents: 5367
diff changeset
2569 TITLE should not end with a colon or a newline; we supply that.
12710
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2570 If NOMENU is not 0, then omit menu-bar commands.
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2571
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2572 If TRANSL is nonzero, the definitions are actually key translations
13245
2e0c4159e94b (describe_map_tree): New arg always_title. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 13201
diff changeset
2573 so print strings and vectors differently.
2e0c4159e94b (describe_map_tree): New arg always_title. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 13201
diff changeset
2574
2e0c4159e94b (describe_map_tree): New arg always_title. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 13201
diff changeset
2575 If ALWAYS_TITLE is nonzero, print the title even if there are no maps
2e0c4159e94b (describe_map_tree): New arg always_title. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 13201
diff changeset
2576 to look through. */
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2577
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2578 void
13245
2e0c4159e94b (describe_map_tree): New arg always_title. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 13201
diff changeset
2579 describe_map_tree (startmap, partial, shadow, prefix, title, nomenu, transl,
2e0c4159e94b (describe_map_tree): New arg always_title. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 13201
diff changeset
2580 always_title)
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2581 Lisp_Object startmap, shadow, prefix;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2582 int partial;
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2583 char *title;
5551
2b8f405f5103 (describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents: 5367
diff changeset
2584 int nomenu;
12710
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2585 int transl;
13245
2e0c4159e94b (describe_map_tree): New arg always_title. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 13201
diff changeset
2586 int always_title;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2587 {
20883
4aeabf3b8f98 (describe_map_tree): Add the maps we have already
Richard M. Stallman <rms@gnu.org>
parents: 20850
diff changeset
2588 Lisp_Object maps, orig_maps, seen, sub_shadows;
7184
caac285c072d (describe_map_tree): gcpro some things.
Karl Heuer <kwzh@gnu.org>
parents: 7183
diff changeset
2589 struct gcpro gcpro1, gcpro2, gcpro3;
4023
5e4f918d5d44 (describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents: 3962
diff changeset
2590 int something = 0;
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2591 char *key_heading
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2592 = "\
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2593 key binding\n\
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2594 --- -------\n";
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2595
20883
4aeabf3b8f98 (describe_map_tree): Add the maps we have already
Richard M. Stallman <rms@gnu.org>
parents: 20850
diff changeset
2596 orig_maps = maps = Faccessible_keymaps (startmap, prefix);
6976
4d540eeb2dd5 (describe_map_tree, describe_map): Skip keymaps we've seen before.
Karl Heuer <kwzh@gnu.org>
parents: 6974
diff changeset
2597 seen = Qnil;
7184
caac285c072d (describe_map_tree): gcpro some things.
Karl Heuer <kwzh@gnu.org>
parents: 7183
diff changeset
2598 sub_shadows = Qnil;
caac285c072d (describe_map_tree): gcpro some things.
Karl Heuer <kwzh@gnu.org>
parents: 7183
diff changeset
2599 GCPRO3 (maps, seen, sub_shadows);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2600
5551
2b8f405f5103 (describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents: 5367
diff changeset
2601 if (nomenu)
2b8f405f5103 (describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents: 5367
diff changeset
2602 {
2b8f405f5103 (describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents: 5367
diff changeset
2603 Lisp_Object list;
2b8f405f5103 (describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents: 5367
diff changeset
2604
2b8f405f5103 (describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents: 5367
diff changeset
2605 /* Delete from MAPS each element that is for the menu bar. */
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
2606 for (list = maps; !NILP (list); list = XCDR (list))
5551
2b8f405f5103 (describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents: 5367
diff changeset
2607 {
2b8f405f5103 (describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents: 5367
diff changeset
2608 Lisp_Object elt, prefix, tem;
2b8f405f5103 (describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents: 5367
diff changeset
2609
2b8f405f5103 (describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents: 5367
diff changeset
2610 elt = Fcar (list);
2b8f405f5103 (describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents: 5367
diff changeset
2611 prefix = Fcar (elt);
2b8f405f5103 (describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents: 5367
diff changeset
2612 if (XVECTOR (prefix)->size >= 1)
2b8f405f5103 (describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents: 5367
diff changeset
2613 {
2b8f405f5103 (describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents: 5367
diff changeset
2614 tem = Faref (prefix, make_number (0));
2b8f405f5103 (describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents: 5367
diff changeset
2615 if (EQ (tem, Qmenu_bar))
2b8f405f5103 (describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents: 5367
diff changeset
2616 maps = Fdelq (elt, maps);
2b8f405f5103 (describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents: 5367
diff changeset
2617 }
2b8f405f5103 (describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents: 5367
diff changeset
2618 }
2b8f405f5103 (describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents: 5367
diff changeset
2619 }
2b8f405f5103 (describe_map_tree): New arg NOMENU.
Richard M. Stallman <rms@gnu.org>
parents: 5367
diff changeset
2620
13245
2e0c4159e94b (describe_map_tree): New arg always_title. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 13201
diff changeset
2621 if (!NILP (maps) || always_title)
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2622 {
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2623 if (title)
4023
5e4f918d5d44 (describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents: 3962
diff changeset
2624 {
5e4f918d5d44 (describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents: 3962
diff changeset
2625 insert_string (title);
5e4f918d5d44 (describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents: 3962
diff changeset
2626 if (!NILP (prefix))
5e4f918d5d44 (describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents: 3962
diff changeset
2627 {
5e4f918d5d44 (describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents: 3962
diff changeset
2628 insert_string (" Starting With ");
5e4f918d5d44 (describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents: 3962
diff changeset
2629 insert1 (Fkey_description (prefix));
5e4f918d5d44 (describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents: 3962
diff changeset
2630 }
5e4f918d5d44 (describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents: 3962
diff changeset
2631 insert_string (":\n");
5e4f918d5d44 (describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents: 3962
diff changeset
2632 }
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2633 insert_string (key_heading);
4023
5e4f918d5d44 (describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents: 3962
diff changeset
2634 something = 1;
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2635 }
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2636
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
2637 for (; !NILP (maps); maps = Fcdr (maps))
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2638 {
7184
caac285c072d (describe_map_tree): gcpro some things.
Karl Heuer <kwzh@gnu.org>
parents: 7183
diff changeset
2639 register Lisp_Object elt, prefix, tail;
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2640
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2641 elt = Fcar (maps);
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2642 prefix = Fcar (elt);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2643
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2644 sub_shadows = Qnil;
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2645
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
2646 for (tail = shadow; CONSP (tail); tail = XCDR (tail))
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2647 {
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2648 Lisp_Object shmap;
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2649
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
2650 shmap = XCAR (tail);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2651
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2652 /* If the sequence by which we reach this keymap is zero-length,
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2653 then the shadow map for this keymap is just SHADOW. */
9123
c225137ddefb (get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents: 8922
diff changeset
2654 if ((STRINGP (prefix) && XSTRING (prefix)->size == 0)
c225137ddefb (get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents: 8922
diff changeset
2655 || (VECTORP (prefix) && XVECTOR (prefix)->size == 0))
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2656 ;
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2657 /* If the sequence by which we reach this keymap actually has
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2658 some elements, then the sequence's definition in SHADOW is
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2659 what we should use. */
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2660 else
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2661 {
6859
f34b91fa388c (describe_map_tree): Fix call to Flookup_key.
Richard M. Stallman <rms@gnu.org>
parents: 6834
diff changeset
2662 shmap = Flookup_key (shmap, Fcar (elt), Qt);
9123
c225137ddefb (get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents: 8922
diff changeset
2663 if (INTEGERP (shmap))
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2664 shmap = Qnil;
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2665 }
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2666
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2667 /* If shmap is not nil and not a keymap,
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2668 it completely shadows this map, so don't
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2669 describe this map at all. */
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2670 if (!NILP (shmap) && NILP (Fkeymapp (shmap)))
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2671 goto skip;
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2672
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2673 if (!NILP (shmap))
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2674 sub_shadows = Fcons (shmap, sub_shadows);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2675 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2676
20883
4aeabf3b8f98 (describe_map_tree): Add the maps we have already
Richard M. Stallman <rms@gnu.org>
parents: 20850
diff changeset
2677 /* Maps we have already listed in this loop shadow this map. */
4aeabf3b8f98 (describe_map_tree): Add the maps we have already
Richard M. Stallman <rms@gnu.org>
parents: 20850
diff changeset
2678 for (tail = orig_maps; ! EQ (tail, maps); tail = XCDR (tail))
4aeabf3b8f98 (describe_map_tree): Add the maps we have already
Richard M. Stallman <rms@gnu.org>
parents: 20850
diff changeset
2679 {
4aeabf3b8f98 (describe_map_tree): Add the maps we have already
Richard M. Stallman <rms@gnu.org>
parents: 20850
diff changeset
2680 Lisp_Object tem;
4aeabf3b8f98 (describe_map_tree): Add the maps we have already
Richard M. Stallman <rms@gnu.org>
parents: 20850
diff changeset
2681 tem = Fequal (Fcar (XCAR (tail)), prefix);
4aeabf3b8f98 (describe_map_tree): Add the maps we have already
Richard M. Stallman <rms@gnu.org>
parents: 20850
diff changeset
2682 if (! NILP (tem))
4aeabf3b8f98 (describe_map_tree): Add the maps we have already
Richard M. Stallman <rms@gnu.org>
parents: 20850
diff changeset
2683 sub_shadows = Fcons (XCDR (XCAR (tail)), sub_shadows);
4aeabf3b8f98 (describe_map_tree): Add the maps we have already
Richard M. Stallman <rms@gnu.org>
parents: 20850
diff changeset
2684 }
4aeabf3b8f98 (describe_map_tree): Add the maps we have already
Richard M. Stallman <rms@gnu.org>
parents: 20850
diff changeset
2685
4aeabf3b8f98 (describe_map_tree): Add the maps we have already
Richard M. Stallman <rms@gnu.org>
parents: 20850
diff changeset
2686 describe_map (Fcdr (elt), prefix,
12710
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2687 transl ? describe_translation : describe_command,
14129
d0b95da4f1f2 (describe_map): New arg nomenu.
Karl Heuer <kwzh@gnu.org>
parents: 14099
diff changeset
2688 partial, sub_shadows, &seen, nomenu);
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2689
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2690 skip: ;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2691 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2692
4023
5e4f918d5d44 (describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents: 3962
diff changeset
2693 if (something)
5e4f918d5d44 (describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents: 3962
diff changeset
2694 insert_string ("\n");
5e4f918d5d44 (describe_map_tree): When inserting TITLE, mention PREFIX.
Richard M. Stallman <rms@gnu.org>
parents: 3962
diff changeset
2695
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2696 UNGCPRO;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2697 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2698
14304
57194b6a555d (Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
2699 static int previous_description_column;
57194b6a555d (Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
2700
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2701 static void
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2702 describe_command (definition)
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2703 Lisp_Object definition;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2704 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2705 register Lisp_Object tem1;
14304
57194b6a555d (Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
2706 int column = current_column ();
57194b6a555d (Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
2707 int description_column;
57194b6a555d (Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
2708
57194b6a555d (Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
2709 /* If column 16 is no good, go to col 32;
57194b6a555d (Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
2710 but don't push beyond that--go to next line instead. */
57194b6a555d (Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
2711 if (column > 30)
57194b6a555d (Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
2712 {
57194b6a555d (Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
2713 insert_char ('\n');
57194b6a555d (Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
2714 description_column = 32;
57194b6a555d (Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
2715 }
57194b6a555d (Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
2716 else if (column > 14 || (column > 10 && previous_description_column == 32))
57194b6a555d (Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
2717 description_column = 32;
57194b6a555d (Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
2718 else
57194b6a555d (Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
2719 description_column = 16;
57194b6a555d (Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
2720
57194b6a555d (Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
2721 Findent_to (make_number (description_column), make_number (1));
57194b6a555d (Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
2722 previous_description_column = description_column;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2723
9123
c225137ddefb (get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents: 8922
diff changeset
2724 if (SYMBOLP (definition))
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2725 {
9273
129621997564 (synkey, Fdescribe_bindings, describe_command): Use new accessor macros
Karl Heuer <kwzh@gnu.org>
parents: 9123
diff changeset
2726 XSETSTRING (tem1, XSYMBOL (definition)->name);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2727 insert1 (tem1);
21539
b9606d56f91f Revert erroneous 1998-04-08 change.
Dave Love <fx@gnu.org>
parents: 21514
diff changeset
2728 insert_string ("\n");
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2729 }
12710
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2730 else if (STRINGP (definition) || VECTORP (definition))
5367
e4f5f2674f34 (describe_command): If binding is a kbd macro, say so.
Richard M. Stallman <rms@gnu.org>
parents: 5246
diff changeset
2731 insert_string ("Keyboard Macro\n");
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2732 else
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2733 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2734 tem1 = Fkeymapp (definition);
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
2735 if (!NILP (tem1))
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2736 insert_string ("Prefix Command\n");
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2737 else
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2738 insert_string ("??\n");
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2739 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2740 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2741
12710
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2742 static void
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2743 describe_translation (definition)
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2744 Lisp_Object definition;
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2745 {
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2746 register Lisp_Object tem1;
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2747
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2748 Findent_to (make_number (16), make_number (1));
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2749
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2750 if (SYMBOLP (definition))
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2751 {
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2752 XSETSTRING (tem1, XSYMBOL (definition)->name);
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2753 insert1 (tem1);
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2754 insert_string ("\n");
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2755 }
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2756 else if (STRINGP (definition) || VECTORP (definition))
13343
cc0f24bdfab1 (describe_translation): Insert newline after key description.
Richard M. Stallman <rms@gnu.org>
parents: 13245
diff changeset
2757 {
cc0f24bdfab1 (describe_translation): Insert newline after key description.
Richard M. Stallman <rms@gnu.org>
parents: 13245
diff changeset
2758 insert1 (Fkey_description (definition));
cc0f24bdfab1 (describe_translation): Insert newline after key description.
Richard M. Stallman <rms@gnu.org>
parents: 13245
diff changeset
2759 insert_string ("\n");
cc0f24bdfab1 (describe_translation): Insert newline after key description.
Richard M. Stallman <rms@gnu.org>
parents: 13245
diff changeset
2760 }
12710
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2761 else
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2762 {
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2763 tem1 = Fkeymapp (definition);
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2764 if (!NILP (tem1))
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2765 insert_string ("Prefix Command\n");
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2766 else
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2767 insert_string ("??\n");
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2768 }
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2769 }
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
2770
6974
ab22b527d380 (describe_map): Merge with describe_map_2.
Karl Heuer <kwzh@gnu.org>
parents: 6859
diff changeset
2771 /* Describe the contents of map MAP, assuming that this map itself is
ab22b527d380 (describe_map): Merge with describe_map_2.
Karl Heuer <kwzh@gnu.org>
parents: 6859
diff changeset
2772 reached by the sequence of prefix keys KEYS (a string or vector).
14129
d0b95da4f1f2 (describe_map): New arg nomenu.
Karl Heuer <kwzh@gnu.org>
parents: 14099
diff changeset
2773 PARTIAL, SHADOW, NOMENU are as in `describe_map_tree' above. */
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2774
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2775 static void
14129
d0b95da4f1f2 (describe_map): New arg nomenu.
Karl Heuer <kwzh@gnu.org>
parents: 14099
diff changeset
2776 describe_map (map, keys, elt_describer, partial, shadow, seen, nomenu)
6974
ab22b527d380 (describe_map): Merge with describe_map_2.
Karl Heuer <kwzh@gnu.org>
parents: 6859
diff changeset
2777 register Lisp_Object map;
ab22b527d380 (describe_map): Merge with describe_map_2.
Karl Heuer <kwzh@gnu.org>
parents: 6859
diff changeset
2778 Lisp_Object keys;
20381
1dd3842977c0 (describe_map): Fix decl of arg ELT_DESCRIBER.
Andreas Schwab <schwab@suse.de>
parents: 20374
diff changeset
2779 void (*elt_describer) P_ ((Lisp_Object));
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2780 int partial;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2781 Lisp_Object shadow;
6976
4d540eeb2dd5 (describe_map_tree, describe_map): Skip keymaps we've seen before.
Karl Heuer <kwzh@gnu.org>
parents: 6974
diff changeset
2782 Lisp_Object *seen;
14129
d0b95da4f1f2 (describe_map): New arg nomenu.
Karl Heuer <kwzh@gnu.org>
parents: 14099
diff changeset
2783 int nomenu;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2784 {
6974
ab22b527d380 (describe_map): Merge with describe_map_2.
Karl Heuer <kwzh@gnu.org>
parents: 6859
diff changeset
2785 Lisp_Object elt_prefix;
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2786 Lisp_Object tail, definition, event;
3908
a148b4ff79c6 (describe_map_2): Cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 3735
diff changeset
2787 Lisp_Object tem;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2788 Lisp_Object suppress;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2789 Lisp_Object kludge;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2790 int first = 1;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2791 struct gcpro gcpro1, gcpro2, gcpro3;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2792
31829
43566b0aec59 Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents: 31496
diff changeset
2793 suppress = Qnil;
43566b0aec59 Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents: 31496
diff changeset
2794
6974
ab22b527d380 (describe_map): Merge with describe_map_2.
Karl Heuer <kwzh@gnu.org>
parents: 6859
diff changeset
2795 if (!NILP (keys) && XFASTINT (Flength (keys)) > 0)
ab22b527d380 (describe_map): Merge with describe_map_2.
Karl Heuer <kwzh@gnu.org>
parents: 6859
diff changeset
2796 {
ab22b527d380 (describe_map): Merge with describe_map_2.
Karl Heuer <kwzh@gnu.org>
parents: 6859
diff changeset
2797 /* Call Fkey_description first, to avoid GC bug for the other string. */
ab22b527d380 (describe_map): Merge with describe_map_2.
Karl Heuer <kwzh@gnu.org>
parents: 6859
diff changeset
2798 tem = Fkey_description (keys);
ab22b527d380 (describe_map): Merge with describe_map_2.
Karl Heuer <kwzh@gnu.org>
parents: 6859
diff changeset
2799 elt_prefix = concat2 (tem, build_string (" "));
ab22b527d380 (describe_map): Merge with describe_map_2.
Karl Heuer <kwzh@gnu.org>
parents: 6859
diff changeset
2800 }
ab22b527d380 (describe_map): Merge with describe_map_2.
Karl Heuer <kwzh@gnu.org>
parents: 6859
diff changeset
2801 else
ab22b527d380 (describe_map): Merge with describe_map_2.
Karl Heuer <kwzh@gnu.org>
parents: 6859
diff changeset
2802 elt_prefix = Qnil;
ab22b527d380 (describe_map): Merge with describe_map_2.
Karl Heuer <kwzh@gnu.org>
parents: 6859
diff changeset
2803
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2804 if (partial)
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2805 suppress = intern ("suppress-keymap");
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2806
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2807 /* This vector gets used to present single keys to Flookup_key. Since
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2808 that is done once per keymap element, we don't want to cons up a
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2809 fresh vector every time. */
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2810 kludge = Fmake_vector (make_number (1), Qnil);
3908
a148b4ff79c6 (describe_map_2): Cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 3735
diff changeset
2811 definition = Qnil;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2812
3908
a148b4ff79c6 (describe_map_2): Cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 3735
diff changeset
2813 GCPRO3 (elt_prefix, definition, kludge);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2814
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
2815 for (tail = map; CONSP (tail); tail = XCDR (tail))
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2816 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2817 QUIT;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2818
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
2819 if (VECTORP (XCAR (tail))
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
2820 || CHAR_TABLE_P (XCAR (tail)))
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
2821 describe_vector (XCAR (tail),
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2822 elt_prefix, elt_describer, partial, shadow, map,
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2823 (int *)0, 0);
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
2824 else if (CONSP (XCAR (tail)))
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2825 {
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
2826 event = XCAR (XCAR (tail));
7341
516dd16e2017 (describe_map): Ignore bindings for all except symbols and integers.
Richard M. Stallman <rms@gnu.org>
parents: 7191
diff changeset
2827
516dd16e2017 (describe_map): Ignore bindings for all except symbols and integers.
Richard M. Stallman <rms@gnu.org>
parents: 7191
diff changeset
2828 /* Ignore bindings whose "keys" are not really valid events.
516dd16e2017 (describe_map): Ignore bindings for all except symbols and integers.
Richard M. Stallman <rms@gnu.org>
parents: 7191
diff changeset
2829 (We get these in the frames and buffers menu.) */
516dd16e2017 (describe_map): Ignore bindings for all except symbols and integers.
Richard M. Stallman <rms@gnu.org>
parents: 7191
diff changeset
2830 if (! (SYMBOLP (event) || INTEGERP (event)))
7191
bd2f9c5ee54e (Fsingle_key_description): Undo previous change.
Karl Heuer <kwzh@gnu.org>
parents: 7186
diff changeset
2831 continue;
7341
516dd16e2017 (describe_map): Ignore bindings for all except symbols and integers.
Richard M. Stallman <rms@gnu.org>
parents: 7191
diff changeset
2832
14129
d0b95da4f1f2 (describe_map): New arg nomenu.
Karl Heuer <kwzh@gnu.org>
parents: 14099
diff changeset
2833 if (nomenu && EQ (event, Qmenu_bar))
d0b95da4f1f2 (describe_map): New arg nomenu.
Karl Heuer <kwzh@gnu.org>
parents: 14099
diff changeset
2834 continue;
d0b95da4f1f2 (describe_map): New arg nomenu.
Karl Heuer <kwzh@gnu.org>
parents: 14099
diff changeset
2835
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
2836 definition = get_keyelt (XCDR (XCAR (tail)), 0);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2837
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2838 /* Don't show undefined commands or suppressed commands. */
3908
a148b4ff79c6 (describe_map_2): Cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 3735
diff changeset
2839 if (NILP (definition)) continue;
9123
c225137ddefb (get_keyelt, store_in_keymap, Fcopy_keymap, Fdefine_key, Flookup_key,
Karl Heuer <kwzh@gnu.org>
parents: 8922
diff changeset
2840 if (SYMBOLP (definition) && partial)
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2841 {
3908
a148b4ff79c6 (describe_map_2): Cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 3735
diff changeset
2842 tem = Fget (definition, suppress);
a148b4ff79c6 (describe_map_2): Cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 3735
diff changeset
2843 if (!NILP (tem))
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2844 continue;
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2845 }
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2846
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2847 /* Don't show a command that isn't really visible
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2848 because a local definition of the same key shadows it. */
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2849
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
2850 ASET (kludge, 0, event);
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2851 if (!NILP (shadow))
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2852 {
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
2853 tem = shadow_lookup (shadow, kludge, Qt);
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2854 if (!NILP (tem)) continue;
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2855 }
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2856
6974
ab22b527d380 (describe_map): Merge with describe_map_2.
Karl Heuer <kwzh@gnu.org>
parents: 6859
diff changeset
2857 tem = Flookup_key (map, kludge, Qt);
3908
a148b4ff79c6 (describe_map_2): Cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 3735
diff changeset
2858 if (! EQ (tem, definition)) continue;
a148b4ff79c6 (describe_map_2): Cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 3735
diff changeset
2859
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2860 if (first)
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2861 {
14304
57194b6a555d (Faccessible_keymaps): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
2862 previous_description_column = 0;
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2863 insert ("\n", 1);
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2864 first = 0;
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2865 }
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2866
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2867 if (!NILP (elt_prefix))
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2868 insert1 (elt_prefix);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2869
3908
a148b4ff79c6 (describe_map_2): Cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 3735
diff changeset
2870 /* THIS gets the string to describe the character EVENT. */
30559
16a291eedbd8 (Fsingle_key_description): Add parameter NO_ANGLES.
Gerd Moellmann <gerd@gnu.org>
parents: 30134
diff changeset
2871 insert1 (Fsingle_key_description (event, Qnil));
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2872
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2873 /* Print a description of the definition of this character.
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2874 elt_describer will take care of spacing out far enough
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2875 for alignment purposes. */
3908
a148b4ff79c6 (describe_map_2): Cleanups.
Richard M. Stallman <rms@gnu.org>
parents: 3735
diff changeset
2876 (*elt_describer) (definition);
1209
1aa2cd425737 * keymap.c (DENSE_TABLE_SIZE): Doc fix.
Jim Blandy <jimb@redhat.com>
parents: 1160
diff changeset
2877 }
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
2878 else if (EQ (XCAR (tail), Qkeymap))
6976
4d540eeb2dd5 (describe_map_tree, describe_map): Skip keymaps we've seen before.
Karl Heuer <kwzh@gnu.org>
parents: 6974
diff changeset
2879 {
4d540eeb2dd5 (describe_map_tree, describe_map): Skip keymaps we've seen before.
Karl Heuer <kwzh@gnu.org>
parents: 6974
diff changeset
2880 /* The same keymap might be in the structure twice, if we're
4d540eeb2dd5 (describe_map_tree, describe_map): Skip keymaps we've seen before.
Karl Heuer <kwzh@gnu.org>
parents: 6974
diff changeset
2881 using an inherited keymap. So skip anything we've already
4d540eeb2dd5 (describe_map_tree, describe_map): Skip keymaps we've seen before.
Karl Heuer <kwzh@gnu.org>
parents: 6974
diff changeset
2882 encountered. */
4d540eeb2dd5 (describe_map_tree, describe_map): Skip keymaps we've seen before.
Karl Heuer <kwzh@gnu.org>
parents: 6974
diff changeset
2883 tem = Fassq (tail, *seen);
25662
0a7261c1d487 Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents: 25600
diff changeset
2884 if (CONSP (tem) && !NILP (Fequal (XCAR (tem), keys)))
6976
4d540eeb2dd5 (describe_map_tree, describe_map): Skip keymaps we've seen before.
Karl Heuer <kwzh@gnu.org>
parents: 6974
diff changeset
2885 break;
4d540eeb2dd5 (describe_map_tree, describe_map): Skip keymaps we've seen before.
Karl Heuer <kwzh@gnu.org>
parents: 6974
diff changeset
2886 *seen = Fcons (Fcons (tail, keys), *seen);
4d540eeb2dd5 (describe_map_tree, describe_map): Skip keymaps we've seen before.
Karl Heuer <kwzh@gnu.org>
parents: 6974
diff changeset
2887 }
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2888 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2889
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2890 UNGCPRO;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2891 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2892
20319
81424cf4d446 (copy_keymap_1): Fix return type.
Andreas Schwab <schwab@suse.de>
parents: 20076
diff changeset
2893 static void
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2894 describe_vector_princ (elt)
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2895 Lisp_Object elt;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2896 {
3691
49ce2242f5c1 (get_keymap_1): Add missing semicolon.
Richard M. Stallman <rms@gnu.org>
parents: 3674
diff changeset
2897 Findent_to (make_number (16), make_number (1));
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2898 Fprinc (elt, Qnil);
3632
72cfde0cd8cd (Fdescribe_vector): Use current buf, not standard-output.
Richard M. Stallman <rms@gnu.org>
parents: 3542
diff changeset
2899 Fterpri (Qnil);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2900 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2901
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2902 DEFUN ("describe-vector", Fdescribe_vector, Sdescribe_vector, 1, 1, 0,
3632
72cfde0cd8cd (Fdescribe_vector): Use current buf, not standard-output.
Richard M. Stallman <rms@gnu.org>
parents: 3542
diff changeset
2903 "Insert a description of contents of VECTOR.\n\
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2904 This is text showing the elements of vector matched against indices.")
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2905 (vector)
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2906 Lisp_Object vector;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2907 {
3632
72cfde0cd8cd (Fdescribe_vector): Use current buf, not standard-output.
Richard M. Stallman <rms@gnu.org>
parents: 3542
diff changeset
2908 int count = specpdl_ptr - specpdl;
72cfde0cd8cd (Fdescribe_vector): Use current buf, not standard-output.
Richard M. Stallman <rms@gnu.org>
parents: 3542
diff changeset
2909
72cfde0cd8cd (Fdescribe_vector): Use current buf, not standard-output.
Richard M. Stallman <rms@gnu.org>
parents: 3542
diff changeset
2910 specbind (Qstandard_output, Fcurrent_buffer ());
13201
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
2911 CHECK_VECTOR_OR_CHAR_TABLE (vector, 0);
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2912 describe_vector (vector, Qnil, describe_vector_princ, 0,
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2913 Qnil, Qnil, (int *)0, 0);
3632
72cfde0cd8cd (Fdescribe_vector): Use current buf, not standard-output.
Richard M. Stallman <rms@gnu.org>
parents: 3542
diff changeset
2914
72cfde0cd8cd (Fdescribe_vector): Use current buf, not standard-output.
Richard M. Stallman <rms@gnu.org>
parents: 3542
diff changeset
2915 return unbind_to (count, Qnil);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2916 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2917
13201
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
2918 /* Insert in the current buffer a description of the contents of VECTOR.
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
2919 We call ELT_DESCRIBER to insert the description of one value found
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
2920 in VECTOR.
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
2921
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
2922 ELT_PREFIX describes what "comes before" the keys or indices defined
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2923 by this vector. This is a human-readable string whose size
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2924 is not necessarily related to the situation.
13201
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
2925
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
2926 If the vector is in a keymap, ELT_PREFIX is a prefix key which
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
2927 leads to this keymap.
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
2928
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
2929 If the vector is a chartable, ELT_PREFIX is the vector
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
2930 of bytes that lead to the character set or portion of a character
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
2931 set described by this chartable.
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
2932
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
2933 If PARTIAL is nonzero, it means do not mention suppressed commands
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
2934 (that assumes the vector is in a keymap).
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
2935
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
2936 SHADOW is a list of keymaps that shadow this map.
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
2937 If it is non-nil, then we look up the key in those maps
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
2938 and we don't mention it now if it is defined by any of them.
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
2939
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
2940 ENTIRE_MAP is the keymap in which this vector appears.
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
2941 If the definition in effect in the whole map does not match
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2942 the one in this vector, we ignore this one.
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2943
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2944 When describing a sub-char-table, INDICES is a list of
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2945 indices at higher levels in this char-table,
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2946 and CHAR_TABLE_DEPTH says how many levels down we have gone. */
13201
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
2947
20374
0b6c4f1041ae (describe_vector): Declaration fixed (delete `.' at the
Kenichi Handa <handa@m17n.org>
parents: 20319
diff changeset
2948 void
11973
4e0f3e3b4cc7 (describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents: 11924
diff changeset
2949 describe_vector (vector, elt_prefix, elt_describer,
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2950 partial, shadow, entire_map,
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2951 indices, char_table_depth)
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2952 register Lisp_Object vector;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2953 Lisp_Object elt_prefix;
20319
81424cf4d446 (copy_keymap_1): Fix return type.
Andreas Schwab <schwab@suse.de>
parents: 20076
diff changeset
2954 void (*elt_describer) P_ ((Lisp_Object));
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2955 int partial;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2956 Lisp_Object shadow;
11973
4e0f3e3b4cc7 (describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents: 11924
diff changeset
2957 Lisp_Object entire_map;
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2958 int *indices;
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2959 int char_table_depth;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2960 {
11973
4e0f3e3b4cc7 (describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents: 11924
diff changeset
2961 Lisp_Object definition;
4e0f3e3b4cc7 (describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents: 11924
diff changeset
2962 Lisp_Object tem2;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2963 register int i;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2964 Lisp_Object suppress;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2965 Lisp_Object kludge;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2966 int first = 1;
25785
0d701c4484e3 (Flookup_key, Faccessible_keymaps, describe_vector,
Gerd Moellmann <gerd@gnu.org>
parents: 25662
diff changeset
2967 struct gcpro gcpro1, gcpro2, gcpro3;
17036
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
2968 /* Range of elements to be handled. */
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
2969 int from, to;
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
2970 /* A flag to tell if a leaf in this level of char-table is not a
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
2971 generic character (i.e. a complete multibyte character). */
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
2972 int complete_char;
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2973 int character;
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2974 int starting_i;
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2975
31829
43566b0aec59 Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents: 31496
diff changeset
2976 suppress = Qnil;
43566b0aec59 Avoid some more compiler warnings.
Gerd Moellmann <gerd@gnu.org>
parents: 31496
diff changeset
2977
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2978 if (indices == 0)
18613
614b916ff5bf Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents: 18142
diff changeset
2979 indices = (int *) alloca (3 * sizeof (int));
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2980
11973
4e0f3e3b4cc7 (describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents: 11924
diff changeset
2981 definition = Qnil;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2982
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2983 /* This vector gets used to present single keys to Flookup_key. Since
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2984 that is done once per vector element, we don't want to cons up a
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2985 fresh vector every time. */
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2986 kludge = Fmake_vector (make_number (1), Qnil);
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2987 GCPRO3 (elt_prefix, definition, kludge);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2988
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2989 if (partial)
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2990 suppress = intern ("suppress-keymap");
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2991
17036
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
2992 if (CHAR_TABLE_P (vector))
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
2993 {
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2994 if (char_table_depth == 0)
17036
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
2995 {
17327
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
2996 /* VECTOR is a top level char-table. */
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
2997 complete_char = 1;
17036
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
2998 from = 0;
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
2999 to = CHAR_TABLE_ORDINARY_SLOTS;
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3000 }
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3001 else
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3002 {
17327
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3003 /* VECTOR is a sub char-table. */
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3004 if (char_table_depth >= 3)
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3005 /* A char-table is never that deep. */
17327
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3006 error ("Too deep char table");
17036
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3007
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3008 complete_char
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3009 = (CHARSET_VALID_P (indices[0])
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3010 && ((CHARSET_DIMENSION (indices[0]) == 1
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3011 && char_table_depth == 1)
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3012 || char_table_depth == 2));
17036
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3013
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3014 /* Meaningful elements are from 32th to 127th. */
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3015 from = 32;
17327
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3016 to = SUB_CHAR_TABLE_ORDINARY_SLOTS;
17036
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3017 }
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3018 }
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3019 else
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3020 {
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3021 /* This does the right thing for ordinary vectors. */
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3022
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3023 complete_char = 1;
17036
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3024 from = 0;
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3025 to = XVECTOR (vector)->size;
17036
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3026 }
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3027
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3028 for (i = from; i < to; i++)
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3029 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3030 QUIT;
17189
7c008ec99e97 (describe_vector): Adjusted for the change of CHAR_TABLE_ORDINARY_SLOTS.
Kenichi Handa <handa@m17n.org>
parents: 17111
diff changeset
3031
17327
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3032 if (CHAR_TABLE_P (vector))
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3033 {
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3034 if (char_table_depth == 0 && i >= CHAR_TABLE_SINGLE_BYTE_SLOTS)
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3035 complete_char = 0;
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3036
17327
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3037 if (i >= CHAR_TABLE_SINGLE_BYTE_SLOTS
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3038 && !CHARSET_DEFINED_P (i - 128))
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3039 continue;
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3040
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3041 definition
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3042 = get_keyelt (XCHAR_TABLE (vector)->contents[i], 0);
17327
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3043 }
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3044 else
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
3045 definition = get_keyelt (AREF (vector, i), 0);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3046
17511
10ead0052174 (describe_vector): Test for suppressed commands in
Richard M. Stallman <rms@gnu.org>
parents: 17510
diff changeset
3047 if (NILP (definition)) continue;
10ead0052174 (describe_vector): Test for suppressed commands in
Richard M. Stallman <rms@gnu.org>
parents: 17510
diff changeset
3048
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3049 /* Don't mention suppressed commands. */
11973
4e0f3e3b4cc7 (describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents: 11924
diff changeset
3050 if (SYMBOLP (definition) && partial)
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3051 {
17036
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3052 Lisp_Object tem;
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3053
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3054 tem = Fget (definition, suppress);
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3055
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3056 if (!NILP (tem)) continue;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3057 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3058
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3059 /* Set CHARACTER to the character this entry describes, if any.
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3060 Also update *INDICES. */
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3061 if (CHAR_TABLE_P (vector))
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3062 {
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3063 indices[char_table_depth] = i;
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3064
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3065 if (char_table_depth == 0)
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3066 {
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3067 character = i;
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3068 indices[0] = i - 128;
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3069 }
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3070 else if (complete_char)
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3071 {
29013
b9565b4bcdf8 (Fsingle_key_description): Use SPLIT_CHAR instead of
Kenichi Handa <handa@m17n.org>
parents: 26864
diff changeset
3072 character = MAKE_CHAR (indices[0], indices[1], indices[2]);
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3073 }
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3074 else
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3075 character = 0;
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3076 }
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3077 else
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3078 character = i;
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3079
11973
4e0f3e3b4cc7 (describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents: 11924
diff changeset
3080 /* If this binding is shadowed by some other map, ignore it. */
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3081 if (!NILP (shadow) && complete_char)
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3082 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3083 Lisp_Object tem;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3084
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
3085 ASET (kludge, 0, make_number (character));
3952
f9dfc2872fb0 (describe_map_tree): Insert key_heading here.
Richard M. Stallman <rms@gnu.org>
parents: 3908
diff changeset
3086 tem = shadow_lookup (shadow, kludge, Qt);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3087
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
3088 if (!NILP (tem)) continue;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3089 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3090
11973
4e0f3e3b4cc7 (describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents: 11924
diff changeset
3091 /* Ignore this definition if it is shadowed by an earlier
4e0f3e3b4cc7 (describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents: 11924
diff changeset
3092 one in the same keymap. */
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3093 if (!NILP (entire_map) && complete_char)
11973
4e0f3e3b4cc7 (describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents: 11924
diff changeset
3094 {
4e0f3e3b4cc7 (describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents: 11924
diff changeset
3095 Lisp_Object tem;
4e0f3e3b4cc7 (describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents: 11924
diff changeset
3096
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
3097 ASET (kludge, 0, make_number (character));
11973
4e0f3e3b4cc7 (describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents: 11924
diff changeset
3098 tem = Flookup_key (entire_map, kludge, Qt);
4e0f3e3b4cc7 (describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents: 11924
diff changeset
3099
4e0f3e3b4cc7 (describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents: 11924
diff changeset
3100 if (! EQ (tem, definition))
4e0f3e3b4cc7 (describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents: 11924
diff changeset
3101 continue;
4e0f3e3b4cc7 (describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents: 11924
diff changeset
3102 }
4e0f3e3b4cc7 (describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents: 11924
diff changeset
3103
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3104 if (first)
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3105 {
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3106 if (char_table_depth == 0)
17036
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3107 insert ("\n", 1);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3108 first = 0;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3109 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3110
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3111 /* For a sub char-table, show the depth by indentation.
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3112 CHAR_TABLE_DEPTH can be greater than 0 only for a char-table. */
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3113 if (char_table_depth > 0)
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3114 insert (" ", char_table_depth * 2); /* depth is 1 or 2. */
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3115
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3116 /* Output the prefix that applies to every entry in this map. */
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3117 if (!NILP (elt_prefix))
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3118 insert1 (elt_prefix);
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3119
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3120 /* Insert or describe the character this slot is for,
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3121 or a description of what it is for. */
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3122 if (SUB_CHAR_TABLE_P (vector))
17327
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3123 {
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3124 if (complete_char)
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3125 insert_char (character);
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3126 else
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3127 {
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3128 /* We need an octal representation for this block of
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3129 characters. */
17795
41b7d56b62fb (describe_vector): Identify charset row numbers clearly.
Richard M. Stallman <rms@gnu.org>
parents: 17788
diff changeset
3130 char work[16];
41b7d56b62fb (describe_vector): Identify charset row numbers clearly.
Richard M. Stallman <rms@gnu.org>
parents: 17788
diff changeset
3131 sprintf (work, "(row %d)", i);
41b7d56b62fb (describe_vector): Identify charset row numbers clearly.
Richard M. Stallman <rms@gnu.org>
parents: 17788
diff changeset
3132 insert (work, strlen (work));
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3133 }
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3134 }
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3135 else if (CHAR_TABLE_P (vector))
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3136 {
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3137 if (complete_char)
30559
16a291eedbd8 (Fsingle_key_description): Add parameter NO_ANGLES.
Gerd Moellmann <gerd@gnu.org>
parents: 30134
diff changeset
3138 insert1 (Fsingle_key_description (make_number (character), Qnil));
17327
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3139 else
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3140 {
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3141 /* Print the information for this character set. */
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3142 insert_string ("<");
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3143 tem2 = CHARSET_TABLE_INFO (i - 128, CHARSET_SHORT_NAME_IDX);
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3144 if (STRINGP (tem2))
20624
9ac0b485cf60 (describe_vector): Unconditionally handle multibyte chars.
Richard M. Stallman <rms@gnu.org>
parents: 20576
diff changeset
3145 insert_from_string (tem2, 0, 0, XSTRING (tem2)->size,
21244
50929073a0ba Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents: 21241
diff changeset
3146 STRING_BYTES (XSTRING (tem2)), 0);
17327
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3147 else
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3148 insert ("?", 1);
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3149 insert (">", 1);
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3150 }
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3151 }
13201
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
3152 else
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
3153 {
30559
16a291eedbd8 (Fsingle_key_description): Add parameter NO_ANGLES.
Gerd Moellmann <gerd@gnu.org>
parents: 30134
diff changeset
3154 insert1 (Fsingle_key_description (make_number (character), Qnil));
17036
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3155 }
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3156
17327
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3157 /* If we find a sub char-table within a char-table,
17036
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3158 scan it recursively; it defines the details for
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3159 a character set or a portion of a character set. */
20624
9ac0b485cf60 (describe_vector): Unconditionally handle multibyte chars.
Richard M. Stallman <rms@gnu.org>
parents: 20576
diff changeset
3160 if (CHAR_TABLE_P (vector) && SUB_CHAR_TABLE_P (definition))
17036
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3161 {
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3162 insert ("\n", 1);
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3163 describe_vector (definition, elt_prefix, elt_describer,
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3164 partial, shadow, entire_map,
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3165 indices, char_table_depth + 1);
17036
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3166 continue;
13201
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
3167 }
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3168
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3169 starting_i = i;
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3170
17795
41b7d56b62fb (describe_vector): Identify charset row numbers clearly.
Richard M. Stallman <rms@gnu.org>
parents: 17788
diff changeset
3171 /* Find all consecutive characters or rows that have the same
17327
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3172 definition. But, for elements of a top level char table, if
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3173 they are for charsets, we had better describe one by one even
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3174 if they have the same definition. */
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3175 if (CHAR_TABLE_P (vector))
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3176 {
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3177 int limit = to;
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3178
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3179 if (char_table_depth == 0)
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3180 limit = CHAR_TABLE_SINGLE_BYTE_SLOTS;
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3181
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3182 while (i + 1 < limit
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3183 && (tem2 = get_keyelt (XCHAR_TABLE (vector)->contents[i + 1], 0),
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3184 !NILP (tem2))
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3185 && !NILP (Fequal (tem2, definition)))
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3186 i++;
17327
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3187 }
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3188 else
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3189 while (i + 1 < to
32846
c1b3ab2a1ccc Use AREF, ASET and ASIZE macros.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32844
diff changeset
3190 && (tem2 = get_keyelt (AREF (vector, i + 1), 0),
17327
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3191 !NILP (tem2))
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3192 && !NILP (Fequal (tem2, definition)))
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3193 i++;
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3194
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3195
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3196 /* If we have a range of more than one character,
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3197 print where the range reaches to. */
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3198
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3199 if (i != starting_i)
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3200 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3201 insert (" .. ", 4);
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3202
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3203 if (!NILP (elt_prefix))
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3204 insert1 (elt_prefix);
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3205
13201
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
3206 if (CHAR_TABLE_P (vector))
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
3207 {
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3208 if (char_table_depth == 0)
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3209 {
30559
16a291eedbd8 (Fsingle_key_description): Add parameter NO_ANGLES.
Gerd Moellmann <gerd@gnu.org>
parents: 30134
diff changeset
3210 insert1 (Fsingle_key_description (make_number (i), Qnil));
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3211 }
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3212 else if (complete_char)
13201
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
3213 {
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3214 indices[char_table_depth] = i;
29013
b9565b4bcdf8 (Fsingle_key_description): Use SPLIT_CHAR instead of
Kenichi Handa <handa@m17n.org>
parents: 26864
diff changeset
3215 character = MAKE_CHAR (indices[0], indices[1], indices[2]);
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3216 insert_char (character);
17036
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3217 }
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3218 else
17036
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3219 {
17795
41b7d56b62fb (describe_vector): Identify charset row numbers clearly.
Richard M. Stallman <rms@gnu.org>
parents: 17788
diff changeset
3220 /* We need an octal representation for this block of
41b7d56b62fb (describe_vector): Identify charset row numbers clearly.
Richard M. Stallman <rms@gnu.org>
parents: 17788
diff changeset
3221 characters. */
41b7d56b62fb (describe_vector): Identify charset row numbers clearly.
Richard M. Stallman <rms@gnu.org>
parents: 17788
diff changeset
3222 char work[16];
41b7d56b62fb (describe_vector): Identify charset row numbers clearly.
Richard M. Stallman <rms@gnu.org>
parents: 17788
diff changeset
3223 sprintf (work, "(row %d)", i);
41b7d56b62fb (describe_vector): Identify charset row numbers clearly.
Richard M. Stallman <rms@gnu.org>
parents: 17788
diff changeset
3224 insert (work, strlen (work));
13201
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
3225 }
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
3226 }
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
3227 else
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
3228 {
30559
16a291eedbd8 (Fsingle_key_description): Add parameter NO_ANGLES.
Gerd Moellmann <gerd@gnu.org>
parents: 30134
diff changeset
3229 insert1 (Fsingle_key_description (make_number (i), Qnil));
13201
e9007fec678e (describe_vector): Support nested char-tables.
Richard M. Stallman <rms@gnu.org>
parents: 13145
diff changeset
3230 }
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3231 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3232
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3233 /* Print a description of the definition of this character.
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3234 elt_describer will take care of spacing out far enough
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3235 for alignment purposes. */
11973
4e0f3e3b4cc7 (describe_vector): New arg entire_map.
Karl Heuer <kwzh@gnu.org>
parents: 11924
diff changeset
3236 (*elt_describer) (definition);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3237 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3238
17327
0cb065f8702e (describe_vector): Adjusted for the new structure of Lisp_Char_Table.
Kenichi Handa <handa@m17n.org>
parents: 17264
diff changeset
3239 /* For (sub) char-table, print `defalt' slot at last. */
17036
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3240 if (CHAR_TABLE_P (vector) && !NILP (XCHAR_TABLE (vector)->defalt))
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3241 {
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3242 insert (" ", char_table_depth * 2);
17036
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3243 insert_string ("<<default>>");
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3244 (*elt_describer) (XCHAR_TABLE (vector)->defalt);
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3245 }
7e4c52fd4430 Include charset.h.
Karl Heuer <kwzh@gnu.org>
parents: 16875
diff changeset
3246
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3247 UNGCPRO;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3248 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3249
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
3250 /* Apropos - finding all symbols whose names match a regexp. */
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3251 Lisp_Object apropos_predicate;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3252 Lisp_Object apropos_accumulate;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3253
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3254 static void
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3255 apropos_accum (symbol, string)
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3256 Lisp_Object symbol, string;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3257 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3258 register Lisp_Object tem;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3259
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3260 tem = Fstring_match (string, Fsymbol_name (symbol), Qnil);
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
3261 if (!NILP (tem) && !NILP (apropos_predicate))
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3262 tem = call1 (apropos_predicate, symbol);
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 465
diff changeset
3263 if (!NILP (tem))
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3264 apropos_accumulate = Fcons (symbol, apropos_accumulate);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3265 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3266
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3267 DEFUN ("apropos-internal", Fapropos_internal, Sapropos_internal, 1, 2, 0,
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3268 "Show all symbols whose names contain match for REGEXP.\n\
14080
439185f0ef37 (Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents: 13947
diff changeset
3269 If optional 2nd arg PREDICATE is non-nil, (funcall PREDICATE SYMBOL) is done\n\
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3270 for each symbol and a symbol is mentioned only if that returns non-nil.\n\
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3271 Return list of symbols found.")
14080
439185f0ef37 (Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents: 13947
diff changeset
3272 (regexp, predicate)
439185f0ef37 (Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents: 13947
diff changeset
3273 Lisp_Object regexp, predicate;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3274 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3275 struct gcpro gcpro1, gcpro2;
14099
6215cbb7f702 (Fapropos_internal): Fix previous change.
Karl Heuer <kwzh@gnu.org>
parents: 14080
diff changeset
3276 CHECK_STRING (regexp, 0);
14080
439185f0ef37 (Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents: 13947
diff changeset
3277 apropos_predicate = predicate;
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3278 GCPRO2 (apropos_predicate, apropos_accumulate);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3279 apropos_accumulate = Qnil;
14080
439185f0ef37 (Fkeymapp, Fdefine_prefix_command, Faccessible_keymaps,
Erik Naggum <erik@naggum.no>
parents: 13947
diff changeset
3280 map_obarray (Vobarray, apropos_accum, regexp);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3281 apropos_accumulate = Fsort (apropos_accumulate, Qstring_lessp);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3282 UNGCPRO;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3283 return apropos_accumulate;
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3284 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3285
21514
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 21429
diff changeset
3286 void
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3287 syms_of_keymap ()
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3288 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3289 Qkeymap = intern ("keymap");
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3290 staticpro (&Qkeymap);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3291
17788
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3292 /* Now we are ready to set up this property, so we can
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3293 create char tables. */
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3294 Fput (Qkeymap, Qchar_table_extra_slots, make_number (0));
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3295
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3296 /* Initialize the keymaps standardly used.
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3297 Each one is the value of a Lisp variable, and is also
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3298 pointed to by a C variable */
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3299
208d71ea3a4f (get_keyelt): Handle an indirect entry with meta char.
Richard M. Stallman <rms@gnu.org>
parents: 17511
diff changeset
3300 global_map = Fmake_keymap (Qnil);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3301 Fset (intern ("global-map"), global_map);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3302
16125
2e0a45264368 (syms_of_keymap): staticpro current_global_map;
Richard M. Stallman <rms@gnu.org>
parents: 15422
diff changeset
3303 current_global_map = global_map;
16227
6acf08913847 (syms_of_keymap): staticpro global_map.
Erik Naggum <erik@naggum.no>
parents: 16125
diff changeset
3304 staticpro (&global_map);
16125
2e0a45264368 (syms_of_keymap): staticpro current_global_map;
Richard M. Stallman <rms@gnu.org>
parents: 15422
diff changeset
3305 staticpro (&current_global_map);
2e0a45264368 (syms_of_keymap): staticpro current_global_map;
Richard M. Stallman <rms@gnu.org>
parents: 15422
diff changeset
3306
1095
6578f07e9eb8 (Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 647
diff changeset
3307 meta_map = Fmake_keymap (Qnil);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3308 Fset (intern ("esc-map"), meta_map);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3309 Ffset (intern ("ESC-prefix"), meta_map);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3310
1095
6578f07e9eb8 (Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 647
diff changeset
3311 control_x_map = Fmake_keymap (Qnil);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3312 Fset (intern ("ctl-x-map"), control_x_map);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3313 Ffset (intern ("Control-X-prefix"), control_x_map);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3314
12297
fe458a8ecfa2 (Vdefine_key_rebound_commands): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 12262
diff changeset
3315 DEFVAR_LISP ("define-key-rebound-commands", &Vdefine_key_rebound_commands,
fe458a8ecfa2 (Vdefine_key_rebound_commands): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 12262
diff changeset
3316 "List of commands given new key bindings recently.\n\
fe458a8ecfa2 (Vdefine_key_rebound_commands): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 12262
diff changeset
3317 This is used for internal purposes during Emacs startup;\n\
fe458a8ecfa2 (Vdefine_key_rebound_commands): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 12262
diff changeset
3318 don't alter it yourself.");
fe458a8ecfa2 (Vdefine_key_rebound_commands): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 12262
diff changeset
3319 Vdefine_key_rebound_commands = Qt;
fe458a8ecfa2 (Vdefine_key_rebound_commands): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 12262
diff changeset
3320
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3321 DEFVAR_LISP ("minibuffer-local-map", &Vminibuffer_local_map,
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3322 "Default keymap to use when reading from the minibuffer.");
1095
6578f07e9eb8 (Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 647
diff changeset
3323 Vminibuffer_local_map = Fmake_sparse_keymap (Qnil);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3324
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3325 DEFVAR_LISP ("minibuffer-local-ns-map", &Vminibuffer_local_ns_map,
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3326 "Local keymap for the minibuffer when spaces are not allowed.");
1095
6578f07e9eb8 (Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 647
diff changeset
3327 Vminibuffer_local_ns_map = Fmake_sparse_keymap (Qnil);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3328
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3329 DEFVAR_LISP ("minibuffer-local-completion-map", &Vminibuffer_local_completion_map,
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3330 "Local keymap for minibuffer input with completion.");
1095
6578f07e9eb8 (Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 647
diff changeset
3331 Vminibuffer_local_completion_map = Fmake_sparse_keymap (Qnil);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3332
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3333 DEFVAR_LISP ("minibuffer-local-must-match-map", &Vminibuffer_local_must_match_map,
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3334 "Local keymap for minibuffer input with completion, for exact match.");
1095
6578f07e9eb8 (Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 647
diff changeset
3335 Vminibuffer_local_must_match_map = Fmake_sparse_keymap (Qnil);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3336
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
3337 DEFVAR_LISP ("minor-mode-map-alist", &Vminor_mode_map_alist,
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
3338 "Alist of keymaps to use for minor modes.\n\
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
3339 Each element looks like (VARIABLE . KEYMAP); KEYMAP is used to read\n\
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
3340 key sequences and look up bindings iff VARIABLE's value is non-nil.\n\
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
3341 If two active keymaps bind the same key, the keymap appearing earlier\n\
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
3342 in the list takes precedence.");
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
3343 Vminor_mode_map_alist = Qnil;
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
3344
20517
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
3345 DEFVAR_LISP ("minor-mode-overriding-map-alist", &Vminor_mode_overriding_map_alist,
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
3346 "Alist of keymaps to use for minor modes, in current major mode.\n\
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
3347 This variable is a alist just like `minor-mode-map-alist', and it is\n\
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
3348 used the same way (and before `minor-mode-map-alist'); however,\n\
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
3349 it is provided for major modes to bind locally.");
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
3350 Vminor_mode_overriding_map_alist = Qnil;
40bfe766d355 (Vminor_mode_overriding_map_alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 20381
diff changeset
3351
517
2f2206ac3dba *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
3352 DEFVAR_LISP ("function-key-map", &Vfunction_key_map,
2f2206ac3dba *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
3353 "Keymap mapping ASCII function key sequences onto their preferred forms.\n\
2f2206ac3dba *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
3354 This allows Emacs to recognize function keys sent from ASCII\n\
2f2206ac3dba *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
3355 terminals at any point in a key sequence.\n\
2f2206ac3dba *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
3356 \n\
8731
7ebb77d4aff2 (syms_of_keymap): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 8517
diff changeset
3357 The `read-key-sequence' function replaces any subsequence bound by\n\
7ebb77d4aff2 (syms_of_keymap): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 8517
diff changeset
3358 `function-key-map' with its binding. More precisely, when the active\n\
517
2f2206ac3dba *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
3359 keymaps have no binding for the current key sequence but\n\
8731
7ebb77d4aff2 (syms_of_keymap): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 8517
diff changeset
3360 `function-key-map' binds a suffix of the sequence to a vector or string,\n\
7ebb77d4aff2 (syms_of_keymap): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 8517
diff changeset
3361 `read-key-sequence' replaces the matching suffix with its binding, and\n\
517
2f2206ac3dba *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
3362 continues with the new sequence.\n\
2f2206ac3dba *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
3363 \n\
8731
7ebb77d4aff2 (syms_of_keymap): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 8517
diff changeset
3364 The events that come from bindings in `function-key-map' are not\n\
7ebb77d4aff2 (syms_of_keymap): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 8517
diff changeset
3365 themselves looked up in `function-key-map'.\n\
7ebb77d4aff2 (syms_of_keymap): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 8517
diff changeset
3366 \n\
7ebb77d4aff2 (syms_of_keymap): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 8517
diff changeset
3367 For example, suppose `function-key-map' binds `ESC O P' to [f1].\n\
7ebb77d4aff2 (syms_of_keymap): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 8517
diff changeset
3368 Typing `ESC O P' to `read-key-sequence' would return [f1]. Typing\n\
4138
42faad1466fa * keyboard.c (read_key_sequence): Accept both strings and vectors
Jim Blandy <jimb@redhat.com>
parents: 4023
diff changeset
3369 `C-x ESC O P' would return [?\\C-x f1]. If [f1] were a prefix\n\
42faad1466fa * keyboard.c (read_key_sequence): Accept both strings and vectors
Jim Blandy <jimb@redhat.com>
parents: 4023
diff changeset
3370 key, typing `ESC O P x' would return [f1 x].");
1095
6578f07e9eb8 (Fmake_sparse_keymap, Fmake_keymap): New optional arg. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 647
diff changeset
3371 Vfunction_key_map = Fmake_sparse_keymap (Qnil);
517
2f2206ac3dba *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
3372
12710
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
3373 DEFVAR_LISP ("key-translation-map", &Vkey_translation_map,
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
3374 "Keymap of key translations that can override keymaps.\n\
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
3375 This keymap works like `function-key-map', but comes after that,\n\
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
3376 and applies even for keys that have ordinary bindings.");
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
3377 Vkey_translation_map = Qnil;
26c09987d2f3 (describe_buffer_bindings): Print bindings from
Richard M. Stallman <rms@gnu.org>
parents: 12542
diff changeset
3378
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3379 Qsingle_key_description = intern ("single-key-description");
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3380 staticpro (&Qsingle_key_description);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3381
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3382 Qkey_description = intern ("key-description");
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3383 staticpro (&Qkey_description);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3384
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3385 Qkeymapp = intern ("keymapp");
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3386 staticpro (&Qkeymapp);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3387
2727
b8911c8b9700 * keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents: 2652
diff changeset
3388 Qnon_ascii = intern ("non-ascii");
b8911c8b9700 * keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents: 2652
diff changeset
3389 staticpro (&Qnon_ascii);
b8911c8b9700 * keymap.c (Fwhere_is_internal): If FIRSTONLY is non-nil, avoid
Jim Blandy <jimb@redhat.com>
parents: 2652
diff changeset
3390
21241
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
3391 Qmenu_item = intern ("menu-item");
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
3392 staticpro (&Qmenu_item);
31bd04a792c2 (fix_submap_inheritance, get_keyelt, store_in_keymap,
Richard M. Stallman <rms@gnu.org>
parents: 20883
diff changeset
3393
32889
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
3394 where_is_cache_keymaps = Qt;
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
3395 where_is_cache = Qnil;
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
3396 staticpro (&where_is_cache);
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
3397 staticpro (&where_is_cache_keymaps);
673e3ef1f7f6 (where_is_cache, where_is_cache_keymaps): New vars.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 32846
diff changeset
3398
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3399 defsubr (&Skeymapp);
15344
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
3400 defsubr (&Skeymap_parent);
82615c826910 (Fkeymap_parent, Fset_keymap_parent): New functions.
Richard M. Stallman <rms@gnu.org>
parents: 14738
diff changeset
3401 defsubr (&Sset_keymap_parent);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3402 defsubr (&Smake_keymap);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3403 defsubr (&Smake_sparse_keymap);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3404 defsubr (&Scopy_keymap);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3405 defsubr (&Skey_binding);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3406 defsubr (&Slocal_key_binding);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3407 defsubr (&Sglobal_key_binding);
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
3408 defsubr (&Sminor_mode_key_binding);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3409 defsubr (&Sdefine_key);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3410 defsubr (&Slookup_key);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3411 defsubr (&Sdefine_prefix_command);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3412 defsubr (&Suse_global_map);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3413 defsubr (&Suse_local_map);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3414 defsubr (&Scurrent_local_map);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3415 defsubr (&Scurrent_global_map);
465
36359663b6d8 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 368
diff changeset
3416 defsubr (&Scurrent_minor_mode_maps);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3417 defsubr (&Saccessible_keymaps);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3418 defsubr (&Skey_description);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3419 defsubr (&Sdescribe_vector);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3420 defsubr (&Ssingle_key_description);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3421 defsubr (&Stext_char_description);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3422 defsubr (&Swhere_is_internal);
20850
ffbaaba0bf76 (Fdescribe_bindings_internal):
Richard M. Stallman <rms@gnu.org>
parents: 20708
diff changeset
3423 defsubr (&Sdescribe_bindings_internal);
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3424 defsubr (&Sapropos_internal);
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3425 }
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3426
21514
fa9ff387d260 Fix -Wimplicit warnings.
Andreas Schwab <schwab@suse.de>
parents: 21429
diff changeset
3427 void
250
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3428 keys_of_keymap ()
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3429 {
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3430 initial_define_key (global_map, 033, "ESC-prefix");
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3431 initial_define_key (global_map, Ctl('X'), "Control-X-prefix");
7e94ea5958e0 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3432 }