aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Blandy1992-11-16 00:45:02 +0000
committerJim Blandy1992-11-16 00:45:02 +0000
commite37c080581f5517697c6fc8fbabd626e1ca69b74 (patch)
tree1a92bd3eb41515db3df82a601311fdadb7c29c00
parent8f805655d50508e04b80e5cd37b5f4f40b4098c7 (diff)
downloademacs-e37c080581f5517697c6fc8fbabd626e1ca69b74.tar.gz
emacs-e37c080581f5517697c6fc8fbabd626e1ca69b74.zip
* lread.c: #include "keyboard.h".
(Fread_char, Fread_char_exclusive): Don't signal an error for or throw away switch-frame events; instead, put them off until after we've found a character we can respond to. Rename unread_command_char to unread_command_event; it has subtly different semantics now, and we should use `make-obsolete-variable' to warn people. * lread.c (Fread_char): Change reference.
-rw-r--r--src/lread.c80
1 files changed, 66 insertions, 14 deletions
diff --git a/src/lread.c b/src/lread.c
index 0a5c0b2b940..ded35fa780a 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -32,6 +32,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
32#include "buffer.h" 32#include "buffer.h"
33#include "paths.h" 33#include "paths.h"
34#include "commands.h" 34#include "commands.h"
35#include "keyboard.h"
35#endif 36#endif
36 37
37#ifdef lint 38#ifdef lint
@@ -164,20 +165,48 @@ DEFUN ("read-char", Fread_char, Sread_char, 0, 0, 0,
164 "Read a character from the command input (keyboard or macro).\n\ 165 "Read a character from the command input (keyboard or macro).\n\
165It is returned as a number.\n\ 166It is returned as a number.\n\
166If the user generates an event which is not a character (i.e. a mouse\n\ 167If the user generates an event which is not a character (i.e. a mouse\n\
167click or function key event), `read-char' signals an error. If you\n\ 168click or function key event), `read-char' signals an error. As an\n\
168want to read non-character events, or ignore them, call `read-event'\n\ 169exception, switch-frame events are put off until non-ASCII events can\n\
169or `read-char-exclusive' instead.") 170be read.\n\
171If you want to read non-character events, or ignore them, call\n\
172`read-event' or `read-char-exclusive' instead.")
170 () 173 ()
171{ 174{
172 register Lisp_Object val; 175 register Lisp_Object val;
173 176
174#ifndef standalone 177#ifndef standalone
175 val = read_char (0, 0, 0, Qnil, 0); 178 {
176 if (XTYPE (val) != Lisp_Int) 179 register Lisp_Object delayed_switch_frame;
177 { 180
178 unread_command_char = val; 181 delayed_switch_frame = Qnil;
179 error ("Object read was not a character"); 182
180 } 183 for (;;)
184 {
185 val = read_char (0, 0, 0, Qnil, 0);
186
187 /* switch-frame events are put off until after the next ASCII
188 character. This is better than signalling an error just
189 because the last characters were typed to a separate
190 minibuffer frame, for example. Eventually, some code which
191 can deal with switch-frame events will read it and process
192 it. */
193 if (EVENT_HAS_PARAMETERS (val)
194 && EQ (EVENT_HEAD (val), Qswitch_frame))
195 delayed_switch_frame = val;
196 else
197 break;
198 }
199
200 if (! NILP (delayed_switch_frame))
201 unread_switch_frame = delayed_switch_frame;
202
203 /* Only ASCII characters are acceptable. */
204 if (XTYPE (val) != Lisp_Int)
205 {
206 unread_command_event = val;
207 error ("Object read was not a character");
208 }
209 }
181#else 210#else
182 val = getchar (); 211 val = getchar ();
183#endif 212#endif
@@ -203,11 +232,34 @@ It is returned as a number. Non character events are ignored.")
203 register Lisp_Object val; 232 register Lisp_Object val;
204 233
205#ifndef standalone 234#ifndef standalone
206 do 235 {
207 { 236 Lisp_Object delayed_switch_frame;
208 val = read_char (0, 0, 0, Qnil, 0); 237
209 } 238 delayed_switch_frame = Qnil;
210 while (XTYPE (val) != Lisp_Int); 239
240 for (;;)
241 {
242 val = read_char (0, 0, 0, Qnil, 0);
243
244 if (XTYPE (val) == Lisp_Int)
245 break;
246
247 /* switch-frame events are put off until after the next ASCII
248 character. This is better than signalling an error just
249 because the last characters were typed to a separate
250 minibuffer frame, for example. Eventually, some code which
251 can deal with switch-frame events will read it and process
252 it. */
253 else if (EVENT_HAS_PARAMETERS (val)
254 && EQ (EVENT_HEAD (val), Qswitch_frame))
255 delayed_switch_frame = val;
256
257 /* Drop everything else. */
258 }
259
260 if (! NILP (delayed_switch_frame))
261 unread_switch_frame = delayed_switch_frame;
262 }
211#else 263#else
212 val = getchar (); 264 val = getchar ();
213#endif 265#endif