aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStephen Gildea2018-07-31 22:34:35 -0700
committerStephen Gildea2018-07-31 22:34:35 -0700
commit1804fece02691798394c9e9bd519cd4a53776018 (patch)
tree9d5d441db29404f04417332be3507ba968eec42f /src
parent17205d361795eaaa8e09ae62875c7439bb57a078 (diff)
parent82d6416a28dc5b4ab65b8081f035679bec4e3604 (diff)
downloademacs-1804fece02691798394c9e9bd519cd4a53776018.tar.gz
emacs-1804fece02691798394c9e9bd519cd4a53776018.zip
Merge branch 'master' of git.savannah.gnu.org:/srv/git/emacs
Diffstat (limited to 'src')
-rw-r--r--src/alloc.c2
-rw-r--r--src/callint.c2
-rw-r--r--src/character.c10
-rw-r--r--src/chartab.c4
-rw-r--r--src/dbusbind.c4
-rw-r--r--src/dired.c2
-rw-r--r--src/editfns.c66
-rw-r--r--src/emacs.c11
-rw-r--r--src/eval.c20
-rw-r--r--src/fileio.c35
-rw-r--r--src/fns.c103
-rw-r--r--src/frame.c27
-rw-r--r--src/gnutls.c38
-rw-r--r--src/image.c2
-rw-r--r--src/intervals.c2
-rw-r--r--src/intervals.h2
-rw-r--r--src/json.c2
-rw-r--r--src/keyboard.c47
-rw-r--r--src/lisp.h3
-rw-r--r--src/lread.c9
-rw-r--r--src/menu.c6
-rw-r--r--src/nsfns.m4
-rw-r--r--src/nsmenu.m2
-rw-r--r--src/nsselect.m6
-rw-r--r--src/process.c20
-rw-r--r--src/terminal.c2
-rw-r--r--src/textprop.c2
-rw-r--r--src/thread.c41
-rw-r--r--src/thread.h3
-rw-r--r--src/w32cygwinx.c37
-rw-r--r--src/w32term.c2
-rw-r--r--src/xdisp.c2
-rw-r--r--src/xfaces.c4
-rw-r--r--src/xfns.c4
-rw-r--r--src/xmenu.c4
-rw-r--r--src/xselect.c4
-rw-r--r--src/xwidget.c2
37 files changed, 336 insertions, 200 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 8764591336e..ad716f543c3 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -6585,7 +6585,7 @@ mark_object (Lisp_Object arg)
6585 CHECK_ALLOCATED_AND_LIVE (live_cons_p); 6585 CHECK_ALLOCATED_AND_LIVE (live_cons_p);
6586 CONS_MARK (ptr); 6586 CONS_MARK (ptr);
6587 /* If the cdr is nil, avoid recursion for the car. */ 6587 /* If the cdr is nil, avoid recursion for the car. */
6588 if (EQ (ptr->u.s.u.cdr, Qnil)) 6588 if (NILP (ptr->u.s.u.cdr))
6589 { 6589 {
6590 obj = ptr->u.s.car; 6590 obj = ptr->u.s.car;
6591 cdr_count = 0; 6591 cdr_count = 0;
diff --git a/src/callint.c b/src/callint.c
index c6e003ed408..807e1cca9cc 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -200,7 +200,7 @@ fix_command (Lisp_Object input, Lisp_Object values)
200 carelt = XCAR (elt); 200 carelt = XCAR (elt);
201 /* If it is (if X Y), look at Y. */ 201 /* If it is (if X Y), look at Y. */
202 if (EQ (carelt, Qif) 202 if (EQ (carelt, Qif)
203 && EQ (Fnthcdr (make_number (3), elt), Qnil)) 203 && NILP (Fnthcdr (make_number (3), elt)))
204 elt = Fnth (make_number (2), elt); 204 elt = Fnth (make_number (2), elt);
205 /* If it is (when ... Y), look at Y. */ 205 /* If it is (when ... Y), look at Y. */
206 else if (EQ (carelt, Qwhen)) 206 else if (EQ (carelt, Qwhen))
diff --git a/src/character.c b/src/character.c
index 6a689808043..8920da2748f 100644
--- a/src/character.c
+++ b/src/character.c
@@ -34,6 +34,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
34#include "lisp.h" 34#include "lisp.h"
35#include "character.h" 35#include "character.h"
36#include "buffer.h" 36#include "buffer.h"
37#include "dispextern.h"
37#include "composite.h" 38#include "composite.h"
38#include "disptab.h" 39#include "disptab.h"
39 40
@@ -288,10 +289,15 @@ char_width (int c, struct Lisp_Char_Table *dp)
288 if (VECTORP (disp)) 289 if (VECTORP (disp))
289 for (i = 0, width = 0; i < ASIZE (disp); i++) 290 for (i = 0, width = 0; i < ASIZE (disp); i++)
290 { 291 {
292 int c = -1;
291 ch = AREF (disp, i); 293 ch = AREF (disp, i);
292 if (CHARACTERP (ch)) 294 if (GLYPH_CODE_P (ch))
295 c = GLYPH_CODE_CHAR (ch);
296 else if (CHARACTERP (ch))
297 c = XFASTINT (ch);
298 if (c >= 0)
293 { 299 {
294 int w = CHARACTER_WIDTH (XFASTINT (ch)); 300 int w = CHARACTER_WIDTH (c);
295 if (INT_ADD_WRAPV (width, w, &width)) 301 if (INT_ADD_WRAPV (width, w, &width))
296 string_overflow (); 302 string_overflow ();
297 } 303 }
diff --git a/src/chartab.c b/src/chartab.c
index 065ae4f9f20..89983503ac6 100644
--- a/src/chartab.c
+++ b/src/chartab.c
@@ -605,7 +605,7 @@ a cons of character codes (for characters in the range), or a character code. *
605 Lisp_Object val; 605 Lisp_Object val;
606 CHECK_CHAR_TABLE (char_table); 606 CHECK_CHAR_TABLE (char_table);
607 607
608 if (EQ (range, Qnil)) 608 if (NILP (range))
609 val = XCHAR_TABLE (char_table)->defalt; 609 val = XCHAR_TABLE (char_table)->defalt;
610 else if (CHARACTERP (range)) 610 else if (CHARACTERP (range))
611 val = CHAR_TABLE_REF (char_table, XFASTINT (range)); 611 val = CHAR_TABLE_REF (char_table, XFASTINT (range));
@@ -642,7 +642,7 @@ or a character code. Return VALUE. */)
642 for (i = 0; i < chartab_size[0]; i++) 642 for (i = 0; i < chartab_size[0]; i++)
643 set_char_table_contents (char_table, i, value); 643 set_char_table_contents (char_table, i, value);
644 } 644 }
645 else if (EQ (range, Qnil)) 645 else if (NILP (range))
646 set_char_table_defalt (char_table, value); 646 set_char_table_defalt (char_table, value);
647 else if (CHARACTERP (range)) 647 else if (CHARACTERP (range))
648 char_table_set (char_table, XINT (range), value); 648 char_table_set (char_table, XINT (range), value);
diff --git a/src/dbusbind.c b/src/dbusbind.c
index 4ebea5712a8..96429810e22 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -200,7 +200,7 @@ xd_symbol_to_dbus_type (Lisp_Object object)
200 `dbus-send-signal', into corresponding C values appended as 200 `dbus-send-signal', into corresponding C values appended as
201 arguments to a D-Bus message. */ 201 arguments to a D-Bus message. */
202#define XD_OBJECT_TO_DBUS_TYPE(object) \ 202#define XD_OBJECT_TO_DBUS_TYPE(object) \
203 ((EQ (object, Qt) || EQ (object, Qnil)) ? DBUS_TYPE_BOOLEAN \ 203 ((EQ (object, Qt) || NILP (object)) ? DBUS_TYPE_BOOLEAN \
204 : (NATNUMP (object)) ? DBUS_TYPE_UINT32 \ 204 : (NATNUMP (object)) ? DBUS_TYPE_UINT32 \
205 : (INTEGERP (object)) ? DBUS_TYPE_INT32 \ 205 : (INTEGERP (object)) ? DBUS_TYPE_INT32 \
206 : (FLOATP (object)) ? DBUS_TYPE_DOUBLE \ 206 : (FLOATP (object)) ? DBUS_TYPE_DOUBLE \
@@ -360,7 +360,7 @@ xd_signature (char *signature, int dtype, int parent_type, Lisp_Object object)
360 break; 360 break;
361 361
362 case DBUS_TYPE_BOOLEAN: 362 case DBUS_TYPE_BOOLEAN:
363 if (!EQ (object, Qt) && !EQ (object, Qnil)) 363 if (!EQ (object, Qt) && !NILP (object))
364 wrong_type_argument (intern ("booleanp"), object); 364 wrong_type_argument (intern ("booleanp"), object);
365 sprintf (signature, "%c", dtype); 365 sprintf (signature, "%c", dtype);
366 break; 366 break;
diff --git a/src/dired.c b/src/dired.c
index 5812c569fa6..472ec113d44 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -1058,7 +1058,7 @@ return a list with one element, taken from `user-real-login-name'. */)
1058 1058
1059 endpwent (); 1059 endpwent ();
1060#endif 1060#endif
1061 if (EQ (users, Qnil)) 1061 if (NILP (users))
1062 /* At least current user is always known. */ 1062 /* At least current user is always known. */
1063 users = list1 (Vuser_real_login_name); 1063 users = list1 (Vuser_real_login_name);
1064 return users; 1064 return users;
diff --git a/src/editfns.c b/src/editfns.c
index 4dbf4805721..0fbc5aad8c3 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -3256,21 +3256,9 @@ differences between the two buffers. */)
3256 Instead, we announce a single modification for the entire 3256 Instead, we announce a single modification for the entire
3257 modified region. But don't do that if the caller inhibited 3257 modified region. But don't do that if the caller inhibited
3258 modification hooks, because then they don't want that. */ 3258 modification hooks, because then they don't want that. */
3259 ptrdiff_t from, to;
3260 if (!inhibit_modification_hooks) 3259 if (!inhibit_modification_hooks)
3261 { 3260 {
3262 ptrdiff_t k, l; 3261 prepare_to_modify_buffer (BEGV, ZV, NULL);
3263
3264 /* Find the first character position to be changed. */
3265 for (k = 0; k < size_a && !bit_is_set (ctx.deletions, k); k++)
3266 ;
3267 from = BEGV + k;
3268
3269 /* Find the last character position to be changed. */
3270 for (l = size_a; l > 0 && !bit_is_set (ctx.deletions, l - 1); l--)
3271 ;
3272 to = BEGV + l;
3273 prepare_to_modify_buffer (from, to, NULL);
3274 specbind (Qinhibit_modification_hooks, Qt); 3262 specbind (Qinhibit_modification_hooks, Qt);
3275 modification_hooks_inhibited = true; 3263 modification_hooks_inhibited = true;
3276 } 3264 }
@@ -3322,9 +3310,8 @@ differences between the two buffers. */)
3322 3310
3323 if (modification_hooks_inhibited) 3311 if (modification_hooks_inhibited)
3324 { 3312 {
3325 ptrdiff_t updated_to = to + ZV - BEGV - size_a; 3313 signal_after_change (BEGV, size_a, ZV - BEGV);
3326 signal_after_change (from, to - from, updated_to - from); 3314 update_compositions (BEGV, ZV, CHECK_INSIDE);
3327 update_compositions (from, updated_to, CHECK_INSIDE);
3328 } 3315 }
3329 3316
3330 return Qnil; 3317 return Qnil;
@@ -4195,14 +4182,14 @@ Nth argument is substituted instead of the next one. A format can
4195contain either numbered or unnumbered %-sequences but not both, except 4182contain either numbered or unnumbered %-sequences but not both, except
4196that %% can be mixed with numbered %-sequences. 4183that %% can be mixed with numbered %-sequences.
4197 4184
4198The + flag character inserts a + before any positive number, while a 4185The + flag character inserts a + before any nonnegative number, while a
4199space inserts a space before any positive number; these flags only 4186space inserts a space before any nonnegative number; these flags
4200affect %d, %e, %f, and %g sequences, and the + flag takes precedence. 4187affect only numeric %-sequences, and the + flag takes precedence.
4201The - and 0 flags affect the width specifier, as described below. 4188The - and 0 flags affect the width specifier, as described below.
4202 4189
4203The # flag means to use an alternate display form for %o, %x, %X, %e, 4190The # flag means to use an alternate display form for %o, %x, %X, %e,
4204%f, and %g sequences: for %o, it ensures that the result begins with 4191%f, and %g sequences: for %o, it ensures that the result begins with
4205\"0\"; for %x and %X, it prefixes the result with \"0x\" or \"0X\"; 4192\"0\"; for %x and %X, it prefixes nonzero results with \"0x\" or \"0X\";
4206for %e and %f, it causes a decimal point to be included even if the 4193for %e and %f, it causes a decimal point to be included even if the
4207precision is zero; for %g, it causes a decimal point to be 4194precision is zero; for %g, it causes a decimal point to be
4208included even if the precision is zero, and also forces trailing 4195included even if the precision is zero, and also forces trailing
@@ -4736,10 +4723,22 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
4736 } 4723 }
4737 else 4724 else
4738 { 4725 {
4739 /* Don't sign-extend for octal or hex printing. */
4740 uprintmax_t x; 4726 uprintmax_t x;
4727 bool negative;
4741 if (INTEGERP (arg)) 4728 if (INTEGERP (arg))
4742 x = XUINT (arg); 4729 {
4730 if (binary_as_unsigned)
4731 {
4732 x = XUINT (arg);
4733 negative = false;
4734 }
4735 else
4736 {
4737 EMACS_INT i = XINT (arg);
4738 negative = i < 0;
4739 x = negative ? -i : i;
4740 }
4741 }
4743 else 4742 else
4744 { 4743 {
4745 double d = XFLOAT_DATA (arg); 4744 double d = XFLOAT_DATA (arg);
@@ -4747,8 +4746,13 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
4747 if (! (0 <= d && d < uprintmax + 1)) 4746 if (! (0 <= d && d < uprintmax + 1))
4748 xsignal1 (Qoverflow_error, arg); 4747 xsignal1 (Qoverflow_error, arg);
4749 x = d; 4748 x = d;
4749 negative = false;
4750 } 4750 }
4751 sprintf_bytes = sprintf (sprintf_buf, convspec, prec, x); 4751 sprintf_buf[0] = negative ? '-' : plus_flag ? '+' : ' ';
4752 bool signedp = negative | plus_flag | space_flag;
4753 sprintf_bytes = sprintf (sprintf_buf + signedp,
4754 convspec, prec, x);
4755 sprintf_bytes += signedp;
4752 } 4756 }
4753 4757
4754 /* Now the length of the formatted item is known, except it omits 4758 /* Now the length of the formatted item is known, except it omits
@@ -5558,6 +5562,22 @@ functions if all the text being accessed has this property. */);
5558 DEFVAR_LISP ("operating-system-release", Voperating_system_release, 5562 DEFVAR_LISP ("operating-system-release", Voperating_system_release,
5559 doc: /* The release of the operating system Emacs is running on. */); 5563 doc: /* The release of the operating system Emacs is running on. */);
5560 5564
5565 DEFVAR_BOOL ("binary-as-unsigned",
5566 binary_as_unsigned,
5567 doc: /* Non-nil means `format' %x and %o treat integers as unsigned.
5568This has machine-dependent results. Nil means to treat integers as
5569signed, which is portable; for example, if N is a negative integer,
5570(read (format "#x%x") N) returns N only when this variable is nil.
5571
5572This variable is experimental; email 32252@debbugs.gnu.org if you need
5573it to be non-nil. */);
5574 /* For now, default to true if bignums exist, false in traditional Emacs. */
5575#ifdef lisp_h_FIXNUMP
5576 binary_as_unsigned = false;
5577#else
5578 binary_as_unsigned = true;
5579#endif
5580
5561 defsubr (&Spropertize); 5581 defsubr (&Spropertize);
5562 defsubr (&Schar_equal); 5582 defsubr (&Schar_equal);
5563 defsubr (&Sgoto_char); 5583 defsubr (&Sgoto_char);
diff --git a/src/emacs.c b/src/emacs.c
index 861d70735ca..130a9f8fc8e 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -2019,6 +2019,10 @@ all of which are called before Emacs is actually killed. */
2019{ 2019{
2020 int exit_code; 2020 int exit_code;
2021 2021
2022#ifdef HAVE_LIBSYSTEMD
2023 sd_notify(0, "STOPPING=1");
2024#endif /* HAVE_LIBSYSTEMD */
2025
2022 /* Fsignal calls emacs_abort () if it sees that waiting_for_input is 2026 /* Fsignal calls emacs_abort () if it sees that waiting_for_input is
2023 set. */ 2027 set. */
2024 waiting_for_input = 0; 2028 waiting_for_input = 0;
@@ -2479,6 +2483,13 @@ from the parent process and its tty file descriptors. */)
2479 error ("This function can only be called after loading the init files"); 2483 error ("This function can only be called after loading the init files");
2480#ifndef WINDOWSNT 2484#ifndef WINDOWSNT
2481 2485
2486 if (daemon_type == 1)
2487 {
2488#ifdef HAVE_LIBSYSTEMD
2489 sd_notify(0, "READY=1");
2490#endif /* HAVE_LIBSYSTEMD */
2491 }
2492
2482 if (daemon_type == 2) 2493 if (daemon_type == 2)
2483 { 2494 {
2484 int nfd; 2495 int nfd;
diff --git a/src/eval.c b/src/eval.c
index 256ca8ffdc8..5964dd1867a 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1732,28 +1732,12 @@ xsignal3 (Lisp_Object error_symbol, Lisp_Object arg1, Lisp_Object arg2, Lisp_Obj
1732} 1732}
1733 1733
1734/* Signal `error' with message S, and additional arg ARG. 1734/* Signal `error' with message S, and additional arg ARG.
1735 If ARG is not a genuine list, make it a one-element list. */ 1735 If ARG is not a proper list, make it a one-element list. */
1736 1736
1737void 1737void
1738signal_error (const char *s, Lisp_Object arg) 1738signal_error (const char *s, Lisp_Object arg)
1739{ 1739{
1740 Lisp_Object tortoise, hare; 1740 if (NILP (Fproper_list_p (arg)))
1741
1742 hare = tortoise = arg;
1743 while (CONSP (hare))
1744 {
1745 hare = XCDR (hare);
1746 if (!CONSP (hare))
1747 break;
1748
1749 hare = XCDR (hare);
1750 tortoise = XCDR (tortoise);
1751
1752 if (EQ (hare, tortoise))
1753 break;
1754 }
1755
1756 if (!NILP (hare))
1757 arg = list1 (arg); 1741 arg = list1 (arg);
1758 1742
1759 xsignal (Qerror, Fcons (build_string (s), arg)); 1743 xsignal (Qerror, Fcons (build_string (s), arg));
diff --git a/src/fileio.c b/src/fileio.c
index 5a1c7ae10e5..2dcfb73b0d5 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -196,8 +196,8 @@ check_writable (const char *filename, int amode)
196 list before reporting it; this saves report_file_errno's caller the 196 list before reporting it; this saves report_file_errno's caller the
197 trouble of preserving errno before calling list1. */ 197 trouble of preserving errno before calling list1. */
198 198
199void 199Lisp_Object
200report_file_errno (char const *string, Lisp_Object name, int errorno) 200get_file_errno_data (char const *string, Lisp_Object name, int errorno)
201{ 201{
202 Lisp_Object data = CONSP (name) || NILP (name) ? name : list1 (name); 202 Lisp_Object data = CONSP (name) || NILP (name) ? name : list1 (name);
203 char *str = emacs_strerror (errorno); 203 char *str = emacs_strerror (errorno);
@@ -207,10 +207,18 @@ report_file_errno (char const *string, Lisp_Object name, int errorno)
207 Lisp_Object errdata = Fcons (errstring, data); 207 Lisp_Object errdata = Fcons (errstring, data);
208 208
209 if (errorno == EEXIST) 209 if (errorno == EEXIST)
210 xsignal (Qfile_already_exists, errdata); 210 return Fcons (Qfile_already_exists, errdata);
211 else 211 else
212 xsignal (errorno == ENOENT ? Qfile_missing : Qfile_error, 212 return Fcons (errorno == ENOENT ? Qfile_missing : Qfile_error,
213 Fcons (build_string (string), errdata)); 213 Fcons (build_string (string), errdata));
214}
215
216void
217report_file_errno (char const *string, Lisp_Object name, int errorno)
218{
219 Lisp_Object data = get_file_errno_data (string, name, errorno);
220
221 xsignal (Fcar (data), Fcdr (data));
214} 222}
215 223
216/* Signal a file-access failure that set errno. STRING describes the 224/* Signal a file-access failure that set errno. STRING describes the
@@ -2288,6 +2296,21 @@ The arg must be a string. */)
2288 if (!NILP (handler)) 2296 if (!NILP (handler))
2289 return call2 (handler, Qfile_name_case_insensitive_p, filename); 2297 return call2 (handler, Qfile_name_case_insensitive_p, filename);
2290 2298
2299 /* If the file doesn't exist, move up the filesystem tree until we
2300 reach an existing directory or the root. */
2301 if (NILP (Ffile_exists_p (filename)))
2302 {
2303 filename = Ffile_name_directory (filename);
2304 while (NILP (Ffile_exists_p (filename)))
2305 {
2306 Lisp_Object newname = expand_and_dir_to_file (filename);
2307 /* Avoid infinite loop if the root is reported as non-existing
2308 (impossible?). */
2309 if (!NILP (Fstring_equal (newname, filename)))
2310 break;
2311 filename = newname;
2312 }
2313 }
2291 filename = ENCODE_FILE (filename); 2314 filename = ENCODE_FILE (filename);
2292 return file_name_case_insensitive_p (SSDATA (filename)) ? Qt : Qnil; 2315 return file_name_case_insensitive_p (SSDATA (filename)) ? Qt : Qnil;
2293} 2316}
@@ -5714,7 +5737,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */)
5714 spare the user annoying messages. */ 5737 spare the user annoying messages. */
5715 && XFASTINT (BVAR (b, save_length)) > 5000 5738 && XFASTINT (BVAR (b, save_length)) > 5000
5716 /* These messages are frequent and annoying for `*mail*'. */ 5739 /* These messages are frequent and annoying for `*mail*'. */
5717 && !EQ (BVAR (b, filename), Qnil) 5740 && !NILP (BVAR (b, filename))
5718 && NILP (no_message)) 5741 && NILP (no_message))
5719 { 5742 {
5720 /* It has shrunk too much; turn off auto-saving here. */ 5743 /* It has shrunk too much; turn off auto-saving here. */
diff --git a/src/fns.c b/src/fns.c
index c171784d290..5247140ead4 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -144,6 +144,28 @@ which is at least the number of distinct elements. */)
144 return make_fixnum_or_float (len); 144 return make_fixnum_or_float (len);
145} 145}
146 146
147DEFUN ("proper-list-p", Fproper_list_p, Sproper_list_p, 1, 1, 0,
148 doc: /* Return OBJECT's length if it is a proper list, nil otherwise.
149A proper list is neither circular nor dotted (i.e., its last cdr is nil). */
150 attributes: const)
151 (Lisp_Object object)
152{
153 intptr_t len = 0;
154 Lisp_Object last_tail = object;
155 Lisp_Object tail = object;
156 FOR_EACH_TAIL_SAFE (tail)
157 {
158 len++;
159 rarely_quit (len);
160 last_tail = XCDR (tail);
161 }
162 if (!NILP (last_tail))
163 return Qnil;
164 if (MOST_POSITIVE_FIXNUM < len)
165 xsignal0 (Qoverflow_error);
166 return make_number (len);
167}
168
147DEFUN ("string-bytes", Fstring_bytes, Sstring_bytes, 1, 1, 0, 169DEFUN ("string-bytes", Fstring_bytes, Sstring_bytes, 1, 1, 0,
148 doc: /* Return the number of bytes in STRING. 170 doc: /* Return the number of bytes in STRING.
149If STRING is multibyte, this may be greater than the length of STRING. */) 171If STRING is multibyte, this may be greater than the length of STRING. */)
@@ -718,7 +740,7 @@ concat (ptrdiff_t nargs, Lisp_Object *args,
718 val = make_uninit_string (result_len); 740 val = make_uninit_string (result_len);
719 741
720 /* In `append', if all but last arg are nil, return last arg. */ 742 /* In `append', if all but last arg are nil, return last arg. */
721 if (target_type == Lisp_Cons && EQ (val, Qnil)) 743 if (target_type == Lisp_Cons && NILP (val))
722 return last_tail; 744 return last_tail;
723 745
724 /* Copy the contents of the args into the result. */ 746 /* Copy the contents of the args into the result. */
@@ -1419,6 +1441,29 @@ DEFUN ("elt", Felt, Selt, 2, 2, 0,
1419 return Faref (sequence, n); 1441 return Faref (sequence, n);
1420} 1442}
1421 1443
1444enum { WORDS_PER_DOUBLE = (sizeof (double) / sizeof (EMACS_UINT)
1445 + (sizeof (double) % sizeof (EMACS_UINT) != 0)) };
1446union double_and_words
1447{
1448 double val;
1449 EMACS_UINT word[WORDS_PER_DOUBLE];
1450};
1451
1452/* Return true if X and Y are the same floating-point value.
1453 This looks at X's and Y's representation, since (unlike '==')
1454 it returns true if X and Y are the same NaN. */
1455static bool
1456same_float (Lisp_Object x, Lisp_Object y)
1457{
1458 union double_and_words
1459 xu = { .val = XFLOAT_DATA (x) },
1460 yu = { .val = XFLOAT_DATA (y) };
1461 EMACS_UINT neql = 0;
1462 for (int i = 0; i < WORDS_PER_DOUBLE; i++)
1463 neql |= xu.word[i] ^ yu.word[i];
1464 return !neql;
1465}
1466
1422DEFUN ("member", Fmember, Smember, 2, 2, 0, 1467DEFUN ("member", Fmember, Smember, 2, 2, 0,
1423 doc: /* Return non-nil if ELT is an element of LIST. Comparison done with `equal'. 1468 doc: /* Return non-nil if ELT is an element of LIST. Comparison done with `equal'.
1424The value is actually the tail of LIST whose car is ELT. */) 1469The value is actually the tail of LIST whose car is ELT. */)
@@ -1457,7 +1502,7 @@ The value is actually the tail of LIST whose car is ELT. */)
1457 FOR_EACH_TAIL (tail) 1502 FOR_EACH_TAIL (tail)
1458 { 1503 {
1459 Lisp_Object tem = XCAR (tail); 1504 Lisp_Object tem = XCAR (tail);
1460 if (FLOATP (tem) && equal_no_quit (elt, tem)) 1505 if (FLOATP (tem) && same_float (elt, tem))
1461 return tail; 1506 return tail;
1462 } 1507 }
1463 CHECK_LIST_END (tail, list); 1508 CHECK_LIST_END (tail, list);
@@ -2170,12 +2215,14 @@ The PLIST is modified by side effects. */)
2170} 2215}
2171 2216
2172DEFUN ("eql", Feql, Seql, 2, 2, 0, 2217DEFUN ("eql", Feql, Seql, 2, 2, 0,
2173 doc: /* Return t if the two args are the same Lisp object. 2218 doc: /* Return t if the two args are `eq' or are indistinguishable numbers.
2174Floating-point numbers of equal value are `eql', but they may not be `eq'. */) 2219Floating-point values with the same sign, exponent and fraction are `eql'.
2220This differs from numeric comparison: (eql 0.0 -0.0) returns nil and
2221\(eql 0.0e+NaN 0.0e+NaN) returns t, whereas `=' does the opposite. */)
2175 (Lisp_Object obj1, Lisp_Object obj2) 2222 (Lisp_Object obj1, Lisp_Object obj2)
2176{ 2223{
2177 if (FLOATP (obj1)) 2224 if (FLOATP (obj1))
2178 return equal_no_quit (obj1, obj2) ? Qt : Qnil; 2225 return FLOATP (obj2) && same_float (obj1, obj2) ? Qt : Qnil;
2179 else 2226 else
2180 return EQ (obj1, obj2) ? Qt : Qnil; 2227 return EQ (obj1, obj2) ? Qt : Qnil;
2181} 2228}
@@ -2185,8 +2232,8 @@ DEFUN ("equal", Fequal, Sequal, 2, 2, 0,
2185They must have the same data type. 2232They must have the same data type.
2186Conses are compared by comparing the cars and the cdrs. 2233Conses are compared by comparing the cars and the cdrs.
2187Vectors and strings are compared element by element. 2234Vectors and strings are compared element by element.
2188Numbers are compared by value, but integers cannot equal floats. 2235Numbers are compared via `eql', so integers do not equal floats.
2189 (Use `=' if you want integers and floats to be able to be equal.) 2236\(Use `=' if you want integers and floats to be able to be equal.)
2190Symbols must match exactly. */) 2237Symbols must match exactly. */)
2191 (Lisp_Object o1, Lisp_Object o2) 2238 (Lisp_Object o1, Lisp_Object o2)
2192{ 2239{
@@ -2266,13 +2313,7 @@ internal_equal (Lisp_Object o1, Lisp_Object o2, enum equal_kind equal_kind,
2266 switch (XTYPE (o1)) 2313 switch (XTYPE (o1))
2267 { 2314 {
2268 case Lisp_Float: 2315 case Lisp_Float:
2269 { 2316 return same_float (o1, o2);
2270 double d1 = XFLOAT_DATA (o1);
2271 double d2 = XFLOAT_DATA (o2);
2272 /* If d is a NaN, then d != d. Two NaNs should be `equal' even
2273 though they are not =. */
2274 return d1 == d2 || (d1 != d1 && d2 != d2);
2275 }
2276 2317
2277 case Lisp_Cons: 2318 case Lisp_Cons:
2278 if (equal_kind == EQUAL_NO_QUIT) 2319 if (equal_kind == EQUAL_NO_QUIT)
@@ -3706,24 +3747,20 @@ HASH_INDEX (struct Lisp_Hash_Table *h, ptrdiff_t idx)
3706 return XINT (AREF (h->index, idx)); 3747 return XINT (AREF (h->index, idx));
3707} 3748}
3708 3749
3709/* Compare KEY1 which has hash code HASH1 and KEY2 with hash code 3750/* Compare KEY1 and KEY2 in hash table HT using `eql'. Value is true
3710 HASH2 in hash table H using `eql'. Value is true if KEY1 and 3751 if KEY1 and KEY2 are the same. KEY1 and KEY2 must not be eq. */
3711 KEY2 are the same. */
3712 3752
3713static bool 3753static bool
3714cmpfn_eql (struct hash_table_test *ht, 3754cmpfn_eql (struct hash_table_test *ht,
3715 Lisp_Object key1, 3755 Lisp_Object key1,
3716 Lisp_Object key2) 3756 Lisp_Object key2)
3717{ 3757{
3718 return (FLOATP (key1) 3758 return FLOATP (key1) && FLOATP (key2) && same_float (key1, key2);
3719 && FLOATP (key2)
3720 && XFLOAT_DATA (key1) == XFLOAT_DATA (key2));
3721} 3759}
3722 3760
3723 3761
3724/* Compare KEY1 which has hash code HASH1 and KEY2 with hash code 3762/* Compare KEY1 and KEY2 in hash table HT using `equal'. Value is
3725 HASH2 in hash table H using `equal'. Value is true if KEY1 and 3763 true if KEY1 and KEY2 are the same. */
3726 KEY2 are the same. */
3727 3764
3728static bool 3765static bool
3729cmpfn_equal (struct hash_table_test *ht, 3766cmpfn_equal (struct hash_table_test *ht,
@@ -3734,9 +3771,8 @@ cmpfn_equal (struct hash_table_test *ht,
3734} 3771}
3735 3772
3736 3773
3737/* Compare KEY1 which has hash code HASH1, and KEY2 with hash code 3774/* Compare KEY1 and KEY2 in hash table HT using HT->user_cmp_function.
3738 HASH2 in hash table H using H->user_cmp_function. Value is true 3775 Value is true if KEY1 and KEY2 are the same. */
3739 if KEY1 and KEY2 are the same. */
3740 3776
3741static bool 3777static bool
3742cmpfn_user_defined (struct hash_table_test *ht, 3778cmpfn_user_defined (struct hash_table_test *ht,
@@ -4328,18 +4364,8 @@ static EMACS_UINT
4328sxhash_float (double val) 4364sxhash_float (double val)
4329{ 4365{
4330 EMACS_UINT hash = 0; 4366 EMACS_UINT hash = 0;
4331 enum { 4367 union double_and_words u = { .val = val };
4332 WORDS_PER_DOUBLE = (sizeof val / sizeof hash 4368 for (int i = 0; i < WORDS_PER_DOUBLE; i++)
4333 + (sizeof val % sizeof hash != 0))
4334 };
4335 union {
4336 double val;
4337 EMACS_UINT word[WORDS_PER_DOUBLE];
4338 } u;
4339 int i;
4340 u.val = val;
4341 memset (&u.val + 1, 0, sizeof u - sizeof u.val);
4342 for (i = 0; i < WORDS_PER_DOUBLE; i++)
4343 hash = sxhash_combine (hash, u.word[i]); 4369 hash = sxhash_combine (hash, u.word[i]);
4344 return SXHASH_REDUCE (hash); 4370 return SXHASH_REDUCE (hash);
4345} 4371}
@@ -5291,6 +5317,7 @@ this variable. */);
5291 defsubr (&Srandom); 5317 defsubr (&Srandom);
5292 defsubr (&Slength); 5318 defsubr (&Slength);
5293 defsubr (&Ssafe_length); 5319 defsubr (&Ssafe_length);
5320 defsubr (&Sproper_list_p);
5294 defsubr (&Sstring_bytes); 5321 defsubr (&Sstring_bytes);
5295 defsubr (&Sstring_distance); 5322 defsubr (&Sstring_distance);
5296 defsubr (&Sstring_equal); 5323 defsubr (&Sstring_equal);
diff --git a/src/frame.c b/src/frame.c
index d477c1acc3f..85ec7401d6e 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -139,14 +139,9 @@ check_window_system (struct frame *f)
139/* Return the value of frame parameter PROP in frame FRAME. */ 139/* Return the value of frame parameter PROP in frame FRAME. */
140 140
141Lisp_Object 141Lisp_Object
142get_frame_param (register struct frame *frame, Lisp_Object prop) 142get_frame_param (struct frame *frame, Lisp_Object prop)
143{ 143{
144 register Lisp_Object tem; 144 return Fcdr (Fassq (prop, frame->param_alist));
145
146 tem = Fassq (prop, frame->param_alist);
147 if (EQ (tem, Qnil))
148 return tem;
149 return Fcdr (tem);
150} 145}
151 146
152 147
@@ -189,9 +184,9 @@ frame_inhibit_resize (struct frame *f, bool horizontal, Lisp_Object parameter)
189 || (CONSP (frame_inhibit_implied_resize) 184 || (CONSP (frame_inhibit_implied_resize)
190 && !NILP (Fmemq (parameter, frame_inhibit_implied_resize))) 185 && !NILP (Fmemq (parameter, frame_inhibit_implied_resize)))
191 || (horizontal 186 || (horizontal
192 && !EQ (fullscreen, Qnil) && !EQ (fullscreen, Qfullheight)) 187 && !NILP (fullscreen) && !EQ (fullscreen, Qfullheight))
193 || (!horizontal 188 || (!horizontal
194 && !EQ (fullscreen, Qnil) && !EQ (fullscreen, Qfullwidth)) 189 && !NILP (fullscreen) && !EQ (fullscreen, Qfullwidth))
195 || FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f)) 190 || FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f))
196 : ((horizontal && f->inhibit_horizontal_resize) 191 : ((horizontal && f->inhibit_horizontal_resize)
197 || (!horizontal && f->inhibit_vertical_resize))); 192 || (!horizontal && f->inhibit_vertical_resize)));
@@ -2808,10 +2803,8 @@ frames_discard_buffer (Lisp_Object buffer)
2808void 2803void
2809store_in_alist (Lisp_Object *alistptr, Lisp_Object prop, Lisp_Object val) 2804store_in_alist (Lisp_Object *alistptr, Lisp_Object prop, Lisp_Object val)
2810{ 2805{
2811 register Lisp_Object tem; 2806 Lisp_Object tem = Fassq (prop, *alistptr);
2812 2807 if (NILP (tem))
2813 tem = Fassq (prop, *alistptr);
2814 if (EQ (tem, Qnil))
2815 *alistptr = Fcons (Fcons (prop, val), *alistptr); 2808 *alistptr = Fcons (Fcons (prop, val), *alistptr);
2816 else 2809 else
2817 Fsetcdr (tem, val); 2810 Fsetcdr (tem, val);
@@ -2975,7 +2968,7 @@ store_frame_param (struct frame *f, Lisp_Object prop, Lisp_Object val)
2975 2968
2976 /* Update the frame parameter alist. */ 2969 /* Update the frame parameter alist. */
2977 old_alist_elt = Fassq (prop, f->param_alist); 2970 old_alist_elt = Fassq (prop, f->param_alist);
2978 if (EQ (old_alist_elt, Qnil)) 2971 if (NILP (old_alist_elt))
2979 fset_param_alist (f, Fcons (Fcons (prop, val), f->param_alist)); 2972 fset_param_alist (f, Fcons (Fcons (prop, val), f->param_alist));
2980 else 2973 else
2981 Fsetcdr (old_alist_elt, val); 2974 Fsetcdr (old_alist_elt, val);
@@ -4516,13 +4509,13 @@ x_set_visibility (struct frame *f, Lisp_Object value, Lisp_Object oldval)
4516void 4509void
4517x_set_autoraise (struct frame *f, Lisp_Object arg, Lisp_Object oldval) 4510x_set_autoraise (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
4518{ 4511{
4519 f->auto_raise = !EQ (Qnil, arg); 4512 f->auto_raise = !NILP (arg);
4520} 4513}
4521 4514
4522void 4515void
4523x_set_autolower (struct frame *f, Lisp_Object arg, Lisp_Object oldval) 4516x_set_autolower (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
4524{ 4517{
4525 f->auto_lower = !EQ (Qnil, arg); 4518 f->auto_lower = !NILP (arg);
4526} 4519}
4527 4520
4528void 4521void
@@ -4973,7 +4966,7 @@ x_get_arg (Display_Info *dpyinfo, Lisp_Object alist, Lisp_Object param,
4973 4966
4974 /* If it wasn't specified in ALIST or the Lisp-level defaults, 4967 /* If it wasn't specified in ALIST or the Lisp-level defaults,
4975 look in the X resources. */ 4968 look in the X resources. */
4976 if (EQ (tem, Qnil)) 4969 if (NILP (tem))
4977 { 4970 {
4978 if (attribute && dpyinfo) 4971 if (attribute && dpyinfo)
4979 { 4972 {
diff --git a/src/gnutls.c b/src/gnutls.c
index d7a4ee474f7..4e98f16f484 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -2071,7 +2071,14 @@ gnutls_symmetric (bool encrypting, Lisp_Object cipher,
2071 cipher = intern (SSDATA (cipher)); 2071 cipher = intern (SSDATA (cipher));
2072 2072
2073 if (SYMBOLP (cipher)) 2073 if (SYMBOLP (cipher))
2074 info = XCDR (Fassq (cipher, Fgnutls_ciphers ())); 2074 {
2075 info = Fassq (cipher, Fgnutls_ciphers ());
2076 if (!CONSP (info))
2077 xsignal2 (Qerror,
2078 build_string ("GnuTLS cipher is invalid or not found"),
2079 cipher);
2080 info = XCDR (info);
2081 }
2075 else if (TYPE_RANGED_INTEGERP (gnutls_cipher_algorithm_t, cipher)) 2082 else if (TYPE_RANGED_INTEGERP (gnutls_cipher_algorithm_t, cipher))
2076 gca = XINT (cipher); 2083 gca = XINT (cipher);
2077 else 2084 else
@@ -2086,7 +2093,8 @@ gnutls_symmetric (bool encrypting, Lisp_Object cipher,
2086 2093
2087 ptrdiff_t key_size = gnutls_cipher_get_key_size (gca); 2094 ptrdiff_t key_size = gnutls_cipher_get_key_size (gca);
2088 if (key_size == 0) 2095 if (key_size == 0)
2089 error ("GnuTLS cipher is invalid or not found"); 2096 xsignal2 (Qerror,
2097 build_string ("GnuTLS cipher is invalid or not found"), cipher);
2090 2098
2091 ptrdiff_t kstart_byte, kend_byte; 2099 ptrdiff_t kstart_byte, kend_byte;
2092 const char *kdata = extract_data_from_object (key, &kstart_byte, &kend_byte); 2100 const char *kdata = extract_data_from_object (key, &kstart_byte, &kend_byte);
@@ -2342,7 +2350,14 @@ itself. */)
2342 hash_method = intern (SSDATA (hash_method)); 2350 hash_method = intern (SSDATA (hash_method));
2343 2351
2344 if (SYMBOLP (hash_method)) 2352 if (SYMBOLP (hash_method))
2345 info = XCDR (Fassq (hash_method, Fgnutls_macs ())); 2353 {
2354 info = Fassq (hash_method, Fgnutls_macs ());
2355 if (!CONSP (info))
2356 xsignal2 (Qerror,
2357 build_string ("GnuTLS MAC-method is invalid or not found"),
2358 hash_method);
2359 info = XCDR (info);
2360 }
2346 else if (TYPE_RANGED_INTEGERP (gnutls_mac_algorithm_t, hash_method)) 2361 else if (TYPE_RANGED_INTEGERP (gnutls_mac_algorithm_t, hash_method))
2347 gma = XINT (hash_method); 2362 gma = XINT (hash_method);
2348 else 2363 else
@@ -2357,7 +2372,9 @@ itself. */)
2357 2372
2358 ptrdiff_t digest_length = gnutls_hmac_get_len (gma); 2373 ptrdiff_t digest_length = gnutls_hmac_get_len (gma);
2359 if (digest_length == 0) 2374 if (digest_length == 0)
2360 error ("GnuTLS MAC-method is invalid or not found"); 2375 xsignal2 (Qerror,
2376 build_string ("GnuTLS MAC-method is invalid or not found"),
2377 hash_method);
2361 2378
2362 ptrdiff_t kstart_byte, kend_byte; 2379 ptrdiff_t kstart_byte, kend_byte;
2363 const char *kdata = extract_data_from_object (key, &kstart_byte, &kend_byte); 2380 const char *kdata = extract_data_from_object (key, &kstart_byte, &kend_byte);
@@ -2423,7 +2440,14 @@ the number itself. */)
2423 digest_method = intern (SSDATA (digest_method)); 2440 digest_method = intern (SSDATA (digest_method));
2424 2441
2425 if (SYMBOLP (digest_method)) 2442 if (SYMBOLP (digest_method))
2426 info = XCDR (Fassq (digest_method, Fgnutls_digests ())); 2443 {
2444 info = Fassq (digest_method, Fgnutls_digests ());
2445 if (!CONSP (info))
2446 xsignal2 (Qerror,
2447 build_string ("GnuTLS digest-method is invalid or not found"),
2448 digest_method);
2449 info = XCDR (info);
2450 }
2427 else if (TYPE_RANGED_INTEGERP (gnutls_digest_algorithm_t, digest_method)) 2451 else if (TYPE_RANGED_INTEGERP (gnutls_digest_algorithm_t, digest_method))
2428 gda = XINT (digest_method); 2452 gda = XINT (digest_method);
2429 else 2453 else
@@ -2438,7 +2462,9 @@ the number itself. */)
2438 2462
2439 ptrdiff_t digest_length = gnutls_hash_get_len (gda); 2463 ptrdiff_t digest_length = gnutls_hash_get_len (gda);
2440 if (digest_length == 0) 2464 if (digest_length == 0)
2441 error ("GnuTLS digest-method is invalid or not found"); 2465 xsignal2 (Qerror,
2466 build_string ("GnuTLS digest-method is invalid or not found"),
2467 digest_method);
2442 2468
2443 gnutls_hash_hd_t hash; 2469 gnutls_hash_hd_t hash;
2444 int ret = gnutls_hash_init (&hash, gda); 2470 int ret = gnutls_hash_init (&hash, gda);
diff --git a/src/image.c b/src/image.c
index 992b225d7b7..a83f0641aba 100644
--- a/src/image.c
+++ b/src/image.c
@@ -1610,7 +1610,7 @@ Anything else, means only clear those images which refer to FILTER,
1610which is then usually a filename. */) 1610which is then usually a filename. */)
1611 (Lisp_Object filter) 1611 (Lisp_Object filter)
1612{ 1612{
1613 if (!(EQ (filter, Qnil) || FRAMEP (filter))) 1613 if (! (NILP (filter) || FRAMEP (filter)))
1614 clear_image_caches (filter); 1614 clear_image_caches (filter);
1615 else 1615 else
1616 clear_image_cache (decode_window_system_frame (filter), Qt); 1616 clear_image_cache (decode_window_system_frame (filter), Qt);
diff --git a/src/intervals.c b/src/intervals.c
index 4c624ea79c1..c3e137cc38c 100644
--- a/src/intervals.c
+++ b/src/intervals.c
@@ -197,7 +197,7 @@ intervals_equal (INTERVAL i0, INTERVAL i1)
197 } 197 }
198 198
199 /* i0 has something i1 doesn't. */ 199 /* i0 has something i1 doesn't. */
200 if (EQ (i1_val, Qnil)) 200 if (NILP (i1_val))
201 return false; 201 return false;
202 202
203 /* i0 and i1 both have sym, but it has different values in each. */ 203 /* i0 and i1 both have sym, but it has different values in each. */
diff --git a/src/intervals.h b/src/intervals.h
index 162c4efc62e..f37372a42c8 100644
--- a/src/intervals.h
+++ b/src/intervals.h
@@ -116,7 +116,7 @@ struct interval
116 116
117/* True if this is a default interval, which is the same as being null 117/* True if this is a default interval, which is the same as being null
118 or having no properties. */ 118 or having no properties. */
119#define DEFAULT_INTERVAL_P(i) (!i || EQ ((i)->plist, Qnil)) 119#define DEFAULT_INTERVAL_P(i) (!i || NILP ((i)->plist))
120 120
121/* Test what type of parent we have. Three possibilities: another 121/* Test what type of parent we have. Three possibilities: another
122 interval, a buffer or string object, or NULL. */ 122 interval, a buffer or string object, or NULL. */
diff --git a/src/json.c b/src/json.c
index ea941d7bb5d..afdd9a25481 100644
--- a/src/json.c
+++ b/src/json.c
@@ -7,7 +7,7 @@ This file is part of GNU Emacs.
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 3 of the License, or (at 9the Free Software Foundation, either version 3 of the License, or (at
10nyour option) any later version. 10your option) any 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,
13but WITHOUT ANY WARRANTY; without even the implied warranty of 13but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/src/keyboard.c b/src/keyboard.c
index aa58e268435..7ab9a6069ad 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -3150,6 +3150,10 @@ help_char_p (Lisp_Object c)
3150static void 3150static void
3151record_char (Lisp_Object c) 3151record_char (Lisp_Object c)
3152{ 3152{
3153 /* quail.el binds this to avoid recording keys twice. */
3154 if (inhibit_record_char)
3155 return;
3156
3153 int recorded = 0; 3157 int recorded = 0;
3154 3158
3155 if (CONSP (c) && (EQ (XCAR (c), Qhelp_echo) || EQ (XCAR (c), Qmouse_movement))) 3159 if (CONSP (c) && (EQ (XCAR (c), Qhelp_echo) || EQ (XCAR (c), Qmouse_movement)))
@@ -3256,7 +3260,7 @@ record_char (Lisp_Object c)
3256 /* Write c to the dribble file. If c is a lispy event, write 3260 /* Write c to the dribble file. If c is a lispy event, write
3257 the event's symbol to the dribble file, in <brackets>. Bleaugh. 3261 the event's symbol to the dribble file, in <brackets>. Bleaugh.
3258 If you, dear reader, have a better idea, you've got the source. :-) */ 3262 If you, dear reader, have a better idea, you've got the source. :-) */
3259 if (dribble) 3263 if (dribble && NILP (Vexecuting_kbd_macro))
3260 { 3264 {
3261 block_input (); 3265 block_input ();
3262 if (INTEGERP (c)) 3266 if (INTEGERP (c))
@@ -10110,10 +10114,13 @@ DEFUN ("recursion-depth", Frecursion_depth, Srecursion_depth, 0, 0, 0,
10110 10114
10111DEFUN ("open-dribble-file", Fopen_dribble_file, Sopen_dribble_file, 1, 1, 10115DEFUN ("open-dribble-file", Fopen_dribble_file, Sopen_dribble_file, 1, 1,
10112 "FOpen dribble file: ", 10116 "FOpen dribble file: ",
10113 doc: /* Start writing all keyboard characters to a dribble file called FILE. 10117 doc: /* Start writing input events to a dribble file called FILE.
10114If FILE is nil, close any open dribble file. 10118If FILE is nil, close any open dribble file.
10115The file will be closed when Emacs exits. 10119The file will be closed when Emacs exits.
10116 10120
10121The events written to the file include keyboard and mouse input
10122events, but not events from executing keyboard macros.
10123
10117Be aware that this records ALL characters you type! 10124Be aware that this records ALL characters you type!
10118This may include sensitive information such as passwords. */) 10125This may include sensitive information such as passwords. */)
10119 (Lisp_Object file) 10126 (Lisp_Object file)
@@ -11813,10 +11820,10 @@ if the command is in this list, the selection is not updated. */);
11813 11820
11814 DEFVAR_LISP ("debug-on-event", 11821 DEFVAR_LISP ("debug-on-event",
11815 Vdebug_on_event, 11822 Vdebug_on_event,
11816 doc: /* Enter debugger on this event. When Emacs 11823 doc: /* Enter debugger on this event.
11817receives the special event specified by this variable, it will try to 11824When Emacs receives the special event specified by this variable,
11818break into the debugger as soon as possible instead of processing the 11825it will try to break into the debugger as soon as possible instead
11819event normally through `special-event-map'. 11826of processing the event normally through `special-event-map'.
11820 11827
11821Currently, the only supported values for this 11828Currently, the only supported values for this
11822variable are `sigusr1' and `sigusr2'. */); 11829variable are `sigusr1' and `sigusr2'. */);
@@ -11824,21 +11831,23 @@ variable are `sigusr1' and `sigusr2'. */);
11824 11831
11825 DEFVAR_BOOL ("attempt-stack-overflow-recovery", 11832 DEFVAR_BOOL ("attempt-stack-overflow-recovery",
11826 attempt_stack_overflow_recovery, 11833 attempt_stack_overflow_recovery,
11827 doc: /* If non-nil, attempt to recover from C stack 11834 doc: /* If non-nil, attempt to recover from C stack overflows.
11828overflow. This recovery is unsafe and may lead to deadlocks or data 11835This recovery is potentially unsafe and may lead to deadlocks or data
11829corruption, but it usually works and may preserve modified buffers 11836corruption, but it usually works and may preserve modified buffers
11830that would otherwise be lost. If nil, treat stack overflow like any 11837that would otherwise be lost. If nil, treat stack overflow like any
11831other kind of crash. */); 11838other kind of crash or fatal error. */);
11832 attempt_stack_overflow_recovery = true; 11839 attempt_stack_overflow_recovery = true;
11833 11840
11834 DEFVAR_BOOL ("attempt-orderly-shutdown-on-fatal-signal", 11841 DEFVAR_BOOL ("attempt-orderly-shutdown-on-fatal-signal",
11835 attempt_orderly_shutdown_on_fatal_signal, 11842 attempt_orderly_shutdown_on_fatal_signal,
11836 doc: /* If non-nil, attempt to perform an orderly 11843 doc: /* If non-nil, attempt orderly shutdown on fatal signals.
11837shutdown when Emacs receives a fatal signal (e.g., a crash). 11844By default this variable is non-nil, and Emacs attempts to perform
11838This cleanup is unsafe and may lead to deadlocks or data corruption, 11845an orderly shutdown when it catches a fatal signal (e.g., a crash).
11839but it usually works and may preserve modified buffers that would 11846The orderly shutdown includes an attempt to auto-save your unsaved edits
11840otherwise be lost. If nil, crash immediately in response to fatal 11847and other useful cleanups. These cleanups are potentially unsafe and may
11841signals. */); 11848lead to deadlocks or data corruption, but it usually works and may
11849preserve data in modified buffers that would otherwise be lost.
11850If nil, Emacs crashes immediately in response to fatal signals. */);
11842 attempt_orderly_shutdown_on_fatal_signal = true; 11851 attempt_orderly_shutdown_on_fatal_signal = true;
11843 11852
11844 /* Create the initial keyboard. Qt means 'unset'. */ 11853 /* Create the initial keyboard. Qt means 'unset'. */
@@ -11848,6 +11857,14 @@ signals. */);
11848 Vwhile_no_input_ignore_events, 11857 Vwhile_no_input_ignore_events,
11849 doc: /* Ignored events from while-no-input. */); 11858 doc: /* Ignored events from while-no-input. */);
11850 Vwhile_no_input_ignore_events = Qnil; 11859 Vwhile_no_input_ignore_events = Qnil;
11860
11861 DEFVAR_BOOL ("inhibit--record-char",
11862 inhibit_record_char,
11863 doc: /* If non-nil, don't record input events.
11864This inhibits recording input events for the purposes of keyboard
11865macros, dribble file, and `recent-keys'.
11866Internal use only. */);
11867 inhibit_record_char = false;
11851} 11868}
11852 11869
11853void 11870void
diff --git a/src/lisp.h b/src/lisp.h
index 731a45da11a..96de60e4670 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4015,6 +4015,7 @@ extern Lisp_Object write_region (Lisp_Object, Lisp_Object, Lisp_Object,
4015extern void close_file_unwind (int); 4015extern void close_file_unwind (int);
4016extern void fclose_unwind (void *); 4016extern void fclose_unwind (void *);
4017extern void restore_point_unwind (Lisp_Object); 4017extern void restore_point_unwind (Lisp_Object);
4018extern Lisp_Object get_file_errno_data (const char *, Lisp_Object, int);
4018extern _Noreturn void report_file_errno (const char *, Lisp_Object, int); 4019extern _Noreturn void report_file_errno (const char *, Lisp_Object, int);
4019extern _Noreturn void report_file_error (const char *, Lisp_Object); 4020extern _Noreturn void report_file_error (const char *, Lisp_Object);
4020extern _Noreturn void report_file_notify_error (const char *, Lisp_Object); 4021extern _Noreturn void report_file_notify_error (const char *, Lisp_Object);
@@ -4698,7 +4699,7 @@ enum
4698#define FOR_EACH_TAIL(tail) \ 4699#define FOR_EACH_TAIL(tail) \
4699 FOR_EACH_TAIL_INTERNAL (tail, circular_list (tail), true) 4700 FOR_EACH_TAIL_INTERNAL (tail, circular_list (tail), true)
4700 4701
4701/* Like FOR_EACH_TAIL (LIST), except do not signal or quit. 4702/* Like FOR_EACH_TAIL (TAIL), except do not signal or quit.
4702 If the loop exits due to a cycle, TAIL’s value is undefined. */ 4703 If the loop exits due to a cycle, TAIL’s value is undefined. */
4703 4704
4704#define FOR_EACH_TAIL_SAFE(tail) \ 4705#define FOR_EACH_TAIL_SAFE(tail) \
diff --git a/src/lread.c b/src/lread.c
index 4ce6a442c36..50fc6ef8f3a 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -3603,7 +3603,7 @@ substitute_object_recurse (struct subst *subst, Lisp_Object subtree)
3603 return subtree; 3603 return subtree;
3604 3604
3605 /* If we've been to this node before, don't explore it again. */ 3605 /* If we've been to this node before, don't explore it again. */
3606 if (!EQ (Qnil, Fmemq (subtree, subst->seen))) 3606 if (!NILP (Fmemq (subtree, subst->seen)))
3607 return subtree; 3607 return subtree;
3608 3608
3609 /* If this node can be the entry point to a cycle, remember that 3609 /* If this node can be the entry point to a cycle, remember that
@@ -3798,10 +3798,11 @@ string_to_number (char const *string, int base, int flags)
3798 3798
3799 if (! (state & DOT_CHAR) && ! (flags & S2N_OVERFLOW_TO_FLOAT)) 3799 if (! (state & DOT_CHAR) && ! (flags & S2N_OVERFLOW_TO_FLOAT))
3800 { 3800 {
3801 AUTO_STRING (fmt, ("%s is out of fixnum range; " 3801 AUTO_STRING (fmt, ("%s (base %d) is out of fixnum range; "
3802 "maybe set `read-integer-overflow-as-float'?")); 3802 "maybe set `read-integer-overflow-as-float'?"));
3803 AUTO_STRING_WITH_LEN (arg, string, cp - string); 3803 AUTO_STRING_WITH_LEN (arg, string, cp - string);
3804 xsignal1 (Qoverflow_error, CALLN (Fformat_message, fmt, arg)); 3804 xsignal1 (Qoverflow_error,
3805 CALLN (Fformat_message, fmt, arg, make_number (base)));
3805 } 3806 }
3806 } 3807 }
3807 3808
@@ -4236,7 +4237,7 @@ usage: (unintern NAME OBARRAY) */)
4236 session if we unintern them, as well as even more ways to use 4237 session if we unintern them, as well as even more ways to use
4237 `setq' or `fset' or whatnot to make the Emacs session 4238 `setq' or `fset' or whatnot to make the Emacs session
4238 unusable. Let's not go down this silly road. --Stef */ 4239 unusable. Let's not go down this silly road. --Stef */
4239 /* if (EQ (tem, Qnil) || EQ (tem, Qt)) 4240 /* if (NILP (tem) || EQ (tem, Qt))
4240 error ("Attempt to unintern t or nil"); */ 4241 error ("Attempt to unintern t or nil"); */
4241 4242
4242 XSYMBOL (tem)->u.s.interned = SYMBOL_UNINTERNED; 4243 XSYMBOL (tem)->u.s.interned = SYMBOL_UNINTERNED;
diff --git a/src/menu.c b/src/menu.c
index e7d4d782fe8..a088083df27 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -647,7 +647,7 @@ digest_single_submenu (int start, int end, bool top_level_items)
647 i = start; 647 i = start;
648 while (i < end) 648 while (i < end)
649 { 649 {
650 if (EQ (AREF (menu_items, i), Qnil)) 650 if (NILP (AREF (menu_items, i)))
651 { 651 {
652 submenu_stack[submenu_depth++] = save_wv; 652 submenu_stack[submenu_depth++] = save_wv;
653 save_wv = prev_wv; 653 save_wv = prev_wv;
@@ -900,7 +900,7 @@ find_and_call_menu_selection (struct frame *f, int menu_bar_items_used,
900 900
901 while (i < menu_bar_items_used) 901 while (i < menu_bar_items_used)
902 { 902 {
903 if (EQ (AREF (vector, i), Qnil)) 903 if (NILP (AREF (vector, i)))
904 { 904 {
905 subprefix_stack[submenu_depth++] = prefix; 905 subprefix_stack[submenu_depth++] = prefix;
906 prefix = entry; 906 prefix = entry;
@@ -985,7 +985,7 @@ find_and_return_menu_selection (struct frame *f, bool keymaps, void *client_data
985 985
986 while (i < menu_items_used) 986 while (i < menu_items_used)
987 { 987 {
988 if (EQ (AREF (menu_items, i), Qnil)) 988 if (NILP (AREF (menu_items, i)))
989 { 989 {
990 subprefix_stack[submenu_depth++] = prefix; 990 subprefix_stack[submenu_depth++] = prefix;
991 prefix = entry; 991 prefix = entry;
diff --git a/src/nsfns.m b/src/nsfns.m
index 9ff7e88a8d4..184657f3b4f 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -363,7 +363,7 @@ x_set_icon_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
363 if (STRINGP (oldval) && EQ (Fstring_equal (oldval, arg), Qt)) 363 if (STRINGP (oldval) && EQ (Fstring_equal (oldval, arg), Qt))
364 return; 364 return;
365 } 365 }
366 else if (!STRINGP (oldval) && EQ (oldval, Qnil) == EQ (arg, Qnil)) 366 else if (!STRINGP (oldval) && NILP (oldval) == NILP (arg))
367 return; 367 return;
368 368
369 fset_icon_name (f, arg); 369 fset_icon_name (f, arg);
@@ -1291,7 +1291,7 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
1291 window_prompting = x_figure_window_size (f, parms, true, &x_width, &x_height); 1291 window_prompting = x_figure_window_size (f, parms, true, &x_width, &x_height);
1292 1292
1293 tem = x_get_arg (dpyinfo, parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN); 1293 tem = x_get_arg (dpyinfo, parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);
1294 f->no_split = minibuffer_only || (!EQ (tem, Qunbound) && !EQ (tem, Qnil)); 1294 f->no_split = minibuffer_only || (!EQ (tem, Qunbound) && !NILP (tem));
1295 1295
1296 /* NOTE: on other terms, this is done in set_mouse_color, however this 1296 /* NOTE: on other terms, this is done in set_mouse_color, however this
1297 was not getting called under Nextstep. */ 1297 was not getting called under Nextstep. */
diff --git a/src/nsmenu.m b/src/nsmenu.m
index a438952818a..18c3230a742 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -828,7 +828,7 @@ ns_menu_show (struct frame *f, int x, int y, int menuflags,
828 i = 0; 828 i = 0;
829 while (i < menu_items_used) 829 while (i < menu_items_used)
830 { 830 {
831 if (EQ (AREF (menu_items, i), Qnil)) 831 if (NILP (AREF (menu_items, i)))
832 { 832 {
833 submenu_stack[submenu_depth++] = save_wv; 833 submenu_stack[submenu_depth++] = save_wv;
834 save_wv = prev_wv; 834 save_wv = prev_wv;
diff --git a/src/nsselect.m b/src/nsselect.m
index c72f179ab38..e71a20ed92e 100644
--- a/src/nsselect.m
+++ b/src/nsselect.m
@@ -164,7 +164,7 @@ ns_get_our_change_count_for (Lisp_Object selection)
164static void 164static void
165ns_string_to_pasteboard_internal (id pb, Lisp_Object str, NSString *gtype) 165ns_string_to_pasteboard_internal (id pb, Lisp_Object str, NSString *gtype)
166{ 166{
167 if (EQ (str, Qnil)) 167 if (NILP (str))
168 { 168 {
169 [pb declareTypes: [NSArray array] owner: nil]; 169 [pb declareTypes: [NSArray array] owner: nil];
170 } 170 }
@@ -399,7 +399,7 @@ these literal upper-case names.) The symbol nil is the same as
399 return Qnil; 399 return Qnil;
400 400
401 CHECK_SYMBOL (selection); 401 CHECK_SYMBOL (selection);
402 if (EQ (selection, Qnil)) selection = QPRIMARY; 402 if (NILP (selection)) selection = QPRIMARY;
403 if (EQ (selection, Qt)) selection = QSECONDARY; 403 if (EQ (selection, Qt)) selection = QSECONDARY;
404 pb = ns_symbol_to_pb (selection); 404 pb = ns_symbol_to_pb (selection);
405 if (pb == nil) return Qnil; 405 if (pb == nil) return Qnil;
@@ -421,7 +421,7 @@ and t is the same as `SECONDARY'. */)
421{ 421{
422 check_window_system (NULL); 422 check_window_system (NULL);
423 CHECK_SYMBOL (selection); 423 CHECK_SYMBOL (selection);
424 if (EQ (selection, Qnil)) selection = QPRIMARY; 424 if (NILP (selection)) selection = QPRIMARY;
425 if (EQ (selection, Qt)) selection = QSECONDARY; 425 if (EQ (selection, Qt)) selection = QSECONDARY;
426 return ns_get_pb_change_count (selection) 426 return ns_get_pb_change_count (selection)
427 == ns_get_our_change_count_for (selection) 427 == ns_get_our_change_count_for (selection)
diff --git a/src/process.c b/src/process.c
index 3fccd962da6..aafb46c3615 100644
--- a/src/process.c
+++ b/src/process.c
@@ -3587,17 +3587,23 @@ connect_network_socket (Lisp_Object proc, Lisp_Object addrinfos,
3587 3587
3588 if (s < 0) 3588 if (s < 0)
3589 { 3589 {
3590 const char *err = (p->is_server
3591 ? "make server process failed"
3592 : "make client process failed");
3593
3590 /* If non-blocking got this far - and failed - assume non-blocking is 3594 /* If non-blocking got this far - and failed - assume non-blocking is
3591 not supported after all. This is probably a wrong assumption, but 3595 not supported after all. This is probably a wrong assumption, but
3592 the normal blocking calls to open-network-stream handles this error 3596 the normal blocking calls to open-network-stream handles this error
3593 better. */ 3597 better. */
3594 if (p->is_non_blocking_client) 3598 if (p->is_non_blocking_client)
3595 return; 3599 {
3600 Lisp_Object data = get_file_errno_data (err, contact, xerrno);
3601
3602 pset_status (p, list2 (Fcar (data), Fcdr (data)));
3603 return;
3604 }
3596 3605
3597 report_file_errno ((p->is_server 3606 report_file_errno (err, contact, xerrno);
3598 ? "make server process failed"
3599 : "make client process failed"),
3600 contact, xerrno);
3601 } 3607 }
3602 3608
3603 inch = s; 3609 inch = s;
@@ -4608,7 +4614,7 @@ is nil, from any process) before the timeout expired. */)
4608 4614
4609 /* Can't wait for a process that is dedicated to a different 4615 /* Can't wait for a process that is dedicated to a different
4610 thread. */ 4616 thread. */
4611 if (!EQ (proc->thread, Qnil) && !EQ (proc->thread, Fcurrent_thread ())) 4617 if (!NILP (proc->thread) && !EQ (proc->thread, Fcurrent_thread ()))
4612 { 4618 {
4613 Lisp_Object proc_thread_name = XTHREAD (proc->thread)->name; 4619 Lisp_Object proc_thread_name = XTHREAD (proc->thread)->name;
4614 4620
@@ -5015,7 +5021,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
5015 struct timespec now = invalid_timespec (); 5021 struct timespec now = invalid_timespec ();
5016 5022
5017 eassert (wait_proc == NULL 5023 eassert (wait_proc == NULL
5018 || EQ (wait_proc->thread, Qnil) 5024 || NILP (wait_proc->thread)
5019 || XTHREAD (wait_proc->thread) == current_thread); 5025 || XTHREAD (wait_proc->thread) == current_thread);
5020 5026
5021 FD_ZERO (&Available); 5027 FD_ZERO (&Available);
diff --git a/src/terminal.c b/src/terminal.c
index 070b8aac1fe..1b3acbe07cf 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -483,7 +483,7 @@ static Lisp_Object
483store_terminal_param (struct terminal *t, Lisp_Object parameter, Lisp_Object value) 483store_terminal_param (struct terminal *t, Lisp_Object parameter, Lisp_Object value)
484{ 484{
485 Lisp_Object old_alist_elt = Fassq (parameter, t->param_alist); 485 Lisp_Object old_alist_elt = Fassq (parameter, t->param_alist);
486 if (EQ (old_alist_elt, Qnil)) 486 if (NILP (old_alist_elt))
487 { 487 {
488 tset_param_alist (t, Fcons (Fcons (parameter, value), t->param_alist)); 488 tset_param_alist (t, Fcons (Fcons (parameter, value), t->param_alist));
489 return Qnil; 489 return Qnil;
diff --git a/src/textprop.c b/src/textprop.c
index f7e69f30ea6..fe5b61e2ddc 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -2269,7 +2269,7 @@ verify_interval_modification (struct buffer *buf,
2269 if (!inhibit_modification_hooks) 2269 if (!inhibit_modification_hooks)
2270 { 2270 {
2271 hooks = Fnreverse (hooks); 2271 hooks = Fnreverse (hooks);
2272 while (! EQ (hooks, Qnil)) 2272 while (! NILP (hooks))
2273 { 2273 {
2274 call_mod_hooks (Fcar (hooks), make_number (start), 2274 call_mod_hooks (Fcar (hooks), make_number (start),
2275 make_number (end)); 2275 make_number (end));
diff --git a/src/thread.c b/src/thread.c
index 3eba25b7b43..1c73d938655 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -681,7 +681,7 @@ invoke_thread_function (void)
681{ 681{
682 ptrdiff_t count = SPECPDL_INDEX (); 682 ptrdiff_t count = SPECPDL_INDEX ();
683 683
684 Ffuncall (1, &current_thread->function); 684 current_thread->result = Ffuncall (1, &current_thread->function);
685 return unbind_to (count, Qnil); 685 return unbind_to (count, Qnil);
686} 686}
687 687
@@ -789,6 +789,7 @@ If NAME is given, it must be a string; it names the new thread. */)
789 new_thread->m_last_thing_searched = Qnil; /* copy from parent? */ 789 new_thread->m_last_thing_searched = Qnil; /* copy from parent? */
790 new_thread->m_saved_last_thing_searched = Qnil; 790 new_thread->m_saved_last_thing_searched = Qnil;
791 new_thread->m_current_buffer = current_thread->m_current_buffer; 791 new_thread->m_current_buffer = current_thread->m_current_buffer;
792 new_thread->result = Qnil;
792 new_thread->error_symbol = Qnil; 793 new_thread->error_symbol = Qnil;
793 new_thread->error_data = Qnil; 794 new_thread->error_data = Qnil;
794 new_thread->event_object = Qnil; 795 new_thread->event_object = Qnil;
@@ -933,12 +934,13 @@ thread_join_callback (void *arg)
933 934
934DEFUN ("thread-join", Fthread_join, Sthread_join, 1, 1, 0, 935DEFUN ("thread-join", Fthread_join, Sthread_join, 1, 1, 0,
935 doc: /* Wait for THREAD to exit. 936 doc: /* Wait for THREAD to exit.
936This blocks the current thread until THREAD exits or until 937This blocks the current thread until THREAD exits or until the current
937the current thread is signaled. 938thread is signaled. It returns the result of the THREAD function. It
938It is an error for a thread to try to join itself. */) 939is an error for a thread to try to join itself. */)
939 (Lisp_Object thread) 940 (Lisp_Object thread)
940{ 941{
941 struct thread_state *tstate; 942 struct thread_state *tstate;
943 Lisp_Object error_symbol, error_data;
942 944
943 CHECK_THREAD (thread); 945 CHECK_THREAD (thread);
944 tstate = XTHREAD (thread); 946 tstate = XTHREAD (thread);
@@ -946,10 +948,16 @@ It is an error for a thread to try to join itself. */)
946 if (tstate == current_thread) 948 if (tstate == current_thread)
947 error ("Cannot join current thread"); 949 error ("Cannot join current thread");
948 950
951 error_symbol = tstate->error_symbol;
952 error_data = tstate->error_data;
953
949 if (thread_alive_p (tstate)) 954 if (thread_alive_p (tstate))
950 flush_stack_call_func (thread_join_callback, tstate); 955 flush_stack_call_func (thread_join_callback, tstate);
951 956
952 return Qnil; 957 if (!NILP (error_symbol))
958 Fsignal (error_symbol, error_data);
959
960 return tstate->result;
953} 961}
954 962
955DEFUN ("all-threads", Fall_threads, Sall_threads, 0, 0, 0, 963DEFUN ("all-threads", Fall_threads, Sall_threads, 0, 0, 0,
@@ -973,11 +981,17 @@ DEFUN ("all-threads", Fall_threads, Sall_threads, 0, 0, 0,
973 return result; 981 return result;
974} 982}
975 983
976DEFUN ("thread-last-error", Fthread_last_error, Sthread_last_error, 0, 0, 0, 984DEFUN ("thread-last-error", Fthread_last_error, Sthread_last_error, 0, 1, 0,
977 doc: /* Return the last error form recorded by a dying thread. */) 985 doc: /* Return the last error form recorded by a dying thread.
978 (void) 986If CLEANUP is non-nil, remove this error form from history. */)
987 (Lisp_Object cleanup)
979{ 988{
980 return last_thread_error; 989 Lisp_Object result = last_thread_error;
990
991 if (!NILP (cleanup))
992 last_thread_error = Qnil;
993
994 return result;
981} 995}
982 996
983 997
@@ -1011,6 +1025,7 @@ init_main_thread (void)
1011 main_thread.m_saved_last_thing_searched = Qnil; 1025 main_thread.m_saved_last_thing_searched = Qnil;
1012 main_thread.name = Qnil; 1026 main_thread.name = Qnil;
1013 main_thread.function = Qnil; 1027 main_thread.function = Qnil;
1028 main_thread.result = Qnil;
1014 main_thread.error_symbol = Qnil; 1029 main_thread.error_symbol = Qnil;
1015 main_thread.error_data = Qnil; 1030 main_thread.error_data = Qnil;
1016 main_thread.event_object = Qnil; 1031 main_thread.event_object = Qnil;
@@ -1083,4 +1098,12 @@ syms_of_threads (void)
1083 DEFSYM (Qthreadp, "threadp"); 1098 DEFSYM (Qthreadp, "threadp");
1084 DEFSYM (Qmutexp, "mutexp"); 1099 DEFSYM (Qmutexp, "mutexp");
1085 DEFSYM (Qcondition_variable_p, "condition-variable-p"); 1100 DEFSYM (Qcondition_variable_p, "condition-variable-p");
1101
1102 DEFVAR_LISP ("main-thread", Vmain_thread,
1103 doc: /* The main thread of Emacs. */);
1104#ifdef THREADS_ENABLED
1105 XSETTHREAD (Vmain_thread, &main_thread);
1106#else
1107 Vmain_thread = Qnil;
1108#endif
1086} 1109}
diff --git a/src/thread.h b/src/thread.h
index c10e5ecb758..922eea62178 100644
--- a/src/thread.h
+++ b/src/thread.h
@@ -52,6 +52,9 @@ struct thread_state
52 /* The thread's function. */ 52 /* The thread's function. */
53 Lisp_Object function; 53 Lisp_Object function;
54 54
55 /* The thread's result, if function has finished. */
56 Lisp_Object result;
57
55 /* If non-nil, this thread has been signaled. */ 58 /* If non-nil, this thread has been signaled. */
56 Lisp_Object error_symbol; 59 Lisp_Object error_symbol;
57 Lisp_Object error_data; 60 Lisp_Object error_data;
diff --git a/src/w32cygwinx.c b/src/w32cygwinx.c
index 8d3ae164cf6..5d48c3a9e1e 100644
--- a/src/w32cygwinx.c
+++ b/src/w32cygwinx.c
@@ -24,6 +24,16 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
24#include "lisp.h" 24#include "lisp.h"
25#include "w32common.h" 25#include "w32common.h"
26 26
27static Lisp_Object ATTRIBUTE_FORMAT_PRINTF (1, 2)
28format_string (char const *format, ...)
29{
30 va_list args;
31 va_start (args, format);
32 Lisp_Object str = vformat_string (format, args);
33 va_end (args);
34 return str;
35}
36
27DEFUN ("w32-battery-status", Fw32_battery_status, Sw32_battery_status, 0, 0, 0, 37DEFUN ("w32-battery-status", Fw32_battery_status, Sw32_battery_status, 0, 0, 0,
28 doc: /* Get power status information from Windows system. 38 doc: /* Get power status information from Windows system.
29 39
@@ -92,32 +102,17 @@ The following %-sequences are provided:
92 if (system_status.BatteryLifePercent > 100) 102 if (system_status.BatteryLifePercent > 100)
93 load_percentage = build_string ("N/A"); 103 load_percentage = build_string ("N/A");
94 else 104 else
95 { 105 load_percentage = format_string ("%d", system_status.BatteryLifePercent);
96 char buffer[16];
97 snprintf (buffer, 16, "%d", system_status.BatteryLifePercent);
98 load_percentage = build_string (buffer);
99 }
100 106
101 if (seconds_left < 0) 107 if (seconds_left < 0)
102 seconds = minutes = hours = remain = build_string ("N/A"); 108 seconds = minutes = hours = remain = build_string ("N/A");
103 else 109 else
104 { 110 {
105 long m; 111 long m = seconds_left / 60;
106 double h; 112 seconds = format_string ("%ld", seconds_left);
107 char buffer[16]; 113 minutes = format_string ("%ld", m);
108 snprintf (buffer, 16, "%ld", seconds_left); 114 hours = format_string ("%3.1f", seconds_left / 3600.0);
109 seconds = build_string (buffer); 115 remain = format_string ("%ld:%02ld", m / 60, m % 60);
110
111 m = seconds_left / 60;
112 snprintf (buffer, 16, "%ld", m);
113 minutes = build_string (buffer);
114
115 h = seconds_left / 3600.0;
116 snprintf (buffer, 16, "%3.1f", h);
117 hours = build_string (buffer);
118
119 snprintf (buffer, 16, "%ld:%02ld", m / 60, m % 60);
120 remain = build_string (buffer);
121 } 116 }
122 117
123 status = listn (CONSTYPE_HEAP, 8, 118 status = listn (CONSTYPE_HEAP, 8,
diff --git a/src/w32term.c b/src/w32term.c
index ff0d2bf5ddb..0ae173a876b 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -1476,7 +1476,7 @@ x_draw_glyphless_glyph_string_foreground (struct glyph_string *s)
1476 { 1476 {
1477 sprintf ((char *) buf, "%0*X", 1477 sprintf ((char *) buf, "%0*X",
1478 glyph->u.glyphless.ch < 0x10000 ? 4 : 6, 1478 glyph->u.glyphless.ch < 0x10000 ? 4 : 6,
1479 (unsigned int) glyph->u.glyphless.ch); 1479 (unsigned int) glyph->u.glyphless.ch & 0xffffff);
1480 str = buf; 1480 str = buf;
1481 } 1481 }
1482 1482
diff --git a/src/xdisp.c b/src/xdisp.c
index 1199e1c1b7d..316c12ee73f 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -8384,7 +8384,7 @@ next_element_from_buffer (struct it *it)
8384 eassert (IT_CHARPOS (*it) >= BEGV); 8384 eassert (IT_CHARPOS (*it) >= BEGV);
8385 eassert (NILP (it->string) && !it->s); 8385 eassert (NILP (it->string) && !it->s);
8386 eassert (!it->bidi_p 8386 eassert (!it->bidi_p
8387 || (EQ (it->bidi_it.string.lstring, Qnil) 8387 || (NILP (it->bidi_it.string.lstring)
8388 && it->bidi_it.string.s == NULL)); 8388 && it->bidi_it.string.s == NULL));
8389 8389
8390 /* With bidi reordering, the character to display might not be the 8390 /* With bidi reordering, the character to display might not be the
diff --git a/src/xfaces.c b/src/xfaces.c
index eea06724185..0f9a741dfe3 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -2971,7 +2971,7 @@ FRAME 0 means change the face on all frames, and change the default
2971 if (!UNSPECIFIEDP (value) && !IGNORE_DEFFACE_P (value)) 2971 if (!UNSPECIFIEDP (value) && !IGNORE_DEFFACE_P (value))
2972 if ((SYMBOLP (value) 2972 if ((SYMBOLP (value)
2973 && !EQ (value, Qt) 2973 && !EQ (value, Qt)
2974 && !EQ (value, Qnil)) 2974 && !NILP (value))
2975 /* Overline color. */ 2975 /* Overline color. */
2976 || (STRINGP (value) 2976 || (STRINGP (value)
2977 && SCHARS (value) == 0)) 2977 && SCHARS (value) == 0))
@@ -2985,7 +2985,7 @@ FRAME 0 means change the face on all frames, and change the default
2985 if (!UNSPECIFIEDP (value) && !IGNORE_DEFFACE_P (value)) 2985 if (!UNSPECIFIEDP (value) && !IGNORE_DEFFACE_P (value))
2986 if ((SYMBOLP (value) 2986 if ((SYMBOLP (value)
2987 && !EQ (value, Qt) 2987 && !EQ (value, Qt)
2988 && !EQ (value, Qnil)) 2988 && !NILP (value))
2989 /* Strike-through color. */ 2989 /* Strike-through color. */
2990 || (STRINGP (value) 2990 || (STRINGP (value)
2991 && SCHARS (value) == 0)) 2991 && SCHARS (value) == 0))
diff --git a/src/xfns.c b/src/xfns.c
index fe8170cf635..66e49df2985 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -1456,7 +1456,7 @@ x_set_icon_type (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
1456 if (STRINGP (oldval) && EQ (Fstring_equal (oldval, arg), Qt)) 1456 if (STRINGP (oldval) && EQ (Fstring_equal (oldval, arg), Qt))
1457 return; 1457 return;
1458 } 1458 }
1459 else if (!STRINGP (oldval) && EQ (oldval, Qnil) == EQ (arg, Qnil)) 1459 else if (!STRINGP (oldval) && NILP (oldval) == NILP (arg))
1460 return; 1460 return;
1461 1461
1462 block_input (); 1462 block_input ();
@@ -5722,7 +5722,7 @@ If TERMINAL is omitted or nil, that stands for the selected frame's display. */
5722{ 5722{
5723 struct x_display_info *dpyinfo = check_x_display_info (terminal); 5723 struct x_display_info *dpyinfo = check_x_display_info (terminal);
5724 5724
5725 XSynchronize (dpyinfo->display, !EQ (on, Qnil)); 5725 XSynchronize (dpyinfo->display, !NILP (on));
5726 5726
5727 return Qnil; 5727 return Qnil;
5728} 5728}
diff --git a/src/xmenu.c b/src/xmenu.c
index 58fba8c3225..a99e8ab9f09 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -1487,7 +1487,7 @@ x_menu_show (struct frame *f, int x, int y, int menuflags,
1487 i = 0; 1487 i = 0;
1488 while (i < menu_items_used) 1488 while (i < menu_items_used)
1489 { 1489 {
1490 if (EQ (AREF (menu_items, i), Qnil)) 1490 if (NILP (AREF (menu_items, i)))
1491 { 1491 {
1492 submenu_stack[submenu_depth++] = save_wv; 1492 submenu_stack[submenu_depth++] = save_wv;
1493 save_wv = prev_wv; 1493 save_wv = prev_wv;
@@ -1656,7 +1656,7 @@ x_menu_show (struct frame *f, int x, int y, int menuflags,
1656 i = 0; 1656 i = 0;
1657 while (i < menu_items_used) 1657 while (i < menu_items_used)
1658 { 1658 {
1659 if (EQ (AREF (menu_items, i), Qnil)) 1659 if (NILP (AREF (menu_items, i)))
1660 { 1660 {
1661 subprefix_stack[submenu_depth++] = prefix; 1661 subprefix_stack[submenu_depth++] = prefix;
1662 prefix = entry; 1662 prefix = entry;
diff --git a/src/xselect.c b/src/xselect.c
index 1f51be4c522..8448944c00f 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -2094,7 +2094,7 @@ On Nextstep, TERMINAL is unused. */)
2094 struct frame *f = frame_for_x_selection (terminal); 2094 struct frame *f = frame_for_x_selection (terminal);
2095 2095
2096 CHECK_SYMBOL (selection); 2096 CHECK_SYMBOL (selection);
2097 if (EQ (selection, Qnil)) selection = QPRIMARY; 2097 if (NILP (selection)) selection = QPRIMARY;
2098 if (EQ (selection, Qt)) selection = QSECONDARY; 2098 if (EQ (selection, Qt)) selection = QSECONDARY;
2099 2099
2100 if (f && !NILP (LOCAL_SELECTION (selection, FRAME_DISPLAY_INFO (f)))) 2100 if (f && !NILP (LOCAL_SELECTION (selection, FRAME_DISPLAY_INFO (f))))
@@ -2124,7 +2124,7 @@ On Nextstep, TERMINAL is unused. */)
2124 struct x_display_info *dpyinfo; 2124 struct x_display_info *dpyinfo;
2125 2125
2126 CHECK_SYMBOL (selection); 2126 CHECK_SYMBOL (selection);
2127 if (EQ (selection, Qnil)) selection = QPRIMARY; 2127 if (NILP (selection)) selection = QPRIMARY;
2128 if (EQ (selection, Qt)) selection = QSECONDARY; 2128 if (EQ (selection, Qt)) selection = QSECONDARY;
2129 2129
2130 if (!f) 2130 if (!f)
diff --git a/src/xwidget.c b/src/xwidget.c
index 2a53966ef43..758e6408781 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -1099,7 +1099,7 @@ xwidget_view_lookup (struct xwidget *xw, struct window *w)
1099 1099
1100 ret = Fxwidget_view_lookup (xwidget, window); 1100 ret = Fxwidget_view_lookup (xwidget, window);
1101 1101
1102 return EQ (ret, Qnil) ? NULL : XXWIDGET_VIEW (ret); 1102 return NILP (ret) ? NULL : XXWIDGET_VIEW (ret);
1103} 1103}
1104 1104
1105struct xwidget * 1105struct xwidget *