aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/emacs-lisp/autoload.el5
-rw-r--r--lisp/loadup.el5
-rw-r--r--lisp/startup.el16
-rw-r--r--lisp/subr.el4
-rw-r--r--src/.gdbinit1
-rw-r--r--src/alloc.c12
-rw-r--r--src/buffer.c45
-rw-r--r--src/callint.c7
-rw-r--r--src/callproc.c36
-rw-r--r--src/data.c78
-rw-r--r--src/editfns.c45
-rw-r--r--src/eval.c62
-rw-r--r--src/fileio.c2
-rw-r--r--src/keyboard.c39
-rw-r--r--src/lisp.h4
-rw-r--r--src/minibuf.c6
-rw-r--r--src/process.c84
-rw-r--r--src/search.c80
-rw-r--r--src/sysdep.c8
-rw-r--r--src/systty.h13
-rw-r--r--src/termhooks.h6
-rw-r--r--src/xselect.c.old17
22 files changed, 328 insertions, 247 deletions
diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el
index 0a7c9dc74c7..5e78798c05e 100644
--- a/lisp/emacs-lisp/autoload.el
+++ b/lisp/emacs-lisp/autoload.el
@@ -1,5 +1,5 @@
1;;; Maintain autoloads in loaddefs.el. 1;;; Maintain autoloads in loaddefs.el.
2;;; Copyright (C) 1991 Free Software Foundation, Inc. 2;;; Copyright (C) 1991, 1992 Free Software Foundation, Inc.
3;;; Written by Roland McGrath. 3;;; Written by Roland McGrath.
4;;; 4;;;
5;;; This program is free software; you can redistribute it and/or modify 5;;; This program is free software; you can redistribute it and/or modify
@@ -267,7 +267,7 @@ file \"%s\") doesn't exist. Remove its autoload section? "
267Runs \\[update-file-autoloads] on files and \\[update-directory-autoloads] 267Runs \\[update-file-autoloads] on files and \\[update-directory-autoloads]
268on directories. Must be used only with -batch, and kills Emacs on completion. 268on directories. Must be used only with -batch, and kills Emacs on completion.
269Each file will be processed even if an error occurred previously. 269Each file will be processed even if an error occurred previously.
270For example, invoke \"emacs -batch -f batch-byte-compile *.el\"" 270For example, invoke \"emacs -batch -f batch-update-autoloads *.el\""
271 (if (not noninteractive) 271 (if (not noninteractive)
272 (error "batch-update-file-autoloads is to be used only with -batch")) 272 (error "batch-update-file-autoloads is to be used only with -batch"))
273 (let ((lost nil) 273 (let ((lost nil)
@@ -288,3 +288,4 @@ For example, invoke \"emacs -batch -f batch-byte-compile *.el\""
288 (kill-emacs (if lost 1 0)))) 288 (kill-emacs (if lost 1 0))))
289 289
290(provide 'autoload) 290(provide 'autoload)
291
diff --git a/lisp/loadup.el b/lisp/loadup.el
index a94f4d6cc25..3b8e7bbd67e 100644
--- a/lisp/loadup.el
+++ b/lisp/loadup.el
@@ -18,6 +18,8 @@
18;; along with GNU Emacs; see the file COPYING. If not, write to 18;; along with GNU Emacs; see the file COPYING. If not, write to
19;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 19;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20 20
21;;; We don't want to have any undo records in the dumped Emacs.
22(buffer-disable-undo "*scratch*")
21 23
22(load "subr") 24(load "subr")
23(load "map-ynp") 25(load "map-ynp")
@@ -107,6 +109,9 @@
107(load "site-init" t) 109(load "site-init" t)
108(garbage-collect) 110(garbage-collect)
109 111
112;;; At this point, we're ready to resume undo recording for scratch.
113(buffer-enable-undo "*scratch*")
114
110(if (or (equal (nth 3 command-line-args) "dump") 115(if (or (equal (nth 3 command-line-args) "dump")
111 (equal (nth 4 command-line-args) "dump")) 116 (equal (nth 4 command-line-args) "dump"))
112 (if (eq system-type 'vax-vms) 117 (if (eq system-type 'vax-vms)
diff --git a/lisp/startup.el b/lisp/startup.el
index 3bd20aa9de5..0594a0b2daa 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -115,11 +115,17 @@ directory name of the directory where the `.emacs' file was looked for.")
115 (message "Back to top level.") 115 (message "Back to top level.")
116 (setq command-line-processed t) 116 (setq command-line-processed t)
117 ;; In presence of symlinks, switch to cleaner form of default directory. 117 ;; In presence of symlinks, switch to cleaner form of default directory.
118 (if (and (not (eq system-type 'vax-vms)) 118 (if (not (eq system-type 'vax-vms))
119 (getenv "PWD") 119 (mapcar (function
120 (equal (nthcdr 10 (file-attributes default-directory)) 120 (lambda (var)
121 (nthcdr 10 (file-attributes (getenv "PWD"))))) 121 (let ((value (getev var)))
122 (setq default-directory (file-name-as-directory (getenv "PWD")))) 122 (if (and value
123 (< (length value) (length default-directory))
124 (equal (file-attributes default-directory)
125 (file-attributes value)))
126 (setq default-directory
127 (file-name-as-directory value))))))
128 '("PWD" "HOME")))
123 (let ((tail directory-abbrev-alist)) 129 (let ((tail directory-abbrev-alist))
124 (while tail 130 (while tail
125 (if (string-match (car (car tail)) default-directory) 131 (if (string-match (car (car tail)) default-directory)
diff --git a/lisp/subr.el b/lisp/subr.el
index 245ac651e26..c29261c7d57 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -340,3 +340,7 @@ and then modifies one entry in it."
340 (setq i (1+ i))) 340 (setq i (1+ i)))
341 (setq keyboard-translate-table table))) 341 (setq keyboard-translate-table table)))
342 (aset keyboard-translate-table from to)) 342 (aset keyboard-translate-table from to))
343
344
345(defmacro lambda (&rest cdr)
346 (` (function (lambda (,@ cdr)))))
diff --git a/src/.gdbinit b/src/.gdbinit
index 55000f571eb..91a921119e8 100644
--- a/src/.gdbinit
+++ b/src/.gdbinit
@@ -91,6 +91,7 @@ end
91define xcons 91define xcons
92print (struct Lisp_Cons *) ($ & 0x00ffffff) 92print (struct Lisp_Cons *) ($ & 0x00ffffff)
93print *$ 93print *$
94print $$
94end 95end
95document xcons 96document xcons
96Print the contents of $, assuming it is an Elisp cons. 97Print the contents of $, assuming it is an Elisp cons.
diff --git a/src/alloc.c b/src/alloc.c
index 9b7da1d0f5b..9c63f8fe132 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -1077,15 +1077,21 @@ Garbage collection happens automatically if you cons more than\n\
1077 tem = Fnthcdr (make_number (30), Vcommand_history); 1077 tem = Fnthcdr (make_number (30), Vcommand_history);
1078 if (CONSP (tem)) 1078 if (CONSP (tem))
1079 XCONS (tem)->cdr = Qnil; 1079 XCONS (tem)->cdr = Qnil;
1080
1080 /* Likewise for undo information. */ 1081 /* Likewise for undo information. */
1081 { 1082 {
1082 register struct buffer *nextb = all_buffers; 1083 register struct buffer *nextb = all_buffers;
1083 1084
1084 while (nextb) 1085 while (nextb)
1085 { 1086 {
1086 nextb->undo_list 1087 /* If a buffer's undo list is Qt, that means that undo is
1087 = truncate_undo_list (nextb->undo_list, undo_threshold, 1088 turned off in that buffer. Calling truncate_undo_list on
1088 undo_high_threshold); 1089 Qt tends to return NULL, which effectively turns undo back on.
1090 So don't call truncate_undo_list if undo_list is Qt. */
1091 if (! EQ (nextb->undo_list, Qt))
1092 nextb->undo_list
1093 = truncate_undo_list (nextb->undo_list, undo_threshold,
1094 undo_high_threshold);
1089 nextb = nextb->next; 1095 nextb = nextb->next;
1090 } 1096 }
1091 } 1097 }
diff --git a/src/buffer.c b/src/buffer.c
index fbf6bb8b611..de9e4246f80 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -558,11 +558,22 @@ If BUFFER is omitted or nil, some interesting buffer is returned.")
558DEFUN ("buffer-disable-undo", Fbuffer_disable_undo, Sbuffer_disable_undo, 1,1, 558DEFUN ("buffer-disable-undo", Fbuffer_disable_undo, Sbuffer_disable_undo, 1,1,
5590, 5590,
560 "Make BUFFER stop keeping undo information.") 560 "Make BUFFER stop keeping undo information.")
561 (buf) 561 (buffer)
562 register Lisp_Object buf; 562 register Lisp_Object buffer;
563{ 563{
564 CHECK_BUFFER (buf, 0); 564 Lisp_Object real_buffer;
565 XBUFFER (buf)->undo_list = Qt; 565
566 if (NILP (buffer))
567 XSET (real_buffer, Lisp_Buffer, current_buffer);
568 else
569 {
570 real_buffer = Fget_buffer (buffer);
571 if (NILP (real_buffer))
572 nsberror (buffer);
573 }
574
575 XBUFFER (real_buffer)->undo_list = Qt;
576
566 return Qnil; 577 return Qnil;
567} 578}
568 579
@@ -570,23 +581,22 @@ DEFUN ("buffer-enable-undo", Fbuffer_enable_undo, Sbuffer_enable_undo,
570 0, 1, "", 581 0, 1, "",
571 "Start keeping undo information for buffer BUFFER.\n\ 582 "Start keeping undo information for buffer BUFFER.\n\
572No argument or nil as argument means do this for the current buffer.") 583No argument or nil as argument means do this for the current buffer.")
573 (buf) 584 (buffer)
574 register Lisp_Object buf; 585 register Lisp_Object buffer;
575{ 586{
576 register struct buffer *b; 587 Lisp_Object real_buffer;
577 register Lisp_Object buf1;
578 588
579 if (NILP (buf)) 589 if (NILP (buffer))
580 b = current_buffer; 590 XSET (real_buffer, Lisp_Buffer, current_buffer);
581 else 591 else
582 { 592 {
583 buf1 = Fget_buffer (buf); 593 real_buffer = Fget_buffer (buffer);
584 if (NILP (buf1)) nsberror (buf); 594 if (NILP (real_buffer))
585 b = XBUFFER (buf1); 595 nsberror (buffer);
586 } 596 }
587 597
588 if (EQ (b->undo_list, Qt)) 598 if (EQ (XBUFFER (real_buffer)->undo_list, Qt))
589 b->undo_list = Qnil; 599 XBUFFER (real_buffer)->undo_list = Qnil;
590 600
591 return Qnil; 601 return Qnil;
592} 602}
@@ -1285,10 +1295,7 @@ init_buffer_once ()
1285 /* super-magic invisible buffer */ 1295 /* super-magic invisible buffer */
1286 Vbuffer_alist = Qnil; 1296 Vbuffer_alist = Qnil;
1287 1297
1288 tem = Fset_buffer (Fget_buffer_create (build_string ("*scratch*"))); 1298 Fset_buffer (Fget_buffer_create (build_string ("*scratch*")));
1289 /* Want no undo records for *scratch*
1290 until after Emacs is dumped */
1291 Fbuffer_disable_undo (tem);
1292} 1299}
1293 1300
1294init_buffer () 1301init_buffer ()
diff --git a/src/callint.c b/src/callint.c
index 88c16721116..aeb6ef38720 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -179,12 +179,7 @@ Otherwise, this is done only if an arg is read using the minibuffer.")
179 179
180 retry: 180 retry:
181 181
182 for (fun = function; 182 fun = indirect_function (function);
183 XTYPE (fun) == Lisp_Symbol && !EQ (fun, Qunbound);
184 fun = XSYMBOL (fun)->function)
185 {
186 QUIT;
187 }
188 183
189 specs = Qnil; 184 specs = Qnil;
190 string = 0; 185 string = 0;
diff --git a/src/callproc.c b/src/callproc.c
index 9544ecf0a21..85fbcf7c784 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -125,25 +125,29 @@ If you quit, the process is killed with SIGKILL.")
125 CHECK_STRING (infile, 1); 125 CHECK_STRING (infile, 1);
126 } 126 }
127 else 127 else
128#ifdef VMS
129 infile = build_string ("NLA0:");
130#else
128 infile = build_string ("/dev/null"); 131 infile = build_string ("/dev/null");
132#endif /* not VMS */
129 133
130 { 134 if (nargs >= 3)
131 register Lisp_Object tem; 135 {
132 if (nargs < 3) 136 register Lisp_Object tem;
133 buffer = Qnil; 137
134 else 138 buffer = tem = args[2];
135 { 139 if (!(EQ (tem, Qnil)
136 buffer = tem = args[2]; 140 || EQ (tem, Qt)
137 if (!(EQ (tem, Qnil) || EQ (tem, Qt) 141 || XFASTINT (tem) == 0))
138 || XFASTINT (tem) == 0)) 142 {
139 { 143 buffer = Fget_buffer (tem);
140 buffer = Fget_buffer (tem); 144 CHECK_BUFFER (buffer, 2);
141 CHECK_BUFFER (buffer, 2); 145 }
142 } 146 }
143 } 147 else
144 } 148 buffer = Qnil;
145 149
146 display = nargs >= 3 ? args[3] : Qnil; 150 display = nargs >= 4 ? args[3] : Qnil;
147 151
148 { 152 {
149 register int i; 153 register int i;
diff --git a/src/data.c b/src/data.c
index 4e95494d593..df85ef254ea 100644
--- a/src/data.c
+++ b/src/data.c
@@ -37,7 +37,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
37Lisp_Object Qnil, Qt, Qquote, Qlambda, Qsubr, Qunbound; 37Lisp_Object Qnil, Qt, Qquote, Qlambda, Qsubr, Qunbound;
38Lisp_Object Qerror_conditions, Qerror_message, Qtop_level; 38Lisp_Object Qerror_conditions, Qerror_message, Qtop_level;
39Lisp_Object Qerror, Qquit, Qwrong_type_argument, Qargs_out_of_range; 39Lisp_Object Qerror, Qquit, Qwrong_type_argument, Qargs_out_of_range;
40Lisp_Object Qvoid_variable, Qvoid_function; 40Lisp_Object Qvoid_variable, Qvoid_function, Qcyclic_function_indirection;
41Lisp_Object Qsetting_constant, Qinvalid_read_syntax; 41Lisp_Object Qsetting_constant, Qinvalid_read_syntax;
42Lisp_Object Qinvalid_function, Qwrong_number_of_arguments, Qno_catch; 42Lisp_Object Qinvalid_function, Qwrong_number_of_arguments, Qno_catch;
43Lisp_Object Qend_of_file, Qarith_error; 43Lisp_Object Qend_of_file, Qarith_error;
@@ -480,13 +480,13 @@ DEFUN ("fmakunbound", Ffmakunbound, Sfmakunbound, 1, 1, 0, "Make SYMBOL's functi
480 480
481DEFUN ("symbol-function", Fsymbol_function, Ssymbol_function, 1, 1, 0, 481DEFUN ("symbol-function", Fsymbol_function, Ssymbol_function, 1, 1, 0,
482 "Return SYMBOL's function definition. Error if that is void.") 482 "Return SYMBOL's function definition. Error if that is void.")
483 (sym) 483 (symbol)
484 register Lisp_Object sym; 484 register Lisp_Object symbol;
485{ 485{
486 CHECK_SYMBOL (sym, 0); 486 CHECK_SYMBOL (symbol, 0);
487 if (EQ (XSYMBOL (sym)->function, Qunbound)) 487 if (EQ (XSYMBOL (symbol)->function, Qunbound))
488 return Fsignal (Qvoid_function, Fcons (sym, Qnil)); 488 return Fsignal (Qvoid_function, Fcons (symbol, Qnil));
489 return XSYMBOL (sym)->function; 489 return XSYMBOL (symbol)->function;
490} 490}
491 491
492DEFUN ("symbol-plist", Fsymbol_plist, Ssymbol_plist, 1, 1, 0, "Return SYMBOL's property list.") 492DEFUN ("symbol-plist", Fsymbol_plist, Ssymbol_plist, 1, 1, 0, "Return SYMBOL's property list.")
@@ -530,6 +530,7 @@ DEFUN ("setplist", Fsetplist, Ssetplist, 2, 2, 0,
530 XSYMBOL (sym)->plist = newplist; 530 XSYMBOL (sym)->plist = newplist;
531 return newplist; 531 return newplist;
532} 532}
533
533 534
534/* Getting and setting values of symbols */ 535/* Getting and setting values of symbols */
535 536
@@ -1094,6 +1095,61 @@ From now on the default value will apply in this buffer.")
1094 return sym; 1095 return sym;
1095} 1096}
1096 1097
1098/* Find the function at the end of a chain of symbol function indirections. */
1099
1100/* If OBJECT is a symbol, find the end of its function chain and
1101 return the value found there. If OBJECT is not a symbol, just
1102 return it. If there is a cycle in the function chain, signal a
1103 cyclic-function-indirection error.
1104
1105 This is like Findirect_function, except that it doesn't signal an
1106 error if the chain ends up unbound. */
1107Lisp_Object
1108indirect_function (object, error)
1109 register Lisp_Object object;
1110{
1111 Lisp_Object tortise, hare;
1112
1113 hare = tortise = object;
1114
1115 for (;;)
1116 {
1117 if (XTYPE (hare) != Lisp_Symbol || EQ (hare, Qunbound))
1118 break;
1119 hare = XSYMBOL (hare)->function;
1120 if (XTYPE (hare) != Lisp_Symbol || EQ (hare, Qunbound))
1121 break;
1122 hare = XSYMBOL (hare)->function;
1123
1124 tortise = XSYMBOL (tortise)->function;
1125
1126 if (EQ (hare, tortise))
1127 Fsignal (Qcyclic_function_indirection, Fcons (object, Qnil));
1128 }
1129
1130 return hare;
1131}
1132
1133DEFUN ("indirect-function", Findirect_function, Sindirect_function, 1, 1, 0,
1134 "Return the function at the end of OBJECT's function chain.\n\
1135If OBJECT is a symbol, follow all function indirections and return the final\n\
1136function binding.\n\
1137If OBJECT is not a symbol, just return it.\n\
1138Signal a void-function error if the final symbol is unbound.\n\
1139Signal a cyclic-function-indirection error if there is a loop in the\n\
1140function chain of symbols.")
1141 (object)
1142 register Lisp_Object object;
1143{
1144 Lisp_Object result;
1145
1146 result = indirect_function (object);
1147
1148 if (EQ (result, Qunbound))
1149 return Fsignal (Qvoid_function, Fcons (object, Qnil));
1150 return result;
1151}
1152
1097/* Extract and set vector and string elements */ 1153/* Extract and set vector and string elements */
1098 1154
1099DEFUN ("aref", Faref, Saref, 2, 2, 0, 1155DEFUN ("aref", Faref, Saref, 2, 2, 0,
@@ -1698,6 +1754,7 @@ syms_of_data ()
1698 Qwrong_type_argument = intern ("wrong-type-argument"); 1754 Qwrong_type_argument = intern ("wrong-type-argument");
1699 Qargs_out_of_range = intern ("args-out-of-range"); 1755 Qargs_out_of_range = intern ("args-out-of-range");
1700 Qvoid_function = intern ("void-function"); 1756 Qvoid_function = intern ("void-function");
1757 Qcyclic_function_indirection = intern ("cyclic-function-indirection");
1701 Qvoid_variable = intern ("void-variable"); 1758 Qvoid_variable = intern ("void-variable");
1702 Qsetting_constant = intern ("setting-constant"); 1759 Qsetting_constant = intern ("setting-constant");
1703 Qinvalid_read_syntax = intern ("invalid-read-syntax"); 1760 Qinvalid_read_syntax = intern ("invalid-read-syntax");
@@ -1762,6 +1819,11 @@ syms_of_data ()
1762 Fput (Qvoid_function, Qerror_message, 1819 Fput (Qvoid_function, Qerror_message,
1763 build_string ("Symbol's function definition is void")); 1820 build_string ("Symbol's function definition is void"));
1764 1821
1822 Fput (Qcyclic_function_indirection, Qerror_conditions,
1823 Fcons (Qcyclic_function_indirection, Fcons (Qerror, Qnil)));
1824 Fput (Qcyclic_function_indirection, Qerror_message,
1825 build_string ("Symbol's chain of function indirections contains a loop"));
1826
1765 Fput (Qvoid_variable, Qerror_conditions, 1827 Fput (Qvoid_variable, Qerror_conditions,
1766 Fcons (Qvoid_variable, Fcons (Qerror, Qnil))); 1828 Fcons (Qvoid_variable, Fcons (Qerror, Qnil)));
1767 Fput (Qvoid_variable, Qerror_message, 1829 Fput (Qvoid_variable, Qerror_message,
@@ -1832,6 +1894,7 @@ syms_of_data ()
1832 staticpro (&Qwrong_type_argument); 1894 staticpro (&Qwrong_type_argument);
1833 staticpro (&Qargs_out_of_range); 1895 staticpro (&Qargs_out_of_range);
1834 staticpro (&Qvoid_function); 1896 staticpro (&Qvoid_function);
1897 staticpro (&Qcyclic_function_indirection);
1835 staticpro (&Qvoid_variable); 1898 staticpro (&Qvoid_variable);
1836 staticpro (&Qsetting_constant); 1899 staticpro (&Qsetting_constant);
1837 staticpro (&Qinvalid_read_syntax); 1900 staticpro (&Qinvalid_read_syntax);
@@ -1898,6 +1961,7 @@ syms_of_data ()
1898 defsubr (&Ssetcar); 1961 defsubr (&Ssetcar);
1899 defsubr (&Ssetcdr); 1962 defsubr (&Ssetcdr);
1900 defsubr (&Ssymbol_function); 1963 defsubr (&Ssymbol_function);
1964 defsubr (&Sindirect_function);
1901 defsubr (&Ssymbol_plist); 1965 defsubr (&Ssymbol_plist);
1902 defsubr (&Ssymbol_name); 1966 defsubr (&Ssymbol_name);
1903 defsubr (&Smakunbound); 1967 defsubr (&Smakunbound);
diff --git a/src/editfns.c b/src/editfns.c
index 0ef059aa055..6164ef32799 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -680,7 +680,32 @@ Both arguments are required.")
680} 680}
681 681
682 682
683/* Return a string with the contents of the current region */ 683/* Making strings from buffer contents. */
684
685/* Return a Lisp_String containing the text of the current buffer from
686 START to END.
687
688 We don't want to use plain old make_string here, because it calls
689 make_uninit_string, which can cause the buffer arena to be
690 compacted. make_string has no way of knowing that the data has
691 been moved, and thus copies the wrong data into the string. This
692 doesn't effect most of the other users of make_string, so it should
693 be left as is. But we should use this function when conjuring
694 buffer substrings. */
695Lisp_Object
696make_buffer_string (start, end)
697 int start, end;
698{
699 Lisp_Object result;
700
701 if (start < GPT && GPT < end)
702 move_gap (start);
703
704 result = make_uninit_string (end - start);
705 bcopy (&FETCH_CHAR (start), XSTRING (result)->data, end - start);
706
707 return result;
708}
684 709
685DEFUN ("buffer-substring", Fbuffer_substring, Sbuffer_substring, 2, 2, 0, 710DEFUN ("buffer-substring", Fbuffer_substring, Sbuffer_substring, 2, 2, 0,
686 "Return the contents of part of the current buffer as a string.\n\ 711 "Return the contents of part of the current buffer as a string.\n\
@@ -690,33 +715,19 @@ they can be in either order.")
690 Lisp_Object b, e; 715 Lisp_Object b, e;
691{ 716{
692 register int beg, end; 717 register int beg, end;
693 Lisp_Object result;
694 718
695 validate_region (&b, &e); 719 validate_region (&b, &e);
696 beg = XINT (b); 720 beg = XINT (b);
697 end = XINT (e); 721 end = XINT (e);
698 722
699 if (beg < GPT && end > GPT) 723 return make_buffer_string (beg, end);
700 move_gap (beg);
701
702 /* Plain old make_string calls make_uninit_string, which can cause
703 the buffer arena to be compacted. make_string has no way of
704 knowing that the data has been moved, and thus copies the wrong
705 data into the string. This doesn't effect most of the other
706 users of make_string, so it should be left as is. */
707 result = make_uninit_string (end - beg);
708 bcopy (&FETCH_CHAR (beg), XSTRING (result)->data, end - beg);
709
710 return result;
711} 724}
712 725
713DEFUN ("buffer-string", Fbuffer_string, Sbuffer_string, 0, 0, 0, 726DEFUN ("buffer-string", Fbuffer_string, Sbuffer_string, 0, 0, 0,
714 "Return the contents of the current buffer as a string.") 727 "Return the contents of the current buffer as a string.")
715 () 728 ()
716{ 729{
717 if (BEGV < GPT && ZV > GPT) 730 return make_buffer_string (BEGV, ZV);
718 move_gap (BEGV);
719 return make_string (BEGV_ADDR, ZV - BEGV);
720} 731}
721 732
722DEFUN ("insert-buffer-substring", Finsert_buffer_substring, Sinsert_buffer_substring, 733DEFUN ("insert-buffer-substring", Finsert_buffer_substring, Sinsert_buffer_substring,
diff --git a/src/eval.c b/src/eval.c
index c4fcc808c5d..ab0ae207f2c 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -465,12 +465,7 @@ and input is currently coming from the keyboard (not in keyboard macro).")
465 that DOES eval its args. 465 that DOES eval its args.
466 If it is a built-in function (such as load or eval-region) 466 If it is a built-in function (such as load or eval-region)
467 return nil. */ 467 return nil. */
468 fun = *btp->function; 468 fun = Findirect_function (*btp->function);
469 while (XTYPE (fun) == Lisp_Symbol)
470 {
471 QUIT;
472 fun = Fsymbol_function (fun);
473 }
474 if (XTYPE (fun) == Lisp_Subr) 469 if (XTYPE (fun) == Lisp_Subr)
475 return Qnil; 470 return Qnil;
476 /* btp points to the frame of a Lisp function that called interactive-p. 471 /* btp points to the frame of a Lisp function that called interactive-p.
@@ -1206,14 +1201,9 @@ Also, a symbol satisfies `commandp' if its function definition does so.")
1206 1201
1207 fun = function; 1202 fun = function;
1208 1203
1209 /* Dereference symbols, but avoid infinte loops. Eech. */ 1204 fun = indirect_function (fun);
1210 while (XTYPE (fun) == Lisp_Symbol) 1205 if (EQ (fun, Qunbound))
1211 { 1206 return Qnil;
1212 if (++i > 10) return Qnil;
1213 tem = Ffboundp (fun);
1214 if (NILP (tem)) return Qnil;
1215 fun = Fsymbol_function (fun);
1216 }
1217 1207
1218 /* Emacs primitives are interactive if their DEFUN specifies an 1208 /* Emacs primitives are interactive if their DEFUN specifies an
1219 interactive spec. */ 1209 interactive spec. */
@@ -1333,14 +1323,8 @@ do_autoload (fundef, funname)
1333 Vautoload_queue = Qt; 1323 Vautoload_queue = Qt;
1334 unbind_to (count, Qnil); 1324 unbind_to (count, Qnil);
1335 1325
1336 while (XTYPE (fun) == Lisp_Symbol) 1326 fun = Findirect_function (fun);
1337 { 1327
1338 QUIT;
1339 val = XSYMBOL (fun)->function;
1340 if (EQ (val, Qunbound))
1341 Fsymbol_function (fun); /* Get the right kind of error! */
1342 fun = val;
1343 }
1344 if (XTYPE (fun) == Lisp_Cons 1328 if (XTYPE (fun) == Lisp_Cons
1345 && EQ (XCONS (fun)->car, Qautoload)) 1329 && EQ (XCONS (fun)->car, Qautoload))
1346 error ("Autoloading failed to define function %s", 1330 error ("Autoloading failed to define function %s",
@@ -1404,15 +1388,7 @@ DEFUN ("eval", Feval, Seval, 1, 1, 0,
1404 /* At this point, only original_fun and original_args 1388 /* At this point, only original_fun and original_args
1405 have values that will be used below */ 1389 have values that will be used below */
1406 retry: 1390 retry:
1407 fun = original_fun; 1391 fun = Findirect_function (original_fun);
1408 while (XTYPE (fun) == Lisp_Symbol)
1409 {
1410 QUIT;
1411 val = XSYMBOL (fun)->function;
1412 if (EQ (val, Qunbound))
1413 Fsymbol_function (fun); /* Get the right kind of error! */
1414 fun = val;
1415 }
1416 1392
1417 if (XTYPE (fun) == Lisp_Subr) 1393 if (XTYPE (fun) == Lisp_Subr)
1418 { 1394 {
@@ -1582,16 +1558,12 @@ Thus, (apply '+ 1 2 '(3 4)) returns 10.")
1582 1558
1583 numargs += nargs - 2; 1559 numargs += nargs - 2;
1584 1560
1585 while (XTYPE (fun) == Lisp_Symbol) 1561 fun = indirect_function (fun);
1562 if (EQ (fun, Qunbound))
1586 { 1563 {
1587 QUIT; 1564 /* Let funcall get the error */
1588 fun = XSYMBOL (fun)->function; 1565 fun = args[0];
1589 if (EQ (fun, Qunbound)) 1566 goto funcall;
1590 {
1591 /* Let funcall get the error */
1592 fun = args[0];
1593 goto funcall;
1594 }
1595 } 1567 }
1596 1568
1597 if (XTYPE (fun) == Lisp_Subr) 1569 if (XTYPE (fun) == Lisp_Subr)
@@ -1779,14 +1751,8 @@ Thus, (funcall 'cons 'x 'y) returns (x . y).")
1779 retry: 1751 retry:
1780 1752
1781 fun = args[0]; 1753 fun = args[0];
1782 while (XTYPE (fun) == Lisp_Symbol) 1754
1783 { 1755 fun = Findirect_function (fun);
1784 QUIT;
1785 val = XSYMBOL (fun)->function;
1786 if (EQ (val, Qunbound))
1787 Fsymbol_function (fun); /* Get the right kind of error! */
1788 fun = val;
1789 }
1790 1756
1791 if (XTYPE (fun) == Lisp_Subr) 1757 if (XTYPE (fun) == Lisp_Subr)
1792 { 1758 {
diff --git a/src/fileio.c b/src/fileio.c
index f977ee0c623..a317db7c69f 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
17along with GNU Emacs; see the file COPYING. If not, write to 17along with GNU Emacs; see the file COPYING. If not, write to
18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ 18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19 19
20#include "config.h"
20 21
21#include <sys/types.h> 22#include <sys/types.h>
22#include <sys/stat.h> 23#include <sys/stat.h>
@@ -52,7 +53,6 @@ extern int sys_nerr;
52#include <sys/time.h> 53#include <sys/time.h>
53#endif 54#endif
54 55
55#include "config.h"
56#include "lisp.h" 56#include "lisp.h"
57#include "buffer.h" 57#include "buffer.h"
58#include "window.h" 58#include "window.h"
diff --git a/src/keyboard.c b/src/keyboard.c
index e6139cfaf11..5b0d5facfc6 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -43,6 +43,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
43 43
44#include "syssignal.h" 44#include "syssignal.h"
45#include "systerm.h" 45#include "systerm.h"
46#include "systime.h"
46 47
47extern int errno; 48extern int errno;
48 49
@@ -311,8 +312,9 @@ Lisp_Object Qmode_line;
311Lisp_Object Qvertical_split; 312Lisp_Object Qvertical_split;
312 313
313 314
314/* Address (if not 0) of word to zero out if a SIGIO interrupt happens. */ 315/* Address (if not 0) of EMACS_TIME to zero out if a SIGIO interrupt
315long *input_available_clear_word; 316 happens. */
317EMACS_TIME *input_available_clear_time;
316 318
317/* Nonzero means use SIGIO interrupts; zero means use CBREAK mode. 319/* Nonzero means use SIGIO interrupts; zero means use CBREAK mode.
318 Default is 1 if INTERRUPT_INPUT is defined. */ 320 Default is 1 if INTERRUPT_INPUT is defined. */
@@ -1160,8 +1162,7 @@ read_char (commandflag)
1160 XSET (Vlast_event_screen, Lisp_Screen, selected_screen); 1162 XSET (Vlast_event_screen, Lisp_Screen, selected_screen);
1161#endif 1163#endif
1162 1164
1163 waiting_for_input = 0; 1165 clear_waiting_for_input ();
1164 input_available_clear_word = 0;
1165 1166
1166 goto non_reread; 1167 goto non_reread;
1167 } 1168 }
@@ -1491,7 +1492,7 @@ kbd_buffer_store_event (event)
1491 will set Vlast_event_screen again, so this is safe to do. */ 1492 will set Vlast_event_screen again, so this is safe to do. */
1492 extern SIGTYPE interrupt_signal (); 1493 extern SIGTYPE interrupt_signal ();
1493 XSET (Vlast_event_screen, Lisp_Screen, event->screen); 1494 XSET (Vlast_event_screen, Lisp_Screen, event->screen);
1494 last_event_timestamp = XINT (event->timestamp); 1495 last_event_timestamp = event->timestamp;
1495 interrupt_signal (); 1496 interrupt_signal ();
1496 return; 1497 return;
1497 } 1498 }
@@ -2237,8 +2238,8 @@ input_available_signal (signo)
2237 sigisheld (SIGIO); 2238 sigisheld (SIGIO);
2238#endif 2239#endif
2239 2240
2240 if (input_available_clear_word) 2241 if (input_available_clear_time)
2241 *input_available_clear_word = 0; 2242 EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0);
2242 2243
2243 while (1) 2244 while (1)
2244 { 2245 {
@@ -2793,13 +2794,7 @@ Otherwise, that is done only if an arg is read using the minibuffer.")
2793 2794
2794 while (1) 2795 while (1)
2795 { 2796 {
2796 final = cmd; 2797 final = Findirect_function (cmd);
2797 while (XTYPE (final) == Lisp_Symbol)
2798 {
2799 if (EQ (Qunbound, XSYMBOL (final)->function))
2800 Fsymbol_function (final); /* Get an error! */
2801 final = XSYMBOL (final)->function;
2802 }
2803 2798
2804 if (CONSP (final) && (tem = Fcar (final), EQ (tem, Qautoload))) 2799 if (CONSP (final) && (tem = Fcar (final), EQ (tem, Qautoload)))
2805 do_autoload (final, cmd); 2800 do_autoload (final, cmd);
@@ -3012,6 +3007,14 @@ detect_input_pending ()
3012 return input_pending; 3007 return input_pending;
3013} 3008}
3014 3009
3010/* This is called in some cases before a possible quit.
3011 It cases the next call to detect_input_pending to recompute input_pending.
3012 So calling this function unnecessarily can't do any harm. */
3013clear_input_pending ()
3014{
3015 input_pending = 0;
3016}
3017
3015DEFUN ("input-pending-p", Finput_pending_p, Sinput_pending_p, 0, 0, 0, 3018DEFUN ("input-pending-p", Finput_pending_p, Sinput_pending_p, 0, 0, 0,
3016 "T if command input is currently available with no waiting.\n\ 3019 "T if command input is currently available with no waiting.\n\
3017Actually, the value is nil only if we can be sure that no input is available.") 3020Actually, the value is nil only if we can be sure that no input is available.")
@@ -3194,10 +3197,10 @@ stuff_buffered_input (stuffstring)
3194#endif /* BSD and not BSD4_1 */ 3197#endif /* BSD and not BSD4_1 */
3195} 3198}
3196 3199
3197set_waiting_for_input (word_to_clear) 3200set_waiting_for_input (time_to_clear)
3198 long *word_to_clear; 3201 EMACS_TIME *time_to_clear;
3199{ 3202{
3200 input_available_clear_word = word_to_clear; 3203 input_available_clear_time = time_to_clear;
3201 3204
3202 /* Tell interrupt_signal to throw back to read_char, */ 3205 /* Tell interrupt_signal to throw back to read_char, */
3203 waiting_for_input = 1; 3206 waiting_for_input = 1;
@@ -3219,7 +3222,7 @@ clear_waiting_for_input ()
3219{ 3222{
3220 /* Tell interrupt_signal not to throw back to read_char, */ 3223 /* Tell interrupt_signal not to throw back to read_char, */
3221 waiting_for_input = 0; 3224 waiting_for_input = 0;
3222 input_available_clear_word = 0; 3225 input_available_clear_time = 0;
3223} 3226}
3224 3227
3225/* This routine is called at interrupt level in response to C-G. 3228/* This routine is called at interrupt level in response to C-G.
diff --git a/src/lisp.h b/src/lisp.h
index b263370dac6..b0b0cb4fc56 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -852,6 +852,7 @@ extern Lisp_Object Fcar (), Fcar_safe(), Fcdr (), Fcdr_safe();
852extern Lisp_Object Fsetcar (), Fsetcdr (); 852extern Lisp_Object Fsetcar (), Fsetcdr ();
853extern Lisp_Object Fboundp (), Ffboundp (), Fmakunbound (), Ffmakunbound (); 853extern Lisp_Object Fboundp (), Ffboundp (), Fmakunbound (), Ffmakunbound ();
854extern Lisp_Object Fsymbol_function (), Fsymbol_plist (), Fsymbol_name (); 854extern Lisp_Object Fsymbol_function (), Fsymbol_plist (), Fsymbol_name ();
855extern Lisp_Object indirect_function (), Findirect_function ();
855extern Lisp_Object Ffset (), Fsetplist (); 856extern Lisp_Object Ffset (), Fsetplist ();
856extern Lisp_Object Fsymbol_value (), find_symbol_value (), Fset (); 857extern Lisp_Object Fsymbol_value (), find_symbol_value (), Fset ();
857extern Lisp_Object Fdefault_value (), Fset_default (); 858extern Lisp_Object Fdefault_value (), Fset_default ();
@@ -951,7 +952,8 @@ extern Lisp_Object Ffollowing_char (), Fprevious_char (), Fchar_after ();
951extern Lisp_Object Finsert (); 952extern Lisp_Object Finsert ();
952extern Lisp_Object Feolp (), Feobp (), Fbolp (), Fbobp (); 953extern Lisp_Object Feolp (), Feobp (), Fbolp (), Fbobp ();
953extern Lisp_Object Fformat (), format1 (); 954extern Lisp_Object Fformat (), format1 ();
954extern Lisp_Object Fbuffer_substring (), Fbuffer_string (); 955extern Lisp_Object make_buffer_string (), Fbuffer_substring ();
956extern Lisp_Object Fbuffer_string ();
955extern Lisp_Object Fstring_equal (), Fstring_lessp (), Fbuffer_substring_lessp (); 957extern Lisp_Object Fstring_equal (), Fstring_lessp (), Fbuffer_substring_lessp ();
956extern Lisp_Object save_excursion_save (), save_restriction_save (); 958extern Lisp_Object save_excursion_save (), save_restriction_save ();
957extern Lisp_Object save_excursion_restore (), save_restriction_restore (); 959extern Lisp_Object save_excursion_restore (), save_restriction_restore ();
diff --git a/src/minibuf.c b/src/minibuf.c
index 93c9f26727a..df45dac7483 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -1,11 +1,11 @@
1/* Minibuffer input and completion. 1/* Minibuffer input and completion.
2 Copyright (C) 1985, 1986 Free Software Foundation, Inc. 2 Copyright (C) 1985, 1986, 1992 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
6GNU Emacs is free software; you can redistribute it and/or modify 6GNU Emacs is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by 7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 1, or (at your option) 8the Free Software Foundation; either version 2, or (at your option)
9any later version. 9any later version.
10 10
11GNU Emacs is distributed in the hope that it will be useful, 11GNU Emacs is distributed in the hope that it will be useful,
@@ -195,7 +195,7 @@ read_minibuf (map, initial, prompt, backup_n, expflag)
195 } 195 }
196 196
197 /* Make minibuffer contents into a string */ 197 /* Make minibuffer contents into a string */
198 val = make_string (BEG_ADDR, Z - BEG); 198 val = make_buffer_string (1, Z);
199 bcopy (GAP_END_ADDR, XSTRING (val)->data + GPT - BEG, Z - GPT); 199 bcopy (GAP_END_ADDR, XSTRING (val)->data + GPT - BEG, Z - GPT);
200 unbind_to (count, Qnil); /* The appropriate screen will get selected 200 unbind_to (count, Qnil); /* The appropriate screen will get selected
201 in set-window-configuration. */ 201 in set-window-configuration. */
diff --git a/src/process.c b/src/process.c
index 9ba48ef7d56..68bdfa334e6 100644
--- a/src/process.c
+++ b/src/process.c
@@ -65,41 +65,12 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
65#include <bsdtty.h> 65#include <bsdtty.h>
66#endif 66#endif
67 67
68#ifdef HPUX
69#undef TIOCGPGRP
70#endif
71
72#ifdef IRIS 68#ifdef IRIS
73#include <sys/sysmacros.h> /* for "minor" */ 69#include <sys/sysmacros.h> /* for "minor" */
74#endif /* not IRIS */ 70#endif /* not IRIS */
75 71
76#include "systime.h" 72#include "systime.h"
77 73#include "systerm.h"
78#if defined (HPUX) && defined (HAVE_PTYS)
79#include <sys/ptyio.h>
80#endif
81
82#ifdef AIX
83#include <sys/pty.h>
84#include <unistd.h>
85#endif
86
87#ifdef SYSV_PTYS
88#include <sys/tty.h>
89#ifdef titan
90#include <sys/ttyhw.h>
91#include <sys/stream.h>
92#endif
93#include <sys/pty.h>
94#endif
95
96#ifdef XENIX
97#undef TIOCGETC /* Avoid confusing some conditionals that test this. */
98#endif
99
100#ifdef BROKEN_TIOCGETC
101#undef TIOCGETC
102#endif
103 74
104#include "lisp.h" 75#include "lisp.h"
105#include "window.h" 76#include "window.h"
@@ -1690,10 +1661,6 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
1690 EMACS_ADD_TIME (end_time, end_time, timeout); 1661 EMACS_ADD_TIME (end_time, end_time, timeout);
1691 } 1662 }
1692 1663
1693 /* Turn off periodic alarms (in case they are in use)
1694 because the select emulator uses alarms. */
1695 stop_polling ();
1696
1697 while (1) 1664 while (1)
1698 { 1665 {
1699 /* If calling from keyboard input, do not quit 1666 /* If calling from keyboard input, do not quit
@@ -1752,6 +1719,13 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
1752 if (!read_kbd) 1719 if (!read_kbd)
1753 FD_CLR (0, &Available); 1720 FD_CLR (0, &Available);
1754 1721
1722 /* If screen size has changed or the window is newly mapped,
1723 redisplay now, before we start to wait. There is a race
1724 condition here; if a SIGIO arrives between now and the select
1725 and indicates that a screen is trashed, we lose. */
1726 if (screen_garbaged)
1727 redisplay_preserve_echo_area ();
1728
1755 if (read_kbd && detect_input_pending ()) 1729 if (read_kbd && detect_input_pending ())
1756 nfds = 0; 1730 nfds = 0;
1757 else 1731 else
@@ -1765,7 +1739,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
1765 /* If we woke up due to SIGWINCH, actually change size now. */ 1739 /* If we woke up due to SIGWINCH, actually change size now. */
1766 do_pending_window_change (); 1740 do_pending_window_change ();
1767 1741
1768 if (time_limit && nfds == 0) /* timeout elapsed */ 1742 if (time_limit && nfds == 0) /* timeout elapsed */
1769 break; 1743 break;
1770 if (nfds < 0) 1744 if (nfds < 0)
1771 { 1745 {
@@ -1787,7 +1761,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
1787 So, SIGHUP is ignored (see def of PTY_TTY_NAME_SPRINTF 1761 So, SIGHUP is ignored (see def of PTY_TTY_NAME_SPRINTF
1788 in m-ibmrt-aix.h), and here we just ignore the select error. 1762 in m-ibmrt-aix.h), and here we just ignore the select error.
1789 Cleanup occurs c/o status_notify after SIGCLD. */ 1763 Cleanup occurs c/o status_notify after SIGCLD. */
1790 FD_ZERO (&Available); /* Cannot depend on values returned */ 1764 FD_ZERO (&Available); /* Cannot depend on values returned */
1791#else 1765#else
1792 abort (); 1766 abort ();
1793#endif 1767#endif
@@ -1815,8 +1789,8 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
1815 but select says there is input. */ 1789 but select says there is input. */
1816 1790
1817 /* 1791 /*
1818 if (read_kbd && interrupt_input && (Available & fileno (stdin))) 1792 if (read_kbd && interrupt_input && (Available & fileno (stdin)))
1819 */ 1793 */
1820 if (read_kbd && interrupt_input && (FD_ISSET (fileno (stdin), &Available))) 1794 if (read_kbd && interrupt_input && (FD_ISSET (fileno (stdin), &Available)))
1821 kill (0, SIGIO); 1795 kill (0, SIGIO);
1822#endif 1796#endif
@@ -1839,11 +1813,6 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
1839 if (read_kbd) 1813 if (read_kbd)
1840 do_pending_window_change (); 1814 do_pending_window_change ();
1841 1815
1842 /* If screen size has changed, redisplay now
1843 for either sit-for or keyboard input. */
1844 if (read_kbd && screen_garbaged)
1845 redisplay_preserve_echo_area ();
1846
1847 /* Check for data from a process or a command channel */ 1816 /* Check for data from a process or a command channel */
1848 for (channel = FIRST_PROC_DESC; channel < MAXDESC; channel++) 1817 for (channel = FIRST_PROC_DESC; channel < MAXDESC; channel++)
1849 { 1818 {
@@ -1880,7 +1849,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
1880 } 1849 }
1881 continue; 1850 continue;
1882 } 1851 }
1883#endif /* vipc */ 1852#endif /* vipc */
1884 1853
1885 /* Read data from the process, starting with our 1854 /* Read data from the process, starting with our
1886 buffered-ahead character if we have one. */ 1855 buffered-ahead character if we have one. */
@@ -1914,9 +1883,9 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
1914 subprocess termination and SIGCHLD. */ 1883 subprocess termination and SIGCHLD. */
1915 else if (nread == 0 && !NETCONN_P (proc)) 1884 else if (nread == 0 && !NETCONN_P (proc))
1916 ; 1885 ;
1917#endif /* O_NDELAY */ 1886#endif /* O_NDELAY */
1918#endif /* O_NONBLOCK */ 1887#endif /* O_NONBLOCK */
1919#endif /* EWOULDBLOCK */ 1888#endif /* EWOULDBLOCK */
1920#ifdef HAVE_PTYS 1889#ifdef HAVE_PTYS
1921 /* On some OSs with ptys, when the process on one end of 1890 /* On some OSs with ptys, when the process on one end of
1922 a pty exits, the other end gets an error reading with 1891 a pty exits, the other end gets an error reading with
@@ -1927,9 +1896,9 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
1927 get a SIGCHLD). */ 1896 get a SIGCHLD). */
1928 else if (nread == -1 && errno == EIO) 1897 else if (nread == -1 && errno == EIO)
1929 ; 1898 ;
1930#endif /* HAVE_PTYS */ 1899#endif /* HAVE_PTYS */
1931/* If we can detect process termination, don't consider the process 1900 /* If we can detect process termination, don't consider the process
1932 gone just because its pipe is closed. */ 1901 gone just because its pipe is closed. */
1933#ifdef SIGCHLD 1902#ifdef SIGCHLD
1934 else if (nread == 0 && !NETCONN_P (proc)) 1903 else if (nread == 0 && !NETCONN_P (proc))
1935 ; 1904 ;
@@ -1946,11 +1915,18 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
1946 = Fcons (Qexit, Fcons (make_number (256), Qnil)); 1915 = Fcons (Qexit, Fcons (make_number (256), Qnil));
1947 } 1916 }
1948 } 1917 }
1949 } /* end for each file descriptor */ 1918 } /* end for each file descriptor */
1950 } /* end while exit conditions not met */ 1919 } /* end while exit conditions not met */
1951 1920
1952 /* Resume periodic signals to poll for input, if necessary. */ 1921 /* If calling from keyboard input, do not quit
1953 start_polling (); 1922 since we want to return C-g as an input character.
1923 Otherwise, do pending quit if requested. */
1924 if (read_kbd >= 0)
1925 {
1926 /* Prevent input_pending from remaining set if we quit. */
1927 clear_input_pending ();
1928 QUIT;
1929 }
1954 1930
1955 return got_some_input; 1931 return got_some_input;
1956} 1932}
diff --git a/src/search.c b/src/search.c
index 9ac63aea874..5f1f17f2d53 100644
--- a/src/search.c
+++ b/src/search.c
@@ -210,80 +210,94 @@ matched by parenthesis constructs in the pattern.")
210 return make_number (val); 210 return make_number (val);
211} 211}
212 212
213scan_buffer (target, pos, cnt, shortage) 213/* Search for COUNT instances of the character TARGET, starting at START.
214 int *shortage, pos; 214 If COUNT is negative, search backwards.
215 register int cnt, target; 215
216 If we find COUNT instances, set *SHORTAGE to zero, and return the
217 position of the COUNTth character.
218
219 If we don't find COUNT instances before reaching the end of the
220 buffer (or the beginning, if scanning backwards), set *SHORTAGE to
221 the number of TARGETs left unfound, and return the end of the
222 buffer we bumped up against. */
223
224scan_buffer (target, start, count, shortage)
225 int *shortage, start;
226 register int count, target;
216{ 227{
217 int lim = ((cnt > 0) ? ZV - 1 : BEGV); 228 int limit = ((count > 0) ? ZV - 1 : BEGV);
218 int direction = ((cnt > 0) ? 1 : -1); 229 int direction = ((count > 0) ? 1 : -1);
219 register int lim0; 230
231 register unsigned char *cursor;
220 unsigned char *base; 232 unsigned char *base;
221 register unsigned char *cursor, *limit; 233
234 register int ceiling;
235 register unsigned char *ceiling_addr;
222 236
223 if (shortage != 0) 237 if (shortage != 0)
224 *shortage = 0; 238 *shortage = 0;
225 239
226 immediate_quit = 1; 240 immediate_quit = 1;
227 241
228 if (cnt > 0) 242 if (count > 0)
229 while (pos != lim + 1) 243 while (start != limit + 1)
230 { 244 {
231 lim0 = BUFFER_CEILING_OF (pos); 245 ceiling = BUFFER_CEILING_OF (start);
232 lim0 = min (lim, lim0); 246 ceiling = min (limit, ceiling);
233 limit = &FETCH_CHAR (lim0) + 1; 247 ceiling_addr = &FETCH_CHAR (ceiling) + 1;
234 base = (cursor = &FETCH_CHAR (pos)); 248 base = (cursor = &FETCH_CHAR (start));
235 while (1) 249 while (1)
236 { 250 {
237 while (*cursor != target && ++cursor != limit) 251 while (*cursor != target && ++cursor != ceiling_addr)
238 ; 252 ;
239 if (cursor != limit) 253 if (cursor != ceiling_addr)
240 { 254 {
241 if (--cnt == 0) 255 if (--count == 0)
242 { 256 {
243 immediate_quit = 0; 257 immediate_quit = 0;
244 return (pos + cursor - base + 1); 258 return (start + cursor - base + 1);
245 } 259 }
246 else 260 else
247 if (++cursor == limit) 261 if (++cursor == ceiling_addr)
248 break; 262 break;
249 } 263 }
250 else 264 else
251 break; 265 break;
252 } 266 }
253 pos += cursor - base; 267 start += cursor - base;
254 } 268 }
255 else 269 else
256 { 270 {
257 pos--; /* first character we scan */ 271 start--; /* first character we scan */
258 while (pos > lim - 1) 272 while (start > limit - 1)
259 { /* we WILL scan under pos */ 273 { /* we WILL scan under start */
260 lim0 = BUFFER_FLOOR_OF (pos); 274 ceiling = BUFFER_FLOOR_OF (start);
261 lim0 = max (lim, lim0); 275 ceiling = max (limit, ceiling);
262 limit = &FETCH_CHAR (lim0) - 1; 276 ceiling_addr = &FETCH_CHAR (ceiling) - 1;
263 base = (cursor = &FETCH_CHAR (pos)); 277 base = (cursor = &FETCH_CHAR (start));
264 cursor++; 278 cursor++;
265 while (1) 279 while (1)
266 { 280 {
267 while (--cursor != limit && *cursor != target) 281 while (--cursor != ceiling_addr && *cursor != target)
268 ; 282 ;
269 if (cursor != limit) 283 if (cursor != ceiling_addr)
270 { 284 {
271 if (++cnt == 0) 285 if (++count == 0)
272 { 286 {
273 immediate_quit = 0; 287 immediate_quit = 0;
274 return (pos + cursor - base + 1); 288 return (start + cursor - base + 1);
275 } 289 }
276 } 290 }
277 else 291 else
278 break; 292 break;
279 } 293 }
280 pos += cursor - base; 294 start += cursor - base;
281 } 295 }
282 } 296 }
283 immediate_quit = 0; 297 immediate_quit = 0;
284 if (shortage != 0) 298 if (shortage != 0)
285 *shortage = cnt * direction; 299 *shortage = count * direction;
286 return (pos + ((direction == 1 ? 0 : 1))); 300 return (start + ((direction == 1 ? 0 : 1)));
287} 301}
288 302
289int 303int
diff --git a/src/sysdep.c b/src/sysdep.c
index 5f6090a2460..51c5bd920a7 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -479,7 +479,7 @@ child_setup_tty (out)
479setpgrp_of_tty (pid) 479setpgrp_of_tty (pid)
480 int pid; 480 int pid;
481{ 481{
482 EMACS_SET_TTY_PGRP (input_fd, pid); 482 EMACS_SET_TTY_PGRP (input_fd, &pid);
483} 483}
484 484
485/* Record a signal code and the handler for it. */ 485/* Record a signal code and the handler for it. */
@@ -1199,7 +1199,7 @@ kbd_input_ast ()
1199{ 1199{
1200 register int c = -1; 1200 register int c = -1;
1201 int old_errno = errno; 1201 int old_errno = errno;
1202 extern int *input_available_clear_word; 1202 extern EMACS_TIME *input_available_clear_time;
1203 1203
1204 if (waiting_for_ast) 1204 if (waiting_for_ast)
1205 SYS$SETEF (input_ef); 1205 SYS$SETEF (input_ef);
@@ -1236,8 +1236,8 @@ kbd_input_ast ()
1236 kbd_buffer_store_event (&e); 1236 kbd_buffer_store_event (&e);
1237 } 1237 }
1238 1238
1239 if (input_available_clear_word) 1239 if (input_available_clear_time)
1240 *input_available_clear_word = 0; 1240 EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0);
1241 errno = old_errno; 1241 errno = old_errno;
1242} 1242}
1243 1243
diff --git a/src/systty.h b/src/systty.h
index 4bbf021595d..910810dc15d 100644
--- a/src/systty.h
+++ b/src/systty.h
@@ -61,6 +61,10 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
61 61
62#ifdef SYSV_PTYS 62#ifdef SYSV_PTYS
63#include <sys/tty.h> 63#include <sys/tty.h>
64#ifdef titan
65#include <sys/ttyhw.h>
66#include <sys/stream.h>
67#endif
64#include <sys/pty.h> 68#include <sys/pty.h>
65#endif 69#endif
66 70
@@ -78,6 +82,10 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
78#undef TIOCSTART 82#undef TIOCSTART
79#endif 83#endif
80 84
85#ifdef XENIX
86#undef TIOCGETC /* Avoid confusing some conditionals that test this. */
87#endif
88
81#ifdef BROKEN_TIOCGETC 89#ifdef BROKEN_TIOCGETC
82#undef TIOCGETC /* Avoid confusing some conditionals that test this. */ 90#undef TIOCGETC /* Avoid confusing some conditionals that test this. */
83#endif 91#endif
@@ -128,6 +136,10 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
128 EMACS_SET_TTY_PGRP(int FD, int *PGID) sets the terminal FD's 136 EMACS_SET_TTY_PGRP(int FD, int *PGID) sets the terminal FD's
129 current process group to *PGID. Return -1 if there is an error. */ 137 current process group to *PGID. Return -1 if there is an error. */
130 138
139#ifdef HPUX
140/* HPUX tty process group stuff doesn't work, says the anonymous voice
141 from the past. */
142#else
131#ifdef TIOCGPGRP 143#ifdef TIOCGPGRP
132#define EMACS_HAVE_TTY_PGRP 144#define EMACS_HAVE_TTY_PGRP
133#else 145#else
@@ -135,6 +147,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
135#define EMACS_HAVE_TTY_PGRP 147#define EMACS_HAVE_TTY_PGRP
136#endif 148#endif
137#endif 149#endif
150#endif
138 151
139#ifdef EMACS_HAVE_TTY_PGRP 152#ifdef EMACS_HAVE_TTY_PGRP
140 153
diff --git a/src/termhooks.h b/src/termhooks.h
index ff1df84059d..08c8e818e80 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -1,12 +1,12 @@
1/* Hooks by which low level terminal operations 1/* Hooks by which low level terminal operations
2 can be made to call other routines. 2 can be made to call other routines.
3 Copyright (C) 1985, 1986 Free Software Foundation, Inc. 3 Copyright (C) 1985, 1986, 1992 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
7GNU Emacs is free software; you can redistribute it and/or modify 7GNU Emacs is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by 8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 1, or (at your option) 9the Free Software Foundation; either version 2, or (at your option)
10any later version. 10any later version.
11 11
12GNU Emacs is distributed in the hope that it will be useful, 12GNU Emacs is distributed in the hope that it will be useful,
@@ -138,7 +138,7 @@ struct input_event {
138 struct screen *screen; 138 struct screen *screen;
139 int modifiers; /* See enum below for interpretation. */ 139 int modifiers; /* See enum below for interpretation. */
140 Lisp_Object x, y; 140 Lisp_Object x, y;
141 Lisp_Object timestamp; 141 unsigned long timestamp;
142}; 142};
143 143
144/* Bits in the modifiers member of the input_event structure. */ 144/* Bits in the modifiers member of the input_event structure. */
diff --git a/src/xselect.c.old b/src/xselect.c.old
index a8c26f7e994..a88208bece9 100644
--- a/src/xselect.c.old
+++ b/src/xselect.c.old
@@ -1,11 +1,11 @@
1/* X Selection processing for emacs 1/* X Selection processing for emacs
2 Copyright (C) 1990 Free Software Foundation. 2 Copyright (C) 1990, 1992 Free Software Foundation.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
6GNU Emacs is free software; you can redistribute it and/or modify 6GNU Emacs is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by 7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 1, or (at your option) 8the Free Software Foundation; either version 2, or (at your option)
9any later version. 9any later version.
10 10
11GNU Emacs is distributed in the hope that it will be useful, 11GNU Emacs is distributed in the hope that it will be useful,
@@ -32,6 +32,9 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
32/* The last 23 bits of the timestamp of the last mouse button event. */ 32/* The last 23 bits of the timestamp of the last mouse button event. */
33extern Time mouse_timestamp; 33extern Time mouse_timestamp;
34 34
35/* An expedient hack! Fix this! */
36#define last_event_timestamp CurrentTime
37
35/* t if a mouse button is depressed. */ 38/* t if a mouse button is depressed. */
36extern Lisp_Object Vmouse_grabbed; 39extern Lisp_Object Vmouse_grabbed;
37 40
@@ -130,7 +133,7 @@ own_selection (selection_type, time)
130 selecting_window, time); 133 selecting_window, time);
131 owner_window = XGetSelectionOwner (x_current_display, selection_type); 134 owner_window = XGetSelectionOwner (x_current_display, selection_type);
132 135
133 if (owner_window != selecting_window) 136 if (owner_window != selecting_window)
134 return 0; 137 return 0;
135 138
136 return 1; 139 return 1;
@@ -160,7 +163,7 @@ but optional second argument TYPE may specify secondary or clipboard.")
160 x_begin_selection_own = event_time; 163 x_begin_selection_own = event_time;
161 val = Vx_selection_value = string; 164 val = Vx_selection_value = string;
162 } 165 }
163 UNBLOCK_INPUT; 166 UNBLOCK_INPUT;
164 } 167 }
165 else if (EQ (type, Qsecondary)) 168 else if (EQ (type, Qsecondary))
166 { 169 {
@@ -177,10 +180,10 @@ but optional second argument TYPE may specify secondary or clipboard.")
177 BLOCK_INPUT; 180 BLOCK_INPUT;
178 if (own_selection (Xatom_clipboard, event_time)) 181 if (own_selection (Xatom_clipboard, event_time))
179 { 182 {
180 x_begin_clipboard_own = event_time; 183 x_begin_clipboard_own = event_time;
181 val = Vx_clipboard_value = string; 184 val = Vx_clipboard_value = string;
182 } 185 }
183 UNBLOCK_INPUT; 186 UNBLOCK_INPUT;
184 } 187 }
185 else 188 else
186 error ("Invalid X selection type"); 189 error ("Invalid X selection type");
@@ -545,7 +548,7 @@ selection, but optional argument TYPE may specify secondary or clipboard.")
545 if (NILP (type) || EQ (type, Qprimary)) 548 if (NILP (type) || EQ (type, Qprimary))
546 { 549 {
547 if (!NILP (Vx_selection_value)) 550 if (!NILP (Vx_selection_value))
548 return Vx_selection_value; 551 return Vx_selection_value;
549 552
550 return get_selection_value (XA_PRIMARY); 553 return get_selection_value (XA_PRIMARY);
551 } 554 }