aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2017-01-25 21:13:19 -0800
committerPaul Eggert2017-01-25 21:25:37 -0800
commitb3a3ed526d2c490c9c5605707f0cd7bff3c88693 (patch)
tree096de6603250aafcab11c31876d39faecf1b2db4 /src
parent1392ec7420ee23238a1588b759c631d87a677483 (diff)
downloademacs-b3a3ed526d2c490c9c5605707f0cd7bff3c88693.tar.gz
emacs-b3a3ed526d2c490c9c5605707f0cd7bff3c88693.zip
Replace QUIT with maybe_quit
There’s no longer need to have QUIT stand for a slug of C statements. Use the more-obvious function-call syntax instead. Also, use true and false when setting immediate_quit. These changes should not affect the generated machine code. * src/lisp.h (QUIT): Remove. All uses replaced by maybe_quit.
Diffstat (limited to 'src')
-rw-r--r--src/alloc.c2
-rw-r--r--src/buffer.c13
-rw-r--r--src/bytecode.c2
-rw-r--r--src/callint.c2
-rw-r--r--src/callproc.c16
-rw-r--r--src/ccl.c2
-rw-r--r--src/decompress.c2
-rw-r--r--src/dired.c10
-rw-r--r--src/editfns.c2
-rw-r--r--src/eval.c20
-rw-r--r--src/fileio.c44
-rw-r--r--src/filelock.c2
-rw-r--r--src/fns.c6
-rw-r--r--src/gnutls.c2
-rw-r--r--src/indent.c6
-rw-r--r--src/insdel.c12
-rw-r--r--src/keyboard.c18
-rw-r--r--src/keymap.c12
-rw-r--r--src/lisp.h25
-rw-r--r--src/lread.c6
-rw-r--r--src/macros.c2
-rw-r--r--src/minibuf.c2
-rw-r--r--src/print.c10
-rw-r--r--src/process.c22
-rw-r--r--src/profiler.c4
-rw-r--r--src/regex.c7
-rw-r--r--src/search.c49
-rw-r--r--src/syntax.c50
-rw-r--r--src/sysdep.c10
-rw-r--r--src/textprop.c2
-rw-r--r--src/w32fns.c8
-rw-r--r--src/w32notify.c2
-rw-r--r--src/w32proc.c2
-rw-r--r--src/window.c7
-rw-r--r--src/xdisp.c2
-rw-r--r--src/xselect.c4
-rw-r--r--src/xterm.c2
37 files changed, 192 insertions, 197 deletions
diff --git a/src/alloc.c b/src/alloc.c
index f7da7e44f29..f7b6515f4e7 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -2880,7 +2880,7 @@ DEFUN ("make-list", Fmake_list, Smake_list, 2, 2, 0,
2880 for (EMACS_INT size = XFASTINT (length); 0 < size; size--) 2880 for (EMACS_INT size = XFASTINT (length); 0 < size; size--)
2881 { 2881 {
2882 val = Fcons (init, val); 2882 val = Fcons (init, val);
2883 QUIT; 2883 maybe_quit ();
2884 } 2884 }
2885 2885
2886 return val; 2886 return val;
diff --git a/src/buffer.c b/src/buffer.c
index fde23cace1a..c00cc40d6f2 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -415,19 +415,16 @@ followed by the rest of the buffers. */)
415} 415}
416 416
417/* Like Fassoc, but use Fstring_equal to compare 417/* Like Fassoc, but use Fstring_equal to compare
418 (which ignores text properties), 418 (which ignores text properties), and don't ever quit. */
419 and don't ever QUIT. */
420 419
421static Lisp_Object 420static Lisp_Object
422assoc_ignore_text_properties (register Lisp_Object key, Lisp_Object list) 421assoc_ignore_text_properties (Lisp_Object key, Lisp_Object list)
423{ 422{
424 register Lisp_Object tail; 423 Lisp_Object tail;
425 for (tail = list; CONSP (tail); tail = XCDR (tail)) 424 for (tail = list; CONSP (tail); tail = XCDR (tail))
426 { 425 {
427 register Lisp_Object elt, tem; 426 Lisp_Object elt = XCAR (tail);
428 elt = XCAR (tail); 427 if (!NILP (Fstring_equal (Fcar (elt), key)))
429 tem = Fstring_equal (Fcar (elt), key);
430 if (!NILP (tem))
431 return elt; 428 return elt;
432 } 429 }
433 return Qnil; 430 return Qnil;
diff --git a/src/bytecode.c b/src/bytecode.c
index a64bc171d14..499fb881e2e 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -679,7 +679,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
679 { 679 {
680 quitcounter = 1; 680 quitcounter = 1;
681 maybe_gc (); 681 maybe_gc ();
682 QUIT; 682 maybe_quit ();
683 } 683 }
684 pc += op; 684 pc += op;
685 NEXT; 685 NEXT;
diff --git a/src/callint.c b/src/callint.c
index 565fac8a451..d96454883cf 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -794,7 +794,7 @@ invoke it. If KEYS is omitted or nil, the return value of
794 } 794 }
795 unbind_to (speccount, Qnil); 795 unbind_to (speccount, Qnil);
796 796
797 QUIT; 797 maybe_quit ();
798 798
799 args[0] = Qfuncall_interactively; 799 args[0] = Qfuncall_interactively;
800 args[1] = function; 800 args[1] = function;
diff --git a/src/callproc.c b/src/callproc.c
index 90c15de2913..301ccf383b5 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -198,11 +198,11 @@ call_process_cleanup (Lisp_Object buffer)
198 { 198 {
199 kill (-synch_process_pid, SIGINT); 199 kill (-synch_process_pid, SIGINT);
200 message1 ("Waiting for process to die...(type C-g again to kill it instantly)"); 200 message1 ("Waiting for process to die...(type C-g again to kill it instantly)");
201 immediate_quit = 1; 201 immediate_quit = true;
202 QUIT; 202 maybe_quit ();
203 wait_for_termination (synch_process_pid, 0, 1); 203 wait_for_termination (synch_process_pid, 0, 1);
204 synch_process_pid = 0; 204 synch_process_pid = 0;
205 immediate_quit = 0; 205 immediate_quit = false;
206 message1 ("Waiting for process to die...done"); 206 message1 ("Waiting for process to die...done");
207 } 207 }
208#endif /* !MSDOS */ 208#endif /* !MSDOS */
@@ -726,8 +726,8 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd,
726 process_coding.src_multibyte = 0; 726 process_coding.src_multibyte = 0;
727 } 727 }
728 728
729 immediate_quit = 1; 729 immediate_quit = true;
730 QUIT; 730 maybe_quit ();
731 731
732 if (0 <= fd0) 732 if (0 <= fd0)
733 { 733 {
@@ -769,7 +769,7 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd,
769 } 769 }
770 770
771 /* Now NREAD is the total amount of data in the buffer. */ 771 /* Now NREAD is the total amount of data in the buffer. */
772 immediate_quit = 0; 772 immediate_quit = false;
773 773
774 if (!nread) 774 if (!nread)
775 ; 775 ;
@@ -843,7 +843,7 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd,
843 display_on_the_fly = true; 843 display_on_the_fly = true;
844 } 844 }
845 immediate_quit = true; 845 immediate_quit = true;
846 QUIT; 846 maybe_quit ();
847 } 847 }
848 give_up: ; 848 give_up: ;
849 849
@@ -860,7 +860,7 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd,
860 wait_for_termination (pid, &status, fd0 < 0); 860 wait_for_termination (pid, &status, fd0 < 0);
861#endif 861#endif
862 862
863 immediate_quit = 0; 863 immediate_quit = false;
864 864
865 /* Don't kill any children that the subprocess may have left behind 865 /* Don't kill any children that the subprocess may have left behind
866 when exiting. */ 866 when exiting. */
diff --git a/src/ccl.c b/src/ccl.c
index c172fc66811..90bd2f46794 100644
--- a/src/ccl.c
+++ b/src/ccl.c
@@ -1993,7 +1993,7 @@ programs. */)
1993 : 0); 1993 : 0);
1994 1994
1995 ccl_driver (&ccl, NULL, NULL, 0, 0, Qnil); 1995 ccl_driver (&ccl, NULL, NULL, 0, 0, Qnil);
1996 QUIT; 1996 maybe_quit ();
1997 if (ccl.status != CCL_STAT_SUCCESS) 1997 if (ccl.status != CCL_STAT_SUCCESS)
1998 error ("Error in CCL program at %dth code", ccl.ic); 1998 error ("Error in CCL program at %dth code", ccl.ic);
1999 1999
diff --git a/src/decompress.c b/src/decompress.c
index f6628d5ddd9..a53a66df187 100644
--- a/src/decompress.c
+++ b/src/decompress.c
@@ -186,7 +186,7 @@ This function can be called only in unibyte buffers. */)
186 decompressed = avail_out - stream.avail_out; 186 decompressed = avail_out - stream.avail_out;
187 insert_from_gap (decompressed, decompressed, 0); 187 insert_from_gap (decompressed, decompressed, 0);
188 unwind_data.nbytes += decompressed; 188 unwind_data.nbytes += decompressed;
189 QUIT; 189 maybe_quit ();
190 } 190 }
191 while (inflate_status == Z_OK); 191 while (inflate_status == Z_OK);
192 192
diff --git a/src/dired.c b/src/dired.c
index bf10f1710ff..52e81fb380b 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -139,7 +139,7 @@ read_dirent (DIR *dir, Lisp_Object dirname)
139#endif 139#endif
140 report_file_error ("Reading directory", dirname); 140 report_file_error ("Reading directory", dirname);
141 } 141 }
142 QUIT; 142 maybe_quit ();
143 } 143 }
144} 144}
145 145
@@ -248,13 +248,13 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full,
248 248
249 /* Now that we have unwind_protect in place, we might as well 249 /* Now that we have unwind_protect in place, we might as well
250 allow matching to be interrupted. */ 250 allow matching to be interrupted. */
251 immediate_quit = 1; 251 immediate_quit = true;
252 QUIT; 252 maybe_quit ();
253 253
254 bool wanted = (NILP (match) 254 bool wanted = (NILP (match)
255 || re_search (bufp, SSDATA (name), len, 0, len, 0) >= 0); 255 || re_search (bufp, SSDATA (name), len, 0, len, 0) >= 0);
256 256
257 immediate_quit = 0; 257 immediate_quit = false;
258 258
259 if (wanted) 259 if (wanted)
260 { 260 {
@@ -508,7 +508,7 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, bool all_flag,
508 ptrdiff_t len = dirent_namelen (dp); 508 ptrdiff_t len = dirent_namelen (dp);
509 bool canexclude = 0; 509 bool canexclude = 0;
510 510
511 QUIT; 511 maybe_quit ();
512 if (len < SCHARS (encoded_file) 512 if (len < SCHARS (encoded_file)
513 || (scmp (dp->d_name, SSDATA (encoded_file), 513 || (scmp (dp->d_name, SSDATA (encoded_file),
514 SCHARS (encoded_file)) 514 SCHARS (encoded_file))
diff --git a/src/editfns.c b/src/editfns.c
index 634aa1f63b2..82c6abb9987 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -2695,7 +2695,7 @@ called interactively, INHERIT is t. */)
2695 string[i] = str[i % len]; 2695 string[i] = str[i % len];
2696 while (n > stringlen) 2696 while (n > stringlen)
2697 { 2697 {
2698 QUIT; 2698 maybe_quit ();
2699 if (!NILP (inherit)) 2699 if (!NILP (inherit))
2700 insert_and_inherit (string, stringlen); 2700 insert_and_inherit (string, stringlen);
2701 else 2701 else
diff --git a/src/eval.c b/src/eval.c
index 734f01d81ae..62d4af15e27 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -858,7 +858,7 @@ usage: (let* VARLIST BODY...) */)
858 858
859 for (varlist = XCAR (args); CONSP (varlist); varlist = XCDR (varlist)) 859 for (varlist = XCAR (args); CONSP (varlist); varlist = XCDR (varlist))
860 { 860 {
861 QUIT; 861 maybe_quit ();
862 862
863 elt = XCAR (varlist); 863 elt = XCAR (varlist);
864 if (SYMBOLP (elt)) 864 if (SYMBOLP (elt))
@@ -925,7 +925,7 @@ usage: (let VARLIST BODY...) */)
925 925
926 for (argnum = 0; CONSP (varlist); varlist = XCDR (varlist)) 926 for (argnum = 0; CONSP (varlist); varlist = XCDR (varlist))
927 { 927 {
928 QUIT; 928 maybe_quit ();
929 elt = XCAR (varlist); 929 elt = XCAR (varlist);
930 if (SYMBOLP (elt)) 930 if (SYMBOLP (elt))
931 temps [argnum++] = Qnil; 931 temps [argnum++] = Qnil;
@@ -978,7 +978,7 @@ usage: (while TEST BODY...) */)
978 body = XCDR (args); 978 body = XCDR (args);
979 while (!NILP (eval_sub (test))) 979 while (!NILP (eval_sub (test)))
980 { 980 {
981 QUIT; 981 maybe_quit ();
982 prog_ignore (body); 982 prog_ignore (body);
983 } 983 }
984 984
@@ -1011,7 +1011,7 @@ definitions to shadow the loaded ones for use in file byte-compilation. */)
1011 until we get a symbol that is not an alias. */ 1011 until we get a symbol that is not an alias. */
1012 while (SYMBOLP (def)) 1012 while (SYMBOLP (def))
1013 { 1013 {
1014 QUIT; 1014 maybe_quit ();
1015 sym = def; 1015 sym = def;
1016 tem = Fassq (sym, environment); 1016 tem = Fassq (sym, environment);
1017 if (NILP (tem)) 1017 if (NILP (tem))
@@ -1131,7 +1131,7 @@ unwind_to_catch (struct handler *catch, Lisp_Object value)
1131 /* Restore certain special C variables. */ 1131 /* Restore certain special C variables. */
1132 set_poll_suppress_count (catch->poll_suppress_count); 1132 set_poll_suppress_count (catch->poll_suppress_count);
1133 unblock_input_to (catch->interrupt_input_blocked); 1133 unblock_input_to (catch->interrupt_input_blocked);
1134 immediate_quit = 0; 1134 immediate_quit = false;
1135 1135
1136 do 1136 do
1137 { 1137 {
@@ -1514,10 +1514,10 @@ signal_or_quit (Lisp_Object error_symbol, Lisp_Object data, bool keyboard_quit)
1514 Lisp_Object string; 1514 Lisp_Object string;
1515 Lisp_Object real_error_symbol 1515 Lisp_Object real_error_symbol
1516 = (NILP (error_symbol) ? Fcar (data) : error_symbol); 1516 = (NILP (error_symbol) ? Fcar (data) : error_symbol);
1517 register Lisp_Object clause = Qnil; 1517 Lisp_Object clause = Qnil;
1518 struct handler *h; 1518 struct handler *h;
1519 1519
1520 immediate_quit = 0; 1520 immediate_quit = false;
1521 if (gc_in_progress || waiting_for_input) 1521 if (gc_in_progress || waiting_for_input)
1522 emacs_abort (); 1522 emacs_abort ();
1523 1523
@@ -2135,7 +2135,7 @@ eval_sub (Lisp_Object form)
2135 if (!CONSP (form)) 2135 if (!CONSP (form))
2136 return form; 2136 return form;
2137 2137
2138 QUIT; 2138 maybe_quit ();
2139 2139
2140 maybe_gc (); 2140 maybe_gc ();
2141 2141
@@ -2721,7 +2721,7 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */)
2721 Lisp_Object val; 2721 Lisp_Object val;
2722 ptrdiff_t count; 2722 ptrdiff_t count;
2723 2723
2724 QUIT; 2724 maybe_quit ();
2725 2725
2726 if (++lisp_eval_depth > max_lisp_eval_depth) 2726 if (++lisp_eval_depth > max_lisp_eval_depth)
2727 { 2727 {
@@ -2966,7 +2966,7 @@ funcall_lambda (Lisp_Object fun, ptrdiff_t nargs,
2966 bool previous_optional_or_rest = false; 2966 bool previous_optional_or_rest = false;
2967 for (; CONSP (syms_left); syms_left = XCDR (syms_left)) 2967 for (; CONSP (syms_left); syms_left = XCDR (syms_left))
2968 { 2968 {
2969 QUIT; 2969 maybe_quit ();
2970 2970
2971 next = XCAR (syms_left); 2971 next = XCAR (syms_left);
2972 if (!SYMBOLP (next)) 2972 if (!SYMBOLP (next))
diff --git a/src/fileio.c b/src/fileio.c
index 8c8cba9e49c..ac6d7819411 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -316,7 +316,7 @@ use the standard functions without calling themselves recursively. */)
316 } 316 }
317 } 317 }
318 318
319 QUIT; 319 maybe_quit ();
320 } 320 }
321 return result; 321 return result;
322} 322}
@@ -1960,9 +1960,9 @@ permissions. */)
1960 report_file_error ("Copying permissions to", newname); 1960 report_file_error ("Copying permissions to", newname);
1961 } 1961 }
1962#else /* not WINDOWSNT */ 1962#else /* not WINDOWSNT */
1963 immediate_quit = 1; 1963 immediate_quit = true;
1964 ifd = emacs_open (SSDATA (encoded_file), O_RDONLY, 0); 1964 ifd = emacs_open (SSDATA (encoded_file), O_RDONLY, 0);
1965 immediate_quit = 0; 1965 immediate_quit = false;
1966 1966
1967 if (ifd < 0) 1967 if (ifd < 0)
1968 report_file_error ("Opening input file", file); 1968 report_file_error ("Opening input file", file);
@@ -2024,8 +2024,8 @@ permissions. */)
2024 oldsize = out_st.st_size; 2024 oldsize = out_st.st_size;
2025 } 2025 }
2026 2026
2027 immediate_quit = 1; 2027 immediate_quit = true;
2028 QUIT; 2028 maybe_quit ();
2029 2029
2030 if (clone_file (ofd, ifd)) 2030 if (clone_file (ofd, ifd))
2031 newsize = st.st_size; 2031 newsize = st.st_size;
@@ -2047,7 +2047,7 @@ permissions. */)
2047 if (newsize < oldsize && ftruncate (ofd, newsize) != 0) 2047 if (newsize < oldsize && ftruncate (ofd, newsize) != 0)
2048 report_file_error ("Truncating output file", newname); 2048 report_file_error ("Truncating output file", newname);
2049 2049
2050 immediate_quit = 0; 2050 immediate_quit = false;
2051 2051
2052#ifndef MSDOS 2052#ifndef MSDOS
2053 /* Preserve the original file permissions, and if requested, also its 2053 /* Preserve the original file permissions, and if requested, also its
@@ -3393,13 +3393,13 @@ read_non_regular (Lisp_Object state)
3393{ 3393{
3394 int nbytes; 3394 int nbytes;
3395 3395
3396 immediate_quit = 1; 3396 immediate_quit = true;
3397 QUIT; 3397 maybe_quit ();
3398 nbytes = emacs_read (XSAVE_INTEGER (state, 0), 3398 nbytes = emacs_read (XSAVE_INTEGER (state, 0),
3399 ((char *) BEG_ADDR + PT_BYTE - BEG_BYTE 3399 ((char *) BEG_ADDR + PT_BYTE - BEG_BYTE
3400 + XSAVE_INTEGER (state, 1)), 3400 + XSAVE_INTEGER (state, 1)),
3401 XSAVE_INTEGER (state, 2)); 3401 XSAVE_INTEGER (state, 2));
3402 immediate_quit = 0; 3402 immediate_quit = false;
3403 /* Fast recycle this object for the likely next call. */ 3403 /* Fast recycle this object for the likely next call. */
3404 free_misc (state); 3404 free_misc (state);
3405 return make_number (nbytes); 3405 return make_number (nbytes);
@@ -3858,8 +3858,8 @@ by calling `format-decode', which see. */)
3858 report_file_error ("Setting file position", orig_filename); 3858 report_file_error ("Setting file position", orig_filename);
3859 } 3859 }
3860 3860
3861 immediate_quit = 1; 3861 immediate_quit = true;
3862 QUIT; 3862 maybe_quit ();
3863 /* Count how many chars at the start of the file 3863 /* Count how many chars at the start of the file
3864 match the text at the beginning of the buffer. */ 3864 match the text at the beginning of the buffer. */
3865 while (1) 3865 while (1)
@@ -3910,7 +3910,7 @@ by calling `format-decode', which see. */)
3910 goto handled; 3910 goto handled;
3911 } 3911 }
3912 immediate_quit = true; 3912 immediate_quit = true;
3913 QUIT; 3913 maybe_quit ();
3914 /* Count how many chars at the end of the file 3914 /* Count how many chars at the end of the file
3915 match the text at the end of the buffer. But, if we have 3915 match the text at the end of the buffer. But, if we have
3916 already found that decoding is necessary, don't waste time. */ 3916 already found that decoding is necessary, don't waste time. */
@@ -3967,7 +3967,7 @@ by calling `format-decode', which see. */)
3967 if (nread == 0) 3967 if (nread == 0)
3968 break; 3968 break;
3969 } 3969 }
3970 immediate_quit = 0; 3970 immediate_quit = false;
3971 3971
3972 if (! giveup_match_end) 3972 if (! giveup_match_end)
3973 { 3973 {
@@ -4065,11 +4065,11 @@ by calling `format-decode', which see. */)
4065 quitting while reading a huge file. */ 4065 quitting while reading a huge file. */
4066 4066
4067 /* Allow quitting out of the actual I/O. */ 4067 /* Allow quitting out of the actual I/O. */
4068 immediate_quit = 1; 4068 immediate_quit = true;
4069 QUIT; 4069 maybe_quit ();
4070 this = emacs_read (fd, read_buf + unprocessed, 4070 this = emacs_read (fd, read_buf + unprocessed,
4071 READ_BUF_SIZE - unprocessed); 4071 READ_BUF_SIZE - unprocessed);
4072 immediate_quit = 0; 4072 immediate_quit = false;
4073 4073
4074 if (this <= 0) 4074 if (this <= 0)
4075 break; 4075 break;
@@ -4284,13 +4284,13 @@ by calling `format-decode', which see. */)
4284 /* Allow quitting out of the actual I/O. We don't make text 4284 /* Allow quitting out of the actual I/O. We don't make text
4285 part of the buffer until all the reading is done, so a C-g 4285 part of the buffer until all the reading is done, so a C-g
4286 here doesn't do any harm. */ 4286 here doesn't do any harm. */
4287 immediate_quit = 1; 4287 immediate_quit = true;
4288 QUIT; 4288 maybe_quit ();
4289 this = emacs_read (fd, 4289 this = emacs_read (fd,
4290 ((char *) BEG_ADDR + PT_BYTE - BEG_BYTE 4290 ((char *) BEG_ADDR + PT_BYTE - BEG_BYTE
4291 + inserted), 4291 + inserted),
4292 trytry); 4292 trytry);
4293 immediate_quit = 0; 4293 immediate_quit = false;
4294 } 4294 }
4295 4295
4296 if (this <= 0) 4296 if (this <= 0)
@@ -4602,7 +4602,7 @@ by calling `format-decode', which see. */)
4602 } 4602 }
4603 } 4603 }
4604 4604
4605 QUIT; 4605 maybe_quit ();
4606 p = XCDR (p); 4606 p = XCDR (p);
4607 } 4607 }
4608 4608
@@ -4992,7 +4992,7 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename,
4992 } 4992 }
4993 } 4993 }
4994 4994
4995 immediate_quit = 1; 4995 immediate_quit = true;
4996 4996
4997 if (STRINGP (start)) 4997 if (STRINGP (start))
4998 ok = a_write (desc, start, 0, SCHARS (start), &annotations, &coding); 4998 ok = a_write (desc, start, 0, SCHARS (start), &annotations, &coding);
@@ -5016,7 +5016,7 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename,
5016 save_errno = errno; 5016 save_errno = errno;
5017 } 5017 }
5018 5018
5019 immediate_quit = 0; 5019 immediate_quit = false;
5020 5020
5021 /* fsync is not crucial for temporary files. Nor for auto-save 5021 /* fsync is not crucial for temporary files. Nor for auto-save
5022 files, since they might lose some work anyway. */ 5022 files, since they might lose some work anyway. */
diff --git a/src/filelock.c b/src/filelock.c
index 886ab61c7aa..de65c52efa1 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -505,7 +505,7 @@ read_lock_data (char *lfname, char lfinfo[MAX_LFINFO + 1])
505 /* readlinkat saw a non-symlink, but emacs_open saw a symlink. 505 /* readlinkat saw a non-symlink, but emacs_open saw a symlink.
506 The former must have been removed and replaced by the latter. 506 The former must have been removed and replaced by the latter.
507 Try again. */ 507 Try again. */
508 QUIT; 508 maybe_quit ();
509 } 509 }
510 510
511 return nbytes; 511 return nbytes;
diff --git a/src/fns.c b/src/fns.c
index c175dd935d3..b8ebfe5b2e7 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -96,7 +96,7 @@ static void
96rarely_quit (unsigned short int *quit_count) 96rarely_quit (unsigned short int *quit_count)
97{ 97{
98 if (! (++*quit_count & (QUIT_COUNT_HEURISTIC - 1))) 98 if (! (++*quit_count & (QUIT_COUNT_HEURISTIC - 1)))
99 QUIT; 99 maybe_quit ();
100} 100}
101 101
102/* Random data-structure functions. */ 102/* Random data-structure functions. */
@@ -132,7 +132,7 @@ To get the number of bytes, use `string-bytes'. */)
132 { 132 {
133 if (MOST_POSITIVE_FIXNUM < i) 133 if (MOST_POSITIVE_FIXNUM < i)
134 error ("List too long"); 134 error ("List too long");
135 QUIT; 135 maybe_quit ();
136 } 136 }
137 sequence = XCDR (sequence); 137 sequence = XCDR (sequence);
138 } 138 }
@@ -178,7 +178,7 @@ which is at least the number of distinct elements. */)
178 halftail = XCDR (halftail); 178 halftail = XCDR (halftail);
179 if ((lolen & (QUIT_COUNT_HEURISTIC - 1)) == 0) 179 if ((lolen & (QUIT_COUNT_HEURISTIC - 1)) == 0)
180 { 180 {
181 QUIT; 181 maybe_quit ();
182 if (lolen == 0) 182 if (lolen == 0)
183 hilen += UINTMAX_MAX + 1.0; 183 hilen += UINTMAX_MAX + 1.0;
184 } 184 }
diff --git a/src/gnutls.c b/src/gnutls.c
index 65b83bad6b8..d0d7f2dfc84 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -390,7 +390,7 @@ gnutls_try_handshake (struct Lisp_Process *proc)
390 { 390 {
391 ret = gnutls_handshake (state); 391 ret = gnutls_handshake (state);
392 emacs_gnutls_handle_error (state, ret); 392 emacs_gnutls_handle_error (state, ret);
393 QUIT; 393 maybe_quit ();
394 } 394 }
395 while (ret < 0 395 while (ret < 0
396 && gnutls_error_is_fatal (ret) == 0 396 && gnutls_error_is_fatal (ret) == 0
diff --git a/src/indent.c b/src/indent.c
index 34449955a6c..23951a16eb6 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -1200,8 +1200,8 @@ compute_motion (ptrdiff_t from, ptrdiff_t frombyte, EMACS_INT fromvpos,
1200 continuation_glyph_width = 0; /* In the fringe. */ 1200 continuation_glyph_width = 0; /* In the fringe. */
1201#endif 1201#endif
1202 1202
1203 immediate_quit = 1; 1203 immediate_quit = true;
1204 QUIT; 1204 maybe_quit ();
1205 1205
1206 /* It's just impossible to be too paranoid here. */ 1206 /* It's just impossible to be too paranoid here. */
1207 eassert (from == BYTE_TO_CHAR (frombyte) && frombyte == CHAR_TO_BYTE (from)); 1207 eassert (from == BYTE_TO_CHAR (frombyte) && frombyte == CHAR_TO_BYTE (from));
@@ -1694,7 +1694,7 @@ compute_motion (ptrdiff_t from, ptrdiff_t frombyte, EMACS_INT fromvpos,
1694 /* Nonzero if have just continued a line */ 1694 /* Nonzero if have just continued a line */
1695 val_compute_motion.contin = (contin_hpos && prev_hpos == 0); 1695 val_compute_motion.contin = (contin_hpos && prev_hpos == 0);
1696 1696
1697 immediate_quit = 0; 1697 immediate_quit = false;
1698 return &val_compute_motion; 1698 return &val_compute_motion;
1699} 1699}
1700 1700
diff --git a/src/insdel.c b/src/insdel.c
index b93606ced85..3f933b0ad85 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -129,7 +129,7 @@ gap_left (ptrdiff_t charpos, ptrdiff_t bytepos, bool newgap)
129 Change BYTEPOS to be where we have actually moved the gap to. 129 Change BYTEPOS to be where we have actually moved the gap to.
130 Note that this cannot happen when we are called to make the 130 Note that this cannot happen when we are called to make the
131 gap larger or smaller, since make_gap_larger and 131 gap larger or smaller, since make_gap_larger and
132 make_gap_smaller prevent QUIT by setting inhibit-quit. */ 132 make_gap_smaller set inhibit-quit. */
133 if (QUITP) 133 if (QUITP)
134 { 134 {
135 bytepos = new_s1; 135 bytepos = new_s1;
@@ -151,7 +151,7 @@ gap_left (ptrdiff_t charpos, ptrdiff_t bytepos, bool newgap)
151 GPT = charpos; 151 GPT = charpos;
152 eassert (charpos <= bytepos); 152 eassert (charpos <= bytepos);
153 if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */ 153 if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */
154 QUIT; 154 maybe_quit ();
155} 155}
156 156
157/* Move the gap to a position greater than the current GPT. 157/* Move the gap to a position greater than the current GPT.
@@ -185,7 +185,7 @@ gap_right (ptrdiff_t charpos, ptrdiff_t bytepos)
185 Change BYTEPOS to be where we have actually moved the gap to. 185 Change BYTEPOS to be where we have actually moved the gap to.
186 Note that this cannot happen when we are called to make the 186 Note that this cannot happen when we are called to make the
187 gap larger or smaller, since make_gap_larger and 187 gap larger or smaller, since make_gap_larger and
188 make_gap_smaller prevent QUIT by setting inhibit-quit. */ 188 make_gap_smaller set inhibit-quit. */
189 if (QUITP) 189 if (QUITP)
190 { 190 {
191 bytepos = new_s1; 191 bytepos = new_s1;
@@ -204,7 +204,7 @@ gap_right (ptrdiff_t charpos, ptrdiff_t bytepos)
204 GPT_BYTE = bytepos; 204 GPT_BYTE = bytepos;
205 eassert (charpos <= bytepos); 205 eassert (charpos <= bytepos);
206 if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */ 206 if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */
207 QUIT; 207 maybe_quit ();
208} 208}
209 209
210/* If the selected window's old pointm is adjacent or covered by the 210/* If the selected window's old pointm is adjacent or covered by the
@@ -464,7 +464,7 @@ make_gap_larger (ptrdiff_t nbytes_added)
464 464
465 enlarge_buffer_text (current_buffer, nbytes_added); 465 enlarge_buffer_text (current_buffer, nbytes_added);
466 466
467 /* Prevent quitting in gap_left. We cannot allow a QUIT there, 467 /* Prevent quitting in gap_left. We cannot allow a quit there,
468 because that would leave the buffer text in an inconsistent 468 because that would leave the buffer text in an inconsistent
469 state, with 2 gap holes instead of just one. */ 469 state, with 2 gap holes instead of just one. */
470 tem = Vinhibit_quit; 470 tem = Vinhibit_quit;
@@ -512,7 +512,7 @@ make_gap_smaller (ptrdiff_t nbytes_removed)
512 if (GAP_SIZE - nbytes_removed < GAP_BYTES_MIN) 512 if (GAP_SIZE - nbytes_removed < GAP_BYTES_MIN)
513 nbytes_removed = GAP_SIZE - GAP_BYTES_MIN; 513 nbytes_removed = GAP_SIZE - GAP_BYTES_MIN;
514 514
515 /* Prevent quitting in gap_right. We cannot allow a QUIT there, 515 /* Prevent quitting in gap_right. We cannot allow a quit there,
516 because that would leave the buffer text in an inconsistent 516 because that would leave the buffer text in an inconsistent
517 state, with 2 gap holes instead of just one. */ 517 state, with 2 gap holes instead of just one. */
518 tem = Vinhibit_quit; 518 tem = Vinhibit_quit;
diff --git a/src/keyboard.c b/src/keyboard.c
index 6aad0acc656..d41603b2e50 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -87,7 +87,7 @@ char const DEV_TTY[] = "/dev/tty";
87volatile int interrupt_input_blocked; 87volatile int interrupt_input_blocked;
88 88
89/* True means an input interrupt or alarm signal has arrived. 89/* True means an input interrupt or alarm signal has arrived.
90 The QUIT macro checks this. */ 90 The maybe_quit function checks this. */
91volatile bool pending_signals; 91volatile bool pending_signals;
92 92
93#define KBD_BUFFER_SIZE 4096 93#define KBD_BUFFER_SIZE 4096
@@ -1416,7 +1416,7 @@ command_loop_1 (void)
1416 if (!NILP (Vquit_flag)) 1416 if (!NILP (Vquit_flag))
1417 { 1417 {
1418 Vexecuting_kbd_macro = Qt; 1418 Vexecuting_kbd_macro = Qt;
1419 QUIT; /* Make some noise. */ 1419 maybe_quit (); /* Make some noise. */
1420 /* Will return since macro now empty. */ 1420 /* Will return since macro now empty. */
1421 } 1421 }
1422 } 1422 }
@@ -3591,7 +3591,7 @@ kbd_buffer_store_buffered_event (union buffered_input_event *event,
3591 if (immediate_quit && NILP (Vinhibit_quit)) 3591 if (immediate_quit && NILP (Vinhibit_quit))
3592 { 3592 {
3593 immediate_quit = false; 3593 immediate_quit = false;
3594 QUIT; 3594 maybe_quit ();
3595 } 3595 }
3596 } 3596 }
3597} 3597}
@@ -7426,7 +7426,7 @@ menu_bar_items (Lisp_Object old)
7426 USE_SAFE_ALLOCA; 7426 USE_SAFE_ALLOCA;
7427 7427
7428 /* In order to build the menus, we need to call the keymap 7428 /* In order to build the menus, we need to call the keymap
7429 accessors. They all call QUIT. But this function is called 7429 accessors. They all call maybe_quit. But this function is called
7430 during redisplay, during which a quit is fatal. So inhibit 7430 during redisplay, during which a quit is fatal. So inhibit
7431 quitting while building the menus. 7431 quitting while building the menus.
7432 We do this instead of specbind because (1) errors will clear it anyway 7432 We do this instead of specbind because (1) errors will clear it anyway
@@ -7987,7 +7987,7 @@ tool_bar_items (Lisp_Object reuse, int *nitems)
7987 *nitems = 0; 7987 *nitems = 0;
7988 7988
7989 /* In order to build the menus, we need to call the keymap 7989 /* In order to build the menus, we need to call the keymap
7990 accessors. They all call QUIT. But this function is called 7990 accessors. They all call maybe_quit. But this function is called
7991 during redisplay, during which a quit is fatal. So inhibit 7991 during redisplay, during which a quit is fatal. So inhibit
7992 quitting while building the menus. We do this instead of 7992 quitting while building the menus. We do this instead of
7993 specbind because (1) errors will clear it anyway and (2) this 7993 specbind because (1) errors will clear it anyway and (2) this
@@ -9806,7 +9806,7 @@ read_key_sequence_vs (Lisp_Object prompt, Lisp_Object continue_echo,
9806 9806
9807 if (!NILP (prompt)) 9807 if (!NILP (prompt))
9808 CHECK_STRING (prompt); 9808 CHECK_STRING (prompt);
9809 QUIT; 9809 maybe_quit ();
9810 9810
9811 specbind (Qinput_method_exit_on_first_char, 9811 specbind (Qinput_method_exit_on_first_char,
9812 (NILP (cmd_loop) ? Qt : Qnil)); 9812 (NILP (cmd_loop) ? Qt : Qnil));
@@ -9840,7 +9840,7 @@ read_key_sequence_vs (Lisp_Object prompt, Lisp_Object continue_echo,
9840 if (i == -1) 9840 if (i == -1)
9841 { 9841 {
9842 Vquit_flag = Qt; 9842 Vquit_flag = Qt;
9843 QUIT; 9843 maybe_quit ();
9844 } 9844 }
9845 9845
9846 return unbind_to (count, 9846 return unbind_to (count,
@@ -10278,7 +10278,7 @@ clear_waiting_for_input (void)
10278 10278
10279 If we have a frame on the controlling tty, we assume that the 10279 If we have a frame on the controlling tty, we assume that the
10280 SIGINT was generated by C-g, so we call handle_interrupt. 10280 SIGINT was generated by C-g, so we call handle_interrupt.
10281 Otherwise, tell QUIT to kill Emacs. */ 10281 Otherwise, tell maybe_quit to kill Emacs. */
10282 10282
10283static void 10283static void
10284handle_interrupt_signal (int sig) 10284handle_interrupt_signal (int sig)
@@ -10289,7 +10289,7 @@ handle_interrupt_signal (int sig)
10289 { 10289 {
10290 /* If there are no frames there, let's pretend that we are a 10290 /* If there are no frames there, let's pretend that we are a
10291 well-behaving UN*X program and quit. We must not call Lisp 10291 well-behaving UN*X program and quit. We must not call Lisp
10292 in a signal handler, so tell QUIT to exit when it is 10292 in a signal handler, so tell maybe_quit to exit when it is
10293 safe. */ 10293 safe. */
10294 Vquit_flag = Qkill_emacs; 10294 Vquit_flag = Qkill_emacs;
10295 } 10295 }
diff --git a/src/keymap.c b/src/keymap.c
index 9e759478518..9caf55f98fb 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -523,7 +523,7 @@ access_keymap_1 (Lisp_Object map, Lisp_Object idx,
523 retval = Fcons (Qkeymap, Fcons (retval, retval_tail)); 523 retval = Fcons (Qkeymap, Fcons (retval, retval_tail));
524 } 524 }
525 } 525 }
526 QUIT; 526 maybe_quit ();
527 } 527 }
528 528
529 return EQ (Qunbound, retval) ? get_keyelt (t_binding, autoload) : retval; 529 return EQ (Qunbound, retval) ? get_keyelt (t_binding, autoload) : retval;
@@ -877,7 +877,7 @@ store_in_keymap (Lisp_Object keymap, register Lisp_Object idx, Lisp_Object def)
877 should be inserted before it. */ 877 should be inserted before it. */
878 goto keymap_end; 878 goto keymap_end;
879 879
880 QUIT; 880 maybe_quit ();
881 } 881 }
882 882
883 keymap_end: 883 keymap_end:
@@ -1250,7 +1250,7 @@ recognize the default bindings, just as `read-key-sequence' does. */)
1250 if (!CONSP (keymap)) 1250 if (!CONSP (keymap))
1251 return make_number (idx); 1251 return make_number (idx);
1252 1252
1253 QUIT; 1253 maybe_quit ();
1254 } 1254 }
1255} 1255}
1256 1256
@@ -2466,7 +2466,7 @@ where_is_internal (Lisp_Object definition, Lisp_Object keymaps,
2466 non-ascii prefixes like `C-down-mouse-2'. */ 2466 non-ascii prefixes like `C-down-mouse-2'. */
2467 continue; 2467 continue;
2468 2468
2469 QUIT; 2469 maybe_quit ();
2470 2470
2471 data.definition = definition; 2471 data.definition = definition;
2472 data.noindirect = noindirect; 2472 data.noindirect = noindirect;
@@ -3173,7 +3173,7 @@ describe_map (Lisp_Object map, Lisp_Object prefix,
3173 3173
3174 for (tail = map; CONSP (tail); tail = XCDR (tail)) 3174 for (tail = map; CONSP (tail); tail = XCDR (tail))
3175 { 3175 {
3176 QUIT; 3176 maybe_quit ();
3177 3177
3178 if (VECTORP (XCAR (tail)) 3178 if (VECTORP (XCAR (tail))
3179 || CHAR_TABLE_P (XCAR (tail))) 3179 || CHAR_TABLE_P (XCAR (tail)))
@@ -3426,7 +3426,7 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args,
3426 int range_beg, range_end; 3426 int range_beg, range_end;
3427 Lisp_Object val; 3427 Lisp_Object val;
3428 3428
3429 QUIT; 3429 maybe_quit ();
3430 3430
3431 if (i == stop) 3431 if (i == stop)
3432 { 3432 {
diff --git a/src/lisp.h b/src/lisp.h
index 01a08a05f20..84d53bb1eec 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3119,18 +3119,18 @@ struct handler
3119 3119
3120extern Lisp_Object memory_signal_data; 3120extern Lisp_Object memory_signal_data;
3121 3121
3122/* Check quit-flag and quit if it is non-nil. 3122/* Check quit-flag and quit if it is non-nil. Typing C-g does not
3123 Typing C-g does not directly cause a quit; it only sets Vquit_flag. 3123 directly cause a quit; it only sets Vquit_flag. So the program
3124 So the program needs to do QUIT at times when it is safe to quit. 3124 needs to call maybe_quit at times when it is safe to quit. Every
3125 Every loop that might run for a long time or might not exit 3125 loop that might run for a long time or might not exit ought to call
3126 ought to do QUIT at least once, at a safe place. 3126 maybe_quit at least once, at a safe place. Unless that is
3127 Unless that is impossible, of course. 3127 impossible, of course. But it is very desirable to avoid creating
3128 But it is very desirable to avoid creating loops where QUIT is impossible. 3128 loops where maybe_quit is impossible.
3129 3129
3130 Exception: if you set immediate_quit to true, 3130 Exception: if you set immediate_quit, the handler that responds to
3131 then the handler that responds to the C-g does the quit itself. 3131 the C-g does the quit itself. This is a good thing to do around a
3132 This is a good thing to do around a loop that has no side effects 3132 loop that has no side effects and (in particular) cannot call
3133 and (in particular) cannot call arbitrary Lisp code. 3133 arbitrary Lisp code.
3134 3134
3135 If quit-flag is set to `kill-emacs' the SIGINT handler has received 3135 If quit-flag is set to `kill-emacs' the SIGINT handler has received
3136 a request to exit Emacs when it is safe to do. 3136 a request to exit Emacs when it is safe to do.
@@ -3138,7 +3138,6 @@ extern Lisp_Object memory_signal_data;
3138 When not quitting, process any pending signals. */ 3138 When not quitting, process any pending signals. */
3139 3139
3140extern void maybe_quit (void); 3140extern void maybe_quit (void);
3141#define QUIT maybe_quit ()
3142 3141
3143/* True if ought to quit now. */ 3142/* True if ought to quit now. */
3144 3143
diff --git a/src/lread.c b/src/lread.c
index 284fd1aafbc..ea2a1d1d858 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -451,7 +451,7 @@ readbyte_from_file (int c, Lisp_Object readcharfun)
451 while (c == EOF && ferror (instream) && errno == EINTR) 451 while (c == EOF && ferror (instream) && errno == EINTR)
452 { 452 {
453 unblock_input (); 453 unblock_input ();
454 QUIT; 454 maybe_quit ();
455 block_input (); 455 block_input ();
456 clearerr (instream); 456 clearerr (instream);
457 c = getc (instream); 457 c = getc (instream);
@@ -1702,14 +1702,14 @@ build_load_history (Lisp_Object filename, bool entire)
1702 Fcons (newelt, XCDR (tem)))); 1702 Fcons (newelt, XCDR (tem))));
1703 1703
1704 tem2 = XCDR (tem2); 1704 tem2 = XCDR (tem2);
1705 QUIT; 1705 maybe_quit ();
1706 } 1706 }
1707 } 1707 }
1708 } 1708 }
1709 else 1709 else
1710 prev = tail; 1710 prev = tail;
1711 tail = XCDR (tail); 1711 tail = XCDR (tail);
1712 QUIT; 1712 maybe_quit ();
1713 } 1713 }
1714 1714
1715 /* If we're loading an entire file, cons the new assoc onto the 1715 /* If we're loading an entire file, cons the new assoc onto the
diff --git a/src/macros.c b/src/macros.c
index 3b29cc67cf8..f0ffda3f441 100644
--- a/src/macros.c
+++ b/src/macros.c
@@ -325,7 +325,7 @@ each iteration of the macro. Iteration stops if LOOPFUNC returns nil. */)
325 325
326 executing_kbd_macro_iterations = ++success_count; 326 executing_kbd_macro_iterations = ++success_count;
327 327
328 QUIT; 328 maybe_quit ();
329 } 329 }
330 while (--repeat 330 while (--repeat
331 && (STRINGP (Vexecuting_kbd_macro) || VECTORP (Vexecuting_kbd_macro))); 331 && (STRINGP (Vexecuting_kbd_macro) || VECTORP (Vexecuting_kbd_macro)));
diff --git a/src/minibuf.c b/src/minibuf.c
index d44bb44baee..1bbe276776e 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -1865,7 +1865,7 @@ single string, rather than a cons cell whose car is a string. */)
1865 case_fold); 1865 case_fold);
1866 if (EQ (tem, Qt)) 1866 if (EQ (tem, Qt))
1867 return elt; 1867 return elt;
1868 QUIT; 1868 maybe_quit ();
1869 } 1869 }
1870 return Qnil; 1870 return Qnil;
1871} 1871}
diff --git a/src/print.c b/src/print.c
index dfaa489a98d..36d68a452ec 100644
--- a/src/print.c
+++ b/src/print.c
@@ -279,7 +279,7 @@ printchar (unsigned int ch, Lisp_Object fun)
279 unsigned char str[MAX_MULTIBYTE_LENGTH]; 279 unsigned char str[MAX_MULTIBYTE_LENGTH];
280 int len = CHAR_STRING (ch, str); 280 int len = CHAR_STRING (ch, str);
281 281
282 QUIT; 282 maybe_quit ();
283 283
284 if (NILP (fun)) 284 if (NILP (fun))
285 { 285 {
@@ -1352,7 +1352,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1352 max (sizeof " . #" + INT_STRLEN_BOUND (printmax_t), 1352 max (sizeof " . #" + INT_STRLEN_BOUND (printmax_t),
1353 40))]; 1353 40))];
1354 1354
1355 QUIT; 1355 maybe_quit ();
1356 1356
1357 /* Detect circularities and truncate them. */ 1357 /* Detect circularities and truncate them. */
1358 if (NILP (Vprint_circle)) 1358 if (NILP (Vprint_circle))
@@ -1446,7 +1446,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1446 1446
1447 FETCH_STRING_CHAR_ADVANCE (c, obj, i, i_byte); 1447 FETCH_STRING_CHAR_ADVANCE (c, obj, i, i_byte);
1448 1448
1449 QUIT; 1449 maybe_quit ();
1450 1450
1451 if (multibyte 1451 if (multibyte
1452 ? (CHAR_BYTE8_P (c) && (c = CHAR_TO_BYTE8 (c), true)) 1452 ? (CHAR_BYTE8_P (c) && (c = CHAR_TO_BYTE8 (c), true))
@@ -1550,7 +1550,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1550 /* Here, we must convert each multi-byte form to the 1550 /* Here, we must convert each multi-byte form to the
1551 corresponding character code before handing it to PRINTCHAR. */ 1551 corresponding character code before handing it to PRINTCHAR. */
1552 FETCH_STRING_CHAR_ADVANCE (c, name, i, i_byte); 1552 FETCH_STRING_CHAR_ADVANCE (c, name, i, i_byte);
1553 QUIT; 1553 maybe_quit ();
1554 1554
1555 if (escapeflag) 1555 if (escapeflag)
1556 { 1556 {
@@ -1707,7 +1707,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
1707 1707
1708 for (i = 0; i < size_in_chars; i++) 1708 for (i = 0; i < size_in_chars; i++)
1709 { 1709 {
1710 QUIT; 1710 maybe_quit ();
1711 c = bool_vector_uchar_data (obj)[i]; 1711 c = bool_vector_uchar_data (obj)[i];
1712 if (c == '\n' && print_escape_newlines) 1712 if (c == '\n' && print_escape_newlines)
1713 print_c_string ("\\n", printcharfun); 1713 print_c_string ("\\n", printcharfun);
diff --git a/src/process.c b/src/process.c
index ab9657b15a4..dbd4358dd1a 100644
--- a/src/process.c
+++ b/src/process.c
@@ -3431,8 +3431,8 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos,
3431 break; 3431 break;
3432 } 3432 }
3433 3433
3434 immediate_quit = 1; 3434 immediate_quit = true;
3435 QUIT; 3435 maybe_quit ();
3436 3436
3437 ret = connect (s, sa, addrlen); 3437 ret = connect (s, sa, addrlen);
3438 xerrno = errno; 3438 xerrno = errno;
@@ -3459,7 +3459,7 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos,
3459 retry_select: 3459 retry_select:
3460 FD_ZERO (&fdset); 3460 FD_ZERO (&fdset);
3461 FD_SET (s, &fdset); 3461 FD_SET (s, &fdset);
3462 QUIT; 3462 maybe_quit ();
3463 sc = pselect (s + 1, NULL, &fdset, NULL, NULL, NULL); 3463 sc = pselect (s + 1, NULL, &fdset, NULL, NULL, NULL);
3464 if (sc == -1) 3464 if (sc == -1)
3465 { 3465 {
@@ -3481,7 +3481,7 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos,
3481 } 3481 }
3482#endif /* !WINDOWSNT */ 3482#endif /* !WINDOWSNT */
3483 3483
3484 immediate_quit = 0; 3484 immediate_quit = false;
3485 3485
3486 /* Discard the unwind protect closing S. */ 3486 /* Discard the unwind protect closing S. */
3487 specpdl_ptr = specpdl + count; 3487 specpdl_ptr = specpdl + count;
@@ -3539,7 +3539,7 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos,
3539#endif 3539#endif
3540 } 3540 }
3541 3541
3542 immediate_quit = 0; 3542 immediate_quit = false;
3543 3543
3544 if (s < 0) 3544 if (s < 0)
3545 { 3545 {
@@ -4012,8 +4012,8 @@ usage: (make-network-process &rest ARGS) */)
4012 struct addrinfo *res, *lres; 4012 struct addrinfo *res, *lres;
4013 int ret; 4013 int ret;
4014 4014
4015 immediate_quit = 1; 4015 immediate_quit = true;
4016 QUIT; 4016 maybe_quit ();
4017 4017
4018 struct addrinfo hints; 4018 struct addrinfo hints;
4019 memset (&hints, 0, sizeof hints); 4019 memset (&hints, 0, sizeof hints);
@@ -4034,7 +4034,7 @@ usage: (make-network-process &rest ARGS) */)
4034#else 4034#else
4035 error ("%s/%s getaddrinfo error %d", SSDATA (host), portstring, ret); 4035 error ("%s/%s getaddrinfo error %d", SSDATA (host), portstring, ret);
4036#endif 4036#endif
4037 immediate_quit = 0; 4037 immediate_quit = false;
4038 4038
4039 for (lres = res; lres; lres = lres->ai_next) 4039 for (lres = res; lres; lres = lres->ai_next)
4040 addrinfos = Fcons (conv_addrinfo_to_lisp (lres), addrinfos); 4040 addrinfos = Fcons (conv_addrinfo_to_lisp (lres), addrinfos);
@@ -5020,7 +5020,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
5020 since we want to return C-g as an input character. 5020 since we want to return C-g as an input character.
5021 Otherwise, do pending quit if requested. */ 5021 Otherwise, do pending quit if requested. */
5022 if (read_kbd >= 0) 5022 if (read_kbd >= 0)
5023 QUIT; 5023 maybe_quit ();
5024 else if (pending_signals) 5024 else if (pending_signals)
5025 process_pending_signals (); 5025 process_pending_signals ();
5026 5026
@@ -5748,7 +5748,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
5748 { 5748 {
5749 /* Prevent input_pending from remaining set if we quit. */ 5749 /* Prevent input_pending from remaining set if we quit. */
5750 clear_input_pending (); 5750 clear_input_pending ();
5751 QUIT; 5751 maybe_quit ();
5752 } 5752 }
5753 5753
5754 return got_some_output; 5754 return got_some_output;
@@ -7486,7 +7486,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
7486 since we want to return C-g as an input character. 7486 since we want to return C-g as an input character.
7487 Otherwise, do pending quit if requested. */ 7487 Otherwise, do pending quit if requested. */
7488 if (read_kbd >= 0) 7488 if (read_kbd >= 0)
7489 QUIT; 7489 maybe_quit ();
7490 7490
7491 /* Exit now if the cell we're waiting for became non-nil. */ 7491 /* Exit now if the cell we're waiting for became non-nil. */
7492 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell))) 7492 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell)))
diff --git a/src/profiler.c b/src/profiler.c
index efc0cb316fc..88825bebdb2 100644
--- a/src/profiler.c
+++ b/src/profiler.c
@@ -174,8 +174,8 @@ record_backtrace (log_t *log, EMACS_INT count)
174 some global flag so that some Elisp code can offload its 174 some global flag so that some Elisp code can offload its
175 data elsewhere, so as to avoid the eviction code. 175 data elsewhere, so as to avoid the eviction code.
176 There are 2 ways to do that, AFAICT: 176 There are 2 ways to do that, AFAICT:
177 - Set a flag checked in QUIT, such that QUIT can then call 177 - Set a flag checked in maybe_quit, such that maybe_quit can then
178 Fprofiler_cpu_log and stash the full log for later use. 178 call Fprofiler_cpu_log and stash the full log for later use.
179 - Set a flag check in post-gc-hook, so that Elisp code can call 179 - Set a flag check in post-gc-hook, so that Elisp code can call
180 profiler-cpu-log. That gives us more flexibility since that 180 profiler-cpu-log. That gives us more flexibility since that
181 Elisp code can then do all kinds of fun stuff like write 181 Elisp code can then do all kinds of fun stuff like write
diff --git a/src/regex.c b/src/regex.c
index db3f0c16a2d..f6e67afef4c 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -1729,12 +1729,9 @@ typedef struct
1729/* Explicit quit checking is needed for Emacs, which uses polling to 1729/* Explicit quit checking is needed for Emacs, which uses polling to
1730 process input events. */ 1730 process input events. */
1731#ifdef emacs 1731#ifdef emacs
1732# define IMMEDIATE_QUIT_CHECK \ 1732# define IMMEDIATE_QUIT_CHECK (immediate_quit ? maybe_quit () : (void) 0)
1733 do { \
1734 if (immediate_quit) QUIT; \
1735 } while (0)
1736#else 1733#else
1737# define IMMEDIATE_QUIT_CHECK ((void)0) 1734# define IMMEDIATE_QUIT_CHECK ((void) 0)
1738#endif 1735#endif
1739 1736
1740/* Structure to manage work area for range table. */ 1737/* Structure to manage work area for range table. */
diff --git a/src/search.c b/src/search.c
index d3045108705..f54f44c8818 100644
--- a/src/search.c
+++ b/src/search.c
@@ -276,8 +276,9 @@ looking_at_1 (Lisp_Object string, bool posix)
276 posix, 276 posix,
277 !NILP (BVAR (current_buffer, enable_multibyte_characters))); 277 !NILP (BVAR (current_buffer, enable_multibyte_characters)));
278 278
279 immediate_quit = 1; 279 /* Do a pending quit right away, to avoid paradoxical behavior */
280 QUIT; /* Do a pending quit right away, to avoid paradoxical behavior */ 280 immediate_quit = true;
281 maybe_quit ();
281 282
282 /* Get pointers and sizes of the two strings 283 /* Get pointers and sizes of the two strings
283 that make up the visible portion of the buffer. */ 284 that make up the visible portion of the buffer. */
@@ -310,7 +311,7 @@ looking_at_1 (Lisp_Object string, bool posix)
310 (NILP (Vinhibit_changing_match_data) 311 (NILP (Vinhibit_changing_match_data)
311 ? &search_regs : NULL), 312 ? &search_regs : NULL),
312 ZV_BYTE - BEGV_BYTE); 313 ZV_BYTE - BEGV_BYTE);
313 immediate_quit = 0; 314 immediate_quit = false;
314#ifdef REL_ALLOC 315#ifdef REL_ALLOC
315 r_alloc_inhibit_buffer_relocation (0); 316 r_alloc_inhibit_buffer_relocation (0);
316#endif 317#endif
@@ -398,7 +399,7 @@ string_match_1 (Lisp_Object regexp, Lisp_Object string, Lisp_Object start,
398 ? BVAR (current_buffer, case_canon_table) : Qnil), 399 ? BVAR (current_buffer, case_canon_table) : Qnil),
399 posix, 400 posix,
400 STRING_MULTIBYTE (string)); 401 STRING_MULTIBYTE (string));
401 immediate_quit = 1; 402 immediate_quit = true;
402 re_match_object = string; 403 re_match_object = string;
403 404
404 val = re_search (bufp, SSDATA (string), 405 val = re_search (bufp, SSDATA (string),
@@ -406,7 +407,7 @@ string_match_1 (Lisp_Object regexp, Lisp_Object string, Lisp_Object start,
406 SBYTES (string) - pos_byte, 407 SBYTES (string) - pos_byte,
407 (NILP (Vinhibit_changing_match_data) 408 (NILP (Vinhibit_changing_match_data)
408 ? &search_regs : NULL)); 409 ? &search_regs : NULL));
409 immediate_quit = 0; 410 immediate_quit = false;
410 411
411 /* Set last_thing_searched only when match data is changed. */ 412 /* Set last_thing_searched only when match data is changed. */
412 if (NILP (Vinhibit_changing_match_data)) 413 if (NILP (Vinhibit_changing_match_data))
@@ -470,13 +471,13 @@ fast_string_match_internal (Lisp_Object regexp, Lisp_Object string,
470 471
471 bufp = compile_pattern (regexp, 0, table, 472 bufp = compile_pattern (regexp, 0, table,
472 0, STRING_MULTIBYTE (string)); 473 0, STRING_MULTIBYTE (string));
473 immediate_quit = 1; 474 immediate_quit = true;
474 re_match_object = string; 475 re_match_object = string;
475 476
476 val = re_search (bufp, SSDATA (string), 477 val = re_search (bufp, SSDATA (string),
477 SBYTES (string), 0, 478 SBYTES (string), 0,
478 SBYTES (string), 0); 479 SBYTES (string), 0);
479 immediate_quit = 0; 480 immediate_quit = false;
480 return val; 481 return val;
481} 482}
482 483
@@ -497,9 +498,9 @@ fast_c_string_match_ignore_case (Lisp_Object regexp,
497 bufp = compile_pattern (regexp, 0, 498 bufp = compile_pattern (regexp, 0,
498 Vascii_canon_table, 0, 499 Vascii_canon_table, 0,
499 0); 500 0);
500 immediate_quit = 1; 501 immediate_quit = true;
501 val = re_search (bufp, string, len, 0, len, 0); 502 val = re_search (bufp, string, len, 0, len, 0);
502 immediate_quit = 0; 503 immediate_quit = false;
503 return val; 504 return val;
504} 505}
505 506
@@ -560,7 +561,7 @@ fast_looking_at (Lisp_Object regexp, ptrdiff_t pos, ptrdiff_t pos_byte,
560 } 561 }
561 562
562 buf = compile_pattern (regexp, 0, Qnil, 0, multibyte); 563 buf = compile_pattern (regexp, 0, Qnil, 0, multibyte);
563 immediate_quit = 1; 564 immediate_quit = true;
564#ifdef REL_ALLOC 565#ifdef REL_ALLOC
565 /* Prevent ralloc.c from relocating the current buffer while 566 /* Prevent ralloc.c from relocating the current buffer while
566 searching it. */ 567 searching it. */
@@ -571,7 +572,7 @@ fast_looking_at (Lisp_Object regexp, ptrdiff_t pos, ptrdiff_t pos_byte,
571#ifdef REL_ALLOC 572#ifdef REL_ALLOC
572 r_alloc_inhibit_buffer_relocation (0); 573 r_alloc_inhibit_buffer_relocation (0);
573#endif 574#endif
574 immediate_quit = 0; 575 immediate_quit = false;
575 576
576 return len; 577 return len;
577} 578}
@@ -703,7 +704,7 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end,
703 ptrdiff_t next_change; 704 ptrdiff_t next_change;
704 int result = 1; 705 int result = 1;
705 706
706 immediate_quit = 0; 707 immediate_quit = false;
707 while (start < end && result) 708 while (start < end && result)
708 { 709 {
709 ptrdiff_t lim1; 710 ptrdiff_t lim1;
@@ -809,7 +810,7 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end,
809 810
810 if (--count == 0) 811 if (--count == 0)
811 { 812 {
812 immediate_quit = 0; 813 immediate_quit = false;
813 if (bytepos) 814 if (bytepos)
814 *bytepos = lim_byte + next; 815 *bytepos = lim_byte + next;
815 return BYTE_TO_CHAR (lim_byte + next); 816 return BYTE_TO_CHAR (lim_byte + next);
@@ -832,7 +833,7 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end,
832 ptrdiff_t next_change; 833 ptrdiff_t next_change;
833 int result = 1; 834 int result = 1;
834 835
835 immediate_quit = 0; 836 immediate_quit = false;
836 while (start > end && result) 837 while (start > end && result)
837 { 838 {
838 ptrdiff_t lim1; 839 ptrdiff_t lim1;
@@ -917,7 +918,7 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end,
917 918
918 if (++count >= 0) 919 if (++count >= 0)
919 { 920 {
920 immediate_quit = 0; 921 immediate_quit = false;
921 if (bytepos) 922 if (bytepos)
922 *bytepos = ceiling_byte + prev + 1; 923 *bytepos = ceiling_byte + prev + 1;
923 return BYTE_TO_CHAR (ceiling_byte + prev + 1); 924 return BYTE_TO_CHAR (ceiling_byte + prev + 1);
@@ -929,7 +930,7 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end,
929 } 930 }
930 } 931 }
931 932
932 immediate_quit = 0; 933 immediate_quit = false;
933 if (shortage) 934 if (shortage)
934 *shortage = count * direction; 935 *shortage = count * direction;
935 if (bytepos) 936 if (bytepos)
@@ -1196,10 +1197,10 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte,
1196 trt, posix, 1197 trt, posix,
1197 !NILP (BVAR (current_buffer, enable_multibyte_characters))); 1198 !NILP (BVAR (current_buffer, enable_multibyte_characters)));
1198 1199
1199 immediate_quit = 1; /* Quit immediately if user types ^G, 1200 immediate_quit = true; /* Quit immediately if user types ^G,
1200 because letting this function finish 1201 because letting this function finish
1201 can take too long. */ 1202 can take too long. */
1202 QUIT; /* Do a pending quit right away, 1203 maybe_quit (); /* Do a pending quit right away,
1203 to avoid paradoxical behavior */ 1204 to avoid paradoxical behavior */
1204 /* Get pointers and sizes of the two strings 1205 /* Get pointers and sizes of the two strings
1205 that make up the visible portion of the buffer. */ 1206 that make up the visible portion of the buffer. */
@@ -1267,7 +1268,7 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte,
1267 } 1268 }
1268 else 1269 else
1269 { 1270 {
1270 immediate_quit = 0; 1271 immediate_quit = false;
1271#ifdef REL_ALLOC 1272#ifdef REL_ALLOC
1272 r_alloc_inhibit_buffer_relocation (0); 1273 r_alloc_inhibit_buffer_relocation (0);
1273#endif 1274#endif
@@ -1312,7 +1313,7 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte,
1312 } 1313 }
1313 else 1314 else
1314 { 1315 {
1315 immediate_quit = 0; 1316 immediate_quit = false;
1316#ifdef REL_ALLOC 1317#ifdef REL_ALLOC
1317 r_alloc_inhibit_buffer_relocation (0); 1318 r_alloc_inhibit_buffer_relocation (0);
1318#endif 1319#endif
@@ -1320,7 +1321,7 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte,
1320 } 1321 }
1321 n--; 1322 n--;
1322 } 1323 }
1323 immediate_quit = 0; 1324 immediate_quit = false;
1324#ifdef REL_ALLOC 1325#ifdef REL_ALLOC
1325 r_alloc_inhibit_buffer_relocation (0); 1326 r_alloc_inhibit_buffer_relocation (0);
1326#endif 1327#endif
@@ -1927,7 +1928,7 @@ boyer_moore (EMACS_INT n, unsigned char *base_pat,
1927 < 0) 1928 < 0)
1928 return (n * (0 - direction)); 1929 return (n * (0 - direction));
1929 /* First we do the part we can by pointers (maybe nothing) */ 1930 /* First we do the part we can by pointers (maybe nothing) */
1930 QUIT; 1931 maybe_quit ();
1931 pat = base_pat; 1932 pat = base_pat;
1932 limit = pos_byte - dirlen + direction; 1933 limit = pos_byte - dirlen + direction;
1933 if (direction > 0) 1934 if (direction > 0)
@@ -3274,7 +3275,7 @@ find_newline1 (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end,
3274 3275
3275 if (--count == 0) 3276 if (--count == 0)
3276 { 3277 {
3277 immediate_quit = 0; 3278 immediate_quit = false;
3278 if (bytepos) 3279 if (bytepos)
3279 *bytepos = lim_byte + next; 3280 *bytepos = lim_byte + next;
3280 return BYTE_TO_CHAR (lim_byte + next); 3281 return BYTE_TO_CHAR (lim_byte + next);
@@ -3286,7 +3287,7 @@ find_newline1 (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end,
3286 } 3287 }
3287 } 3288 }
3288 3289
3289 immediate_quit = 0; 3290 immediate_quit = false;
3290 if (shortage) 3291 if (shortage)
3291 *shortage = count; 3292 *shortage = count;
3292 if (bytepos) 3293 if (bytepos)
diff --git a/src/syntax.c b/src/syntax.c
index 0ee1c746ec3..f9e4093765c 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -1426,8 +1426,8 @@ scan_words (register ptrdiff_t from, register EMACS_INT count)
1426 int ch0, ch1; 1426 int ch0, ch1;
1427 Lisp_Object func, pos; 1427 Lisp_Object func, pos;
1428 1428
1429 immediate_quit = 1; 1429 immediate_quit = true;
1430 QUIT; 1430 maybe_quit ();
1431 1431
1432 SETUP_SYNTAX_TABLE (from, count); 1432 SETUP_SYNTAX_TABLE (from, count);
1433 1433
@@ -1437,7 +1437,7 @@ scan_words (register ptrdiff_t from, register EMACS_INT count)
1437 { 1437 {
1438 if (from == end) 1438 if (from == end)
1439 { 1439 {
1440 immediate_quit = 0; 1440 immediate_quit = false;
1441 return 0; 1441 return 0;
1442 } 1442 }
1443 UPDATE_SYNTAX_TABLE_FORWARD (from); 1443 UPDATE_SYNTAX_TABLE_FORWARD (from);
@@ -1487,7 +1487,7 @@ scan_words (register ptrdiff_t from, register EMACS_INT count)
1487 { 1487 {
1488 if (from == beg) 1488 if (from == beg)
1489 { 1489 {
1490 immediate_quit = 0; 1490 immediate_quit = false;
1491 return 0; 1491 return 0;
1492 } 1492 }
1493 DEC_BOTH (from, from_byte); 1493 DEC_BOTH (from, from_byte);
@@ -1536,7 +1536,7 @@ scan_words (register ptrdiff_t from, register EMACS_INT count)
1536 count++; 1536 count++;
1537 } 1537 }
1538 1538
1539 immediate_quit = 0; 1539 immediate_quit = false;
1540 1540
1541 return from; 1541 return from;
1542} 1542}
@@ -1921,7 +1921,7 @@ skip_chars (bool forwardp, Lisp_Object string, Lisp_Object lim,
1921 stop = (pos >= GPT && GPT > XINT (lim)) ? GAP_END_ADDR : endp; 1921 stop = (pos >= GPT && GPT > XINT (lim)) ? GAP_END_ADDR : endp;
1922 } 1922 }
1923 1923
1924 immediate_quit = 1; 1924 immediate_quit = true;
1925 /* This code may look up syntax tables using functions that rely on the 1925 /* This code may look up syntax tables using functions that rely on the
1926 gl_state object. To make sure this object is not out of date, 1926 gl_state object. To make sure this object is not out of date,
1927 let's initialize it manually. 1927 let's initialize it manually.
@@ -2064,7 +2064,7 @@ skip_chars (bool forwardp, Lisp_Object string, Lisp_Object lim,
2064 } 2064 }
2065 2065
2066 SET_PT_BOTH (pos, pos_byte); 2066 SET_PT_BOTH (pos, pos_byte);
2067 immediate_quit = 0; 2067 immediate_quit = false;
2068 2068
2069 SAFE_FREE (); 2069 SAFE_FREE ();
2070 return make_number (PT - start_point); 2070 return make_number (PT - start_point);
@@ -2138,7 +2138,7 @@ skip_syntaxes (bool forwardp, Lisp_Object string, Lisp_Object lim)
2138 ptrdiff_t pos_byte = PT_BYTE; 2138 ptrdiff_t pos_byte = PT_BYTE;
2139 unsigned char *p, *endp, *stop; 2139 unsigned char *p, *endp, *stop;
2140 2140
2141 immediate_quit = 1; 2141 immediate_quit = true;
2142 SETUP_SYNTAX_TABLE (pos, forwardp ? 1 : -1); 2142 SETUP_SYNTAX_TABLE (pos, forwardp ? 1 : -1);
2143 2143
2144 if (forwardp) 2144 if (forwardp)
@@ -2224,7 +2224,7 @@ skip_syntaxes (bool forwardp, Lisp_Object string, Lisp_Object lim)
2224 2224
2225 done: 2225 done:
2226 SET_PT_BOTH (pos, pos_byte); 2226 SET_PT_BOTH (pos, pos_byte);
2227 immediate_quit = 0; 2227 immediate_quit = false;
2228 2228
2229 return make_number (PT - start_point); 2229 return make_number (PT - start_point);
2230 } 2230 }
@@ -2412,8 +2412,8 @@ between them, return t; otherwise return nil. */)
2412 count1 = XINT (count); 2412 count1 = XINT (count);
2413 stop = count1 > 0 ? ZV : BEGV; 2413 stop = count1 > 0 ? ZV : BEGV;
2414 2414
2415 immediate_quit = 1; 2415 immediate_quit = true;
2416 QUIT; 2416 maybe_quit ();
2417 2417
2418 from = PT; 2418 from = PT;
2419 from_byte = PT_BYTE; 2419 from_byte = PT_BYTE;
@@ -2429,7 +2429,7 @@ between them, return t; otherwise return nil. */)
2429 if (from == stop) 2429 if (from == stop)
2430 { 2430 {
2431 SET_PT_BOTH (from, from_byte); 2431 SET_PT_BOTH (from, from_byte);
2432 immediate_quit = 0; 2432 immediate_quit = false;
2433 return Qnil; 2433 return Qnil;
2434 } 2434 }
2435 c = FETCH_CHAR_AS_MULTIBYTE (from_byte); 2435 c = FETCH_CHAR_AS_MULTIBYTE (from_byte);
@@ -2463,7 +2463,7 @@ between them, return t; otherwise return nil. */)
2463 comstyle = ST_COMMENT_STYLE; 2463 comstyle = ST_COMMENT_STYLE;
2464 else if (code != Scomment) 2464 else if (code != Scomment)
2465 { 2465 {
2466 immediate_quit = 0; 2466 immediate_quit = false;
2467 DEC_BOTH (from, from_byte); 2467 DEC_BOTH (from, from_byte);
2468 SET_PT_BOTH (from, from_byte); 2468 SET_PT_BOTH (from, from_byte);
2469 return Qnil; 2469 return Qnil;
@@ -2474,7 +2474,7 @@ between them, return t; otherwise return nil. */)
2474 from = out_charpos; from_byte = out_bytepos; 2474 from = out_charpos; from_byte = out_bytepos;
2475 if (!found) 2475 if (!found)
2476 { 2476 {
2477 immediate_quit = 0; 2477 immediate_quit = false;
2478 SET_PT_BOTH (from, from_byte); 2478 SET_PT_BOTH (from, from_byte);
2479 return Qnil; 2479 return Qnil;
2480 } 2480 }
@@ -2494,7 +2494,7 @@ between them, return t; otherwise return nil. */)
2494 if (from <= stop) 2494 if (from <= stop)
2495 { 2495 {
2496 SET_PT_BOTH (BEGV, BEGV_BYTE); 2496 SET_PT_BOTH (BEGV, BEGV_BYTE);
2497 immediate_quit = 0; 2497 immediate_quit = false;
2498 return Qnil; 2498 return Qnil;
2499 } 2499 }
2500 2500
@@ -2587,7 +2587,7 @@ between them, return t; otherwise return nil. */)
2587 else if (code != Swhitespace || quoted) 2587 else if (code != Swhitespace || quoted)
2588 { 2588 {
2589 leave: 2589 leave:
2590 immediate_quit = 0; 2590 immediate_quit = false;
2591 INC_BOTH (from, from_byte); 2591 INC_BOTH (from, from_byte);
2592 SET_PT_BOTH (from, from_byte); 2592 SET_PT_BOTH (from, from_byte);
2593 return Qnil; 2593 return Qnil;
@@ -2598,7 +2598,7 @@ between them, return t; otherwise return nil. */)
2598 } 2598 }
2599 2599
2600 SET_PT_BOTH (from, from_byte); 2600 SET_PT_BOTH (from, from_byte);
2601 immediate_quit = 0; 2601 immediate_quit = false;
2602 return Qt; 2602 return Qt;
2603} 2603}
2604 2604
@@ -2640,8 +2640,8 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2640 2640
2641 from_byte = CHAR_TO_BYTE (from); 2641 from_byte = CHAR_TO_BYTE (from);
2642 2642
2643 immediate_quit = 1; 2643 immediate_quit = true;
2644 QUIT; 2644 maybe_quit ();
2645 2645
2646 SETUP_SYNTAX_TABLE (from, count); 2646 SETUP_SYNTAX_TABLE (from, count);
2647 while (count > 0) 2647 while (count > 0)
@@ -2801,7 +2801,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2801 if (depth) 2801 if (depth)
2802 goto lose; 2802 goto lose;
2803 2803
2804 immediate_quit = 0; 2804 immediate_quit = false;
2805 return Qnil; 2805 return Qnil;
2806 2806
2807 /* End of object reached */ 2807 /* End of object reached */
@@ -2984,7 +2984,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2984 if (depth) 2984 if (depth)
2985 goto lose; 2985 goto lose;
2986 2986
2987 immediate_quit = 0; 2987 immediate_quit = false;
2988 return Qnil; 2988 return Qnil;
2989 2989
2990 done2: 2990 done2:
@@ -2992,7 +2992,7 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2992 } 2992 }
2993 2993
2994 2994
2995 immediate_quit = 0; 2995 immediate_quit = false;
2996 XSETFASTINT (val, from); 2996 XSETFASTINT (val, from);
2997 return val; 2997 return val;
2998 2998
@@ -3173,8 +3173,8 @@ do { prev_from = from; \
3173 UPDATE_SYNTAX_TABLE_FORWARD (from); \ 3173 UPDATE_SYNTAX_TABLE_FORWARD (from); \
3174 } while (0) 3174 } while (0)
3175 3175
3176 immediate_quit = 1; 3176 immediate_quit = true;
3177 QUIT; 3177 maybe_quit ();
3178 3178
3179 depth = state->depth; 3179 depth = state->depth;
3180 start_quoted = state->quoted; 3180 start_quoted = state->quoted;
@@ -3432,7 +3432,7 @@ do { prev_from = from; \
3432 state->levelstarts); 3432 state->levelstarts);
3433 state->prev_syntax = (SYNTAX_FLAGS_COMSTARTEND_FIRST (prev_from_syntax) 3433 state->prev_syntax = (SYNTAX_FLAGS_COMSTARTEND_FIRST (prev_from_syntax)
3434 || state->quoted) ? prev_from_syntax : Smax; 3434 || state->quoted) ? prev_from_syntax : Smax;
3435 immediate_quit = 0; 3435 immediate_quit = false;
3436} 3436}
3437 3437
3438/* Convert a (lisp) parse state to the internal form used in 3438/* Convert a (lisp) parse state to the internal form used in
diff --git a/src/sysdep.c b/src/sysdep.c
index 4316c21a1c7..e172dc0aed4 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -391,10 +391,10 @@ get_child_status (pid_t child, int *status, int options, bool interruptible)
391 if (errno != EINTR) 391 if (errno != EINTR)
392 emacs_abort (); 392 emacs_abort ();
393 393
394 /* Note: the MS-Windows emulation of waitpid calls QUIT 394 /* Note: the MS-Windows emulation of waitpid calls maybe_quit
395 internally. */ 395 internally. */
396 if (interruptible) 396 if (interruptible)
397 QUIT; 397 maybe_quit ();
398 } 398 }
399 399
400 /* If successful and status is requested, tell wait_reading_process_output 400 /* If successful and status is requested, tell wait_reading_process_output
@@ -2383,7 +2383,7 @@ emacs_open (const char *file, int oflags, int mode)
2383 oflags |= O_BINARY; 2383 oflags |= O_BINARY;
2384 oflags |= O_CLOEXEC; 2384 oflags |= O_CLOEXEC;
2385 while ((fd = open (file, oflags, mode)) < 0 && errno == EINTR) 2385 while ((fd = open (file, oflags, mode)) < 0 && errno == EINTR)
2386 QUIT; 2386 maybe_quit ();
2387 if (! O_CLOEXEC && 0 <= fd) 2387 if (! O_CLOEXEC && 0 <= fd)
2388 fcntl (fd, F_SETFD, FD_CLOEXEC); 2388 fcntl (fd, F_SETFD, FD_CLOEXEC);
2389 return fd; 2389 return fd;
@@ -2516,7 +2516,7 @@ emacs_read (int fildes, void *buf, ptrdiff_t nbyte)
2516 2516
2517 while ((rtnval = read (fildes, buf, nbyte)) == -1 2517 while ((rtnval = read (fildes, buf, nbyte)) == -1
2518 && (errno == EINTR)) 2518 && (errno == EINTR))
2519 QUIT; 2519 maybe_quit ();
2520 return (rtnval); 2520 return (rtnval);
2521} 2521}
2522 2522
@@ -2538,7 +2538,7 @@ emacs_full_write (int fildes, char const *buf, ptrdiff_t nbyte,
2538 { 2538 {
2539 if (errno == EINTR) 2539 if (errno == EINTR)
2540 { 2540 {
2541 /* I originally used `QUIT' but that might cause files to 2541 /* I originally used maybe_quit but that might cause files to
2542 be truncated if you hit C-g in the middle of it. --Stef */ 2542 be truncated if you hit C-g in the middle of it. --Stef */
2543 if (process_signals && pending_signals) 2543 if (process_signals && pending_signals)
2544 process_pending_signals (); 2544 process_pending_signals ();
diff --git a/src/textprop.c b/src/textprop.c
index 7cb3d3c38e6..225ff28e57e 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -211,7 +211,7 @@ validate_plist (Lisp_Object list)
211 if (! CONSP (tail)) 211 if (! CONSP (tail))
212 error ("Odd length text property list"); 212 error ("Odd length text property list");
213 tail = XCDR (tail); 213 tail = XCDR (tail);
214 QUIT; 214 maybe_quit ();
215 } 215 }
216 while (CONSP (tail)); 216 while (CONSP (tail));
217 217
diff --git a/src/w32fns.c b/src/w32fns.c
index c24fce11fc8..6a576fcec27 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -778,7 +778,7 @@ w32_color_map_lookup (const char *colorname)
778 break; 778 break;
779 } 779 }
780 780
781 QUIT; 781 maybe_quit ();
782 } 782 }
783 783
784 unblock_input (); 784 unblock_input ();
@@ -3166,7 +3166,7 @@ signal_user_input (void)
3166 if (!NILP (Vthrow_on_input)) 3166 if (!NILP (Vthrow_on_input))
3167 { 3167 {
3168 Vquit_flag = Vthrow_on_input; 3168 Vquit_flag = Vthrow_on_input;
3169 /* Doing a QUIT from this thread is a bad idea, since this 3169 /* Calling maybe_quit from this thread is a bad idea, since this
3170 unwinds the stack of the Lisp thread, and the Windows runtime 3170 unwinds the stack of the Lisp thread, and the Windows runtime
3171 rightfully barfs. Disabled. */ 3171 rightfully barfs. Disabled. */
3172#if 0 3172#if 0
@@ -3174,8 +3174,8 @@ signal_user_input (void)
3174 do it now. */ 3174 do it now. */
3175 if (immediate_quit && NILP (Vinhibit_quit)) 3175 if (immediate_quit && NILP (Vinhibit_quit))
3176 { 3176 {
3177 immediate_quit = 0; 3177 immediate_quit = false;
3178 QUIT; 3178 maybe_quit ();
3179 } 3179 }
3180#endif 3180#endif
3181 } 3181 }
diff --git a/src/w32notify.c b/src/w32notify.c
index 1f4cbe2df47..25205816bae 100644
--- a/src/w32notify.c
+++ b/src/w32notify.c
@@ -664,7 +664,7 @@ w32_get_watch_object (void *desc)
664 Lisp_Object descriptor = make_pointer_integer (desc); 664 Lisp_Object descriptor = make_pointer_integer (desc);
665 665
666 /* This is called from the input queue handling code, inside a 666 /* This is called from the input queue handling code, inside a
667 critical section, so we cannot possibly QUIT if watch_list is not 667 critical section, so we cannot possibly quit if watch_list is not
668 in the right condition. */ 668 in the right condition. */
669 return NILP (watch_list) ? Qnil : assoc_no_quit (descriptor, watch_list); 669 return NILP (watch_list) ? Qnil : assoc_no_quit (descriptor, watch_list);
670} 670}
diff --git a/src/w32proc.c b/src/w32proc.c
index a7f2b4a9950..0aa248a6f7b 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -1449,7 +1449,7 @@ waitpid (pid_t pid, int *status, int options)
1449 1449
1450 do 1450 do
1451 { 1451 {
1452 QUIT; 1452 maybe_quit ();
1453 active = WaitForMultipleObjects (nh, wait_hnd, FALSE, timeout_ms); 1453 active = WaitForMultipleObjects (nh, wait_hnd, FALSE, timeout_ms);
1454 } while (active == WAIT_TIMEOUT && !dont_wait); 1454 } while (active == WAIT_TIMEOUT && !dont_wait);
1455 1455
diff --git a/src/window.c b/src/window.c
index 0a6b94d4d1d..71a82b522c4 100644
--- a/src/window.c
+++ b/src/window.c
@@ -521,9 +521,10 @@ select_window (Lisp_Object window, Lisp_Object norecord,
521 bset_last_selected_window (XBUFFER (w->contents), window); 521 bset_last_selected_window (XBUFFER (w->contents), window);
522 522
523 record_and_return: 523 record_and_return:
524 /* record_buffer can run QUIT, so make sure it is run only after we have 524 /* record_buffer can call maybe_quit, so make sure it is run only
525 re-established the invariant between selected_window and selected_frame, 525 after we have re-established the invariant between
526 otherwise the temporary broken invariant might "escape" (bug#14161). */ 526 selected_window and selected_frame, otherwise the temporary
527 broken invariant might "escape" (Bug#14161). */
527 if (NILP (norecord)) 528 if (NILP (norecord))
528 { 529 {
529 w->use_time = ++window_select_count; 530 w->use_time = ++window_select_count;
diff --git a/src/xdisp.c b/src/xdisp.c
index 168922ef06b..33661c882cd 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -22635,7 +22635,7 @@ move_elt_to_front (Lisp_Object elt, Lisp_Object list)
22635 else 22635 else
22636 prev = tail; 22636 prev = tail;
22637 tail = XCDR (tail); 22637 tail = XCDR (tail);
22638 QUIT; 22638 maybe_quit ();
22639 } 22639 }
22640 22640
22641 /* Not found--return unchanged LIST. */ 22641 /* Not found--return unchanged LIST. */
diff --git a/src/xselect.c b/src/xselect.c
index 47ccf6886bf..2249828fb4e 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -329,7 +329,7 @@ x_own_selection (Lisp_Object selection_name, Lisp_Object selection_value,
329 Fcons (selection_data, dpyinfo->terminal->Vselection_alist)); 329 Fcons (selection_data, dpyinfo->terminal->Vselection_alist));
330 330
331 /* If we already owned the selection, remove the old selection 331 /* If we already owned the selection, remove the old selection
332 data. Don't use Fdelq as that may QUIT. */ 332 data. Don't use Fdelq as that may quit. */
333 if (!NILP (prev_value)) 333 if (!NILP (prev_value))
334 { 334 {
335 /* We know it's not the CAR, so it's easy. */ 335 /* We know it's not the CAR, so it's easy. */
@@ -929,7 +929,7 @@ x_handle_selection_clear (struct selection_input_event *event)
929 && local_selection_time > changed_owner_time) 929 && local_selection_time > changed_owner_time)
930 return; 930 return;
931 931
932 /* Otherwise, really clear. Don't use Fdelq as that may QUIT;. */ 932 /* Otherwise, really clear. Don't use Fdelq as that may quit. */
933 Vselection_alist = dpyinfo->terminal->Vselection_alist; 933 Vselection_alist = dpyinfo->terminal->Vselection_alist;
934 if (EQ (local_selection_data, CAR (Vselection_alist))) 934 if (EQ (local_selection_data, CAR (Vselection_alist)))
935 Vselection_alist = XCDR (Vselection_alist); 935 Vselection_alist = XCDR (Vselection_alist);
diff --git a/src/xterm.c b/src/xterm.c
index db561c902a6..80cf8ce1912 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -635,7 +635,7 @@ x_cr_export_frames (Lisp_Object frames, cairo_surface_type_t surface_type)
635 (*surface_set_size_func) (surface, width, height); 635 (*surface_set_size_func) (surface, width, height);
636 636
637 unblock_input (); 637 unblock_input ();
638 QUIT; 638 maybe_quit ();
639 block_input (); 639 block_input ();
640 } 640 }
641 641