aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2017-02-01 15:18:43 -0800
committerPaul Eggert2017-02-01 15:23:19 -0800
commit33be50037c2b4cdb002538534e9915c6bad253b7 (patch)
tree04a387a7afb86c86c4eaea71175d6d9fd1c37047
parent94ad13b93c6fc099a353c8eb27c00a68ee79a952 (diff)
downloademacs-33be50037c2b4cdb002538534e9915c6bad253b7.tar.gz
emacs-33be50037c2b4cdb002538534e9915c6bad253b7.zip
Remove immediate_quit.
The old code that sets and clears immediate_quit was ineffective except when Emacs is running in terminal mode, and has problematic race conditions anyway, so remove it. This will introduce some hangs when Emacs runs in terminal mode, and these hangs should be fixed in followup patches. * src/keyboard.c (immediate_quit): Remove. All uses removed.
-rw-r--r--admin/notes/multi-tty5
-rw-r--r--src/bytecode.c4
-rw-r--r--src/callproc.c8
-rw-r--r--src/dired.c3
-rw-r--r--src/editfns.c9
-rw-r--r--src/eval.c2
-rw-r--r--src/fileio.c19
-rw-r--r--src/fns.c42
-rw-r--r--src/indent.c2
-rw-r--r--src/keyboard.c45
-rw-r--r--src/lisp.h8
-rw-r--r--src/process.c10
-rw-r--r--src/regex.c10
-rw-r--r--src/search.c33
-rw-r--r--src/syntax.c30
-rw-r--r--src/w32fns.c11
-rw-r--r--src/window.c2
17 files changed, 30 insertions, 213 deletions
diff --git a/admin/notes/multi-tty b/admin/notes/multi-tty
index b58180e6fab..d0096adc6d2 100644
--- a/admin/notes/multi-tty
+++ b/admin/notes/multi-tty
@@ -1239,9 +1239,8 @@ DIARY OF CHANGES
1239 (Update: OK, it all seems so easy now (NOT). Input could be done 1239 (Update: OK, it all seems so easy now (NOT). Input could be done
1240 synchronously (with wait_reading_process_input), or asynchronously 1240 synchronously (with wait_reading_process_input), or asynchronously
1241 by SIGIO or polling (SIGALRM). C-g either sets the Vquit_flag, 1241 by SIGIO or polling (SIGALRM). C-g either sets the Vquit_flag,
1242 signals a 'quit condition (when immediate_quit), or throws to 1242 signals a 'quit condition, or throws to 'getcjmp' when Emacs was
1243 'getcjmp' when Emacs was waiting for input when the C-g event 1243 waiting for input when the C-g event arrived.)
1244 arrived.)
1245 1244
1246-- Replace wrong_kboard_jmpbuf with a special return value of 1245-- Replace wrong_kboard_jmpbuf with a special return value of
1247 read_char. It is absurd that we use setjmp/longjmp just to return 1246 read_char. It is absurd that we use setjmp/longjmp just to return
diff --git a/src/bytecode.c b/src/bytecode.c
index 499fb881e2e..ed58d18c618 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -842,10 +842,8 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
842 Lisp_Object v2 = POP, v1 = TOP; 842 Lisp_Object v2 = POP, v1 = TOP;
843 CHECK_NUMBER (v1); 843 CHECK_NUMBER (v1);
844 EMACS_INT n = XINT (v1); 844 EMACS_INT n = XINT (v1);
845 immediate_quit = true;
846 while (--n >= 0 && CONSP (v2)) 845 while (--n >= 0 && CONSP (v2))
847 v2 = XCDR (v2); 846 v2 = XCDR (v2);
848 immediate_quit = false;
849 TOP = CAR (v2); 847 TOP = CAR (v2);
850 NEXT; 848 NEXT;
851 } 849 }
@@ -1276,10 +1274,8 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1276 Lisp_Object v2 = POP, v1 = TOP; 1274 Lisp_Object v2 = POP, v1 = TOP;
1277 CHECK_NUMBER (v2); 1275 CHECK_NUMBER (v2);
1278 EMACS_INT n = XINT (v2); 1276 EMACS_INT n = XINT (v2);
1279 immediate_quit = true;
1280 while (--n >= 0 && CONSP (v1)) 1277 while (--n >= 0 && CONSP (v1))
1281 v1 = XCDR (v1); 1278 v1 = XCDR (v1);
1282 immediate_quit = false;
1283 TOP = CAR (v1); 1279 TOP = CAR (v1);
1284 } 1280 }
1285 else 1281 else
diff --git a/src/callproc.c b/src/callproc.c
index 301ccf383b5..85674bb7d9b 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -198,11 +198,9 @@ 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 = true;
202 maybe_quit (); 201 maybe_quit ();
203 wait_for_termination (synch_process_pid, 0, 1); 202 wait_for_termination (synch_process_pid, 0, 1);
204 synch_process_pid = 0; 203 synch_process_pid = 0;
205 immediate_quit = false;
206 message1 ("Waiting for process to die...done"); 204 message1 ("Waiting for process to die...done");
207 } 205 }
208#endif /* !MSDOS */ 206#endif /* !MSDOS */
@@ -726,7 +724,6 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd,
726 process_coding.src_multibyte = 0; 724 process_coding.src_multibyte = 0;
727 } 725 }
728 726
729 immediate_quit = true;
730 maybe_quit (); 727 maybe_quit ();
731 728
732 if (0 <= fd0) 729 if (0 <= fd0)
@@ -769,7 +766,6 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd,
769 } 766 }
770 767
771 /* Now NREAD is the total amount of data in the buffer. */ 768 /* Now NREAD is the total amount of data in the buffer. */
772 immediate_quit = false;
773 769
774 if (!nread) 770 if (!nread)
775 ; 771 ;
@@ -842,7 +838,7 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd,
842 we should have already detected a coding system. */ 838 we should have already detected a coding system. */
843 display_on_the_fly = true; 839 display_on_the_fly = true;
844 } 840 }
845 immediate_quit = true; 841
846 maybe_quit (); 842 maybe_quit ();
847 } 843 }
848 give_up: ; 844 give_up: ;
@@ -860,8 +856,6 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd,
860 wait_for_termination (pid, &status, fd0 < 0); 856 wait_for_termination (pid, &status, fd0 < 0);
861#endif 857#endif
862 858
863 immediate_quit = false;
864
865 /* Don't kill any children that the subprocess may have left behind 859 /* Don't kill any children that the subprocess may have left behind
866 when exiting. */ 860 when exiting. */
867 synch_process_pid = 0; 861 synch_process_pid = 0;
diff --git a/src/dired.c b/src/dired.c
index 52e81fb380b..5ea00fb8db4 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -248,14 +248,11 @@ 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 = true;
252 maybe_quit (); 251 maybe_quit ();
253 252
254 bool wanted = (NILP (match) 253 bool wanted = (NILP (match)
255 || re_search (bufp, SSDATA (name), len, 0, len, 0) >= 0); 254 || re_search (bufp, SSDATA (name), len, 0, len, 0) >= 0);
256 255
257 immediate_quit = false;
258
259 if (wanted) 256 if (wanted)
260 { 257 {
261 if (!NILP (full)) 258 if (!NILP (full))
diff --git a/src/editfns.c b/src/editfns.c
index 82c6abb9987..b60543702f1 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -3053,7 +3053,6 @@ determines whether case is significant or ignored. */)
3053 i2 = begp2; 3053 i2 = begp2;
3054 i1_byte = buf_charpos_to_bytepos (bp1, i1); 3054 i1_byte = buf_charpos_to_bytepos (bp1, i1);
3055 i2_byte = buf_charpos_to_bytepos (bp2, i2); 3055 i2_byte = buf_charpos_to_bytepos (bp2, i2);
3056 immediate_quit = true;
3057 3056
3058 while (i1 < endp1 && i2 < endp2) 3057 while (i1 < endp1 && i2 < endp2)
3059 { 3058 {
@@ -3092,17 +3091,13 @@ determines whether case is significant or ignored. */)
3092 c1 = char_table_translate (trt, c1); 3091 c1 = char_table_translate (trt, c1);
3093 c2 = char_table_translate (trt, c2); 3092 c2 = char_table_translate (trt, c2);
3094 } 3093 }
3094
3095 if (c1 != c2) 3095 if (c1 != c2)
3096 { 3096 return make_number (c1 < c2 ? -1 - chars : chars + 1);
3097 immediate_quit = false;
3098 return make_number (c1 < c2 ? -1 - chars : chars + 1);
3099 }
3100 3097
3101 chars++; 3098 chars++;
3102 } 3099 }
3103 3100
3104 immediate_quit = false;
3105
3106 /* The strings match as far as they go. 3101 /* The strings match as far as they go.
3107 If one is shorter, that one is less. */ 3102 If one is shorter, that one is less. */
3108 if (chars < endp1 - begp1) 3103 if (chars < endp1 - begp1)
diff --git a/src/eval.c b/src/eval.c
index 62d4af15e27..844879d6a2d 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1131,7 +1131,6 @@ 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 = false;
1135 1134
1136 do 1135 do
1137 { 1136 {
@@ -1517,7 +1516,6 @@ signal_or_quit (Lisp_Object error_symbol, Lisp_Object data, bool keyboard_quit)
1517 Lisp_Object clause = Qnil; 1516 Lisp_Object clause = Qnil;
1518 struct handler *h; 1517 struct handler *h;
1519 1518
1520 immediate_quit = false;
1521 if (gc_in_progress || waiting_for_input) 1519 if (gc_in_progress || waiting_for_input)
1522 emacs_abort (); 1520 emacs_abort ();
1523 1521
diff --git a/src/fileio.c b/src/fileio.c
index a46cfc7ac69..a109737240f 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -1960,9 +1960,7 @@ 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 = true;
1964 ifd = emacs_open (SSDATA (encoded_file), O_RDONLY, 0); 1963 ifd = emacs_open (SSDATA (encoded_file), O_RDONLY, 0);
1965 immediate_quit = false;
1966 1964
1967 if (ifd < 0) 1965 if (ifd < 0)
1968 report_file_error ("Opening input file", file); 1966 report_file_error ("Opening input file", file);
@@ -2024,7 +2022,6 @@ permissions. */)
2024 oldsize = out_st.st_size; 2022 oldsize = out_st.st_size;
2025 } 2023 }
2026 2024
2027 immediate_quit = true;
2028 maybe_quit (); 2025 maybe_quit ();
2029 2026
2030 if (clone_file (ofd, ifd)) 2027 if (clone_file (ofd, ifd))
@@ -2047,8 +2044,6 @@ permissions. */)
2047 if (newsize < oldsize && ftruncate (ofd, newsize) != 0) 2044 if (newsize < oldsize && ftruncate (ofd, newsize) != 0)
2048 report_file_error ("Truncating output file", newname); 2045 report_file_error ("Truncating output file", newname);
2049 2046
2050 immediate_quit = false;
2051
2052#ifndef MSDOS 2047#ifndef MSDOS
2053 /* Preserve the original file permissions, and if requested, also its 2048 /* Preserve the original file permissions, and if requested, also its
2054 owner and group. */ 2049 owner and group. */
@@ -3403,13 +3398,11 @@ read_non_regular (Lisp_Object state)
3403{ 3398{
3404 int nbytes; 3399 int nbytes;
3405 3400
3406 immediate_quit = true;
3407 maybe_quit (); 3401 maybe_quit ();
3408 nbytes = emacs_read (XSAVE_INTEGER (state, 0), 3402 nbytes = emacs_read (XSAVE_INTEGER (state, 0),
3409 ((char *) BEG_ADDR + PT_BYTE - BEG_BYTE 3403 ((char *) BEG_ADDR + PT_BYTE - BEG_BYTE
3410 + XSAVE_INTEGER (state, 1)), 3404 + XSAVE_INTEGER (state, 1)),
3411 XSAVE_INTEGER (state, 2)); 3405 XSAVE_INTEGER (state, 2));
3412 immediate_quit = false;
3413 /* Fast recycle this object for the likely next call. */ 3406 /* Fast recycle this object for the likely next call. */
3414 free_misc (state); 3407 free_misc (state);
3415 return make_number (nbytes); 3408 return make_number (nbytes);
@@ -3868,7 +3861,6 @@ by calling `format-decode', which see. */)
3868 report_file_error ("Setting file position", orig_filename); 3861 report_file_error ("Setting file position", orig_filename);
3869 } 3862 }
3870 3863
3871 immediate_quit = true;
3872 maybe_quit (); 3864 maybe_quit ();
3873 /* Count how many chars at the start of the file 3865 /* Count how many chars at the start of the file
3874 match the text at the beginning of the buffer. */ 3866 match the text at the beginning of the buffer. */
@@ -3907,7 +3899,6 @@ by calling `format-decode', which see. */)
3907 if (bufpos != nread) 3899 if (bufpos != nread)
3908 break; 3900 break;
3909 } 3901 }
3910 immediate_quit = false;
3911 /* If the file matches the buffer completely, 3902 /* If the file matches the buffer completely,
3912 there's no need to replace anything. */ 3903 there's no need to replace anything. */
3913 if (same_at_start - BEGV_BYTE == end_offset - beg_offset) 3904 if (same_at_start - BEGV_BYTE == end_offset - beg_offset)
@@ -3919,7 +3910,6 @@ by calling `format-decode', which see. */)
3919 del_range_1 (same_at_start, same_at_end, 0, 0); 3910 del_range_1 (same_at_start, same_at_end, 0, 0);
3920 goto handled; 3911 goto handled;
3921 } 3912 }
3922 immediate_quit = true;
3923 maybe_quit (); 3913 maybe_quit ();
3924 /* Count how many chars at the end of the file 3914 /* Count how many chars at the end of the file
3925 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
@@ -3977,7 +3967,6 @@ by calling `format-decode', which see. */)
3977 if (nread == 0) 3967 if (nread == 0)
3978 break; 3968 break;
3979 } 3969 }
3980 immediate_quit = false;
3981 3970
3982 if (! giveup_match_end) 3971 if (! giveup_match_end)
3983 { 3972 {
@@ -4075,11 +4064,9 @@ by calling `format-decode', which see. */)
4075 quitting while reading a huge file. */ 4064 quitting while reading a huge file. */
4076 4065
4077 /* Allow quitting out of the actual I/O. */ 4066 /* Allow quitting out of the actual I/O. */
4078 immediate_quit = true;
4079 maybe_quit (); 4067 maybe_quit ();
4080 this = emacs_read (fd, read_buf + unprocessed, 4068 this = emacs_read (fd, read_buf + unprocessed,
4081 READ_BUF_SIZE - unprocessed); 4069 READ_BUF_SIZE - unprocessed);
4082 immediate_quit = false;
4083 4070
4084 if (this <= 0) 4071 if (this <= 0)
4085 break; 4072 break;
@@ -4294,13 +4281,11 @@ by calling `format-decode', which see. */)
4294 /* Allow quitting out of the actual I/O. We don't make text 4281 /* Allow quitting out of the actual I/O. We don't make text
4295 part of the buffer until all the reading is done, so a C-g 4282 part of the buffer until all the reading is done, so a C-g
4296 here doesn't do any harm. */ 4283 here doesn't do any harm. */
4297 immediate_quit = true;
4298 maybe_quit (); 4284 maybe_quit ();
4299 this = emacs_read (fd, 4285 this = emacs_read (fd,
4300 ((char *) BEG_ADDR + PT_BYTE - BEG_BYTE 4286 ((char *) BEG_ADDR + PT_BYTE - BEG_BYTE
4301 + inserted), 4287 + inserted),
4302 trytry); 4288 trytry);
4303 immediate_quit = false;
4304 } 4289 }
4305 4290
4306 if (this <= 0) 4291 if (this <= 0)
@@ -5002,8 +4987,6 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename,
5002 } 4987 }
5003 } 4988 }
5004 4989
5005 immediate_quit = true;
5006
5007 if (STRINGP (start)) 4990 if (STRINGP (start))
5008 ok = a_write (desc, start, 0, SCHARS (start), &annotations, &coding); 4991 ok = a_write (desc, start, 0, SCHARS (start), &annotations, &coding);
5009 else if (XINT (start) != XINT (end)) 4992 else if (XINT (start) != XINT (end))
@@ -5026,8 +5009,6 @@ write_region (Lisp_Object start, Lisp_Object end, Lisp_Object filename,
5026 save_errno = errno; 5009 save_errno = errno;
5027 } 5010 }
5028 5011
5029 immediate_quit = false;
5030
5031 /* fsync is not crucial for temporary files. Nor for auto-save 5012 /* fsync is not crucial for temporary files. Nor for auto-save
5032 files, since they might lose some work anyway. */ 5013 files, since they might lose some work anyway. */
5033 if (open_and_close_file && !auto_saving && !write_region_inhibit_fsync) 5014 if (open_and_close_file && !auto_saving && !write_region_inhibit_fsync)
diff --git a/src/fns.c b/src/fns.c
index 136a2198c2c..444339c5259 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -1361,18 +1361,15 @@ DEFUN ("nthcdr", Fnthcdr, Snthcdr, 2, 2, 0,
1361 CHECK_NUMBER (n); 1361 CHECK_NUMBER (n);
1362 EMACS_INT num = XINT (n); 1362 EMACS_INT num = XINT (n);
1363 Lisp_Object tail = list; 1363 Lisp_Object tail = list;
1364 immediate_quit = true;
1365 for (EMACS_INT i = 0; i < num; i++) 1364 for (EMACS_INT i = 0; i < num; i++)
1366 { 1365 {
1367 if (! CONSP (tail)) 1366 if (! CONSP (tail))
1368 { 1367 {
1369 immediate_quit = false;
1370 CHECK_LIST_END (tail, list); 1368 CHECK_LIST_END (tail, list);
1371 return Qnil; 1369 return Qnil;
1372 } 1370 }
1373 tail = XCDR (tail); 1371 tail = XCDR (tail);
1374 } 1372 }
1375 immediate_quit = false;
1376 return tail; 1373 return tail;
1377} 1374}
1378 1375
@@ -1419,17 +1416,12 @@ DEFUN ("memq", Fmemq, Smemq, 2, 2, 0,
1419The value is actually the tail of LIST whose car is ELT. */) 1416The value is actually the tail of LIST whose car is ELT. */)
1420 (Lisp_Object elt, Lisp_Object list) 1417 (Lisp_Object elt, Lisp_Object list)
1421{ 1418{
1422 immediate_quit = true;
1423 Lisp_Object tail; 1419 Lisp_Object tail;
1424 for (tail = list; CONSP (tail); tail = XCDR (tail)) 1420 for (tail = list; CONSP (tail); tail = XCDR (tail))
1425 { 1421 {
1426 if (EQ (XCAR (tail), elt)) 1422 if (EQ (XCAR (tail), elt))
1427 { 1423 return tail;
1428 immediate_quit = false;
1429 return tail;
1430 }
1431 } 1424 }
1432 immediate_quit = false;
1433 CHECK_LIST_END (tail, list); 1425 CHECK_LIST_END (tail, list);
1434 return Qnil; 1426 return Qnil;
1435} 1427}
@@ -1442,18 +1434,13 @@ The value is actually the tail of LIST whose car is ELT. */)
1442 if (!FLOATP (elt)) 1434 if (!FLOATP (elt))
1443 return Fmemq (elt, list); 1435 return Fmemq (elt, list);
1444 1436
1445 immediate_quit = true;
1446 Lisp_Object tail; 1437 Lisp_Object tail;
1447 for (tail = list; CONSP (tail); tail = XCDR (tail)) 1438 for (tail = list; CONSP (tail); tail = XCDR (tail))
1448 { 1439 {
1449 Lisp_Object tem = XCAR (tail); 1440 Lisp_Object tem = XCAR (tail);
1450 if (FLOATP (tem) && internal_equal (elt, tem, 0, 0, Qnil)) 1441 if (FLOATP (tem) && internal_equal (elt, tem, 0, 0, Qnil))
1451 { 1442 return tail;
1452 immediate_quit = false;
1453 return tail;
1454 }
1455 } 1443 }
1456 immediate_quit = false;
1457 CHECK_LIST_END (tail, list); 1444 CHECK_LIST_END (tail, list);
1458 return Qnil; 1445 return Qnil;
1459} 1446}
@@ -1464,15 +1451,12 @@ The value is actually the first element of LIST whose car is KEY.
1464Elements of LIST that are not conses are ignored. */) 1451Elements of LIST that are not conses are ignored. */)
1465 (Lisp_Object key, Lisp_Object list) 1452 (Lisp_Object key, Lisp_Object list)
1466{ 1453{
1467 immediate_quit = true;
1468 Lisp_Object tail; 1454 Lisp_Object tail;
1469 for (tail = list; CONSP (tail); tail = XCDR (tail)) 1455 for (tail = list; CONSP (tail); tail = XCDR (tail))
1470 if (CONSP (XCAR (tail)) && EQ (XCAR (XCAR (tail)), key)) 1456 {
1471 { 1457 if (CONSP (XCAR (tail)) && EQ (XCAR (XCAR (tail)), key))
1472 immediate_quit = false;
1473 return XCAR (tail); 1458 return XCAR (tail);
1474 } 1459 }
1475 immediate_quit = false;
1476 CHECK_LIST_END (tail, list); 1460 CHECK_LIST_END (tail, list);
1477 return Qnil; 1461 return Qnil;
1478} 1462}
@@ -1529,15 +1513,12 @@ DEFUN ("rassq", Frassq, Srassq, 2, 2, 0,
1529The value is actually the first element of LIST whose cdr is KEY. */) 1513The value is actually the first element of LIST whose cdr is KEY. */)
1530 (Lisp_Object key, Lisp_Object list) 1514 (Lisp_Object key, Lisp_Object list)
1531{ 1515{
1532 immediate_quit = true;
1533 Lisp_Object tail; 1516 Lisp_Object tail;
1534 for (tail = list; CONSP (tail); tail = XCDR (tail)) 1517 for (tail = list; CONSP (tail); tail = XCDR (tail))
1535 if (CONSP (XCAR (tail)) && EQ (XCDR (XCAR (tail)), key)) 1518 {
1536 { 1519 if (CONSP (XCAR (tail)) && EQ (XCDR (XCAR (tail)), key))
1537 immediate_quit = false;
1538 return XCAR (tail); 1520 return XCAR (tail);
1539 } 1521 }
1540 immediate_quit = false;
1541 CHECK_LIST_END (tail, list); 1522 CHECK_LIST_END (tail, list);
1542 return Qnil; 1523 return Qnil;
1543} 1524}
@@ -2077,21 +2058,18 @@ use `(setq x (plist-put x prop val))' to be sure to use the new value.
2077The PLIST is modified by side effects. */) 2058The PLIST is modified by side effects. */)
2078 (Lisp_Object plist, Lisp_Object prop, Lisp_Object val) 2059 (Lisp_Object plist, Lisp_Object prop, Lisp_Object val)
2079{ 2060{
2080 immediate_quit = true;
2081 Lisp_Object prev = Qnil; 2061 Lisp_Object prev = Qnil;
2082 for (Lisp_Object tail = plist; CONSP (tail) && CONSP (XCDR (tail)); 2062 for (Lisp_Object tail = plist; CONSP (tail) && CONSP (XCDR (tail));
2083 tail = XCDR (XCDR (tail))) 2063 tail = XCDR (XCDR (tail)))
2084 { 2064 {
2085 if (EQ (prop, XCAR (tail))) 2065 if (EQ (prop, XCAR (tail)))
2086 { 2066 {
2087 immediate_quit = false;
2088 Fsetcar (XCDR (tail), val); 2067 Fsetcar (XCDR (tail), val);
2089 return plist; 2068 return plist;
2090 } 2069 }
2091 2070
2092 prev = tail; 2071 prev = tail;
2093 } 2072 }
2094 immediate_quit = false;
2095 Lisp_Object newcell 2073 Lisp_Object newcell
2096 = Fcons (prop, Fcons (val, NILP (prev) ? plist : XCDR (XCDR (prev)))); 2074 = Fcons (prop, Fcons (val, NILP (prev) ? plist : XCDR (XCDR (prev))));
2097 if (NILP (prev)) 2075 if (NILP (prev))
@@ -2442,7 +2420,6 @@ usage: (nconc &rest LISTS) */)
2442 2420
2443 CHECK_CONS (tem); 2421 CHECK_CONS (tem);
2444 2422
2445 immediate_quit = true;
2446 Lisp_Object tail; 2423 Lisp_Object tail;
2447 do 2424 do
2448 { 2425 {
@@ -2451,7 +2428,6 @@ usage: (nconc &rest LISTS) */)
2451 } 2428 }
2452 while (CONSP (tem)); 2429 while (CONSP (tem));
2453 2430
2454 immediate_quit = false;
2455 rarely_quit (&quit_count); 2431 rarely_quit (&quit_count);
2456 2432
2457 tem = args[argnum + 1]; 2433 tem = args[argnum + 1];
@@ -2874,13 +2850,11 @@ property and a property with the value nil.
2874The value is actually the tail of PLIST whose car is PROP. */) 2850The value is actually the tail of PLIST whose car is PROP. */)
2875 (Lisp_Object plist, Lisp_Object prop) 2851 (Lisp_Object plist, Lisp_Object prop)
2876{ 2852{
2877 immediate_quit = true;
2878 while (CONSP (plist) && !EQ (XCAR (plist), prop)) 2853 while (CONSP (plist) && !EQ (XCAR (plist), prop))
2879 { 2854 {
2880 plist = XCDR (plist); 2855 plist = XCDR (plist);
2881 plist = CDR (plist); 2856 plist = CDR (plist);
2882 } 2857 }
2883 immediate_quit = false;
2884 return plist; 2858 return plist;
2885} 2859}
2886 2860
diff --git a/src/indent.c b/src/indent.c
index 23951a16eb6..33f709c5041 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -1200,7 +1200,6 @@ 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 = true;
1204 maybe_quit (); 1203 maybe_quit ();
1205 1204
1206 /* It's just impossible to be too paranoid here. */ 1205 /* It's just impossible to be too paranoid here. */
@@ -1694,7 +1693,6 @@ compute_motion (ptrdiff_t from, ptrdiff_t frombyte, EMACS_INT fromvpos,
1694 /* Nonzero if have just continued a line */ 1693 /* Nonzero if have just continued a line */
1695 val_compute_motion.contin = (contin_hpos && prev_hpos == 0); 1694 val_compute_motion.contin = (contin_hpos && prev_hpos == 0);
1696 1695
1697 immediate_quit = false;
1698 return &val_compute_motion; 1696 return &val_compute_motion;
1699} 1697}
1700 1698
diff --git a/src/keyboard.c b/src/keyboard.c
index 0c04d95304c..317669d6a1a 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -169,9 +169,6 @@ struct kboard *echo_kboard;
169 169
170Lisp_Object echo_message_buffer; 170Lisp_Object echo_message_buffer;
171 171
172/* True means C-g should cause immediate error-signal. */
173bool immediate_quit;
174
175/* Character that causes a quit. Normally C-g. 172/* Character that causes a quit. Normally C-g.
176 173
177 If we are running on an ordinary terminal, this must be an ordinary 174 If we are running on an ordinary terminal, this must be an ordinary
@@ -3584,16 +3581,7 @@ kbd_buffer_store_buffered_event (union buffered_input_event *event,
3584 as input, set quit-flag to cause an interrupt. */ 3581 as input, set quit-flag to cause an interrupt. */
3585 if (!NILP (Vthrow_on_input) 3582 if (!NILP (Vthrow_on_input)
3586 && NILP (Fmemq (ignore_event, Vwhile_no_input_ignore_events))) 3583 && NILP (Fmemq (ignore_event, Vwhile_no_input_ignore_events)))
3587 { 3584 Vquit_flag = Vthrow_on_input;
3588 Vquit_flag = Vthrow_on_input;
3589 /* If we're inside a function that wants immediate quits,
3590 do it now. */
3591 if (immediate_quit && NILP (Vinhibit_quit))
3592 {
3593 immediate_quit = false;
3594 maybe_quit ();
3595 }
3596 }
3597} 3585}
3598 3586
3599 3587
@@ -10445,30 +10433,12 @@ handle_interrupt (bool in_signal_handler)
10445 } 10433 }
10446 else 10434 else
10447 { 10435 {
10448 /* If executing a function that wants to be interrupted out of 10436 /* Request quit when it's safe. */
10449 and the user has not deferred quitting by binding `inhibit-quit' 10437 int count = NILP (Vquit_flag) ? 1 : force_quit_count + 1;
10450 then quit right away. */ 10438 force_quit_count = count;
10451 if (immediate_quit && NILP (Vinhibit_quit) && !waiting_for_input) 10439 if (count == 3)
10452 { 10440 Vinhibit_quit = Qnil;
10453 struct gl_state_s saved; 10441 Vquit_flag = Qt;
10454
10455 immediate_quit = false;
10456 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
10457 saved = gl_state;
10458 quit ();
10459 gl_state = saved;
10460 }
10461 else
10462 { /* Else request quit when it's safe. */
10463 int count = NILP (Vquit_flag) ? 1 : force_quit_count + 1;
10464 force_quit_count = count;
10465 if (count == 3)
10466 {
10467 immediate_quit = true;
10468 Vinhibit_quit = Qnil;
10469 }
10470 Vquit_flag = Qt;
10471 }
10472 } 10442 }
10473 10443
10474 pthread_sigmask (SIG_SETMASK, &empty_mask, 0); 10444 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
@@ -10907,7 +10877,6 @@ init_keyboard (void)
10907{ 10877{
10908 /* This is correct before outermost invocation of the editor loop. */ 10878 /* This is correct before outermost invocation of the editor loop. */
10909 command_loop_level = -1; 10879 command_loop_level = -1;
10910 immediate_quit = false;
10911 quit_char = Ctl ('g'); 10880 quit_char = Ctl ('g');
10912 Vunread_command_events = Qnil; 10881 Vunread_command_events = Qnil;
10913 timer_idleness_start_time = invalid_timespec (); 10882 timer_idleness_start_time = invalid_timespec ();
diff --git a/src/lisp.h b/src/lisp.h
index 58e22889889..a18e4da1cfd 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3131,11 +3131,6 @@ extern Lisp_Object memory_signal_data;
3131 impossible, of course. But it is very desirable to avoid creating 3131 impossible, of course. But it is very desirable to avoid creating
3132 loops where maybe_quit is impossible. 3132 loops where maybe_quit is impossible.
3133 3133
3134 Exception: if you set immediate_quit, the handler that responds to
3135 the C-g does the quit itself. This is a good thing to do around a
3136 loop that has no side effects and (in particular) cannot call
3137 arbitrary Lisp code.
3138
3139 If quit-flag is set to `kill-emacs' the SIGINT handler has received 3134 If quit-flag is set to `kill-emacs' the SIGINT handler has received
3140 a request to exit Emacs when it is safe to do. 3135 a request to exit Emacs when it is safe to do.
3141 3136
@@ -4348,9 +4343,6 @@ extern char my_edata[];
4348extern char my_endbss[]; 4343extern char my_endbss[];
4349extern char *my_endbss_static; 4344extern char *my_endbss_static;
4350 4345
4351/* True means ^G can quit instantly. */
4352extern bool immediate_quit;
4353
4354extern void *xmalloc (size_t) ATTRIBUTE_MALLOC_SIZE ((1)); 4346extern void *xmalloc (size_t) ATTRIBUTE_MALLOC_SIZE ((1));
4355extern void *xzalloc (size_t) ATTRIBUTE_MALLOC_SIZE ((1)); 4347extern void *xzalloc (size_t) ATTRIBUTE_MALLOC_SIZE ((1));
4356extern void *xrealloc (void *, size_t) ATTRIBUTE_ALLOC_SIZE ((2)); 4348extern void *xrealloc (void *, size_t) ATTRIBUTE_ALLOC_SIZE ((2));
diff --git a/src/process.c b/src/process.c
index dbd4358dd1a..434a3955b2c 100644
--- a/src/process.c
+++ b/src/process.c
@@ -3431,7 +3431,6 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos,
3431 break; 3431 break;
3432 } 3432 }
3433 3433
3434 immediate_quit = true;
3435 maybe_quit (); 3434 maybe_quit ();
3436 3435
3437 ret = connect (s, sa, addrlen); 3436 ret = connect (s, sa, addrlen);
@@ -3439,8 +3438,7 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos,
3439 3438
3440 if (ret == 0 || xerrno == EISCONN) 3439 if (ret == 0 || xerrno == EISCONN)
3441 { 3440 {
3442 /* The unwind-protect will be discarded afterwards. 3441 /* The unwind-protect will be discarded afterwards. */
3443 Likewise for immediate_quit. */
3444 break; 3442 break;
3445 } 3443 }
3446 3444
@@ -3481,8 +3479,6 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos,
3481 } 3479 }
3482#endif /* !WINDOWSNT */ 3480#endif /* !WINDOWSNT */
3483 3481
3484 immediate_quit = false;
3485
3486 /* Discard the unwind protect closing S. */ 3482 /* Discard the unwind protect closing S. */
3487 specpdl_ptr = specpdl + count; 3483 specpdl_ptr = specpdl + count;
3488 emacs_close (s); 3484 emacs_close (s);
@@ -3539,8 +3535,6 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos,
3539#endif 3535#endif
3540 } 3536 }
3541 3537
3542 immediate_quit = false;
3543
3544 if (s < 0) 3538 if (s < 0)
3545 { 3539 {
3546 /* If non-blocking got this far - and failed - assume non-blocking is 3540 /* If non-blocking got this far - and failed - assume non-blocking is
@@ -4012,7 +4006,6 @@ usage: (make-network-process &rest ARGS) */)
4012 struct addrinfo *res, *lres; 4006 struct addrinfo *res, *lres;
4013 int ret; 4007 int ret;
4014 4008
4015 immediate_quit = true;
4016 maybe_quit (); 4009 maybe_quit ();
4017 4010
4018 struct addrinfo hints; 4011 struct addrinfo hints;
@@ -4034,7 +4027,6 @@ usage: (make-network-process &rest ARGS) */)
4034#else 4027#else
4035 error ("%s/%s getaddrinfo error %d", SSDATA (host), portstring, ret); 4028 error ("%s/%s getaddrinfo error %d", SSDATA (host), portstring, ret);
4036#endif 4029#endif
4037 immediate_quit = false;
4038 4030
4039 for (lres = res; lres; lres = lres->ai_next) 4031 for (lres = res; lres; lres = lres->ai_next)
4040 addrinfos = Fcons (conv_addrinfo_to_lisp (lres), addrinfos); 4032 addrinfos = Fcons (conv_addrinfo_to_lisp (lres), addrinfos);
diff --git a/src/regex.c b/src/regex.c
index f6e67afef4c..796f868d1c2 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -1728,10 +1728,8 @@ typedef struct
1728 1728
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#ifndef emacs
1732# define IMMEDIATE_QUIT_CHECK (immediate_quit ? maybe_quit () : (void) 0) 1732static void maybe_quit (void) {}
1733#else
1734# define IMMEDIATE_QUIT_CHECK ((void) 0)
1735#endif 1733#endif
1736 1734
1737/* Structure to manage work area for range table. */ 1735/* Structure to manage work area for range table. */
@@ -5820,7 +5818,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, const_re_char *string1,
5820 /* Unconditionally jump (without popping any failure points). */ 5818 /* Unconditionally jump (without popping any failure points). */
5821 case jump: 5819 case jump:
5822 unconditional_jump: 5820 unconditional_jump:
5823 IMMEDIATE_QUIT_CHECK; 5821 maybe_quit ();
5824 EXTRACT_NUMBER_AND_INCR (mcnt, p); /* Get the amount to jump. */ 5822 EXTRACT_NUMBER_AND_INCR (mcnt, p); /* Get the amount to jump. */
5825 DEBUG_PRINT ("EXECUTING jump %d ", mcnt); 5823 DEBUG_PRINT ("EXECUTING jump %d ", mcnt);
5826 p += mcnt; /* Do the jump. */ 5824 p += mcnt; /* Do the jump. */
@@ -6168,7 +6166,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, const_re_char *string1,
6168 6166
6169 /* We goto here if a matching operation fails. */ 6167 /* We goto here if a matching operation fails. */
6170 fail: 6168 fail:
6171 IMMEDIATE_QUIT_CHECK; 6169 maybe_quit ();
6172 if (!FAIL_STACK_EMPTY ()) 6170 if (!FAIL_STACK_EMPTY ())
6173 { 6171 {
6174 re_char *str, *pat; 6172 re_char *str, *pat;
diff --git a/src/search.c b/src/search.c
index f54f44c8818..ed9c12c68fe 100644
--- a/src/search.c
+++ b/src/search.c
@@ -277,7 +277,6 @@ looking_at_1 (Lisp_Object string, bool posix)
277 !NILP (BVAR (current_buffer, enable_multibyte_characters))); 277 !NILP (BVAR (current_buffer, enable_multibyte_characters)));
278 278
279 /* Do a pending quit right away, to avoid paradoxical behavior */ 279 /* Do a pending quit right away, to avoid paradoxical behavior */
280 immediate_quit = true;
281 maybe_quit (); 280 maybe_quit ();
282 281
283 /* Get pointers and sizes of the two strings 282 /* Get pointers and sizes of the two strings
@@ -311,7 +310,6 @@ looking_at_1 (Lisp_Object string, bool posix)
311 (NILP (Vinhibit_changing_match_data) 310 (NILP (Vinhibit_changing_match_data)
312 ? &search_regs : NULL), 311 ? &search_regs : NULL),
313 ZV_BYTE - BEGV_BYTE); 312 ZV_BYTE - BEGV_BYTE);
314 immediate_quit = false;
315#ifdef REL_ALLOC 313#ifdef REL_ALLOC
316 r_alloc_inhibit_buffer_relocation (0); 314 r_alloc_inhibit_buffer_relocation (0);
317#endif 315#endif
@@ -399,7 +397,6 @@ string_match_1 (Lisp_Object regexp, Lisp_Object string, Lisp_Object start,
399 ? BVAR (current_buffer, case_canon_table) : Qnil), 397 ? BVAR (current_buffer, case_canon_table) : Qnil),
400 posix, 398 posix,
401 STRING_MULTIBYTE (string)); 399 STRING_MULTIBYTE (string));
402 immediate_quit = true;
403 re_match_object = string; 400 re_match_object = string;
404 401
405 val = re_search (bufp, SSDATA (string), 402 val = re_search (bufp, SSDATA (string),
@@ -407,7 +404,6 @@ string_match_1 (Lisp_Object regexp, Lisp_Object string, Lisp_Object start,
407 SBYTES (string) - pos_byte, 404 SBYTES (string) - pos_byte,
408 (NILP (Vinhibit_changing_match_data) 405 (NILP (Vinhibit_changing_match_data)
409 ? &search_regs : NULL)); 406 ? &search_regs : NULL));
410 immediate_quit = false;
411 407
412 /* Set last_thing_searched only when match data is changed. */ 408 /* Set last_thing_searched only when match data is changed. */
413 if (NILP (Vinhibit_changing_match_data)) 409 if (NILP (Vinhibit_changing_match_data))
@@ -471,13 +467,11 @@ fast_string_match_internal (Lisp_Object regexp, Lisp_Object string,
471 467
472 bufp = compile_pattern (regexp, 0, table, 468 bufp = compile_pattern (regexp, 0, table,
473 0, STRING_MULTIBYTE (string)); 469 0, STRING_MULTIBYTE (string));
474 immediate_quit = true;
475 re_match_object = string; 470 re_match_object = string;
476 471
477 val = re_search (bufp, SSDATA (string), 472 val = re_search (bufp, SSDATA (string),
478 SBYTES (string), 0, 473 SBYTES (string), 0,
479 SBYTES (string), 0); 474 SBYTES (string), 0);
480 immediate_quit = false;
481 return val; 475 return val;
482} 476}
483 477
@@ -498,9 +492,7 @@ fast_c_string_match_ignore_case (Lisp_Object regexp,
498 bufp = compile_pattern (regexp, 0, 492 bufp = compile_pattern (regexp, 0,
499 Vascii_canon_table, 0, 493 Vascii_canon_table, 0,
500 0); 494 0);
501 immediate_quit = true;
502 val = re_search (bufp, string, len, 0, len, 0); 495 val = re_search (bufp, string, len, 0, len, 0);
503 immediate_quit = false;
504 return val; 496 return val;
505} 497}
506 498
@@ -561,7 +553,6 @@ fast_looking_at (Lisp_Object regexp, ptrdiff_t pos, ptrdiff_t pos_byte,
561 } 553 }
562 554
563 buf = compile_pattern (regexp, 0, Qnil, 0, multibyte); 555 buf = compile_pattern (regexp, 0, Qnil, 0, multibyte);
564 immediate_quit = true;
565#ifdef REL_ALLOC 556#ifdef REL_ALLOC
566 /* Prevent ralloc.c from relocating the current buffer while 557 /* Prevent ralloc.c from relocating the current buffer while
567 searching it. */ 558 searching it. */
@@ -572,7 +563,6 @@ fast_looking_at (Lisp_Object regexp, ptrdiff_t pos, ptrdiff_t pos_byte,
572#ifdef REL_ALLOC 563#ifdef REL_ALLOC
573 r_alloc_inhibit_buffer_relocation (0); 564 r_alloc_inhibit_buffer_relocation (0);
574#endif 565#endif
575 immediate_quit = false;
576 566
577 return len; 567 return len;
578} 568}
@@ -649,7 +639,7 @@ newline_cache_on_off (struct buffer *buf)
649 If BYTEPOS is not NULL, set *BYTEPOS to the byte position corresponding 639 If BYTEPOS is not NULL, set *BYTEPOS to the byte position corresponding
650 to the returned character position. 640 to the returned character position.
651 641
652 If ALLOW_QUIT, set immediate_quit. That's good to do 642 If ALLOW_QUIT, check for quitting. That's good to do
653 except when inside redisplay. */ 643 except when inside redisplay. */
654 644
655ptrdiff_t 645ptrdiff_t
@@ -685,8 +675,6 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end,
685 if (shortage != 0) 675 if (shortage != 0)
686 *shortage = 0; 676 *shortage = 0;
687 677
688 immediate_quit = allow_quit;
689
690 if (count > 0) 678 if (count > 0)
691 while (start != end) 679 while (start != end)
692 { 680 {
@@ -704,7 +692,6 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end,
704 ptrdiff_t next_change; 692 ptrdiff_t next_change;
705 int result = 1; 693 int result = 1;
706 694
707 immediate_quit = false;
708 while (start < end && result) 695 while (start < end && result)
709 { 696 {
710 ptrdiff_t lim1; 697 ptrdiff_t lim1;
@@ -757,7 +744,6 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end,
757 start_byte = end_byte; 744 start_byte = end_byte;
758 break; 745 break;
759 } 746 }
760 immediate_quit = allow_quit;
761 747
762 /* START should never be after END. */ 748 /* START should never be after END. */
763 if (start_byte > ceiling_byte) 749 if (start_byte > ceiling_byte)
@@ -810,7 +796,6 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end,
810 796
811 if (--count == 0) 797 if (--count == 0)
812 { 798 {
813 immediate_quit = false;
814 if (bytepos) 799 if (bytepos)
815 *bytepos = lim_byte + next; 800 *bytepos = lim_byte + next;
816 return BYTE_TO_CHAR (lim_byte + next); 801 return BYTE_TO_CHAR (lim_byte + next);
@@ -833,7 +818,6 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end,
833 ptrdiff_t next_change; 818 ptrdiff_t next_change;
834 int result = 1; 819 int result = 1;
835 820
836 immediate_quit = false;
837 while (start > end && result) 821 while (start > end && result)
838 { 822 {
839 ptrdiff_t lim1; 823 ptrdiff_t lim1;
@@ -870,7 +854,6 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end,
870 start_byte = end_byte; 854 start_byte = end_byte;
871 break; 855 break;
872 } 856 }
873 immediate_quit = allow_quit;
874 857
875 /* Start should never be at or before end. */ 858 /* Start should never be at or before end. */
876 if (start_byte <= ceiling_byte) 859 if (start_byte <= ceiling_byte)
@@ -918,7 +901,6 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end,
918 901
919 if (++count >= 0) 902 if (++count >= 0)
920 { 903 {
921 immediate_quit = false;
922 if (bytepos) 904 if (bytepos)
923 *bytepos = ceiling_byte + prev + 1; 905 *bytepos = ceiling_byte + prev + 1;
924 return BYTE_TO_CHAR (ceiling_byte + prev + 1); 906 return BYTE_TO_CHAR (ceiling_byte + prev + 1);
@@ -930,7 +912,6 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end,
930 } 912 }
931 } 913 }
932 914
933 immediate_quit = false;
934 if (shortage) 915 if (shortage)
935 *shortage = count * direction; 916 *shortage = count * direction;
936 if (bytepos) 917 if (bytepos)
@@ -954,7 +935,7 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end,
954 the number of line boundaries left unfound, and position at 935 the number of line boundaries left unfound, and position at
955 the limit we bumped up against. 936 the limit we bumped up against.
956 937
957 If ALLOW_QUIT, set immediate_quit. That's good to do 938 If ALLOW_QUIT, check for quitting. That's good to do
958 except in special cases. */ 939 except in special cases. */
959 940
960ptrdiff_t 941ptrdiff_t
@@ -1197,9 +1178,6 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte,
1197 trt, posix, 1178 trt, posix,
1198 !NILP (BVAR (current_buffer, enable_multibyte_characters))); 1179 !NILP (BVAR (current_buffer, enable_multibyte_characters)));
1199 1180
1200 immediate_quit = true; /* Quit immediately if user types ^G,
1201 because letting this function finish
1202 can take too long. */
1203 maybe_quit (); /* Do a pending quit right away, 1181 maybe_quit (); /* Do a pending quit right away,
1204 to avoid paradoxical behavior */ 1182 to avoid paradoxical behavior */
1205 /* Get pointers and sizes of the two strings 1183 /* Get pointers and sizes of the two strings
@@ -1268,7 +1246,6 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte,
1268 } 1246 }
1269 else 1247 else
1270 { 1248 {
1271 immediate_quit = false;
1272#ifdef REL_ALLOC 1249#ifdef REL_ALLOC
1273 r_alloc_inhibit_buffer_relocation (0); 1250 r_alloc_inhibit_buffer_relocation (0);
1274#endif 1251#endif
@@ -1313,7 +1290,6 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte,
1313 } 1290 }
1314 else 1291 else
1315 { 1292 {
1316 immediate_quit = false;
1317#ifdef REL_ALLOC 1293#ifdef REL_ALLOC
1318 r_alloc_inhibit_buffer_relocation (0); 1294 r_alloc_inhibit_buffer_relocation (0);
1319#endif 1295#endif
@@ -1321,7 +1297,6 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte,
1321 } 1297 }
1322 n--; 1298 n--;
1323 } 1299 }
1324 immediate_quit = false;
1325#ifdef REL_ALLOC 1300#ifdef REL_ALLOC
1326 r_alloc_inhibit_buffer_relocation (0); 1301 r_alloc_inhibit_buffer_relocation (0);
1327#endif 1302#endif
@@ -3231,8 +3206,6 @@ find_newline1 (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end,
3231 if (shortage != 0) 3206 if (shortage != 0)
3232 *shortage = 0; 3207 *shortage = 0;
3233 3208
3234 immediate_quit = allow_quit;
3235
3236 if (count > 0) 3209 if (count > 0)
3237 while (start != end) 3210 while (start != end)
3238 { 3211 {
@@ -3275,7 +3248,6 @@ find_newline1 (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end,
3275 3248
3276 if (--count == 0) 3249 if (--count == 0)
3277 { 3250 {
3278 immediate_quit = false;
3279 if (bytepos) 3251 if (bytepos)
3280 *bytepos = lim_byte + next; 3252 *bytepos = lim_byte + next;
3281 return BYTE_TO_CHAR (lim_byte + next); 3253 return BYTE_TO_CHAR (lim_byte + next);
@@ -3287,7 +3259,6 @@ find_newline1 (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end,
3287 } 3259 }
3288 } 3260 }
3289 3261
3290 immediate_quit = false;
3291 if (shortage) 3262 if (shortage)
3292 *shortage = count; 3263 *shortage = count;
3293 if (bytepos) 3264 if (bytepos)
diff --git a/src/syntax.c b/src/syntax.c
index f9e4093765c..e713922bf10 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -1426,7 +1426,6 @@ 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 = true;
1430 maybe_quit (); 1429 maybe_quit ();
1431 1430
1432 SETUP_SYNTAX_TABLE (from, count); 1431 SETUP_SYNTAX_TABLE (from, count);
@@ -1436,10 +1435,7 @@ scan_words (register ptrdiff_t from, register EMACS_INT count)
1436 while (1) 1435 while (1)
1437 { 1436 {
1438 if (from == end) 1437 if (from == end)
1439 { 1438 return 0;
1440 immediate_quit = false;
1441 return 0;
1442 }
1443 UPDATE_SYNTAX_TABLE_FORWARD (from); 1439 UPDATE_SYNTAX_TABLE_FORWARD (from);
1444 ch0 = FETCH_CHAR_AS_MULTIBYTE (from_byte); 1440 ch0 = FETCH_CHAR_AS_MULTIBYTE (from_byte);
1445 code = SYNTAX (ch0); 1441 code = SYNTAX (ch0);
@@ -1486,10 +1482,7 @@ scan_words (register ptrdiff_t from, register EMACS_INT count)
1486 while (1) 1482 while (1)
1487 { 1483 {
1488 if (from == beg) 1484 if (from == beg)
1489 { 1485 return 0;
1490 immediate_quit = false;
1491 return 0;
1492 }
1493 DEC_BOTH (from, from_byte); 1486 DEC_BOTH (from, from_byte);
1494 UPDATE_SYNTAX_TABLE_BACKWARD (from); 1487 UPDATE_SYNTAX_TABLE_BACKWARD (from);
1495 ch1 = FETCH_CHAR_AS_MULTIBYTE (from_byte); 1488 ch1 = FETCH_CHAR_AS_MULTIBYTE (from_byte);
@@ -1536,8 +1529,6 @@ scan_words (register ptrdiff_t from, register EMACS_INT count)
1536 count++; 1529 count++;
1537 } 1530 }
1538 1531
1539 immediate_quit = false;
1540
1541 return from; 1532 return from;
1542} 1533}
1543 1534
@@ -1921,7 +1912,6 @@ skip_chars (bool forwardp, Lisp_Object string, Lisp_Object lim,
1921 stop = (pos >= GPT && GPT > XINT (lim)) ? GAP_END_ADDR : endp; 1912 stop = (pos >= GPT && GPT > XINT (lim)) ? GAP_END_ADDR : endp;
1922 } 1913 }
1923 1914
1924 immediate_quit = true;
1925 /* This code may look up syntax tables using functions that rely on the 1915 /* 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, 1916 gl_state object. To make sure this object is not out of date,
1927 let's initialize it manually. 1917 let's initialize it manually.
@@ -2064,7 +2054,6 @@ skip_chars (bool forwardp, Lisp_Object string, Lisp_Object lim,
2064 } 2054 }
2065 2055
2066 SET_PT_BOTH (pos, pos_byte); 2056 SET_PT_BOTH (pos, pos_byte);
2067 immediate_quit = false;
2068 2057
2069 SAFE_FREE (); 2058 SAFE_FREE ();
2070 return make_number (PT - start_point); 2059 return make_number (PT - start_point);
@@ -2138,7 +2127,6 @@ skip_syntaxes (bool forwardp, Lisp_Object string, Lisp_Object lim)
2138 ptrdiff_t pos_byte = PT_BYTE; 2127 ptrdiff_t pos_byte = PT_BYTE;
2139 unsigned char *p, *endp, *stop; 2128 unsigned char *p, *endp, *stop;
2140 2129
2141 immediate_quit = true;
2142 SETUP_SYNTAX_TABLE (pos, forwardp ? 1 : -1); 2130 SETUP_SYNTAX_TABLE (pos, forwardp ? 1 : -1);
2143 2131
2144 if (forwardp) 2132 if (forwardp)
@@ -2224,7 +2212,6 @@ skip_syntaxes (bool forwardp, Lisp_Object string, Lisp_Object lim)
2224 2212
2225 done: 2213 done:
2226 SET_PT_BOTH (pos, pos_byte); 2214 SET_PT_BOTH (pos, pos_byte);
2227 immediate_quit = false;
2228 2215
2229 return make_number (PT - start_point); 2216 return make_number (PT - start_point);
2230 } 2217 }
@@ -2412,7 +2399,6 @@ between them, return t; otherwise return nil. */)
2412 count1 = XINT (count); 2399 count1 = XINT (count);
2413 stop = count1 > 0 ? ZV : BEGV; 2400 stop = count1 > 0 ? ZV : BEGV;
2414 2401
2415 immediate_quit = true;
2416 maybe_quit (); 2402 maybe_quit ();
2417 2403
2418 from = PT; 2404 from = PT;
@@ -2429,7 +2415,6 @@ between them, return t; otherwise return nil. */)
2429 if (from == stop) 2415 if (from == stop)
2430 { 2416 {
2431 SET_PT_BOTH (from, from_byte); 2417 SET_PT_BOTH (from, from_byte);
2432 immediate_quit = false;
2433 return Qnil; 2418 return Qnil;
2434 } 2419 }
2435 c = FETCH_CHAR_AS_MULTIBYTE (from_byte); 2420 c = FETCH_CHAR_AS_MULTIBYTE (from_byte);
@@ -2463,7 +2448,6 @@ between them, return t; otherwise return nil. */)
2463 comstyle = ST_COMMENT_STYLE; 2448 comstyle = ST_COMMENT_STYLE;
2464 else if (code != Scomment) 2449 else if (code != Scomment)
2465 { 2450 {
2466 immediate_quit = false;
2467 DEC_BOTH (from, from_byte); 2451 DEC_BOTH (from, from_byte);
2468 SET_PT_BOTH (from, from_byte); 2452 SET_PT_BOTH (from, from_byte);
2469 return Qnil; 2453 return Qnil;
@@ -2474,7 +2458,6 @@ between them, return t; otherwise return nil. */)
2474 from = out_charpos; from_byte = out_bytepos; 2458 from = out_charpos; from_byte = out_bytepos;
2475 if (!found) 2459 if (!found)
2476 { 2460 {
2477 immediate_quit = false;
2478 SET_PT_BOTH (from, from_byte); 2461 SET_PT_BOTH (from, from_byte);
2479 return Qnil; 2462 return Qnil;
2480 } 2463 }
@@ -2494,7 +2477,6 @@ between them, return t; otherwise return nil. */)
2494 if (from <= stop) 2477 if (from <= stop)
2495 { 2478 {
2496 SET_PT_BOTH (BEGV, BEGV_BYTE); 2479 SET_PT_BOTH (BEGV, BEGV_BYTE);
2497 immediate_quit = false;
2498 return Qnil; 2480 return Qnil;
2499 } 2481 }
2500 2482
@@ -2587,7 +2569,6 @@ between them, return t; otherwise return nil. */)
2587 else if (code != Swhitespace || quoted) 2569 else if (code != Swhitespace || quoted)
2588 { 2570 {
2589 leave: 2571 leave:
2590 immediate_quit = false;
2591 INC_BOTH (from, from_byte); 2572 INC_BOTH (from, from_byte);
2592 SET_PT_BOTH (from, from_byte); 2573 SET_PT_BOTH (from, from_byte);
2593 return Qnil; 2574 return Qnil;
@@ -2598,7 +2579,6 @@ between them, return t; otherwise return nil. */)
2598 } 2579 }
2599 2580
2600 SET_PT_BOTH (from, from_byte); 2581 SET_PT_BOTH (from, from_byte);
2601 immediate_quit = false;
2602 return Qt; 2582 return Qt;
2603} 2583}
2604 2584
@@ -2640,7 +2620,6 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2640 2620
2641 from_byte = CHAR_TO_BYTE (from); 2621 from_byte = CHAR_TO_BYTE (from);
2642 2622
2643 immediate_quit = true;
2644 maybe_quit (); 2623 maybe_quit ();
2645 2624
2646 SETUP_SYNTAX_TABLE (from, count); 2625 SETUP_SYNTAX_TABLE (from, count);
@@ -2801,7 +2780,6 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2801 if (depth) 2780 if (depth)
2802 goto lose; 2781 goto lose;
2803 2782
2804 immediate_quit = false;
2805 return Qnil; 2783 return Qnil;
2806 2784
2807 /* End of object reached */ 2785 /* End of object reached */
@@ -2984,7 +2962,6 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2984 if (depth) 2962 if (depth)
2985 goto lose; 2963 goto lose;
2986 2964
2987 immediate_quit = false;
2988 return Qnil; 2965 return Qnil;
2989 2966
2990 done2: 2967 done2:
@@ -2992,7 +2969,6 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag)
2992 } 2969 }
2993 2970
2994 2971
2995 immediate_quit = false;
2996 XSETFASTINT (val, from); 2972 XSETFASTINT (val, from);
2997 return val; 2973 return val;
2998 2974
@@ -3173,7 +3149,6 @@ do { prev_from = from; \
3173 UPDATE_SYNTAX_TABLE_FORWARD (from); \ 3149 UPDATE_SYNTAX_TABLE_FORWARD (from); \
3174 } while (0) 3150 } while (0)
3175 3151
3176 immediate_quit = true;
3177 maybe_quit (); 3152 maybe_quit ();
3178 3153
3179 depth = state->depth; 3154 depth = state->depth;
@@ -3432,7 +3407,6 @@ do { prev_from = from; \
3432 state->levelstarts); 3407 state->levelstarts);
3433 state->prev_syntax = (SYNTAX_FLAGS_COMSTARTEND_FIRST (prev_from_syntax) 3408 state->prev_syntax = (SYNTAX_FLAGS_COMSTARTEND_FIRST (prev_from_syntax)
3434 || state->quoted) ? prev_from_syntax : Smax; 3409 || state->quoted) ? prev_from_syntax : Smax;
3435 immediate_quit = false;
3436} 3410}
3437 3411
3438/* Convert a (lisp) parse state to the internal form used in 3412/* Convert a (lisp) parse state to the internal form used in
diff --git a/src/w32fns.c b/src/w32fns.c
index 6a576fcec27..1b628b0b42e 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -3168,16 +3168,7 @@ signal_user_input (void)
3168 Vquit_flag = Vthrow_on_input; 3168 Vquit_flag = Vthrow_on_input;
3169 /* Calling maybe_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. */
3172#if 0
3173 /* If we're inside a function that wants immediate quits,
3174 do it now. */
3175 if (immediate_quit && NILP (Vinhibit_quit))
3176 {
3177 immediate_quit = false;
3178 maybe_quit ();
3179 }
3180#endif
3181 } 3172 }
3182} 3173}
3183 3174
diff --git a/src/window.c b/src/window.c
index 71a82b522c4..bc3f488f37f 100644
--- a/src/window.c
+++ b/src/window.c
@@ -4770,7 +4770,6 @@ window_scroll (Lisp_Object window, EMACS_INT n, bool whole, bool noerror)
4770{ 4770{
4771 ptrdiff_t count = SPECPDL_INDEX (); 4771 ptrdiff_t count = SPECPDL_INDEX ();
4772 4772
4773 immediate_quit = true;
4774 n = clip_to_bounds (INT_MIN, n, INT_MAX); 4773 n = clip_to_bounds (INT_MIN, n, INT_MAX);
4775 4774
4776 wset_redisplay (XWINDOW (window)); 4775 wset_redisplay (XWINDOW (window));
@@ -4789,7 +4788,6 @@ window_scroll (Lisp_Object window, EMACS_INT n, bool whole, bool noerror)
4789 4788
4790 /* Bug#15957. */ 4789 /* Bug#15957. */
4791 XWINDOW (window)->window_end_valid = false; 4790 XWINDOW (window)->window_end_valid = false;
4792 immediate_quit = false;
4793} 4791}
4794 4792
4795 4793