Mercurial > hg > xemacs-beta
diff 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 |
line wrap: on
line diff
--- a/src/symbols.c Sun Dec 23 15:29:17 2007 +0100 +++ b/src/symbols.c Mon Dec 24 14:00:14 2007 +0100 @@ -256,17 +256,17 @@ return object; } -DEFUN ("intern-soft", Fintern_soft, 1, 2, 0, /* +DEFUN ("intern-soft", Fintern_soft, 1, 3, 0, /* Return the canonical symbol named NAME, or nil if none exists. NAME may be a string or a symbol. If it is a symbol, that exact symbol is searched for. Optional second argument OBARRAY specifies the obarray to use; it defaults to the value of the variable `obarray'. +Optional third argument DEFAULT says what Lisp object to return if there is +no canonical symbol named NAME, and defaults to nil. */ - (name, obarray)) + (name, obarray, default_)) { - /* #### Bug! (intern-soft "nil") returns nil. Perhaps we should - add a DEFAULT-IF-NOT-FOUND arg, like in get. */ Lisp_Object tem; Lisp_Object string; @@ -283,7 +283,7 @@ tem = oblookup (obarray, XSTRING_DATA (string), XSTRING_LENGTH (string)); if (INTP (tem) || (SYMBOLP (name) && !EQ (name, tem))) - return Qnil; + return default_; else return tem; }