(Update: OK, it all seems so easy now (NOT). Input could be done
synchronously (with wait_reading_process_input), or asynchronously
by SIGIO or polling (SIGALRM). C-g either sets the Vquit_flag,
- signals a 'quit condition (when immediate_quit), or throws to
- 'getcjmp' when Emacs was waiting for input when the C-g event
- arrived.)
+ signals a 'quit condition, or throws to 'getcjmp' when Emacs was
+ waiting for input when the C-g event arrived.)
-- Replace wrong_kboard_jmpbuf with a special return value of
read_char. It is absurd that we use setjmp/longjmp just to return
Lisp_Object v2 = POP, v1 = TOP;
CHECK_NUMBER (v1);
EMACS_INT n = XINT (v1);
- immediate_quit = true;
while (--n >= 0 && CONSP (v2))
v2 = XCDR (v2);
- immediate_quit = false;
TOP = CAR (v2);
NEXT;
}
Lisp_Object v2 = POP, v1 = TOP;
CHECK_NUMBER (v2);
EMACS_INT n = XINT (v2);
- immediate_quit = true;
while (--n >= 0 && CONSP (v1))
v1 = XCDR (v1);
- immediate_quit = false;
TOP = CAR (v1);
}
else
{
kill (-synch_process_pid, SIGINT);
message1 ("Waiting for process to die...(type C-g again to kill it instantly)");
- immediate_quit = true;
maybe_quit ();
wait_for_termination (synch_process_pid, 0, 1);
synch_process_pid = 0;
- immediate_quit = false;
message1 ("Waiting for process to die...done");
}
#endif /* !MSDOS */
process_coding.src_multibyte = 0;
}
- immediate_quit = true;
maybe_quit ();
if (0 <= fd0)
}
/* Now NREAD is the total amount of data in the buffer. */
- immediate_quit = false;
if (!nread)
;
we should have already detected a coding system. */
display_on_the_fly = true;
}
- immediate_quit = true;
+
maybe_quit ();
}
give_up: ;
wait_for_termination (pid, &status, fd0 < 0);
#endif
- immediate_quit = false;
-
/* Don't kill any children that the subprocess may have left behind
when exiting. */
synch_process_pid = 0;
/* Now that we have unwind_protect in place, we might as well
allow matching to be interrupted. */
- immediate_quit = true;
maybe_quit ();
bool wanted = (NILP (match)
|| re_search (bufp, SSDATA (name), len, 0, len, 0) >= 0);
- immediate_quit = false;
-
if (wanted)
{
if (!NILP (full))
i2 = begp2;
i1_byte = buf_charpos_to_bytepos (bp1, i1);
i2_byte = buf_charpos_to_bytepos (bp2, i2);
- immediate_quit = true;
while (i1 < endp1 && i2 < endp2)
{
c1 = char_table_translate (trt, c1);
c2 = char_table_translate (trt, c2);
}
+
if (c1 != c2)
- {
- immediate_quit = false;
- return make_number (c1 < c2 ? -1 - chars : chars + 1);
- }
+ return make_number (c1 < c2 ? -1 - chars : chars + 1);
chars++;
}
- immediate_quit = false;
-
/* The strings match as far as they go.
If one is shorter, that one is less. */
if (chars < endp1 - begp1)
/* Restore certain special C variables. */
set_poll_suppress_count (catch->poll_suppress_count);
unblock_input_to (catch->interrupt_input_blocked);
- immediate_quit = false;
do
{
Lisp_Object clause = Qnil;
struct handler *h;
- immediate_quit = false;
if (gc_in_progress || waiting_for_input)
emacs_abort ();
report_file_error ("Copying permissions to", newname);
}
#else /* not WINDOWSNT */
- immediate_quit = true;
ifd = emacs_open (SSDATA (encoded_file), O_RDONLY, 0);
- immediate_quit = false;
if (ifd < 0)
report_file_error ("Opening input file", file);
oldsize = out_st.st_size;
}
- immediate_quit = true;
maybe_quit ();
if (clone_file (ofd, ifd))
if (newsize < oldsize && ftruncate (ofd, newsize) != 0)
report_file_error ("Truncating output file", newname);
- immediate_quit = false;
-
#ifndef MSDOS
/* Preserve the original file permissions, and if requested, also its
owner and group. */
{
int nbytes;
- immediate_quit = true;
maybe_quit ();
nbytes = emacs_read (XSAVE_INTEGER (state, 0),
((char *) BEG_ADDR + PT_BYTE - BEG_BYTE
+ XSAVE_INTEGER (state, 1)),
XSAVE_INTEGER (state, 2));
- immediate_quit = false;
/* Fast recycle this object for the likely next call. */
free_misc (state);
return make_number (nbytes);
report_file_error ("Setting file position", orig_filename);
}
- immediate_quit = true;
maybe_quit ();
/* Count how many chars at the start of the file
match the text at the beginning of the buffer. */
if (bufpos != nread)
break;
}
- immediate_quit = false;
/* If the file matches the buffer completely,
there's no need to replace anything. */
if (same_at_start - BEGV_BYTE == end_offset - beg_offset)
del_range_1 (same_at_start, same_at_end, 0, 0);
goto handled;
}
- immediate_quit = true;
maybe_quit ();
/* Count how many chars at the end of the file
match the text at the end of the buffer. But, if we have
if (nread == 0)
break;
}
- immediate_quit = false;
if (! giveup_match_end)
{
quitting while reading a huge file. */
/* Allow quitting out of the actual I/O. */
- immediate_quit = true;
maybe_quit ();
this = emacs_read (fd, read_buf + unprocessed,
READ_BUF_SIZE - unprocessed);
- immediate_quit = false;
if (this <= 0)
break;
/* Allow quitting out of the actual I/O. We don't make text
part of the buffer until all the reading is done, so a C-g
here doesn't do any harm. */
- immediate_quit = true;
maybe_quit ();
this = emacs_read (fd,
((char *) BEG_ADDR + PT_BYTE - BEG_BYTE
+ inserted),
trytry);
- immediate_quit = false;
}
if (this <= 0)
}
}
- immediate_quit = true;
-
if (STRINGP (start))
ok = a_write (desc, start, 0, SCHARS (start), &annotations, &coding);
else if (XINT (start) != XINT (end))
save_errno = errno;
}
- immediate_quit = false;
-
/* fsync is not crucial for temporary files. Nor for auto-save
files, since they might lose some work anyway. */
if (open_and_close_file && !auto_saving && !write_region_inhibit_fsync)
CHECK_NUMBER (n);
EMACS_INT num = XINT (n);
Lisp_Object tail = list;
- immediate_quit = true;
for (EMACS_INT i = 0; i < num; i++)
{
if (! CONSP (tail))
{
- immediate_quit = false;
CHECK_LIST_END (tail, list);
return Qnil;
}
tail = XCDR (tail);
}
- immediate_quit = false;
return tail;
}
The value is actually the tail of LIST whose car is ELT. */)
(Lisp_Object elt, Lisp_Object list)
{
- immediate_quit = true;
Lisp_Object tail;
for (tail = list; CONSP (tail); tail = XCDR (tail))
{
if (EQ (XCAR (tail), elt))
- {
- immediate_quit = false;
- return tail;
- }
+ return tail;
}
- immediate_quit = false;
CHECK_LIST_END (tail, list);
return Qnil;
}
if (!FLOATP (elt))
return Fmemq (elt, list);
- immediate_quit = true;
Lisp_Object tail;
for (tail = list; CONSP (tail); tail = XCDR (tail))
{
Lisp_Object tem = XCAR (tail);
if (FLOATP (tem) && internal_equal (elt, tem, 0, 0, Qnil))
- {
- immediate_quit = false;
- return tail;
- }
+ return tail;
}
- immediate_quit = false;
CHECK_LIST_END (tail, list);
return Qnil;
}
Elements of LIST that are not conses are ignored. */)
(Lisp_Object key, Lisp_Object list)
{
- immediate_quit = true;
Lisp_Object tail;
for (tail = list; CONSP (tail); tail = XCDR (tail))
- if (CONSP (XCAR (tail)) && EQ (XCAR (XCAR (tail)), key))
- {
- immediate_quit = false;
+ {
+ if (CONSP (XCAR (tail)) && EQ (XCAR (XCAR (tail)), key))
return XCAR (tail);
- }
- immediate_quit = false;
+ }
CHECK_LIST_END (tail, list);
return Qnil;
}
The value is actually the first element of LIST whose cdr is KEY. */)
(Lisp_Object key, Lisp_Object list)
{
- immediate_quit = true;
Lisp_Object tail;
for (tail = list; CONSP (tail); tail = XCDR (tail))
- if (CONSP (XCAR (tail)) && EQ (XCDR (XCAR (tail)), key))
- {
- immediate_quit = false;
+ {
+ if (CONSP (XCAR (tail)) && EQ (XCDR (XCAR (tail)), key))
return XCAR (tail);
- }
- immediate_quit = false;
+ }
CHECK_LIST_END (tail, list);
return Qnil;
}
The PLIST is modified by side effects. */)
(Lisp_Object plist, Lisp_Object prop, Lisp_Object val)
{
- immediate_quit = true;
Lisp_Object prev = Qnil;
for (Lisp_Object tail = plist; CONSP (tail) && CONSP (XCDR (tail));
tail = XCDR (XCDR (tail)))
{
if (EQ (prop, XCAR (tail)))
{
- immediate_quit = false;
Fsetcar (XCDR (tail), val);
return plist;
}
prev = tail;
}
- immediate_quit = false;
Lisp_Object newcell
= Fcons (prop, Fcons (val, NILP (prev) ? plist : XCDR (XCDR (prev))));
if (NILP (prev))
CHECK_CONS (tem);
- immediate_quit = true;
Lisp_Object tail;
do
{
}
while (CONSP (tem));
- immediate_quit = false;
rarely_quit (&quit_count);
tem = args[argnum + 1];
The value is actually the tail of PLIST whose car is PROP. */)
(Lisp_Object plist, Lisp_Object prop)
{
- immediate_quit = true;
while (CONSP (plist) && !EQ (XCAR (plist), prop))
{
plist = XCDR (plist);
plist = CDR (plist);
}
- immediate_quit = false;
return plist;
}
continuation_glyph_width = 0; /* In the fringe. */
#endif
- immediate_quit = true;
maybe_quit ();
/* It's just impossible to be too paranoid here. */
/* Nonzero if have just continued a line */
val_compute_motion.contin = (contin_hpos && prev_hpos == 0);
- immediate_quit = false;
return &val_compute_motion;
}
Lisp_Object echo_message_buffer;
-/* True means C-g should cause immediate error-signal. */
-bool immediate_quit;
-
/* Character that causes a quit. Normally C-g.
If we are running on an ordinary terminal, this must be an ordinary
as input, set quit-flag to cause an interrupt. */
if (!NILP (Vthrow_on_input)
&& NILP (Fmemq (ignore_event, Vwhile_no_input_ignore_events)))
- {
- Vquit_flag = Vthrow_on_input;
- /* If we're inside a function that wants immediate quits,
- do it now. */
- if (immediate_quit && NILP (Vinhibit_quit))
- {
- immediate_quit = false;
- maybe_quit ();
- }
- }
+ Vquit_flag = Vthrow_on_input;
}
}
else
{
- /* If executing a function that wants to be interrupted out of
- and the user has not deferred quitting by binding `inhibit-quit'
- then quit right away. */
- if (immediate_quit && NILP (Vinhibit_quit) && !waiting_for_input)
- {
- struct gl_state_s saved;
-
- immediate_quit = false;
- pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
- saved = gl_state;
- quit ();
- gl_state = saved;
- }
- else
- { /* Else request quit when it's safe. */
- int count = NILP (Vquit_flag) ? 1 : force_quit_count + 1;
- force_quit_count = count;
- if (count == 3)
- {
- immediate_quit = true;
- Vinhibit_quit = Qnil;
- }
- Vquit_flag = Qt;
- }
+ /* Request quit when it's safe. */
+ int count = NILP (Vquit_flag) ? 1 : force_quit_count + 1;
+ force_quit_count = count;
+ if (count == 3)
+ Vinhibit_quit = Qnil;
+ Vquit_flag = Qt;
}
pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
{
/* This is correct before outermost invocation of the editor loop. */
command_loop_level = -1;
- immediate_quit = false;
quit_char = Ctl ('g');
Vunread_command_events = Qnil;
timer_idleness_start_time = invalid_timespec ();
impossible, of course. But it is very desirable to avoid creating
loops where maybe_quit is impossible.
- Exception: if you set immediate_quit, the handler that responds to
- the C-g does the quit itself. This is a good thing to do around a
- loop that has no side effects and (in particular) cannot call
- arbitrary Lisp code.
-
If quit-flag is set to `kill-emacs' the SIGINT handler has received
a request to exit Emacs when it is safe to do.
extern char my_endbss[];
extern char *my_endbss_static;
-/* True means ^G can quit instantly. */
-extern bool immediate_quit;
-
extern void *xmalloc (size_t) ATTRIBUTE_MALLOC_SIZE ((1));
extern void *xzalloc (size_t) ATTRIBUTE_MALLOC_SIZE ((1));
extern void *xrealloc (void *, size_t) ATTRIBUTE_ALLOC_SIZE ((2));
break;
}
- immediate_quit = true;
maybe_quit ();
ret = connect (s, sa, addrlen);
if (ret == 0 || xerrno == EISCONN)
{
- /* The unwind-protect will be discarded afterwards.
- Likewise for immediate_quit. */
+ /* The unwind-protect will be discarded afterwards. */
break;
}
}
#endif /* !WINDOWSNT */
- immediate_quit = false;
-
/* Discard the unwind protect closing S. */
specpdl_ptr = specpdl + count;
emacs_close (s);
#endif
}
- immediate_quit = false;
-
if (s < 0)
{
/* If non-blocking got this far - and failed - assume non-blocking is
struct addrinfo *res, *lres;
int ret;
- immediate_quit = true;
maybe_quit ();
struct addrinfo hints;
#else
error ("%s/%s getaddrinfo error %d", SSDATA (host), portstring, ret);
#endif
- immediate_quit = false;
for (lres = res; lres; lres = lres->ai_next)
addrinfos = Fcons (conv_addrinfo_to_lisp (lres), addrinfos);
/* Explicit quit checking is needed for Emacs, which uses polling to
process input events. */
-#ifdef emacs
-# define IMMEDIATE_QUIT_CHECK (immediate_quit ? maybe_quit () : (void) 0)
-#else
-# define IMMEDIATE_QUIT_CHECK ((void) 0)
+#ifndef emacs
+static void maybe_quit (void) {}
#endif
\f
/* Structure to manage work area for range table. */
/* Unconditionally jump (without popping any failure points). */
case jump:
unconditional_jump:
- IMMEDIATE_QUIT_CHECK;
+ maybe_quit ();
EXTRACT_NUMBER_AND_INCR (mcnt, p); /* Get the amount to jump. */
DEBUG_PRINT ("EXECUTING jump %d ", mcnt);
p += mcnt; /* Do the jump. */
/* We goto here if a matching operation fails. */
fail:
- IMMEDIATE_QUIT_CHECK;
+ maybe_quit ();
if (!FAIL_STACK_EMPTY ())
{
re_char *str, *pat;
!NILP (BVAR (current_buffer, enable_multibyte_characters)));
/* Do a pending quit right away, to avoid paradoxical behavior */
- immediate_quit = true;
maybe_quit ();
/* Get pointers and sizes of the two strings
(NILP (Vinhibit_changing_match_data)
? &search_regs : NULL),
ZV_BYTE - BEGV_BYTE);
- immediate_quit = false;
#ifdef REL_ALLOC
r_alloc_inhibit_buffer_relocation (0);
#endif
? BVAR (current_buffer, case_canon_table) : Qnil),
posix,
STRING_MULTIBYTE (string));
- immediate_quit = true;
re_match_object = string;
val = re_search (bufp, SSDATA (string),
SBYTES (string) - pos_byte,
(NILP (Vinhibit_changing_match_data)
? &search_regs : NULL));
- immediate_quit = false;
/* Set last_thing_searched only when match data is changed. */
if (NILP (Vinhibit_changing_match_data))
bufp = compile_pattern (regexp, 0, table,
0, STRING_MULTIBYTE (string));
- immediate_quit = true;
re_match_object = string;
val = re_search (bufp, SSDATA (string),
SBYTES (string), 0,
SBYTES (string), 0);
- immediate_quit = false;
return val;
}
bufp = compile_pattern (regexp, 0,
Vascii_canon_table, 0,
0);
- immediate_quit = true;
val = re_search (bufp, string, len, 0, len, 0);
- immediate_quit = false;
return val;
}
}
buf = compile_pattern (regexp, 0, Qnil, 0, multibyte);
- immediate_quit = true;
#ifdef REL_ALLOC
/* Prevent ralloc.c from relocating the current buffer while
searching it. */
#ifdef REL_ALLOC
r_alloc_inhibit_buffer_relocation (0);
#endif
- immediate_quit = false;
return len;
}
If BYTEPOS is not NULL, set *BYTEPOS to the byte position corresponding
to the returned character position.
- If ALLOW_QUIT, set immediate_quit. That's good to do
+ If ALLOW_QUIT, check for quitting. That's good to do
except when inside redisplay. */
ptrdiff_t
if (shortage != 0)
*shortage = 0;
- immediate_quit = allow_quit;
-
if (count > 0)
while (start != end)
{
ptrdiff_t next_change;
int result = 1;
- immediate_quit = false;
while (start < end && result)
{
ptrdiff_t lim1;
start_byte = end_byte;
break;
}
- immediate_quit = allow_quit;
/* START should never be after END. */
if (start_byte > ceiling_byte)
if (--count == 0)
{
- immediate_quit = false;
if (bytepos)
*bytepos = lim_byte + next;
return BYTE_TO_CHAR (lim_byte + next);
ptrdiff_t next_change;
int result = 1;
- immediate_quit = false;
while (start > end && result)
{
ptrdiff_t lim1;
start_byte = end_byte;
break;
}
- immediate_quit = allow_quit;
/* Start should never be at or before end. */
if (start_byte <= ceiling_byte)
if (++count >= 0)
{
- immediate_quit = false;
if (bytepos)
*bytepos = ceiling_byte + prev + 1;
return BYTE_TO_CHAR (ceiling_byte + prev + 1);
}
}
- immediate_quit = false;
if (shortage)
*shortage = count * direction;
if (bytepos)
the number of line boundaries left unfound, and position at
the limit we bumped up against.
- If ALLOW_QUIT, set immediate_quit. That's good to do
+ If ALLOW_QUIT, check for quitting. That's good to do
except in special cases. */
ptrdiff_t
trt, posix,
!NILP (BVAR (current_buffer, enable_multibyte_characters)));
- immediate_quit = true; /* Quit immediately if user types ^G,
- because letting this function finish
- can take too long. */
maybe_quit (); /* Do a pending quit right away,
to avoid paradoxical behavior */
/* Get pointers and sizes of the two strings
}
else
{
- immediate_quit = false;
#ifdef REL_ALLOC
r_alloc_inhibit_buffer_relocation (0);
#endif
}
else
{
- immediate_quit = false;
#ifdef REL_ALLOC
r_alloc_inhibit_buffer_relocation (0);
#endif
}
n--;
}
- immediate_quit = false;
#ifdef REL_ALLOC
r_alloc_inhibit_buffer_relocation (0);
#endif
if (shortage != 0)
*shortage = 0;
- immediate_quit = allow_quit;
-
if (count > 0)
while (start != end)
{
if (--count == 0)
{
- immediate_quit = false;
if (bytepos)
*bytepos = lim_byte + next;
return BYTE_TO_CHAR (lim_byte + next);
}
}
- immediate_quit = false;
if (shortage)
*shortage = count;
if (bytepos)
int ch0, ch1;
Lisp_Object func, pos;
- immediate_quit = true;
maybe_quit ();
SETUP_SYNTAX_TABLE (from, count);
while (1)
{
if (from == end)
- {
- immediate_quit = false;
- return 0;
- }
+ return 0;
UPDATE_SYNTAX_TABLE_FORWARD (from);
ch0 = FETCH_CHAR_AS_MULTIBYTE (from_byte);
code = SYNTAX (ch0);
while (1)
{
if (from == beg)
- {
- immediate_quit = false;
- return 0;
- }
+ return 0;
DEC_BOTH (from, from_byte);
UPDATE_SYNTAX_TABLE_BACKWARD (from);
ch1 = FETCH_CHAR_AS_MULTIBYTE (from_byte);
count++;
}
- immediate_quit = false;
-
return from;
}
stop = (pos >= GPT && GPT > XINT (lim)) ? GAP_END_ADDR : endp;
}
- immediate_quit = true;
/* This code may look up syntax tables using functions that rely on the
gl_state object. To make sure this object is not out of date,
let's initialize it manually.
}
SET_PT_BOTH (pos, pos_byte);
- immediate_quit = false;
SAFE_FREE ();
return make_number (PT - start_point);
ptrdiff_t pos_byte = PT_BYTE;
unsigned char *p, *endp, *stop;
- immediate_quit = true;
SETUP_SYNTAX_TABLE (pos, forwardp ? 1 : -1);
if (forwardp)
done:
SET_PT_BOTH (pos, pos_byte);
- immediate_quit = false;
return make_number (PT - start_point);
}
count1 = XINT (count);
stop = count1 > 0 ? ZV : BEGV;
- immediate_quit = true;
maybe_quit ();
from = PT;
if (from == stop)
{
SET_PT_BOTH (from, from_byte);
- immediate_quit = false;
return Qnil;
}
c = FETCH_CHAR_AS_MULTIBYTE (from_byte);
comstyle = ST_COMMENT_STYLE;
else if (code != Scomment)
{
- immediate_quit = false;
DEC_BOTH (from, from_byte);
SET_PT_BOTH (from, from_byte);
return Qnil;
from = out_charpos; from_byte = out_bytepos;
if (!found)
{
- immediate_quit = false;
SET_PT_BOTH (from, from_byte);
return Qnil;
}
if (from <= stop)
{
SET_PT_BOTH (BEGV, BEGV_BYTE);
- immediate_quit = false;
return Qnil;
}
else if (code != Swhitespace || quoted)
{
leave:
- immediate_quit = false;
INC_BOTH (from, from_byte);
SET_PT_BOTH (from, from_byte);
return Qnil;
}
SET_PT_BOTH (from, from_byte);
- immediate_quit = false;
return Qt;
}
\f
from_byte = CHAR_TO_BYTE (from);
- immediate_quit = true;
maybe_quit ();
SETUP_SYNTAX_TABLE (from, count);
if (depth)
goto lose;
- immediate_quit = false;
return Qnil;
/* End of object reached */
if (depth)
goto lose;
- immediate_quit = false;
return Qnil;
done2:
}
- immediate_quit = false;
XSETFASTINT (val, from);
return val;
UPDATE_SYNTAX_TABLE_FORWARD (from); \
} while (0)
- immediate_quit = true;
maybe_quit ();
depth = state->depth;
state->levelstarts);
state->prev_syntax = (SYNTAX_FLAGS_COMSTARTEND_FIRST (prev_from_syntax)
|| state->quoted) ? prev_from_syntax : Smax;
- immediate_quit = false;
}
/* Convert a (lisp) parse state to the internal form used in
Vquit_flag = Vthrow_on_input;
/* Calling maybe_quit from this thread is a bad idea, since this
unwinds the stack of the Lisp thread, and the Windows runtime
- rightfully barfs. Disabled. */
-#if 0
- /* If we're inside a function that wants immediate quits,
- do it now. */
- if (immediate_quit && NILP (Vinhibit_quit))
- {
- immediate_quit = false;
- maybe_quit ();
- }
-#endif
+ rightfully barfs. */
}
}
{
ptrdiff_t count = SPECPDL_INDEX ();
- immediate_quit = true;
n = clip_to_bounds (INT_MIN, n, INT_MAX);
wset_redisplay (XWINDOW (window));
/* Bug#15957. */
XWINDOW (window)->window_end_valid = false;
- immediate_quit = false;
}