aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNicolas Petton2017-07-07 21:21:55 +0200
committerNicolas Petton2017-07-11 10:07:16 +0200
commit0bece6c6815cc59e181817a2765a4ea752f34f56 (patch)
tree856363b2defed20c97a25c29a7739bce9a6bd9cb /src
parent689c5c20d1174e95be50e674d05632545eb4b9c5 (diff)
downloademacs-0bece6c6815cc59e181817a2765a4ea752f34f56.tar.gz
emacs-0bece6c6815cc59e181817a2765a4ea752f34f56.zip
Add an optional testfn parameter to assoc
* src/fns.c (assoc): New optional testfn parameter used for comparison when provided. * test/src/fns-tests.el (test-assoc-testfn): Add tests for the new 'testfn' parameter. * src/buffer.c: * src/coding.c: * src/dbusbind.c: * src/font.c: * src/fontset.c: * src/gfilenotify.c: * src/image.c: * src/keymap.c: * src/process.c: * src/w32fns.c: * src/w32font.c: * src/w32notify.c: * src/w32term.c: * src/xdisp.c: * src/xfont.c: Add a third argument to Fassoc calls. * etc/NEWS: * doc/lispref/lists.texi: Document the new 'testfn' parameter.
Diffstat (limited to 'src')
-rw-r--r--src/buffer.c2
-rw-r--r--src/coding.c6
-rw-r--r--src/dbusbind.c6
-rw-r--r--src/fns.c15
-rw-r--r--src/font.c2
-rw-r--r--src/fontset.c2
-rw-r--r--src/gfilenotify.c2
-rw-r--r--src/image.c2
-rw-r--r--src/keymap.c2
-rw-r--r--src/process.c2
-rw-r--r--src/w32fns.c2
-rw-r--r--src/w32font.c2
-rw-r--r--src/w32notify.c4
-rw-r--r--src/w32term.c2
-rw-r--r--src/xdisp.c6
-rw-r--r--src/xfont.c3
16 files changed, 33 insertions, 27 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 780e4d7a7d6..e0972aac33c 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1164,7 +1164,7 @@ buffer_local_value (Lisp_Object variable, Lisp_Object buffer)
1164 { /* Look in local_var_alist. */ 1164 { /* Look in local_var_alist. */
1165 struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (sym); 1165 struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (sym);
1166 XSETSYMBOL (variable, sym); /* Update In case of aliasing. */ 1166 XSETSYMBOL (variable, sym); /* Update In case of aliasing. */
1167 result = Fassoc (variable, BVAR (buf, local_var_alist)); 1167 result = Fassoc (variable, BVAR (buf, local_var_alist), Qnil);
1168 if (!NILP (result)) 1168 if (!NILP (result))
1169 { 1169 {
1170 if (blv->fwd) 1170 if (blv->fwd)
diff --git a/src/coding.c b/src/coding.c
index 5682fc015ad..50ad206be69 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -10539,7 +10539,7 @@ usage: (define-coding-system-internal ...) */)
10539 ASET (this_spec, 2, this_eol_type); 10539 ASET (this_spec, 2, this_eol_type);
10540 Fputhash (this_name, this_spec, Vcoding_system_hash_table); 10540 Fputhash (this_name, this_spec, Vcoding_system_hash_table);
10541 Vcoding_system_list = Fcons (this_name, Vcoding_system_list); 10541 Vcoding_system_list = Fcons (this_name, Vcoding_system_list);
10542 val = Fassoc (Fsymbol_name (this_name), Vcoding_system_alist); 10542 val = Fassoc (Fsymbol_name (this_name), Vcoding_system_alist, Qnil);
10543 if (NILP (val)) 10543 if (NILP (val))
10544 Vcoding_system_alist 10544 Vcoding_system_alist
10545 = Fcons (Fcons (Fsymbol_name (this_name), Qnil), 10545 = Fcons (Fcons (Fsymbol_name (this_name), Qnil),
@@ -10554,7 +10554,7 @@ usage: (define-coding-system-internal ...) */)
10554 10554
10555 Fputhash (name, spec_vec, Vcoding_system_hash_table); 10555 Fputhash (name, spec_vec, Vcoding_system_hash_table);
10556 Vcoding_system_list = Fcons (name, Vcoding_system_list); 10556 Vcoding_system_list = Fcons (name, Vcoding_system_list);
10557 val = Fassoc (Fsymbol_name (name), Vcoding_system_alist); 10557 val = Fassoc (Fsymbol_name (name), Vcoding_system_alist, Qnil);
10558 if (NILP (val)) 10558 if (NILP (val))
10559 Vcoding_system_alist = Fcons (Fcons (Fsymbol_name (name), Qnil), 10559 Vcoding_system_alist = Fcons (Fcons (Fsymbol_name (name), Qnil),
10560 Vcoding_system_alist); 10560 Vcoding_system_alist);
@@ -10662,7 +10662,7 @@ DEFUN ("define-coding-system-alias", Fdefine_coding_system_alias,
10662 10662
10663 Fputhash (alias, spec, Vcoding_system_hash_table); 10663 Fputhash (alias, spec, Vcoding_system_hash_table);
10664 Vcoding_system_list = Fcons (alias, Vcoding_system_list); 10664 Vcoding_system_list = Fcons (alias, Vcoding_system_list);
10665 val = Fassoc (Fsymbol_name (alias), Vcoding_system_alist); 10665 val = Fassoc (Fsymbol_name (alias), Vcoding_system_alist, Qnil);
10666 if (NILP (val)) 10666 if (NILP (val))
10667 Vcoding_system_alist = Fcons (Fcons (Fsymbol_name (alias), Qnil), 10667 Vcoding_system_alist = Fcons (Fcons (Fsymbol_name (alias), Qnil),
10668 Vcoding_system_alist); 10668 Vcoding_system_alist);
diff --git a/src/dbusbind.c b/src/dbusbind.c
index d2460fd886e..0d9d3e514fd 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -955,7 +955,7 @@ xd_get_connection_address (Lisp_Object bus)
955 DBusConnection *connection; 955 DBusConnection *connection;
956 Lisp_Object val; 956 Lisp_Object val;
957 957
958 val = CDR_SAFE (Fassoc (bus, xd_registered_buses)); 958 val = CDR_SAFE (Fassoc (bus, xd_registered_buses, Qnil));
959 if (NILP (val)) 959 if (NILP (val))
960 XD_SIGNAL2 (build_string ("No connection to bus"), bus); 960 XD_SIGNAL2 (build_string ("No connection to bus"), bus);
961 else 961 else
@@ -1057,7 +1057,7 @@ xd_close_bus (Lisp_Object bus)
1057 Lisp_Object busobj; 1057 Lisp_Object busobj;
1058 1058
1059 /* Check whether we are connected. */ 1059 /* Check whether we are connected. */
1060 val = Fassoc (bus, xd_registered_buses); 1060 val = Fassoc (bus, xd_registered_buses, Qnil);
1061 if (NILP (val)) 1061 if (NILP (val))
1062 return; 1062 return;
1063 1063
@@ -1127,7 +1127,7 @@ this connection to those buses. */)
1127 xd_close_bus (bus); 1127 xd_close_bus (bus);
1128 1128
1129 /* Check, whether we are still connected. */ 1129 /* Check, whether we are still connected. */
1130 val = Fassoc (bus, xd_registered_buses); 1130 val = Fassoc (bus, xd_registered_buses, Qnil);
1131 if (!NILP (val)) 1131 if (!NILP (val))
1132 { 1132 {
1133 connection = xd_get_connection_address (bus); 1133 connection = xd_get_connection_address (bus);
diff --git a/src/fns.c b/src/fns.c
index 6610d2a6d0e..f0e10e311f5 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -1417,17 +1417,22 @@ assq_no_quit (Lisp_Object key, Lisp_Object list)
1417 return Qnil; 1417 return Qnil;
1418} 1418}
1419 1419
1420DEFUN ("assoc", Fassoc, Sassoc, 2, 2, 0, 1420DEFUN ("assoc", Fassoc, Sassoc, 2, 3, 0,
1421 doc: /* Return non-nil if KEY is `equal' to the car of an element of LIST. 1421 doc: /* Return non-nil if KEY is equal to the car of an element of LIST.
1422The value is actually the first element of LIST whose car equals KEY. */) 1422The value is actually the first element of LIST whose car equals KEY.
1423 (Lisp_Object key, Lisp_Object list) 1423
1424Equality is defined by TESTFN if non-nil or by `equal' if nil. */)
1425 (Lisp_Object key, Lisp_Object list, Lisp_Object testfn)
1424{ 1426{
1425 Lisp_Object tail = list; 1427 Lisp_Object tail = list;
1426 FOR_EACH_TAIL (tail) 1428 FOR_EACH_TAIL (tail)
1427 { 1429 {
1428 Lisp_Object car = XCAR (tail); 1430 Lisp_Object car = XCAR (tail);
1429 if (CONSP (car) 1431 if (CONSP (car)
1430 && (EQ (XCAR (car), key) || !NILP (Fequal (XCAR (car), key)))) 1432 && (NILP (testfn)
1433 ? (EQ (XCAR (car), key) || !NILP (Fequal
1434 (XCAR (car), key)))
1435 : !NILP (call2 (testfn, XCAR (car), key))))
1431 return car; 1436 return car;
1432 } 1437 }
1433 CHECK_LIST_END (tail, list); 1438 CHECK_LIST_END (tail, list);
diff --git a/src/font.c b/src/font.c
index 5a3f271ef85..a5e5b6a5b9d 100644
--- a/src/font.c
+++ b/src/font.c
@@ -1893,7 +1893,7 @@ otf_tag_symbol (OTF_Tag tag)
1893static OTF * 1893static OTF *
1894otf_open (Lisp_Object file) 1894otf_open (Lisp_Object file)
1895{ 1895{
1896 Lisp_Object val = Fassoc (file, otf_list); 1896 Lisp_Object val = Fassoc (file, otf_list, Qnil);
1897 OTF *otf; 1897 OTF *otf;
1898 1898
1899 if (! NILP (val)) 1899 if (! NILP (val))
diff --git a/src/fontset.c b/src/fontset.c
index 850558b08a0..74018060b85 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -1186,7 +1186,7 @@ fs_query_fontset (Lisp_Object name, int name_pattern)
1186 { 1186 {
1187 tem = Frassoc (name, Vfontset_alias_alist); 1187 tem = Frassoc (name, Vfontset_alias_alist);
1188 if (NILP (tem)) 1188 if (NILP (tem))
1189 tem = Fassoc (name, Vfontset_alias_alist); 1189 tem = Fassoc (name, Vfontset_alias_alist, Qnil);
1190 if (CONSP (tem) && STRINGP (XCAR (tem))) 1190 if (CONSP (tem) && STRINGP (XCAR (tem)))
1191 name = XCAR (tem); 1191 name = XCAR (tem);
1192 else if (name_pattern == 0) 1192 else if (name_pattern == 0)
diff --git a/src/gfilenotify.c b/src/gfilenotify.c
index 285a253733d..fa4854c664d 100644
--- a/src/gfilenotify.c
+++ b/src/gfilenotify.c
@@ -266,7 +266,7 @@ reason. Removing the watch by calling `gfile-rm-watch' also makes it
266invalid. */) 266invalid. */)
267 (Lisp_Object watch_descriptor) 267 (Lisp_Object watch_descriptor)
268{ 268{
269 Lisp_Object watch_object = Fassoc (watch_descriptor, watch_list); 269 Lisp_Object watch_object = Fassoc (watch_descriptor, watch_list, Qnil);
270 if (NILP (watch_object)) 270 if (NILP (watch_object))
271 return Qnil; 271 return Qnil;
272 else 272 else
diff --git a/src/image.c b/src/image.c
index 91749fb8733..1426e309445 100644
--- a/src/image.c
+++ b/src/image.c
@@ -4231,7 +4231,7 @@ xpm_load_image (struct frame *f,
4231 color_val = Qnil; 4231 color_val = Qnil;
4232 if (!NILP (color_symbols) && !NILP (symbol_color)) 4232 if (!NILP (color_symbols) && !NILP (symbol_color))
4233 { 4233 {
4234 Lisp_Object specified_color = Fassoc (symbol_color, color_symbols); 4234 Lisp_Object specified_color = Fassoc (symbol_color, color_symbols, Qnil);
4235 4235
4236 if (CONSP (specified_color) && STRINGP (XCDR (specified_color))) 4236 if (CONSP (specified_color) && STRINGP (XCDR (specified_color)))
4237 { 4237 {
diff --git a/src/keymap.c b/src/keymap.c
index b568f47cba7..db9aa7cbf38 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -1292,7 +1292,7 @@ silly_event_symbol_error (Lisp_Object c)
1292 base = XCAR (parsed); 1292 base = XCAR (parsed);
1293 name = Fsymbol_name (base); 1293 name = Fsymbol_name (base);
1294 /* This alist includes elements such as ("RET" . "\\r"). */ 1294 /* This alist includes elements such as ("RET" . "\\r"). */
1295 assoc = Fassoc (name, exclude_keys); 1295 assoc = Fassoc (name, exclude_keys, Qnil);
1296 1296
1297 if (! NILP (assoc)) 1297 if (! NILP (assoc))
1298 { 1298 {
diff --git a/src/process.c b/src/process.c
index abd017bb907..19009515336 100644
--- a/src/process.c
+++ b/src/process.c
@@ -951,7 +951,7 @@ DEFUN ("get-process", Fget_process, Sget_process, 1, 1, 0,
951 if (PROCESSP (name)) 951 if (PROCESSP (name))
952 return name; 952 return name;
953 CHECK_STRING (name); 953 CHECK_STRING (name);
954 return Fcdr (Fassoc (name, Vprocess_alist)); 954 return Fcdr (Fassoc (name, Vprocess_alist, Qnil));
955} 955}
956 956
957/* This is how commands for the user decode process arguments. It 957/* This is how commands for the user decode process arguments. It
diff --git a/src/w32fns.c b/src/w32fns.c
index b0842b5ee6c..457599fce0e 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -467,7 +467,7 @@ if the entry is new. */)
467 block_input (); 467 block_input ();
468 468
469 /* replace existing entry in w32-color-map or add new entry. */ 469 /* replace existing entry in w32-color-map or add new entry. */
470 entry = Fassoc (name, Vw32_color_map); 470 entry = Fassoc (name, Vw32_color_map, Qnil);
471 if (NILP (entry)) 471 if (NILP (entry))
472 { 472 {
473 entry = Fcons (name, rgb); 473 entry = Fcons (name, rgb);
diff --git a/src/w32font.c b/src/w32font.c
index 67d2f6d666d..314d7acdcc6 100644
--- a/src/w32font.c
+++ b/src/w32font.c
@@ -1627,7 +1627,7 @@ x_to_w32_charset (char * lpcs)
1627 Format of each entry is 1627 Format of each entry is
1628 (CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE)). 1628 (CHARSET_NAME . (WINDOWS_CHARSET . CODEPAGE)).
1629 */ 1629 */
1630 this_entry = Fassoc (build_string (charset), Vw32_charset_info_alist); 1630 this_entry = Fassoc (build_string (charset), Vw32_charset_info_alist, Qnil);
1631 1631
1632 if (NILP (this_entry)) 1632 if (NILP (this_entry))
1633 { 1633 {
diff --git a/src/w32notify.c b/src/w32notify.c
index 25205816bae..e8bdef8bdd3 100644
--- a/src/w32notify.c
+++ b/src/w32notify.c
@@ -642,7 +642,7 @@ WATCH-DESCRIPTOR should be an object returned by `w32notify-add-watch'. */)
642 /* Remove the watch object from watch list. Do this before freeing 642 /* Remove the watch object from watch list. Do this before freeing
643 the object, do that even if we fail to free it, watch_list is 643 the object, do that even if we fail to free it, watch_list is
644 kept free of junk. */ 644 kept free of junk. */
645 watch_object = Fassoc (watch_descriptor, watch_list); 645 watch_object = Fassoc (watch_descriptor, watch_list, Qnil);
646 if (!NILP (watch_object)) 646 if (!NILP (watch_object))
647 { 647 {
648 watch_list = Fdelete (watch_object, watch_list); 648 watch_list = Fdelete (watch_object, watch_list);
@@ -679,7 +679,7 @@ the watcher thread exits abnormally for any other reason. Removing the
679watch by calling `w32notify-rm-watch' also makes it invalid. */) 679watch by calling `w32notify-rm-watch' also makes it invalid. */)
680 (Lisp_Object watch_descriptor) 680 (Lisp_Object watch_descriptor)
681{ 681{
682 Lisp_Object watch_object = Fassoc (watch_descriptor, watch_list); 682 Lisp_Object watch_object = Fassoc (watch_descriptor, watch_list, Qnil);
683 683
684 if (!NILP (watch_object)) 684 if (!NILP (watch_object))
685 { 685 {
diff --git a/src/w32term.c b/src/w32term.c
index c37805cb6ca..0f7bb9337f6 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -6110,7 +6110,7 @@ x_calc_absolute_position (struct frame *f)
6110 6110
6111 list = CDR(list); 6111 list = CDR(list);
6112 6112
6113 geometry = Fassoc (Qgeometry, attributes); 6113 geometry = Fassoc (Qgeometry, attributes, Qnil);
6114 if (!NILP (geometry)) 6114 if (!NILP (geometry))
6115 { 6115 {
6116 monitor_left = Fnth (make_number (1), geometry); 6116 monitor_left = Fnth (make_number (1), geometry);
diff --git a/src/xdisp.c b/src/xdisp.c
index 28ed7685236..abca6a8137a 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -23314,7 +23314,7 @@ display_mode_element (struct it *it, int depth, int field_width, int precision,
23314 props = oprops; 23314 props = oprops;
23315 } 23315 }
23316 23316
23317 aelt = Fassoc (elt, mode_line_proptrans_alist); 23317 aelt = Fassoc (elt, mode_line_proptrans_alist, Qnil);
23318 if (! NILP (aelt) && !NILP (Fequal (props, XCDR (aelt)))) 23318 if (! NILP (aelt) && !NILP (Fequal (props, XCDR (aelt))))
23319 { 23319 {
23320 /* AELT is what we want. Move it to the front 23320 /* AELT is what we want. Move it to the front
@@ -28788,7 +28788,7 @@ set_frame_cursor_types (struct frame *f, Lisp_Object arg)
28788 28788
28789 /* By default, set up the blink-off state depending on the on-state. */ 28789 /* By default, set up the blink-off state depending on the on-state. */
28790 28790
28791 tem = Fassoc (arg, Vblink_cursor_alist); 28791 tem = Fassoc (arg, Vblink_cursor_alist, Qnil);
28792 if (!NILP (tem)) 28792 if (!NILP (tem))
28793 { 28793 {
28794 FRAME_BLINK_OFF_CURSOR (f) 28794 FRAME_BLINK_OFF_CURSOR (f)
@@ -28926,7 +28926,7 @@ get_window_cursor_type (struct window *w, struct glyph *glyph, int *width,
28926 /* Cursor is blinked off, so determine how to "toggle" it. */ 28926 /* Cursor is blinked off, so determine how to "toggle" it. */
28927 28927
28928 /* First look for an entry matching the buffer's cursor-type in blink-cursor-alist. */ 28928 /* First look for an entry matching the buffer's cursor-type in blink-cursor-alist. */
28929 if ((alt_cursor = Fassoc (BVAR (b, cursor_type), Vblink_cursor_alist), !NILP (alt_cursor))) 28929 if ((alt_cursor = Fassoc (BVAR (b, cursor_type), Vblink_cursor_alist, Qnil), !NILP (alt_cursor)))
28930 return get_specified_cursor_type (XCDR (alt_cursor), width); 28930 return get_specified_cursor_type (XCDR (alt_cursor), width);
28931 28931
28932 /* Then see if frame has specified a specific blink off cursor type. */ 28932 /* Then see if frame has specified a specific blink off cursor type. */
diff --git a/src/xfont.c b/src/xfont.c
index b73596ce7ce..85fccf0dafd 100644
--- a/src/xfont.c
+++ b/src/xfont.c
@@ -505,7 +505,8 @@ xfont_list (struct frame *f, Lisp_Object spec)
505 Lisp_Object alter; 505 Lisp_Object alter;
506 506
507 if ((alter = Fassoc (SYMBOL_NAME (registry), 507 if ((alter = Fassoc (SYMBOL_NAME (registry),
508 Vface_alternative_font_registry_alist), 508 Vface_alternative_font_registry_alist,
509 Qnil),
509 CONSP (alter))) 510 CONSP (alter)))
510 { 511 {
511 /* Pointer to REGISTRY-ENCODING field. */ 512 /* Pointer to REGISTRY-ENCODING field. */