comparison src/eval.c @ 4744:17f7e9191c0b

Rationalise duplicated functionality, #'custom-quote, #'quote-maybe. src/ChangeLog addition: 2009-11-15 Aidan Kehoe <kehoea@parhasard.net> * eval.c (Fquote_maybe): Move this function here from callint.c; make it more comprehensive about which types are self-quoting. * lisp.h: Declare Fquote_maybe here, since it's now used in callint.c and defined in eval.c * callint.c (Fquote_maybe): Remove this function from this file. lisp/ChangeLog addition: 2009-11-15 Aidan Kehoe <kehoea@parhasard.net> * custom.el (custom-quote): Define this as an alias for `quote-maybe', which is in C and more comprehensive; packages still use this name in places. (customize-mark-to-save, customize-mark-as-set): Use `quote-maybe', not `custom-quote'. * cus-edit.el (customize-set-variable, customize-save-variable) (custom-variable-value-create, custom-variable-set) (custom-variable-pre-save): Remove a version of `custom-quote' specific to this file; use `quote-maybe' universally instead.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 15 Nov 2009 14:59:53 +0000
parents 80cd90837ac5
children 084056f46755 e0db3c197671
comparison
equal deleted inserted replaced
4743:776bbf454f3a 4744:17f7e9191c0b
1250 represented as `(quote x)'). 1250 represented as `(quote x)').
1251 */ 1251 */
1252 (args)) 1252 (args))
1253 { 1253 {
1254 return XCAR (args); 1254 return XCAR (args);
1255 }
1256
1257 /* Originally, this was just a function -- but `custom' used a garden-
1258 variety version, so why not make it a subr? */
1259 DEFUN ("quote-maybe", Fquote_maybe, 1, 1, 0, /*
1260 Quote EXPR if it is not self quoting.
1261
1262 In contrast with `quote', this is a function, not a special form; its
1263 argument is evaluated before `quote-maybe' is called. It returns either
1264 EXPR (if it is self-quoting) or a list `(quote EXPR)' if it is not
1265 self-quoting. Lists starting with the symbol `lambda' are regarded as
1266 self-quoting.
1267 */
1268 (expr))
1269 {
1270 if ((XTYPE (expr)) == Lisp_Type_Record)
1271 {
1272 switch (XRECORD_LHEADER (expr)->type)
1273 {
1274 case lrecord_type_symbol:
1275 if (NILP (expr) || (EQ (expr, Qt)) || SYMBOL_IS_KEYWORD (expr))
1276 {
1277 return expr;
1278 }
1279 break;
1280 case lrecord_type_cons:
1281 if (EQ (XCAR (expr), Qlambda))
1282 {
1283 return expr;
1284 }
1285 break;
1286
1287 case lrecord_type_vector:
1288 case lrecord_type_string:
1289 case lrecord_type_compiled_function:
1290 case lrecord_type_bit_vector:
1291 case lrecord_type_float:
1292 case lrecord_type_hash_table:
1293 case lrecord_type_char_table:
1294 case lrecord_type_range_table:
1295 case lrecord_type_bignum:
1296 case lrecord_type_ratio:
1297 case lrecord_type_bigfloat:
1298 return expr;
1299 }
1300 return list2 (Qquote, expr);
1301 }
1302
1303 /* Fixnums and characters are self-quoting: */
1304 return expr;
1255 } 1305 }
1256 1306
1257 DEFUN ("function", Ffunction, 1, UNEVALLED, 0, /* 1307 DEFUN ("function", Ffunction, 1, UNEVALLED, 0, /*
1258 Return the argument, without evaluating it. `(function x)' yields `x'. 1308 Return the argument, without evaluating it. `(function x)' yields `x'.
1259 1309
7258 DEFSUBR (Fprogn); 7308 DEFSUBR (Fprogn);
7259 DEFSUBR (Fprog1); 7309 DEFSUBR (Fprog1);
7260 DEFSUBR (Fprog2); 7310 DEFSUBR (Fprog2);
7261 DEFSUBR (Fsetq); 7311 DEFSUBR (Fsetq);
7262 DEFSUBR (Fquote); 7312 DEFSUBR (Fquote);
7313 DEFSUBR (Fquote_maybe);
7263 DEFSUBR (Ffunction); 7314 DEFSUBR (Ffunction);
7264 DEFSUBR (Fdefun); 7315 DEFSUBR (Fdefun);
7265 DEFSUBR (Fdefmacro); 7316 DEFSUBR (Fdefmacro);
7266 DEFSUBR (Fdefvar); 7317 DEFSUBR (Fdefvar);
7267 DEFSUBR (Fdefconst); 7318 DEFSUBR (Fdefconst);