comparison src/keymap.c @ 4906:6ef8256a020a

implement equalp in C, fix case-folding, add equal() method for keymaps -------------------- ChangeLog entries follow: -------------------- lisp/ChangeLog addition: 2010-02-01 Ben Wing <ben@xemacs.org> * cl-extra.el: * cl-extra.el (cl-string-vector-equalp): Removed. * cl-extra.el (cl-bit-vector-vector-equalp): Removed. * cl-extra.el (cl-vector-array-equalp): Removed. * cl-extra.el (cl-hash-table-contents-equalp): Removed. * cl-extra.el (equalp): Removed. * cl-extra.el (cl-mapcar-many): Comment out the whole `equalp' implementation for the moment; remove once we're sure the C implementation works. * cl-macs.el: * cl-macs.el (equalp): Simplify the compiler-macro for `equalp' -- once it's in C, we don't need to try so hard to expand it. src/ChangeLog addition: 2010-02-01 Ben Wing <ben@xemacs.org> * abbrev.c (abbrev_match_mapper): * buffer.h (CANON_TABLE_OF): * buffer.h: * editfns.c (Fchar_equal): * minibuf.c (scmp_1): * text.c (qxestrcasecmp_i18n): * text.c (qxestrncasecmp_i18n): * text.c (qxetextcasecmp): * text.c (qxetextcasecmp_matching): Create new macro CANONCASE that converts to a canonical mapping and use it to do caseless comparisons instead of DOWNCASE. * alloc.c: * alloc.c (cons_equal): * alloc.c (vector_equal): * alloc.c (string_equal): * bytecode.c (compiled_function_equal): * chartab.c (char_table_entry_equal): * chartab.c (char_table_equal): * data.c (weak_list_equal): * data.c (weak_box_equal): * data.c (ephemeron_equal): * device-msw.c (equal_devmode): * elhash.c (hash_table_equal): * events.c (event_equal): * extents.c (properties_equal): * extents.c (extent_equal): * faces.c: * faces.c (face_equal): * faces.c (face_hash): * floatfns.c (float_equal): * fns.c: * fns.c (bit_vector_equal): * fns.c (plists_differ): * fns.c (Fplists_eq): * fns.c (Fplists_equal): * fns.c (Flax_plists_eq): * fns.c (Flax_plists_equal): * fns.c (internal_equal): * fns.c (internal_equalp): * fns.c (internal_equal_0): * fns.c (syms_of_fns): * glyphs.c (image_instance_equal): * glyphs.c (glyph_equal): * glyphs.c (glyph_hash): * gui.c (gui_item_equal): * lisp.h: * lrecord.h (struct lrecord_implementation): * marker.c (marker_equal): * number.c (bignum_equal): * number.c (ratio_equal): * number.c (bigfloat_equal): * objects.c (color_instance_equal): * objects.c (font_instance_equal): * opaque.c (equal_opaque): * opaque.c (equal_opaque_ptr): * rangetab.c (range_table_equal): * specifier.c (specifier_equal): Add a `foldcase' param to the equal() method and use it to implement `equalp' comparisons. Also add to plists_differ(), although we don't currently use it here. Rewrite internal_equalp(). Implement cross-type vector comparisons. Don't implement our own handling of numeric promotion -- just use the `=' primitive. Add internal_equal_0(), which takes a `foldcase' param and calls either internal_equal() or internal_equalp(). * buffer.h: When given a 0 for buffer (which is the norm when functions don't have a specific buffer available), use the current buffer's table, not `standard-case-table'; otherwise the current settings are ignored. * casetab.c: * casetab.c (set_case_table): When handling old-style vectors of 256 in `set-case-table' don't overwrite the existing table! Instead create a new table and populate. * device-msw.c (sync_printer_with_devmode): * lisp.h: * text.c (lisp_strcasecmp_ascii): Rename lisp_strcasecmp to lisp_strcasecmp_ascii and use lisp_strcasecmp_i18n for caseless comparisons in some places. * elhash.c: Delete unused lisp_string_hash and lisp_string_equal(). * events.h: * keymap-buttons.h: * keymap.h: * keymap.c (keymap_lookup_directly): * keymap.c (keymap_store): * keymap.c (FROB): * keymap.c (key_desc_list_to_event): * keymap.c (describe_map_mapper): * keymap.c (INCLUDE_BUTTON_ZERO): New file keymap-buttons.h; use to handle buttons 1-26 in place of duplicating code 26 times. * frame-gtk.c (allocate_gtk_frame_struct): * frame-msw.c (mswindows_init_frame_1): Fix some comments about internal_equal() in redisplay that don't apply any more. * keymap-slots.h: * keymap.c: New file keymap-slots.h. Use it to notate the slots in a keymap structure, similar to frameslots.h or coding-system-slots.h. * keymap.c (MARKED_SLOT): * keymap.c (keymap_equal): * keymap.c (keymap_hash): Implement. tests/ChangeLog addition: 2010-02-01 Ben Wing <ben@xemacs.org> * automated/case-tests.el: * automated/case-tests.el (uni-mappings): * automated/search-tests.el: Delete old pristine-case-table code. Rewrite the Unicode torture test to take into account whether overlapping mappings exist for more than one character, and not doing the upcase/downcase comparisons in such cases. * automated/lisp-tests.el (foo): * automated/lisp-tests.el (string-variable): * automated/lisp-tests.el (featurep): Replace Assert (equal ... with Assert-equal; same for other types of equality. Replace some awkward equivalents of Assert-equalp with Assert-equalp. Add lots of equalp tests. * automated/case-tests.el: * automated/regexp-tests.el: * automated/search-tests.el: Fix up the comments at the top of the files. Move rules about where to put tests into case-tests.el. * automated/test-harness.el: * automated/test-harness.el (test-harness-aborted-summary-template): New. * automated/test-harness.el (test-harness-from-buffer): * automated/test-harness.el (batch-test-emacs): Fix Assert-test-not. Create Assert-not-equal and variants. Delete the doc strings from all these convenience functions to avoid excessive repetition; instead use one copy in a comment.
author Ben Wing <ben@xemacs.org>
date Mon, 01 Feb 2010 01:02:40 -0600
parents a98ca4640147
children e813cf16c015
comparison
equal deleted inserted replaced
4903:70089046adef 4906:6ef8256a020a
147 */ 147 */
148 148
149 struct Lisp_Keymap 149 struct Lisp_Keymap
150 { 150 {
151 struct LCRECORD_HEADER header; 151 struct LCRECORD_HEADER header;
152 Lisp_Object parents; /* Keymaps to be searched after this one. 152 #define MARKED_SLOT(x) Lisp_Object x;
153 An ordered list */ 153 #include "keymap-slots.h"
154 Lisp_Object prompt; /* Qnil or a string to print in the minibuffer
155 when reading from this keymap */
156 Lisp_Object table; /* The contents of this keymap */
157 Lisp_Object inverse_table; /* The inverse mapping of the above */
158 Lisp_Object default_binding; /* Use this if no other binding is found
159 (this overrides parent maps and the
160 normal global-map lookup). */
161 Lisp_Object sub_maps_cache; /* Cache of directly inferior keymaps;
162 This holds an alist, of the key and the
163 maps, or the modifier bit and the map.
164 If this is the symbol t, then the cache
165 needs to be recomputed. */
166 Lisp_Object name; /* Just for debugging convenience */
167 }; 154 };
168 155
169 #define MAKE_MODIFIER_HASH_KEY(modifier) make_int (modifier) 156 #define MAKE_MODIFIER_HASH_KEY(modifier) make_int (modifier)
170 #define MODIFIER_HASH_KEY_BITS(x) (INTP (x) ? XINT (x) : 0) 157 #define MODIFIER_HASH_KEY_BITS(x) (INTP (x) ? XINT (x) : 0)
171 158
215 int mice_only_p, 202 int mice_only_p,
216 Lisp_Object buffer); 203 Lisp_Object buffer);
217 static Lisp_Object keymap_submaps (Lisp_Object keymap); 204 static Lisp_Object keymap_submaps (Lisp_Object keymap);
218 205
219 Lisp_Object Qcontrol, Qctrl, Qmeta, Qsuper, Qhyper, Qalt, Qshift; 206 Lisp_Object Qcontrol, Qctrl, Qmeta, Qsuper, Qhyper, Qalt, Qshift;
220 Lisp_Object Qbutton0; 207
221 Lisp_Object Qbutton1, Qbutton2, Qbutton3, Qbutton4, Qbutton5; 208 #define INCLUDE_BUTTON_ZERO
222 Lisp_Object Qbutton6, Qbutton7, Qbutton8, Qbutton9, Qbutton10; 209 #define FROB(num) \
223 Lisp_Object Qbutton11, Qbutton12, Qbutton13, Qbutton14, Qbutton15; 210 Lisp_Object Qbutton##num; \
224 Lisp_Object Qbutton16, Qbutton17, Qbutton18, Qbutton19, Qbutton20; 211 Lisp_Object Qbutton##num##up;
225 Lisp_Object Qbutton21, Qbutton22, Qbutton23, Qbutton24, Qbutton25; 212 #include "keymap-buttons.h"
226 Lisp_Object Qbutton26;
227 Lisp_Object Qbutton0up;
228 Lisp_Object Qbutton1up, Qbutton2up, Qbutton3up, Qbutton4up, Qbutton5up;
229 Lisp_Object Qbutton6up, Qbutton7up, Qbutton8up, Qbutton9up, Qbutton10up;
230 Lisp_Object Qbutton11up, Qbutton12up, Qbutton13up, Qbutton14up, Qbutton15up;
231 Lisp_Object Qbutton16up, Qbutton17up, Qbutton18up, Qbutton19up, Qbutton20up;
232 Lisp_Object Qbutton21up, Qbutton22up, Qbutton23up, Qbutton24up, Qbutton25up;
233 Lisp_Object Qbutton26up;
234 213
235 Lisp_Object Qmenu_selection; 214 Lisp_Object Qmenu_selection;
215
236 /* Emacs compatibility */ 216 /* Emacs compatibility */
237 Lisp_Object Qdown_mouse_1, Qmouse_1; 217 #define FROB(num) \
238 Lisp_Object Qdown_mouse_2, Qmouse_2; 218 Lisp_Object Qmouse_##num; \
239 Lisp_Object Qdown_mouse_3, Qmouse_3; 219 Lisp_Object Qdown_mouse_##num;
240 Lisp_Object Qdown_mouse_4, Qmouse_4; 220 #include "keymap-buttons.h"
241 Lisp_Object Qdown_mouse_5, Qmouse_5;
242 Lisp_Object Qdown_mouse_6, Qmouse_6;
243 Lisp_Object Qdown_mouse_7, Qmouse_7;
244 Lisp_Object Qdown_mouse_8, Qmouse_8;
245 Lisp_Object Qdown_mouse_9, Qmouse_9;
246 Lisp_Object Qdown_mouse_10, Qmouse_10;
247 Lisp_Object Qdown_mouse_11, Qmouse_11;
248 Lisp_Object Qdown_mouse_12, Qmouse_12;
249 Lisp_Object Qdown_mouse_13, Qmouse_13;
250 Lisp_Object Qdown_mouse_14, Qmouse_14;
251 Lisp_Object Qdown_mouse_15, Qmouse_15;
252 Lisp_Object Qdown_mouse_16, Qmouse_16;
253 Lisp_Object Qdown_mouse_17, Qmouse_17;
254 Lisp_Object Qdown_mouse_18, Qmouse_18;
255 Lisp_Object Qdown_mouse_19, Qmouse_19;
256 Lisp_Object Qdown_mouse_20, Qmouse_20;
257 Lisp_Object Qdown_mouse_21, Qmouse_21;
258 Lisp_Object Qdown_mouse_22, Qmouse_22;
259 Lisp_Object Qdown_mouse_23, Qmouse_23;
260 Lisp_Object Qdown_mouse_24, Qmouse_24;
261 Lisp_Object Qdown_mouse_25, Qmouse_25;
262 Lisp_Object Qdown_mouse_26, Qmouse_26;
263 221
264 /* Kludge kludge kludge */ 222 /* Kludge kludge kludge */
265 Lisp_Object QLFD, QTAB, QRET, QESC, QDEL, QSPC, QBS; 223 Lisp_Object QLFD, QTAB, QRET, QESC, QDEL, QSPC, QBS;
266 224
267 225
268 /************************************************************************/ 226 /************************************************************************/
269 /* The keymap Lisp object */ 227 /* The keymap Lisp object */
270 /************************************************************************/ 228 /************************************************************************/
271 229
230 /* Keymaps are equal if Faces are equal if all of their display attributes are equal. We
231 don't compare names or doc-strings, because that would make equal
232 be eq.
233
234 This isn't concerned with "unspecified" attributes, that's what
235 #'face-differs-from-default-p is for. */
236 static int
237 keymap_equal (Lisp_Object obj1, Lisp_Object obj2, int depth,
238 int UNUSED (foldcase))
239 {
240 Lisp_Keymap *k1 = XKEYMAP (obj1);
241 Lisp_Keymap *k2 = XKEYMAP (obj2);
242
243 depth++;
244
245 return
246 (
247 #define MARKED_SLOT(x) \
248 internal_equal (k1->x, k2->x, depth) &&
249 #define MARKED_SLOT_NOCOMPARE(x)
250 #include "keymap-slots.h"
251 1
252 );
253 }
254
255 static Hashcode
256 keymap_hash (Lisp_Object obj, int depth)
257 {
258 Lisp_Keymap *k = XKEYMAP (obj);
259 Hashcode hash = 0xCAFEBABE; /* why not? */
260
261 depth++;
262
263 #define MARKED_SLOT(x) \
264 hash = HASH2 (hash, internal_hash (k->x, depth));
265 #define MARKED_SLOT_NOCOMPARE(x)
266 #include "keymap-slots.h"
267
268 return hash;
269 }
270
272 static Lisp_Object 271 static Lisp_Object
273 mark_keymap (Lisp_Object obj) 272 mark_keymap (Lisp_Object obj)
274 { 273 {
275 Lisp_Keymap *keymap = XKEYMAP (obj); 274 Lisp_Keymap *keymap = XKEYMAP (obj);
276 mark_object (keymap->parents); 275 #define MARKED_SLOT(x) mark_object (keymap->x);
277 mark_object (keymap->prompt); 276 #include "keymap-slots.h"
278 mark_object (keymap->inverse_table); 277 return Qnil;
279 mark_object (keymap->sub_maps_cache);
280 mark_object (keymap->default_binding);
281 mark_object (keymap->name);
282 return keymap->table;
283 } 278 }
284 279
285 static void 280 static void
286 print_keymap (Lisp_Object obj, Lisp_Object printcharfun, 281 print_keymap (Lisp_Object obj, Lisp_Object printcharfun,
287 int UNUSED (escapeflag)) 282 int UNUSED (escapeflag))
298 write_fmt_string (printcharfun, "size %ld 0x%x>", 293 write_fmt_string (printcharfun, "size %ld 0x%x>",
299 (long) XINT (Fkeymap_fullness (obj)), keymap->header.uid); 294 (long) XINT (Fkeymap_fullness (obj)), keymap->header.uid);
300 } 295 }
301 296
302 static const struct memory_description keymap_description[] = { 297 static const struct memory_description keymap_description[] = {
303 { XD_LISP_OBJECT, offsetof (Lisp_Keymap, parents) }, 298 #define MARKED_SLOT(x) { XD_LISP_OBJECT, offsetof (Lisp_Keymap, x) },
304 { XD_LISP_OBJECT, offsetof (Lisp_Keymap, prompt) }, 299 #include "keymap-slots.h"
305 { XD_LISP_OBJECT, offsetof (Lisp_Keymap, table) },
306 { XD_LISP_OBJECT, offsetof (Lisp_Keymap, inverse_table) },
307 { XD_LISP_OBJECT, offsetof (Lisp_Keymap, default_binding) },
308 { XD_LISP_OBJECT, offsetof (Lisp_Keymap, sub_maps_cache) },
309 { XD_LISP_OBJECT, offsetof (Lisp_Keymap, name) },
310 { XD_END } 300 { XD_END }
311 }; 301 };
312 302
313 /* No need for keymap_equal #### Why not? */
314 DEFINE_LRECORD_IMPLEMENTATION ("keymap", keymap, 303 DEFINE_LRECORD_IMPLEMENTATION ("keymap", keymap,
315 1, /*dumpable-flag*/ 304 1, /*dumpable-flag*/
316 mark_keymap, print_keymap, 0, 0, 0, 305 mark_keymap, print_keymap, 0,
306 keymap_equal, keymap_hash,
317 keymap_description, 307 keymap_description,
318 Lisp_Keymap); 308 Lisp_Keymap);
319 309
320 /************************************************************************/ 310 /************************************************************************/
321 /* Traversing keymaps and their parents */ 311 /* Traversing keymaps and their parents */
494 keymap_lookup_directly (Lisp_Object keymap, 484 keymap_lookup_directly (Lisp_Object keymap,
495 Lisp_Object keysym, int modifiers) 485 Lisp_Object keysym, int modifiers)
496 { 486 {
497 Lisp_Keymap *k; 487 Lisp_Keymap *k;
498 488
499 modifiers &= ~(XEMACS_MOD_BUTTON1 | XEMACS_MOD_BUTTON2 | XEMACS_MOD_BUTTON3 489 modifiers &= ~(
500 | XEMACS_MOD_BUTTON4 | XEMACS_MOD_BUTTON5 | XEMACS_MOD_BUTTON6 490 #define FROB(num) XEMACS_MOD_BUTTON##num |
501 | XEMACS_MOD_BUTTON7 | XEMACS_MOD_BUTTON8 | XEMACS_MOD_BUTTON9 491 #include "keymap-buttons.h"
502 | XEMACS_MOD_BUTTON10 | XEMACS_MOD_BUTTON11 | XEMACS_MOD_BUTTON12 492 0);
503 | XEMACS_MOD_BUTTON13 | XEMACS_MOD_BUTTON14 | XEMACS_MOD_BUTTON15
504 | XEMACS_MOD_BUTTON16 | XEMACS_MOD_BUTTON17 | XEMACS_MOD_BUTTON18
505 | XEMACS_MOD_BUTTON19 | XEMACS_MOD_BUTTON20 | XEMACS_MOD_BUTTON21
506 | XEMACS_MOD_BUTTON22 | XEMACS_MOD_BUTTON23 | XEMACS_MOD_BUTTON24
507 | XEMACS_MOD_BUTTON25 | XEMACS_MOD_BUTTON26);
508 if ((modifiers & ~(XEMACS_MOD_CONTROL | XEMACS_MOD_META | XEMACS_MOD_SUPER 493 if ((modifiers & ~(XEMACS_MOD_CONTROL | XEMACS_MOD_META | XEMACS_MOD_SUPER
509 | XEMACS_MOD_HYPER | XEMACS_MOD_ALT | XEMACS_MOD_SHIFT)) 494 | XEMACS_MOD_HYPER | XEMACS_MOD_ALT | XEMACS_MOD_SHIFT))
510 != 0) 495 != 0)
511 ABORT (); 496 ABORT ();
512 497
682 { 667 {
683 Lisp_Object keysym = KEY_DATA_KEYSYM (key); 668 Lisp_Object keysym = KEY_DATA_KEYSYM (key);
684 int modifiers = KEY_DATA_MODIFIERS (key); 669 int modifiers = KEY_DATA_MODIFIERS (key);
685 Lisp_Keymap *k = XKEYMAP (keymap); 670 Lisp_Keymap *k = XKEYMAP (keymap);
686 671
687 modifiers &= ~(XEMACS_MOD_BUTTON1 | XEMACS_MOD_BUTTON2 | XEMACS_MOD_BUTTON3 672 modifiers &= ~(
688 | XEMACS_MOD_BUTTON4 | XEMACS_MOD_BUTTON5 | XEMACS_MOD_BUTTON6 673 #define FROB(num) XEMACS_MOD_BUTTON##num |
689 | XEMACS_MOD_BUTTON7 | XEMACS_MOD_BUTTON8 | XEMACS_MOD_BUTTON9 674 #include "keymap-buttons.h"
690 | XEMACS_MOD_BUTTON10 | XEMACS_MOD_BUTTON11 | XEMACS_MOD_BUTTON12 675 0);
691 | XEMACS_MOD_BUTTON13 | XEMACS_MOD_BUTTON14 | XEMACS_MOD_BUTTON15
692 | XEMACS_MOD_BUTTON16 | XEMACS_MOD_BUTTON17 | XEMACS_MOD_BUTTON18
693 | XEMACS_MOD_BUTTON19 | XEMACS_MOD_BUTTON20 | XEMACS_MOD_BUTTON21
694 | XEMACS_MOD_BUTTON22 | XEMACS_MOD_BUTTON23 | XEMACS_MOD_BUTTON24
695 | XEMACS_MOD_BUTTON25 | XEMACS_MOD_BUTTON26);
696 assert ((modifiers & ~(XEMACS_MOD_CONTROL | XEMACS_MOD_META 676 assert ((modifiers & ~(XEMACS_MOD_CONTROL | XEMACS_MOD_META
697 | XEMACS_MOD_SUPER | XEMACS_MOD_HYPER 677 | XEMACS_MOD_SUPER | XEMACS_MOD_HYPER
698 | XEMACS_MOD_ALT | XEMACS_MOD_SHIFT)) == 0); 678 | XEMACS_MOD_ALT | XEMACS_MOD_SHIFT)) == 0);
699 679
700 /* If the keysym is a one-character symbol, use the char code instead. */ 680 /* If the keysym is a one-character symbol, use the char code instead. */
801 Lisp_Object result; 781 Lisp_Object result;
802 Lisp_Keymap *keymap = ALLOC_LCRECORD_TYPE (Lisp_Keymap, &lrecord_keymap); 782 Lisp_Keymap *keymap = ALLOC_LCRECORD_TYPE (Lisp_Keymap, &lrecord_keymap);
803 783
804 result = wrap_keymap (keymap); 784 result = wrap_keymap (keymap);
805 785
806 keymap->parents = Qnil; 786 #define MARKED_SLOT(x) keymap->x = Qnil;
807 keymap->prompt = Qnil; 787 #include "keymap-slots.h"
808 keymap->table = Qnil;
809 keymap->inverse_table = Qnil;
810 keymap->default_binding = Qnil;
811 keymap->sub_maps_cache = Qnil; /* No possible submaps */
812 keymap->name = Qnil;
813 788
814 if (size != 0) /* hack for copy-keymap */ 789 if (size != 0) /* hack for copy-keymap */
815 { 790 {
816 keymap->table = 791 keymap->table =
817 make_lisp_hash_table (size, HASH_TABLE_NON_WEAK, HASH_TABLE_EQ); 792 make_lisp_hash_table (size, HASH_TABLE_NON_WEAK, HASH_TABLE_EQ);
1404 else if (EQ (*keysym, QSPC)) 1379 else if (EQ (*keysym, QSPC))
1405 *keysym = QKspace; 1380 *keysym = QKspace;
1406 else if (EQ (*keysym, QBS)) 1381 else if (EQ (*keysym, QBS))
1407 *keysym = QKbackspace; 1382 *keysym = QKbackspace;
1408 /* Emacs compatibility */ 1383 /* Emacs compatibility */
1409 else if (EQ(*keysym, Qdown_mouse_1)) 1384 #define FROB(num) \
1410 *keysym = Qbutton1; 1385 else if (EQ(*keysym, Qdown_mouse_##num)) \
1411 else if (EQ(*keysym, Qdown_mouse_2)) 1386 *keysym = Qbutton##num; \
1412 *keysym = Qbutton2; 1387 else if (EQ(*keysym, Qmouse_##num)) \
1413 else if (EQ(*keysym, Qdown_mouse_3)) 1388 *keysym = Qbutton##num##up;
1414 *keysym = Qbutton3; 1389 #include "keymap-buttons.h"
1415 else if (EQ(*keysym, Qdown_mouse_4))
1416 *keysym = Qbutton4;
1417 else if (EQ(*keysym, Qdown_mouse_5))
1418 *keysym = Qbutton5;
1419 else if (EQ(*keysym, Qdown_mouse_6))
1420 *keysym = Qbutton6;
1421 else if (EQ(*keysym, Qdown_mouse_7))
1422 *keysym = Qbutton7;
1423 else if (EQ(*keysym, Qdown_mouse_8))
1424 *keysym = Qbutton8;
1425 else if (EQ(*keysym, Qdown_mouse_9))
1426 *keysym = Qbutton9;
1427 else if (EQ(*keysym, Qdown_mouse_10))
1428 *keysym = Qbutton10;
1429 else if (EQ(*keysym, Qdown_mouse_11))
1430 *keysym = Qbutton11;
1431 else if (EQ(*keysym, Qdown_mouse_12))
1432 *keysym = Qbutton12;
1433 else if (EQ(*keysym, Qdown_mouse_13))
1434 *keysym = Qbutton13;
1435 else if (EQ(*keysym, Qdown_mouse_14))
1436 *keysym = Qbutton14;
1437 else if (EQ(*keysym, Qdown_mouse_15))
1438 *keysym = Qbutton15;
1439 else if (EQ(*keysym, Qdown_mouse_16))
1440 *keysym = Qbutton16;
1441 else if (EQ(*keysym, Qdown_mouse_17))
1442 *keysym = Qbutton17;
1443 else if (EQ(*keysym, Qdown_mouse_18))
1444 *keysym = Qbutton18;
1445 else if (EQ(*keysym, Qdown_mouse_19))
1446 *keysym = Qbutton19;
1447 else if (EQ(*keysym, Qdown_mouse_20))
1448 *keysym = Qbutton20;
1449 else if (EQ(*keysym, Qdown_mouse_21))
1450 *keysym = Qbutton21;
1451 else if (EQ(*keysym, Qdown_mouse_22))
1452 *keysym = Qbutton22;
1453 else if (EQ(*keysym, Qdown_mouse_23))
1454 *keysym = Qbutton23;
1455 else if (EQ(*keysym, Qdown_mouse_24))
1456 *keysym = Qbutton24;
1457 else if (EQ(*keysym, Qdown_mouse_25))
1458 *keysym = Qbutton25;
1459 else if (EQ(*keysym, Qdown_mouse_26))
1460 *keysym = Qbutton26;
1461 else if (EQ(*keysym, Qmouse_1))
1462 *keysym = Qbutton1up;
1463 else if (EQ(*keysym, Qmouse_2))
1464 *keysym = Qbutton2up;
1465 else if (EQ(*keysym, Qmouse_3))
1466 *keysym = Qbutton3up;
1467 else if (EQ(*keysym, Qmouse_4))
1468 *keysym = Qbutton4up;
1469 else if (EQ(*keysym, Qmouse_5))
1470 *keysym = Qbutton5up;
1471 else if (EQ(*keysym, Qmouse_6))
1472 *keysym = Qbutton6up;
1473 else if (EQ(*keysym, Qmouse_7))
1474 *keysym = Qbutton7up;
1475 else if (EQ(*keysym, Qmouse_8))
1476 *keysym = Qbutton8up;
1477 else if (EQ(*keysym, Qmouse_9))
1478 *keysym = Qbutton9up;
1479 else if (EQ(*keysym, Qmouse_10))
1480 *keysym = Qbutton10up;
1481 else if (EQ(*keysym, Qmouse_11))
1482 *keysym = Qbutton11up;
1483 else if (EQ(*keysym, Qmouse_12))
1484 *keysym = Qbutton12up;
1485 else if (EQ(*keysym, Qmouse_13))
1486 *keysym = Qbutton13up;
1487 else if (EQ(*keysym, Qmouse_14))
1488 *keysym = Qbutton14up;
1489 else if (EQ(*keysym, Qmouse_15))
1490 *keysym = Qbutton15up;
1491 else if (EQ(*keysym, Qmouse_16))
1492 *keysym = Qbutton16up;
1493 else if (EQ(*keysym, Qmouse_17))
1494 *keysym = Qbutton17up;
1495 else if (EQ(*keysym, Qmouse_18))
1496 *keysym = Qbutton18up;
1497 else if (EQ(*keysym, Qmouse_19))
1498 *keysym = Qbutton19up;
1499 else if (EQ(*keysym, Qmouse_20))
1500 *keysym = Qbutton20up;
1501 else if (EQ(*keysym, Qmouse_21))
1502 *keysym = Qbutton21up;
1503 else if (EQ(*keysym, Qmouse_22))
1504 *keysym = Qbutton22up;
1505 else if (EQ(*keysym, Qmouse_23))
1506 *keysym = Qbutton23up;
1507 else if (EQ(*keysym, Qmouse_24))
1508 *keysym = Qbutton24up;
1509 else if (EQ(*keysym, Qmouse_25))
1510 *keysym = Qbutton25up;
1511 else if (EQ(*keysym, Qmouse_26))
1512 *keysym = Qbutton26up;
1513 } 1390 }
1514 } 1391 }
1515 1392
1516 1393
1517 /* Given any kind of key-specifier, return a keysym and modifier mask. 1394 /* Given any kind of key-specifier, return a keysym and modifier mask.
1550 case button_release_event: 1427 case button_release_event:
1551 { 1428 {
1552 int down = (XEVENT_TYPE (spec) == button_press_event); 1429 int down = (XEVENT_TYPE (spec) == button_press_event);
1553 switch (XEVENT_BUTTON_BUTTON (spec)) 1430 switch (XEVENT_BUTTON_BUTTON (spec))
1554 { 1431 {
1555 case 1: 1432 #define FROB(num) \
1556 SET_KEY_DATA_KEYSYM (returned_value, (down ? Qbutton1 : Qbutton1up)); 1433 case num: \
1434 SET_KEY_DATA_KEYSYM (returned_value, \
1435 (down ? Qbutton##num : \
1436 Qbutton##num##up)); \
1557 break; 1437 break;
1558 case 2: 1438 #include "keymap-buttons.h"
1559 SET_KEY_DATA_KEYSYM (returned_value, (down ? Qbutton2 : Qbutton2up));
1560 break;
1561 case 3:
1562 SET_KEY_DATA_KEYSYM (returned_value, (down ? Qbutton3 : Qbutton3up));
1563 break;
1564 case 4:
1565 SET_KEY_DATA_KEYSYM (returned_value, (down ? Qbutton4 : Qbutton4up));
1566 break;
1567 case 5:
1568 SET_KEY_DATA_KEYSYM (returned_value, (down ? Qbutton5 : Qbutton5up));
1569 break;
1570 case 6:
1571 SET_KEY_DATA_KEYSYM (returned_value, (down ? Qbutton6 : Qbutton6up));
1572 break;
1573 case 7:
1574 SET_KEY_DATA_KEYSYM (returned_value, (down ? Qbutton7 : Qbutton7up));
1575 break;
1576 case 8:
1577 SET_KEY_DATA_KEYSYM(returned_value, (down ? Qbutton8 : Qbutton8up));
1578 break;
1579 case 9:
1580 SET_KEY_DATA_KEYSYM(returned_value, (down ? Qbutton9 : Qbutton9up));
1581 break;
1582 case 10:
1583 SET_KEY_DATA_KEYSYM(returned_value, (down ? Qbutton10 : Qbutton10up));
1584 break;
1585 case 11:
1586 SET_KEY_DATA_KEYSYM(returned_value, (down ? Qbutton11 : Qbutton11up));
1587 break;
1588 case 12:
1589 SET_KEY_DATA_KEYSYM(returned_value, (down ? Qbutton12 : Qbutton12up));
1590 break;
1591 case 13:
1592 SET_KEY_DATA_KEYSYM(returned_value, (down ? Qbutton13 : Qbutton13up));
1593 break;
1594 case 14:
1595 SET_KEY_DATA_KEYSYM(returned_value, (down ? Qbutton14 : Qbutton14up));
1596 break;
1597 case 15:
1598 SET_KEY_DATA_KEYSYM(returned_value, (down ? Qbutton15 : Qbutton15up));
1599 break;
1600 case 16:
1601 SET_KEY_DATA_KEYSYM(returned_value, (down ? Qbutton16 : Qbutton16up));
1602 break;
1603 case 17:
1604 SET_KEY_DATA_KEYSYM(returned_value, (down ? Qbutton17 : Qbutton17up));
1605 break;
1606 case 18:
1607 SET_KEY_DATA_KEYSYM(returned_value, (down ? Qbutton18 : Qbutton18up));
1608 break;
1609 case 19:
1610 SET_KEY_DATA_KEYSYM(returned_value, (down ? Qbutton19 : Qbutton19up));
1611 break;
1612 case 20:
1613 SET_KEY_DATA_KEYSYM(returned_value, (down ? Qbutton20 : Qbutton20up));
1614 break;
1615 case 21:
1616 SET_KEY_DATA_KEYSYM(returned_value, (down ? Qbutton21 : Qbutton21up));
1617 break;
1618 case 22:
1619 SET_KEY_DATA_KEYSYM(returned_value, (down ? Qbutton22 : Qbutton22up));
1620 break;
1621 case 23:
1622 SET_KEY_DATA_KEYSYM(returned_value, (down ? Qbutton23 : Qbutton23up));
1623 break;
1624 case 24:
1625 SET_KEY_DATA_KEYSYM(returned_value, (down ? Qbutton24 : Qbutton24up));
1626 break;
1627 case 25:
1628 SET_KEY_DATA_KEYSYM(returned_value, (down ? Qbutton25 : Qbutton25up));
1629 break;
1630 case 26:
1631 SET_KEY_DATA_KEYSYM(returned_value, (down ? Qbutton26 : Qbutton26up));
1632 break;
1633 default: 1439 default:
1634 SET_KEY_DATA_KEYSYM (returned_value, (down ? Qbutton0 : Qbutton0up)); 1440 SET_KEY_DATA_KEYSYM (returned_value, (down ? Qbutton0 :
1441 Qbutton0up));
1635 break; 1442 break;
1636 } 1443 }
1637 SET_KEY_DATA_MODIFIERS (returned_value, XEVENT_BUTTON_MODIFIERS (spec)); 1444 SET_KEY_DATA_MODIFIERS (returned_value,
1445 XEVENT_BUTTON_MODIFIERS (spec));
1638 break; 1446 break;
1639 } 1447 }
1640 default: 1448 default:
1641 wtaerror ("unable to bind this type of event", spec); 1449 wtaerror ("unable to bind this type of event", spec);
1642 } 1450 }
1720 return; 1528 return;
1721 } 1529 }
1722 1530
1723 define_key_parser (list, &raw_key); 1531 define_key_parser (list, &raw_key);
1724 1532
1725 if (EQ (raw_key.keysym, Qbutton0) || EQ (raw_key.keysym, Qbutton0up) || 1533 if (
1726 EQ (raw_key.keysym, Qbutton1) || EQ (raw_key.keysym, Qbutton1up) || 1534 #define INCLUDE_BUTTON_ZERO
1727 EQ (raw_key.keysym, Qbutton2) || EQ (raw_key.keysym, Qbutton2up) || 1535 #define FROB(num) \
1728 EQ (raw_key.keysym, Qbutton3) || EQ (raw_key.keysym, Qbutton3up) || 1536 EQ (raw_key.keysym, Qbutton##num) || \
1729 EQ (raw_key.keysym, Qbutton4) || EQ (raw_key.keysym, Qbutton4up) || 1537 EQ (raw_key.keysym, Qbutton##num##up) ||
1730 EQ (raw_key.keysym, Qbutton5) || EQ (raw_key.keysym, Qbutton5up) || 1538 #include "keymap-buttons.h"
1731 EQ (raw_key.keysym, Qbutton6) || EQ (raw_key.keysym, Qbutton6up) || 1539 0)
1732 EQ (raw_key.keysym, Qbutton7) || EQ (raw_key.keysym, Qbutton7up) ||
1733 EQ (raw_key.keysym, Qbutton8) || EQ (raw_key.keysym, Qbutton8up) ||
1734 EQ (raw_key.keysym, Qbutton9) || EQ (raw_key.keysym, Qbutton9up) ||
1735 EQ (raw_key.keysym, Qbutton10) || EQ (raw_key.keysym, Qbutton10up) ||
1736 EQ (raw_key.keysym, Qbutton11) || EQ (raw_key.keysym, Qbutton11up) ||
1737 EQ (raw_key.keysym, Qbutton12) || EQ (raw_key.keysym, Qbutton12up) ||
1738 EQ (raw_key.keysym, Qbutton13) || EQ (raw_key.keysym, Qbutton13up) ||
1739 EQ (raw_key.keysym, Qbutton14) || EQ (raw_key.keysym, Qbutton14up) ||
1740 EQ (raw_key.keysym, Qbutton15) || EQ (raw_key.keysym, Qbutton15up) ||
1741 EQ (raw_key.keysym, Qbutton16) || EQ (raw_key.keysym, Qbutton16up) ||
1742 EQ (raw_key.keysym, Qbutton17) || EQ (raw_key.keysym, Qbutton17up) ||
1743 EQ (raw_key.keysym, Qbutton18) || EQ (raw_key.keysym, Qbutton18up) ||
1744 EQ (raw_key.keysym, Qbutton19) || EQ (raw_key.keysym, Qbutton19up) ||
1745 EQ (raw_key.keysym, Qbutton20) || EQ (raw_key.keysym, Qbutton20up) ||
1746 EQ (raw_key.keysym, Qbutton21) || EQ (raw_key.keysym, Qbutton21up) ||
1747 EQ (raw_key.keysym, Qbutton22) || EQ (raw_key.keysym, Qbutton22up) ||
1748 EQ (raw_key.keysym, Qbutton23) || EQ (raw_key.keysym, Qbutton23up) ||
1749 EQ (raw_key.keysym, Qbutton24) || EQ (raw_key.keysym, Qbutton24up) ||
1750 EQ (raw_key.keysym, Qbutton25) || EQ (raw_key.keysym, Qbutton25up) ||
1751 EQ (raw_key.keysym, Qbutton26) || EQ (raw_key.keysym, Qbutton26up))
1752 invalid_operation ("Mouse-clicks can't appear in saved keyboard macros", 1540 invalid_operation ("Mouse-clicks can't appear in saved keyboard macros",
1753 Qunbound); 1541 Qunbound);
1754 1542
1755 XSET_EVENT_CHANNEL (event, Vselected_console); 1543 XSET_EVENT_CHANNEL (event, Vselected_console);
1756 XSET_EVENT_TYPE (event, key_press_event); 1544 XSET_EVENT_TYPE (event, key_press_event);
4250 return; 4038 return;
4251 4039
4252 /* If we're only supposed to display mouse bindings and this isn't one, 4040 /* If we're only supposed to display mouse bindings and this isn't one,
4253 then bug out. */ 4041 then bug out. */
4254 if (closure->mice_only_p && 4042 if (closure->mice_only_p &&
4255 (! (EQ (keysym, Qbutton0) || 4043 (! (
4256 EQ (keysym, Qbutton1) || 4044 #define INCLUDE_BUTTON_ZERO
4257 EQ (keysym, Qbutton2) || 4045 #define FROB(num) EQ (keysym, Qbutton##num) || \
4258 EQ (keysym, Qbutton3) || 4046 EQ (keysym, Qbutton##num##up) ||
4259 EQ (keysym, Qbutton4) || 4047 #include "keymap-buttons.h"
4260 EQ (keysym, Qbutton5) || 4048 0)))
4261 EQ (keysym, Qbutton6) ||
4262 EQ (keysym, Qbutton7) ||
4263 EQ (keysym, Qbutton8) ||
4264 EQ (keysym, Qbutton9) ||
4265 EQ (keysym, Qbutton10) ||
4266 EQ (keysym, Qbutton11) ||
4267 EQ (keysym, Qbutton12) ||
4268 EQ (keysym, Qbutton13) ||
4269 EQ (keysym, Qbutton14) ||
4270 EQ (keysym, Qbutton15) ||
4271 EQ (keysym, Qbutton16) ||
4272 EQ (keysym, Qbutton17) ||
4273 EQ (keysym, Qbutton18) ||
4274 EQ (keysym, Qbutton19) ||
4275 EQ (keysym, Qbutton20) ||
4276 EQ (keysym, Qbutton21) ||
4277 EQ (keysym, Qbutton22) ||
4278 EQ (keysym, Qbutton23) ||
4279 EQ (keysym, Qbutton24) ||
4280 EQ (keysym, Qbutton25) ||
4281 EQ (keysym, Qbutton26) ||
4282 EQ (keysym, Qbutton0up) ||
4283 EQ (keysym, Qbutton1up) ||
4284 EQ (keysym, Qbutton2up) ||
4285 EQ (keysym, Qbutton3up) ||
4286 EQ (keysym, Qbutton4up) ||
4287 EQ (keysym, Qbutton5up) ||
4288 EQ (keysym, Qbutton6up) ||
4289 EQ (keysym, Qbutton7up) ||
4290 EQ (keysym, Qbutton8up) ||
4291 EQ (keysym, Qbutton9up) ||
4292 EQ (keysym, Qbutton10up) ||
4293 EQ (keysym, Qbutton11up) ||
4294 EQ (keysym, Qbutton12up) ||
4295 EQ (keysym, Qbutton13up) ||
4296 EQ (keysym, Qbutton14up) ||
4297 EQ (keysym, Qbutton15up) ||
4298 EQ (keysym, Qbutton16up) ||
4299 EQ (keysym, Qbutton17up) ||
4300 EQ (keysym, Qbutton18up) ||
4301 EQ (keysym, Qbutton19up) ||
4302 EQ (keysym, Qbutton20up) ||
4303 EQ (keysym, Qbutton21up) ||
4304 EQ (keysym, Qbutton22up) ||
4305 EQ (keysym, Qbutton23up) ||
4306 EQ (keysym, Qbutton24up) ||
4307 EQ (keysym, Qbutton25up) ||
4308 EQ (keysym, Qbutton26up))))
4309 return; 4049 return;
4310 4050
4311 /* If this command in this map is shadowed by some other map, ignore it. */ 4051 /* If this command in this map is shadowed by some other map, ignore it. */
4312 { 4052 {
4313 Lisp_Object tail; 4053 Lisp_Object tail;
4607 DEFSYMBOL (Qmeta); 4347 DEFSYMBOL (Qmeta);
4608 DEFSYMBOL (Qsuper); 4348 DEFSYMBOL (Qsuper);
4609 DEFSYMBOL (Qhyper); 4349 DEFSYMBOL (Qhyper);
4610 DEFSYMBOL (Qalt); 4350 DEFSYMBOL (Qalt);
4611 DEFSYMBOL (Qshift); 4351 DEFSYMBOL (Qshift);
4612 DEFSYMBOL (Qbutton0); 4352 #define INCLUDE_BUTTON_ZERO
4613 DEFSYMBOL (Qbutton1); 4353 #define FROB(num) \
4614 DEFSYMBOL (Qbutton2); 4354 DEFSYMBOL (Qbutton##num); \
4615 DEFSYMBOL (Qbutton3); 4355 DEFSYMBOL (Qbutton##num##up);
4616 DEFSYMBOL (Qbutton4); 4356 #include "keymap-buttons.h"
4617 DEFSYMBOL (Qbutton5); 4357 #define FROB(num) \
4618 DEFSYMBOL (Qbutton6); 4358 DEFSYMBOL (Qmouse_##num); \
4619 DEFSYMBOL (Qbutton7); 4359 DEFSYMBOL (Qdown_mouse_##num);
4620 DEFSYMBOL (Qbutton8); 4360 #include "keymap-buttons.h"
4621 DEFSYMBOL (Qbutton9);
4622 DEFSYMBOL (Qbutton10);
4623 DEFSYMBOL (Qbutton11);
4624 DEFSYMBOL (Qbutton12);
4625 DEFSYMBOL (Qbutton13);
4626 DEFSYMBOL (Qbutton14);
4627 DEFSYMBOL (Qbutton15);
4628 DEFSYMBOL (Qbutton16);
4629 DEFSYMBOL (Qbutton17);
4630 DEFSYMBOL (Qbutton18);
4631 DEFSYMBOL (Qbutton19);
4632 DEFSYMBOL (Qbutton20);
4633 DEFSYMBOL (Qbutton21);
4634 DEFSYMBOL (Qbutton22);
4635 DEFSYMBOL (Qbutton23);
4636 DEFSYMBOL (Qbutton24);
4637 DEFSYMBOL (Qbutton25);
4638 DEFSYMBOL (Qbutton26);
4639 DEFSYMBOL (Qbutton0up);
4640 DEFSYMBOL (Qbutton1up);
4641 DEFSYMBOL (Qbutton2up);
4642 DEFSYMBOL (Qbutton3up);
4643 DEFSYMBOL (Qbutton4up);
4644 DEFSYMBOL (Qbutton5up);
4645 DEFSYMBOL (Qbutton6up);
4646 DEFSYMBOL (Qbutton7up);
4647 DEFSYMBOL (Qbutton8up);
4648 DEFSYMBOL (Qbutton9up);
4649 DEFSYMBOL (Qbutton10up);
4650 DEFSYMBOL (Qbutton11up);
4651 DEFSYMBOL (Qbutton12up);
4652 DEFSYMBOL (Qbutton13up);
4653 DEFSYMBOL (Qbutton14up);
4654 DEFSYMBOL (Qbutton15up);
4655 DEFSYMBOL (Qbutton16up);
4656 DEFSYMBOL (Qbutton17up);
4657 DEFSYMBOL (Qbutton18up);
4658 DEFSYMBOL (Qbutton19up);
4659 DEFSYMBOL (Qbutton20up);
4660 DEFSYMBOL (Qbutton21up);
4661 DEFSYMBOL (Qbutton22up);
4662 DEFSYMBOL (Qbutton23up);
4663 DEFSYMBOL (Qbutton24up);
4664 DEFSYMBOL (Qbutton25up);
4665 DEFSYMBOL (Qbutton26up);
4666 DEFSYMBOL (Qmouse_1);
4667 DEFSYMBOL (Qmouse_2);
4668 DEFSYMBOL (Qmouse_3);
4669 DEFSYMBOL (Qmouse_4);
4670 DEFSYMBOL (Qmouse_5);
4671 DEFSYMBOL (Qmouse_6);
4672 DEFSYMBOL (Qmouse_7);
4673 DEFSYMBOL (Qmouse_8);
4674 DEFSYMBOL (Qmouse_9);
4675 DEFSYMBOL (Qmouse_10);
4676 DEFSYMBOL (Qmouse_11);
4677 DEFSYMBOL (Qmouse_12);
4678 DEFSYMBOL (Qmouse_13);
4679 DEFSYMBOL (Qmouse_14);
4680 DEFSYMBOL (Qmouse_15);
4681 DEFSYMBOL (Qmouse_16);
4682 DEFSYMBOL (Qmouse_17);
4683 DEFSYMBOL (Qmouse_18);
4684 DEFSYMBOL (Qmouse_19);
4685 DEFSYMBOL (Qmouse_20);
4686 DEFSYMBOL (Qmouse_21);
4687 DEFSYMBOL (Qmouse_22);
4688 DEFSYMBOL (Qmouse_23);
4689 DEFSYMBOL (Qmouse_24);
4690 DEFSYMBOL (Qmouse_25);
4691 DEFSYMBOL (Qmouse_26);
4692 DEFSYMBOL (Qdown_mouse_1);
4693 DEFSYMBOL (Qdown_mouse_2);
4694 DEFSYMBOL (Qdown_mouse_3);
4695 DEFSYMBOL (Qdown_mouse_4);
4696 DEFSYMBOL (Qdown_mouse_5);
4697 DEFSYMBOL (Qdown_mouse_6);
4698 DEFSYMBOL (Qdown_mouse_7);
4699 DEFSYMBOL (Qdown_mouse_8);
4700 DEFSYMBOL (Qdown_mouse_9);
4701 DEFSYMBOL (Qdown_mouse_10);
4702 DEFSYMBOL (Qdown_mouse_11);
4703 DEFSYMBOL (Qdown_mouse_12);
4704 DEFSYMBOL (Qdown_mouse_13);
4705 DEFSYMBOL (Qdown_mouse_14);
4706 DEFSYMBOL (Qdown_mouse_15);
4707 DEFSYMBOL (Qdown_mouse_16);
4708 DEFSYMBOL (Qdown_mouse_17);
4709 DEFSYMBOL (Qdown_mouse_18);
4710 DEFSYMBOL (Qdown_mouse_19);
4711 DEFSYMBOL (Qdown_mouse_20);
4712 DEFSYMBOL (Qdown_mouse_21);
4713 DEFSYMBOL (Qdown_mouse_22);
4714 DEFSYMBOL (Qdown_mouse_23);
4715 DEFSYMBOL (Qdown_mouse_24);
4716 DEFSYMBOL (Qdown_mouse_25);
4717 DEFSYMBOL (Qdown_mouse_26);
4718 DEFSYMBOL (Qmenu_selection); 4361 DEFSYMBOL (Qmenu_selection);
4719 DEFSYMBOL (QLFD); 4362 DEFSYMBOL (QLFD);
4720 DEFSYMBOL (QTAB); 4363 DEFSYMBOL (QTAB);
4721 DEFSYMBOL (QRET); 4364 DEFSYMBOL (QRET);
4722 DEFSYMBOL (QESC); 4365 DEFSYMBOL (QESC);