Article View: gnu.emacs.help
Article #188983Re: emacs should not ask questions when non-interactive
From: Dan_Jacobson
Date: Wed, 15 May 1991 13:09
Date: Wed, 15 May 1991 13:09
185 lines
5676 bytes
5676 bytes
I am not set up to test new C code... perhaps someone on
gnu.emacs.help will verify that this stops the problem of looping
asking y-or-n in:
$ emacs -batch -l xyz -kill < /dev/null
or
$ emacs -batch -l xyz -kill <&-
when xyz.el has
(y-or-n-p "whatever")
or
(yes-or-no-p "whatever")
in it.
------- Start of forwarded message -------
From: rms@gnu.ai.mit.edu (Richard Stallman)
To: Dan_Jacobson@ihlpz.ATT.COM
Subject: emacs should not ask questions when non-interactive
Date: Tue, 14 May 91 21:39:58 -0400
Does this change make things work? It should exit at eof if noninteractive.
read_command_char (commandflag)
int commandflag;
{
register int c;
int alarmtime;
int count;
Lisp_Object tem;
jmp_buf save_jump;
extern request_echo ();
if (unread_command_char >= 0)
{
c = unread_command_char;
unread_command_char = -1;
if (this_command_key_count == 0)
goto reread_first;
goto reread;
}
if (!NULL (Vexecuting_macro))
{
if (XTYPE (Vexecuting_macro) != Lisp_String
|| XSTRING (Vexecuting_macro)->size <= executing_macro_index)
return -1;
QUIT;
c = XSTRING (Vexecuting_macro)->data[executing_macro_index++];
goto from_macro;
}
/* Save outer setjmp data, in case called recursively. */
bcopy (getcjmp, save_jump, sizeof getcjmp);
stop_polling ();
if (commandflag >= 0 && !detect_input_pending ())
redisplay ();
if (commandflag != 0
&& auto_save_interval > 0
&& num_input_chars - last_auto_save > max (auto_save_interval, 20)
&& !detect_input_pending ())
Fdo_auto_save (Qnil);
if (_setjmp (getcjmp))
{
c = quit_char;
waiting_for_input = 0;
input_available_clear_word = 0;
goto non_reread;
}
/* Message turns off echoing unless more keystrokes turn it on again. */
if (echo_area_contents && *echo_area_contents && echo_area_contents != echobuf)
cancel_echoing ();
else
/* If already echoing, continue, and prompt. */
echo_dash ();
/* If in middle of key sequence and minibuffer not active,
start echoing if enough time elapses. */
if (minibuf_level == 0 && !immediate_echo && this_command_key_count > 0
&& echo_keystrokes > 0
&& (echo_area_contents == 0 || *echo_area_contents == 0))
{
/* Else start echoing if user waits more than `alarmtime' seconds. */
/* This interrupt either calls echo right away
or sets echo_flag, which causes echo to be called
by set_waiting_for_input's next invocation. */
signal (SIGALRM, request_echo);
echo_flag = 0;
echo_now = 0;
alarmtime = echo_keystrokes;
alarm ((unsigned) alarmtime);
}
c = kbd_buffer_read_command_char ();
/* Terminate Emacs in batch mode if at eof. */
if (noninteractive && c < 0)
Fkill_emacs (make_number (1));
non_reread:
bcopy (save_jump, getcjmp, sizeof getcjmp);
/* Cancel alarm if it was set and has not already gone off. */
if (alarmtime > 0) alarm (0);
echo_area_contents = 0;
if (c < 0) return -1;
c &= meta_key ? 0377 : 0177;
if (XTYPE (Vkeyboard_translate_table) == Lisp_String
&& XSTRING (Vkeyboard_translate_table)->size > c)
c = XSTRING (Vkeyboard_translate_table)->data[c];
total_keys++;
recent_keys[recent_keys_index] = c;
recent_keys_index = (recent_keys_index + 1) % sizeof recent_keys;
if (dribble)
{
putc (c, dribble);
fflush (dribble);
}
store_kbd_macro_char (c);
start_polling ();
from_macro:
reread_first: /* Rereading a char and it is the first in a command. */
echo_char (c);
/* Record this character as part of the current key. */
if (this_command_key_count == this_command_keys_size)
{
this_command_keys_size *= 2;
this_command_keys
= (unsigned char *) xrealloc (this_command_keys,
this_command_keys_size);
}
this_command_keys[this_command_key_count++] = c;
/* Rereading in the middle of a command. */
reread:
last_input_char = c;
num_input_chars++;
/* Process the help character specially if enabled */
if (c == help_char && !NULL (Vhelp_form))
{
count = specpdl_ptr - specpdl;
record_unwind_protect (Fset_window_configuration,
Fcurrent_window_configuration ());
tem = Feval (Vhelp_form);
if (XTYPE (tem) == Lisp_String)
internal_with_output_to_temp_buffer ("*Help*", print_help, tem);
cancel_echoing ();
c = read_command_char (0);
/* Remove the help from the screen */
unbind_to (count);
redisplay ();
if (c == 040)
{
cancel_echoing ();
c = read_command_char (0);
}
}
return c;
}
------- End of forwarded message -------
Technical Details
Message-ID:
<1991May15.130943.18521@cbnewse.att.com>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!sunic!uupsi!rpi!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!cbnewse!danj1References:
<9105102206.AA23351@life.ai.mit.edu>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103b8b,faa9f44287e0668b,start X-Google-Attributes: gid103b8b,public X-Google-ArrivalTime: 1991-05-15 14:43:57 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!sunic!uupsi!rpi!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!cbnewse!danj1 From: Dan_Jacobson@ATT.COM Newsgroups: gnu.emacs.help Subject: Re: emacs should not ask questions when non-interactive Message-ID: <1991May15.130943.18521@cbnewse.att.com> Date: 15 May 91 13:09:43 GMT References: <9105102206.AA23351@life.ai.mit.edu> Sender: news@cbnewse.att.com (NetNews Administrator) Reply-To: Dan_Jacobson@ihlpz.ATT.COM Organization: AT&T-BL, Naperville IL, USA Lines: 185 In-Reply-To: Dan_Jacobson@ATT.COM's message of 10 May 91 21: 32:00 GMT