diff options
| author | Gerd Moellmann | 2001-01-29 19:52:22 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2001-01-29 19:52:22 +0000 |
| commit | 341e4f2465a443d85f636098e9acd29f89a1d472 (patch) | |
| tree | 13991401f0a8d63c318497395b052e6ac9f88f5a /src/keymap.c | |
| parent | ddd16e7ab5e2bdfde276887963ddcb74750f4865 (diff) | |
| download | emacs-341e4f2465a443d85f636098e9acd29f89a1d472.tar.gz emacs-341e4f2465a443d85f636098e9acd29f89a1d472.zip | |
(mouse_key_p): New function.
(where_is_internal, Fwhere_is_internal): Use it.
Diffstat (limited to 'src/keymap.c')
| -rw-r--r-- | src/keymap.c | 57 |
1 files changed, 53 insertions, 4 deletions
diff --git a/src/keymap.c b/src/keymap.c index f5b037ffa43..73fa716d36d 100644 --- a/src/keymap.c +++ b/src/keymap.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* Manipulation of keymaps | 1 | /* Manipulation of keymaps |
| 2 | Copyright (C) 1985, 86,87,88,93,94,95,98,99, 2000 | 2 | Copyright (C) 1985, 86,87,88,93,94,95,98,99, 2000, 2001 |
| 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. |
| @@ -114,6 +114,9 @@ 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 | |||
| 117 | 120 | ||
| 118 | /* Keymap object support - constructors and predicates. */ | 121 | /* Keymap object support - constructors and predicates. */ |
| 119 | 122 | ||
| @@ -2013,6 +2016,7 @@ Control characters turn into \"^char\", etc.") | |||
| 2013 | 2016 | ||
| 2014 | /* Return non-zero if SEQ contains only ASCII characters, perhaps with | 2017 | /* Return non-zero if SEQ contains only ASCII characters, perhaps with |
| 2015 | a meta bit. */ | 2018 | a meta bit. */ |
| 2019 | |||
| 2016 | static int | 2020 | static int |
| 2017 | ascii_sequence_p (seq) | 2021 | ascii_sequence_p (seq) |
| 2018 | Lisp_Object seq; | 2022 | Lisp_Object seq; |
| @@ -2035,6 +2039,48 @@ ascii_sequence_p (seq) | |||
| 2035 | return 1; | 2039 | return 1; |
| 2036 | } | 2040 | } |
| 2037 | 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 | |||
| 2038 | 2084 | ||
| 2039 | /* where-is - finding a command in a set of keymaps. */ | 2085 | /* where-is - finding a command in a set of keymaps. */ |
| 2040 | 2086 | ||
| @@ -2102,7 +2148,7 @@ where_is_internal (definition, keymaps, firstonly, noindirect) | |||
| 2102 | last_is_meta = (XINT (last) >= 0 | 2148 | last_is_meta = (XINT (last) >= 0 |
| 2103 | && EQ (Faref (this, last), meta_prefix_char)); | 2149 | && EQ (Faref (this, last), meta_prefix_char)); |
| 2104 | 2150 | ||
| 2105 | if (nomenus && !ascii_sequence_p (this)) | 2151 | if (nomenus && !ascii_sequence_p (this) && !mouse_key_p (this)) |
| 2106 | /* If no menu entries should be returned, skip over the | 2152 | /* If no menu entries should be returned, skip over the |
| 2107 | keymaps bound to `menu-bar' and `tool-bar' and other | 2153 | keymaps bound to `menu-bar' and `tool-bar' and other |
| 2108 | non-ascii prefixes. */ | 2154 | non-ascii prefixes. */ |
| @@ -2204,7 +2250,9 @@ where_is_internal (definition, keymaps, firstonly, noindirect) | |||
| 2204 | we find. */ | 2250 | we find. */ |
| 2205 | if (EQ (firstonly, Qnon_ascii)) | 2251 | if (EQ (firstonly, Qnon_ascii)) |
| 2206 | RETURN_UNGCPRO (sequence); | 2252 | RETURN_UNGCPRO (sequence); |
| 2207 | else if (! NILP (firstonly) && ascii_sequence_p (sequence)) | 2253 | else if (!NILP (firstonly) |
| 2254 | && (ascii_sequence_p (sequence) | ||
| 2255 | || mouse_key_p (sequence))) | ||
| 2208 | RETURN_UNGCPRO (sequence); | 2256 | RETURN_UNGCPRO (sequence); |
| 2209 | } | 2257 | } |
| 2210 | } | 2258 | } |
| @@ -2304,7 +2352,8 @@ indirect definition itself.") | |||
| 2304 | result = Qnil; | 2352 | result = Qnil; |
| 2305 | for (i = n - 1; i >= 0; --i) | 2353 | for (i = n - 1; i >= 0; --i) |
| 2306 | if (EQ (shadow_lookup (keymaps, defns[i], Qnil), definition) | 2354 | if (EQ (shadow_lookup (keymaps, defns[i], Qnil), definition) |
| 2307 | && ascii_sequence_p (defns[i])) | 2355 | && (ascii_sequence_p (defns[i]) |
| 2356 | || mouse_key_p (defns[i]))) | ||
| 2308 | break; | 2357 | break; |
| 2309 | 2358 | ||
| 2310 | result = i >= 0 ? defns[i] : Qnil; | 2359 | result = i >= 0 ? defns[i] : Qnil; |