From: Paul Eggert Date: Fri, 20 Jul 2018 05:03:34 +0000 (-0700) Subject: Prefer NILP (x) to EQ (x, Qnil) X-Git-Tag: emacs-27.0.90~4664^2~57 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=fb24ce37d1bc258cfc3884d9828aa0602fa06e1d;p=emacs.git Prefer NILP (x) to EQ (x, Qnil) This simplifies the code a bit, and also simplifies some potential future changes slightly (e.g., altering eq vs eql). * src/alloc.c (mark_object): * src/callint.c (fix_command): * src/chartab.c (Fchar_table_range, Fset_char_table_range): * src/dbusbind.c (XD_OBJECT_TO_DBUS_TYPE, xd_signature): * src/dired.c (Fsystem_users): * src/fileio.c (Fdo_auto_save): * src/fns.c (concat): * src/frame.c (get_frame_param, frame_inhibit_resize) (store_in_alist, store_frame_param, x_set_autoraise) (x_set_autolower, x_get_arg): * src/image.c (Fclear_image_cache): * src/intervals.c (intervals_equal): * src/intervals.h (DEFAULT_INTERVAL_P): * src/lread.c (substitute_object_recurse): * src/menu.c (digest_single_submenu) (find_and_call_menu_selection) (find_and_return_menu_selection): * src/nsfns.m (x_set_icon_name, Fx_create_frame): * src/nsmenu.m (ns_menu_show): * src/nsselect.m (ns_string_to_pasteboard_internal) (Fns_selection_exists_p, Fns_selection_owner_p): * src/process.c (Faccept_process_output) (wait_reading_process_output): * src/terminal.c (store_terminal_param): * src/textprop.c (verify_interval_modification): * src/xdisp.c (next_element_from_buffer): * src/xfaces.c (Finternal_set_lisp_face_attribute): * src/xfns.c (x_set_icon_type, Fx_synchronize): * src/xmenu.c (x_menu_show): * src/xselect.c (Fx_selection_owner_p) (Fx_selection_exists_p): * src/xwidget.c (xwidget_view_lookup): Prefer NILP (x) to EQ (x, Qnil). --- 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) CHECK_ALLOCATED_AND_LIVE (live_cons_p); CONS_MARK (ptr); /* If the cdr is nil, avoid recursion for the car. */ - if (EQ (ptr->u.s.u.cdr, Qnil)) + if (NILP (ptr->u.s.u.cdr)) { obj = ptr->u.s.car; 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) carelt = XCAR (elt); /* If it is (if X Y), look at Y. */ if (EQ (carelt, Qif) - && EQ (Fnthcdr (make_number (3), elt), Qnil)) + && NILP (Fnthcdr (make_number (3), elt))) elt = Fnth (make_number (2), elt); /* If it is (when ... Y), look at Y. */ else if (EQ (carelt, Qwhen)) 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. * Lisp_Object val; CHECK_CHAR_TABLE (char_table); - if (EQ (range, Qnil)) + if (NILP (range)) val = XCHAR_TABLE (char_table)->defalt; else if (CHARACTERP (range)) val = CHAR_TABLE_REF (char_table, XFASTINT (range)); @@ -642,7 +642,7 @@ or a character code. Return VALUE. */) for (i = 0; i < chartab_size[0]; i++) set_char_table_contents (char_table, i, value); } - else if (EQ (range, Qnil)) + else if (NILP (range)) set_char_table_defalt (char_table, value); else if (CHARACTERP (range)) 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) `dbus-send-signal', into corresponding C values appended as arguments to a D-Bus message. */ #define XD_OBJECT_TO_DBUS_TYPE(object) \ - ((EQ (object, Qt) || EQ (object, Qnil)) ? DBUS_TYPE_BOOLEAN \ + ((EQ (object, Qt) || NILP (object)) ? DBUS_TYPE_BOOLEAN \ : (NATNUMP (object)) ? DBUS_TYPE_UINT32 \ : (INTEGERP (object)) ? DBUS_TYPE_INT32 \ : (FLOATP (object)) ? DBUS_TYPE_DOUBLE \ @@ -360,7 +360,7 @@ xd_signature (char *signature, int dtype, int parent_type, Lisp_Object object) break; case DBUS_TYPE_BOOLEAN: - if (!EQ (object, Qt) && !EQ (object, Qnil)) + if (!EQ (object, Qt) && !NILP (object)) wrong_type_argument (intern ("booleanp"), object); sprintf (signature, "%c", dtype); 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'. */) endpwent (); #endif - if (EQ (users, Qnil)) + if (NILP (users)) /* At least current user is always known. */ users = list1 (Vuser_real_login_name); return users; diff --git a/src/fileio.c b/src/fileio.c index 5a1c7ae10e5..39789e55ff5 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -5714,7 +5714,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer. */) spare the user annoying messages. */ && XFASTINT (BVAR (b, save_length)) > 5000 /* These messages are frequent and annoying for `*mail*'. */ - && !EQ (BVAR (b, filename), Qnil) + && !NILP (BVAR (b, filename)) && NILP (no_message)) { /* It has shrunk too much; turn off auto-saving here. */ diff --git a/src/fns.c b/src/fns.c index 10997da0d46..7d120a90f78 100644 --- a/src/fns.c +++ b/src/fns.c @@ -718,7 +718,7 @@ concat (ptrdiff_t nargs, Lisp_Object *args, val = make_uninit_string (result_len); /* In `append', if all but last arg are nil, return last arg. */ - if (target_type == Lisp_Cons && EQ (val, Qnil)) + if (target_type == Lisp_Cons && NILP (val)) return last_tail; /* Copy the contents of the args into the result. */ 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) /* Return the value of frame parameter PROP in frame FRAME. */ Lisp_Object -get_frame_param (register struct frame *frame, Lisp_Object prop) +get_frame_param (struct frame *frame, Lisp_Object prop) { - register Lisp_Object tem; - - tem = Fassq (prop, frame->param_alist); - if (EQ (tem, Qnil)) - return tem; - return Fcdr (tem); + return Fcdr (Fassq (prop, frame->param_alist)); } @@ -189,9 +184,9 @@ frame_inhibit_resize (struct frame *f, bool horizontal, Lisp_Object parameter) || (CONSP (frame_inhibit_implied_resize) && !NILP (Fmemq (parameter, frame_inhibit_implied_resize))) || (horizontal - && !EQ (fullscreen, Qnil) && !EQ (fullscreen, Qfullheight)) + && !NILP (fullscreen) && !EQ (fullscreen, Qfullheight)) || (!horizontal - && !EQ (fullscreen, Qnil) && !EQ (fullscreen, Qfullwidth)) + && !NILP (fullscreen) && !EQ (fullscreen, Qfullwidth)) || FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f)) : ((horizontal && f->inhibit_horizontal_resize) || (!horizontal && f->inhibit_vertical_resize))); @@ -2808,10 +2803,8 @@ frames_discard_buffer (Lisp_Object buffer) void store_in_alist (Lisp_Object *alistptr, Lisp_Object prop, Lisp_Object val) { - register Lisp_Object tem; - - tem = Fassq (prop, *alistptr); - if (EQ (tem, Qnil)) + Lisp_Object tem = Fassq (prop, *alistptr); + if (NILP (tem)) *alistptr = Fcons (Fcons (prop, val), *alistptr); else Fsetcdr (tem, val); @@ -2975,7 +2968,7 @@ store_frame_param (struct frame *f, Lisp_Object prop, Lisp_Object val) /* Update the frame parameter alist. */ old_alist_elt = Fassq (prop, f->param_alist); - if (EQ (old_alist_elt, Qnil)) + if (NILP (old_alist_elt)) fset_param_alist (f, Fcons (Fcons (prop, val), f->param_alist)); else Fsetcdr (old_alist_elt, val); @@ -4516,13 +4509,13 @@ x_set_visibility (struct frame *f, Lisp_Object value, Lisp_Object oldval) void x_set_autoraise (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { - f->auto_raise = !EQ (Qnil, arg); + f->auto_raise = !NILP (arg); } void x_set_autolower (struct frame *f, Lisp_Object arg, Lisp_Object oldval) { - f->auto_lower = !EQ (Qnil, arg); + f->auto_lower = !NILP (arg); } void @@ -4973,7 +4966,7 @@ x_get_arg (Display_Info *dpyinfo, Lisp_Object alist, Lisp_Object param, /* If it wasn't specified in ALIST or the Lisp-level defaults, look in the X resources. */ - if (EQ (tem, Qnil)) + if (NILP (tem)) { if (attribute && dpyinfo) { 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, which is then usually a filename. */) (Lisp_Object filter) { - if (!(EQ (filter, Qnil) || FRAMEP (filter))) + if (! (NILP (filter) || FRAMEP (filter))) clear_image_caches (filter); else 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) } /* i0 has something i1 doesn't. */ - if (EQ (i1_val, Qnil)) + if (NILP (i1_val)) return false; /* 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 /* True if this is a default interval, which is the same as being null or having no properties. */ -#define DEFAULT_INTERVAL_P(i) (!i || EQ ((i)->plist, Qnil)) +#define DEFAULT_INTERVAL_P(i) (!i || NILP ((i)->plist)) /* Test what type of parent we have. Three possibilities: another interval, a buffer or string object, or NULL. */ diff --git a/src/lread.c b/src/lread.c index 4ce6a442c36..4eba8635521 100644 --- a/src/lread.c +++ b/src/lread.c @@ -3603,7 +3603,7 @@ substitute_object_recurse (struct subst *subst, Lisp_Object subtree) return subtree; /* If we've been to this node before, don't explore it again. */ - if (!EQ (Qnil, Fmemq (subtree, subst->seen))) + if (!NILP (Fmemq (subtree, subst->seen))) return subtree; /* If this node can be the entry point to a cycle, remember that @@ -4236,7 +4236,7 @@ usage: (unintern NAME OBARRAY) */) session if we unintern them, as well as even more ways to use `setq' or `fset' or whatnot to make the Emacs session unusable. Let's not go down this silly road. --Stef */ - /* if (EQ (tem, Qnil) || EQ (tem, Qt)) + /* if (NILP (tem) || EQ (tem, Qt)) error ("Attempt to unintern t or nil"); */ 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) i = start; while (i < end) { - if (EQ (AREF (menu_items, i), Qnil)) + if (NILP (AREF (menu_items, i))) { submenu_stack[submenu_depth++] = save_wv; save_wv = prev_wv; @@ -900,7 +900,7 @@ find_and_call_menu_selection (struct frame *f, int menu_bar_items_used, while (i < menu_bar_items_used) { - if (EQ (AREF (vector, i), Qnil)) + if (NILP (AREF (vector, i))) { subprefix_stack[submenu_depth++] = prefix; prefix = entry; @@ -985,7 +985,7 @@ find_and_return_menu_selection (struct frame *f, bool keymaps, void *client_data while (i < menu_items_used) { - if (EQ (AREF (menu_items, i), Qnil)) + if (NILP (AREF (menu_items, i))) { subprefix_stack[submenu_depth++] = prefix; 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) if (STRINGP (oldval) && EQ (Fstring_equal (oldval, arg), Qt)) return; } - else if (!STRINGP (oldval) && EQ (oldval, Qnil) == EQ (arg, Qnil)) + else if (!STRINGP (oldval) && NILP (oldval) == NILP (arg)) return; fset_icon_name (f, arg); @@ -1291,7 +1291,7 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame, window_prompting = x_figure_window_size (f, parms, true, &x_width, &x_height); tem = x_get_arg (dpyinfo, parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN); - f->no_split = minibuffer_only || (!EQ (tem, Qunbound) && !EQ (tem, Qnil)); + f->no_split = minibuffer_only || (!EQ (tem, Qunbound) && !NILP (tem)); /* NOTE: on other terms, this is done in set_mouse_color, however this 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, i = 0; while (i < menu_items_used) { - if (EQ (AREF (menu_items, i), Qnil)) + if (NILP (AREF (menu_items, i))) { submenu_stack[submenu_depth++] = save_wv; 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) static void ns_string_to_pasteboard_internal (id pb, Lisp_Object str, NSString *gtype) { - if (EQ (str, Qnil)) + if (NILP (str)) { [pb declareTypes: [NSArray array] owner: nil]; } @@ -399,7 +399,7 @@ these literal upper-case names.) The symbol nil is the same as return Qnil; CHECK_SYMBOL (selection); - if (EQ (selection, Qnil)) selection = QPRIMARY; + if (NILP (selection)) selection = QPRIMARY; if (EQ (selection, Qt)) selection = QSECONDARY; pb = ns_symbol_to_pb (selection); if (pb == nil) return Qnil; @@ -421,7 +421,7 @@ and t is the same as `SECONDARY'. */) { check_window_system (NULL); CHECK_SYMBOL (selection); - if (EQ (selection, Qnil)) selection = QPRIMARY; + if (NILP (selection)) selection = QPRIMARY; if (EQ (selection, Qt)) selection = QSECONDARY; return ns_get_pb_change_count (selection) == ns_get_our_change_count_for (selection) diff --git a/src/process.c b/src/process.c index 3fccd962da6..06324641346 100644 --- a/src/process.c +++ b/src/process.c @@ -4608,7 +4608,7 @@ is nil, from any process) before the timeout expired. */) /* Can't wait for a process that is dedicated to a different thread. */ - if (!EQ (proc->thread, Qnil) && !EQ (proc->thread, Fcurrent_thread ())) + if (!NILP (proc->thread) && !EQ (proc->thread, Fcurrent_thread ())) { Lisp_Object proc_thread_name = XTHREAD (proc->thread)->name; @@ -5015,7 +5015,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, struct timespec now = invalid_timespec (); eassert (wait_proc == NULL - || EQ (wait_proc->thread, Qnil) + || NILP (wait_proc->thread) || XTHREAD (wait_proc->thread) == current_thread); 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 store_terminal_param (struct terminal *t, Lisp_Object parameter, Lisp_Object value) { Lisp_Object old_alist_elt = Fassq (parameter, t->param_alist); - if (EQ (old_alist_elt, Qnil)) + if (NILP (old_alist_elt)) { tset_param_alist (t, Fcons (Fcons (parameter, value), t->param_alist)); 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, if (!inhibit_modification_hooks) { hooks = Fnreverse (hooks); - while (! EQ (hooks, Qnil)) + while (! NILP (hooks)) { call_mod_hooks (Fcar (hooks), make_number (start), make_number (end)); 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) eassert (IT_CHARPOS (*it) >= BEGV); eassert (NILP (it->string) && !it->s); eassert (!it->bidi_p - || (EQ (it->bidi_it.string.lstring, Qnil) + || (NILP (it->bidi_it.string.lstring) && it->bidi_it.string.s == NULL)); /* 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 if (!UNSPECIFIEDP (value) && !IGNORE_DEFFACE_P (value)) if ((SYMBOLP (value) && !EQ (value, Qt) - && !EQ (value, Qnil)) + && !NILP (value)) /* Overline color. */ || (STRINGP (value) && SCHARS (value) == 0)) @@ -2985,7 +2985,7 @@ FRAME 0 means change the face on all frames, and change the default if (!UNSPECIFIEDP (value) && !IGNORE_DEFFACE_P (value)) if ((SYMBOLP (value) && !EQ (value, Qt) - && !EQ (value, Qnil)) + && !NILP (value)) /* Strike-through color. */ || (STRINGP (value) && 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) if (STRINGP (oldval) && EQ (Fstring_equal (oldval, arg), Qt)) return; } - else if (!STRINGP (oldval) && EQ (oldval, Qnil) == EQ (arg, Qnil)) + else if (!STRINGP (oldval) && NILP (oldval) == NILP (arg)) return; block_input (); @@ -5722,7 +5722,7 @@ If TERMINAL is omitted or nil, that stands for the selected frame's display. */ { struct x_display_info *dpyinfo = check_x_display_info (terminal); - XSynchronize (dpyinfo->display, !EQ (on, Qnil)); + XSynchronize (dpyinfo->display, !NILP (on)); return Qnil; } 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, i = 0; while (i < menu_items_used) { - if (EQ (AREF (menu_items, i), Qnil)) + if (NILP (AREF (menu_items, i))) { submenu_stack[submenu_depth++] = save_wv; save_wv = prev_wv; @@ -1656,7 +1656,7 @@ x_menu_show (struct frame *f, int x, int y, int menuflags, i = 0; while (i < menu_items_used) { - if (EQ (AREF (menu_items, i), Qnil)) + if (NILP (AREF (menu_items, i))) { subprefix_stack[submenu_depth++] = prefix; 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. */) struct frame *f = frame_for_x_selection (terminal); CHECK_SYMBOL (selection); - if (EQ (selection, Qnil)) selection = QPRIMARY; + if (NILP (selection)) selection = QPRIMARY; if (EQ (selection, Qt)) selection = QSECONDARY; if (f && !NILP (LOCAL_SELECTION (selection, FRAME_DISPLAY_INFO (f)))) @@ -2124,7 +2124,7 @@ On Nextstep, TERMINAL is unused. */) struct x_display_info *dpyinfo; CHECK_SYMBOL (selection); - if (EQ (selection, Qnil)) selection = QPRIMARY; + if (NILP (selection)) selection = QPRIMARY; if (EQ (selection, Qt)) selection = QSECONDARY; 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) ret = Fxwidget_view_lookup (xwidget, window); - return EQ (ret, Qnil) ? NULL : XXWIDGET_VIEW (ret); + return NILP (ret) ? NULL : XXWIDGET_VIEW (ret); } struct xwidget *