Mercurial > hg > xemacs-beta
comparison src/symbols.c @ 4355:a2af1ff1761f
Provide a DEFAULT argument in #'intern-soft.
2007-12-24 Aidan Kehoe <kehoea@parhasard.net>
* symbols.c (Fintern_soft):
Provide a new optional third argument, DEFAULT, for those who want
to check if "nil" is a symbol or not. (More realistically, general
code that may get handed "nil" should probably use this argument.)
* keymap.c (define_key_check_and_coerce_keysym):
Call Fintern_soft with its new argument.
* lisp.h:
Update the declaration of Fintern_soft.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Mon, 24 Dec 2007 14:00:14 +0100 |
parents | c32e4dca0296 |
children | 8748a3f7ceb4 |
comparison
equal
deleted
inserted
replaced
4353:4143b78d0df0 | 4355:a2af1ff1761f |
---|---|
254 } | 254 } |
255 | 255 |
256 return object; | 256 return object; |
257 } | 257 } |
258 | 258 |
259 DEFUN ("intern-soft", Fintern_soft, 1, 2, 0, /* | 259 DEFUN ("intern-soft", Fintern_soft, 1, 3, 0, /* |
260 Return the canonical symbol named NAME, or nil if none exists. | 260 Return the canonical symbol named NAME, or nil if none exists. |
261 NAME may be a string or a symbol. If it is a symbol, that exact | 261 NAME may be a string or a symbol. If it is a symbol, that exact |
262 symbol is searched for. | 262 symbol is searched for. |
263 Optional second argument OBARRAY specifies the obarray to use; | 263 Optional second argument OBARRAY specifies the obarray to use; |
264 it defaults to the value of the variable `obarray'. | 264 it defaults to the value of the variable `obarray'. |
265 */ | 265 Optional third argument DEFAULT says what Lisp object to return if there is |
266 (name, obarray)) | 266 no canonical symbol named NAME, and defaults to nil. |
267 { | 267 */ |
268 /* #### Bug! (intern-soft "nil") returns nil. Perhaps we should | 268 (name, obarray, default_)) |
269 add a DEFAULT-IF-NOT-FOUND arg, like in get. */ | 269 { |
270 Lisp_Object tem; | 270 Lisp_Object tem; |
271 Lisp_Object string; | 271 Lisp_Object string; |
272 | 272 |
273 if (NILP (obarray)) obarray = Vobarray; | 273 if (NILP (obarray)) obarray = Vobarray; |
274 obarray = check_obarray (obarray); | 274 obarray = check_obarray (obarray); |
281 else | 281 else |
282 string = symbol_name (XSYMBOL (name)); | 282 string = symbol_name (XSYMBOL (name)); |
283 | 283 |
284 tem = oblookup (obarray, XSTRING_DATA (string), XSTRING_LENGTH (string)); | 284 tem = oblookup (obarray, XSTRING_DATA (string), XSTRING_LENGTH (string)); |
285 if (INTP (tem) || (SYMBOLP (name) && !EQ (name, tem))) | 285 if (INTP (tem) || (SYMBOLP (name) && !EQ (name, tem))) |
286 return Qnil; | 286 return default_; |
287 else | 287 else |
288 return tem; | 288 return tem; |
289 } | 289 } |
290 | 290 |
291 DEFUN ("unintern", Funintern, 1, 2, 0, /* | 291 DEFUN ("unintern", Funintern, 1, 2, 0, /* |