Commit fb24ce37 authored by Paul Eggert's avatar Paul Eggert
Browse files

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).
parent 96d77f9e
......@@ -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;
......
......@@ -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))
......
......@@ -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);
......
......@@ -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;
......
......@@ -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;
......
......@@ -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. */
......
......@@ -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. */
......
......@@ -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)
{
......
......@@ -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);
......
......@@ -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. */
......
......@@ -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. */
......
......@@ -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;
......
......@@ -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;
......
......@@ -363,7 +363,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side.
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 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side.
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. */
......
......@@ -828,7 +828,7 @@ - (Lisp_Object)runMenuAt: (NSPoint)p forFrame: (struct frame *)f
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;
......
......@@ -164,7 +164,7 @@ Updated by Christian Limpach (chris@nice.ch)
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 @@ Updated by Christian Limpach (chris@nice.ch)
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 @@ Updated by Christian Limpach (chris@nice.ch)
{
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)
......
......@@ -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);
......
......@@ -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;
......
......@@ -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));
......
......@@ -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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment