comparison src/keymap.c @ 35706:952bdd6fb8e5

Undo last change.
author Gerd Moellmann <gerd@gnu.org>
date Mon, 29 Jan 2001 20:04:42 +0000
parents 8bd6c08f7278
children ffdcf20f53f2
comparison
equal deleted inserted replaced
35705:6c05ec832ecc 35706:952bdd6fb8e5
1 /* Manipulation of keymaps 1 /* Manipulation of keymaps
2 Copyright (C) 1985, 86,87,88,93,94,95,98,99, 2000, 2001 2 Copyright (C) 1985, 86,87,88,93,94,95,98,99, 2000
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 4
5 This file is part of GNU Emacs. 5 This file is part of GNU Emacs.
6 6
7 GNU Emacs is free software; you can redistribute it and/or modify 7 GNU Emacs is free software; you can redistribute it and/or modify
112 static void describe_command P_ ((Lisp_Object)); 112 static void describe_command P_ ((Lisp_Object));
113 static void describe_translation P_ ((Lisp_Object)); 113 static void describe_translation P_ ((Lisp_Object));
114 static void describe_map P_ ((Lisp_Object, Lisp_Object, 114 static void describe_map P_ ((Lisp_Object, Lisp_Object,
115 void (*) P_ ((Lisp_Object)), 115 void (*) P_ ((Lisp_Object)),
116 int, Lisp_Object, Lisp_Object*, int)); 116 int, Lisp_Object, Lisp_Object*, int));
117 static int mouse_key_p P_ ((Lisp_Object));
118 static int ascii_sequence_p P_ ((Lisp_Object));
119
120 117
121 /* Keymap object support - constructors and predicates. */ 118 /* Keymap object support - constructors and predicates. */
122 119
123 DEFUN ("make-keymap", Fmake_keymap, Smake_keymap, 0, 1, 0, 120 DEFUN ("make-keymap", Fmake_keymap, Smake_keymap, 0, 1, 0,
124 "Construct and return a new keymap, of the form (keymap CHARTABLE . ALIST).\n\ 121 "Construct and return a new keymap, of the form (keymap CHARTABLE . ALIST).\n\
2014 return build_string (str); 2011 return build_string (str);
2015 } 2012 }
2016 2013
2017 /* Return non-zero if SEQ contains only ASCII characters, perhaps with 2014 /* Return non-zero if SEQ contains only ASCII characters, perhaps with
2018 a meta bit. */ 2015 a meta bit. */
2019
2020 static int 2016 static int
2021 ascii_sequence_p (seq) 2017 ascii_sequence_p (seq)
2022 Lisp_Object seq; 2018 Lisp_Object seq;
2023 { 2019 {
2024 int i; 2020 int i;
2036 return 0; 2032 return 0;
2037 } 2033 }
2038 2034
2039 return 1; 2035 return 1;
2040 } 2036 }
2041
2042
2043 /* Value is non-zero if SEQ is a mouse key.
2044
2045 Note: We can't use the property lists of mouse-key symbols to
2046 determine this, because these symbols and their property lists are
2047 created only when a mouse-event has been seen. */
2048
2049 static int
2050 mouse_key_p (seq)
2051 Lisp_Object seq;
2052 {
2053 int mouse_p = 0;
2054
2055 seq = Faref (seq, 0);
2056 if (SYMBOLP (seq))
2057 {
2058 unsigned char *name = XSYMBOL (seq)->name->data;
2059
2060 while (*(name + 1) == '-'
2061 && (*name == 'S' || *name == 'C' || *name == 'M'
2062 || *name == 'A' || *name == 'H'))
2063 name += 2;
2064
2065 if (bcmp (name, "up-", 3) == 0)
2066 name += 3;
2067 else if (bcmp (name, "down-", 5) == 0)
2068 name += 5;
2069
2070 if (bcmp (name, "mouse-", 6) == 0)
2071 {
2072 name += 6;
2073 while (*name >= '0' && *name <= '9')
2074 ++name;
2075 }
2076
2077 mouse_p = *name == '\0';
2078 }
2079
2080 return mouse_p;
2081 }
2082
2083 2037
2084 2038
2085 /* where-is - finding a command in a set of keymaps. */ 2039 /* where-is - finding a command in a set of keymaps. */
2086 2040
2087 static Lisp_Object where_is_internal_1 (); 2041 static Lisp_Object where_is_internal_1 ();
2146 map = Fcdr (Fcar (maps)); 2100 map = Fcdr (Fcar (maps));
2147 last = make_number (XINT (Flength (this)) - 1); 2101 last = make_number (XINT (Flength (this)) - 1);
2148 last_is_meta = (XINT (last) >= 0 2102 last_is_meta = (XINT (last) >= 0
2149 && EQ (Faref (this, last), meta_prefix_char)); 2103 && EQ (Faref (this, last), meta_prefix_char));
2150 2104
2151 if (nomenus && !ascii_sequence_p (this) && !mouse_key_p (this)) 2105 if (nomenus && !ascii_sequence_p (this))
2152 /* If no menu entries should be returned, skip over the 2106 /* If no menu entries should be returned, skip over the
2153 keymaps bound to `menu-bar' and `tool-bar' and other 2107 keymaps bound to `menu-bar' and `tool-bar' and other
2154 non-ascii prefixes. */ 2108 non-ascii prefixes. */
2155 continue; 2109 continue;
2156 2110
2248 binding we find. If firstonly is not Qnon_ascii but not 2202 binding we find. If firstonly is not Qnon_ascii but not
2249 nil, then we should return the first ascii-only binding 2203 nil, then we should return the first ascii-only binding
2250 we find. */ 2204 we find. */
2251 if (EQ (firstonly, Qnon_ascii)) 2205 if (EQ (firstonly, Qnon_ascii))
2252 RETURN_UNGCPRO (sequence); 2206 RETURN_UNGCPRO (sequence);
2253 else if (!NILP (firstonly) 2207 else if (! NILP (firstonly) && ascii_sequence_p (sequence))
2254 && (ascii_sequence_p (sequence)
2255 || mouse_key_p (sequence)))
2256 RETURN_UNGCPRO (sequence); 2208 RETURN_UNGCPRO (sequence);
2257 } 2209 }
2258 } 2210 }
2259 } 2211 }
2260 2212
2350 the following can GC. */ 2302 the following can GC. */
2351 GCPRO2 (definition, keymaps); 2303 GCPRO2 (definition, keymaps);
2352 result = Qnil; 2304 result = Qnil;
2353 for (i = n - 1; i >= 0; --i) 2305 for (i = n - 1; i >= 0; --i)
2354 if (EQ (shadow_lookup (keymaps, defns[i], Qnil), definition) 2306 if (EQ (shadow_lookup (keymaps, defns[i], Qnil), definition)
2355 && (ascii_sequence_p (defns[i]) 2307 && ascii_sequence_p (defns[i]))
2356 || mouse_key_p (defns[i])))
2357 break; 2308 break;
2358 2309
2359 result = i >= 0 ? defns[i] : Qnil; 2310 result = i >= 0 ? defns[i] : Qnil;
2360 UNGCPRO; 2311 UNGCPRO;
2361 } 2312 }