[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: describe key ESC ESC: Args out of range
From: |
David Hunter |
Subject: |
Re: describe key ESC ESC: Args out of range |
Date: |
Thu, 14 Apr 2005 00:31:20 -0400 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) |
Richard Stallman wrote:
Could someone please look at this question further? I tried to work
on this problem but I could not understand it without more info.
When describe-key is run interactively, echo_message_buffer is set
to "Describe key: " by message3_nolog,
Where in the code for message3_nolog does that happen?
I can't spot it.
It appears to me that echo_message_buffer is set by echo_now
*after* it calls message3_nolog. Which is also *after* the
call to echo_area_display that clears echo_message_buffer.
So I am confused about the sequence of events. Could you investigate
these further?
Hmm, sorry for the bad diagnosis. (I shouldn't debug past my bedtime.) Lemme
try again...
You're absolutely right; echo_message_buffer *is* set by echo_now after
echo_area_display clears it. So immediately after read_key_sequence calls
echo_prompt, both echo_area_buffer[0] and echo_message_buffer are #<buffer *Echo
Area 0*>.
echo_string contains "Describe key: ". read_key_sequence sets echo_start =
echo_length (), which is 14.
Continuing down to keyboard.c:8804, read_key_sequence then calls read_char.
commandflag, input_pending, and help_echo_showing_p are 0, so redisplay is
called at line 2544.
In redisplay_internal at xdisp.c:10094, echo_area_buffer[0] is non-nil and
display_last_displayed_message_p is 0, so echo_area_display is called.
#0 echo_area_display (update_frame_p=0) at xdisp.c:8127
#1 0x01042015 in redisplay_internal (preserve_echo_area=0) at xdisp.c:10094
#2 0x010414f2 in redisplay () at xdisp.c:9645
#3 0x0100a155 in read_char (commandflag=0, nmaps=3, maps=0x82f84c,
prev_event=23629825, used_mouse_menu=0x82f888) at keyboard.c:2544
#4 0x01010b3a in read_key_sequence (keybuf=0x82f9a0, bufsize=30,
prompt=32282419, dont_downcase_last=0, can_return_switch_frame=0,
fix_current_buffer=0) at keyboard.c:8804
echo_message_buffer is once again cleared by echo_area_display, but this time
nothing sets it. The comment where echo_message_buffer is cleared says this
informs read_char that we're not echoing. (This is the part that confuses me.)
Execution returns to read_char at keyboard.c:2582, where echo_message_buffer
is tested. The test calls cancel_echoing, which clears echo_string.
By clearing echo_string, the "Describe key" prompt wiil not be included in
future echo area updates. It will not be displayed as keys are entered. Clearing
echo_string also invalidates echo_start, but this won't be a problem until somebody sets
echo_string again.
Now we press "ESC" the first time.
Execution jumps back to 'replay_sequence:' at keyboard.c:8613, and read_char is
called again. A redisplay occurs, visibly clearing the echo area (because
echo_string is nil).
Now we sit_for Vecho_keystrokes (wait 1 second). read_char calls echo_now, which sets
echo_string to "ESC-" and updates the display.
[***] Please note: if you are using a debugger to follow along, extra input
events could be generated that will affect the outcome. In Win32, frame focus
loss or mouse leaving generates help events. read_char processes the help
event and again calls cancel_echoing. Since this clears echo_string, the error
will not occur. [***]
Now we press "ESC" the second time.
read_char calls echo_char, which sets echo_string to "ESC escape". In read_key_sequence,
execution jumps back to 'replay_sequence:'. Because it's about to echo the captured key sequence all
over again, it wants to clear everything from the echo area except the prompt. Thus it calls
echo_truncate (echo_length), still assuming that echo_string starts with the prompt. This finally
results in the "Args out of range" error, since echo_string is non-nil and echo_length [14]
>= SCHARS(echo_string) [10].
This error did not occur in emacs prior to xdisp.c revision 1.976. Additionally, the old
behavior was that after each keypress, it immediately showed the prompt with the key
sequence (e.g. "Describe key: ESC-").
-Dave