changeset 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 4143b78d0df0
children cc293ef846d2
files src/ChangeLog src/keymap.c src/lisp.h src/symbols.c
diffstat 4 files changed, 14 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Sun Dec 23 15:29:17 2007 +0100
+++ b/src/ChangeLog	Mon Dec 24 14:00:14 2007 +0100
@@ -1,3 +1,10 @@
+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.)
+
 2007-12-23  Aidan Kehoe  <kehoea@parhasard.net>
 
 	* objects-tty.c (tty_find_charset_font): 
--- a/src/keymap.c	Sun Dec 23 15:29:17 2007 +0100
+++ b/src/keymap.c	Mon Dec 24 14:00:14 2007 +0100
@@ -1388,7 +1388,7 @@
 	  DECLARE_EISTRING (temp);
 	  eicpy_raw (temp, name, qxestrlen (name));
 	  eisetch_char (temp, 2, '-');
-	  *keysym = Fintern_soft (eimake_string (temp), Qnil);
+	  *keysym = Fintern_soft (eimake_string (temp), Qnil, Qnil);
 	}
       else if (EQ (*keysym, QLFD))
 	*keysym = QKlinefeed;
--- a/src/lisp.h	Sun Dec 23 15:29:17 2007 +0100
+++ b/src/lisp.h	Mon Dec 24 14:00:14 2007 +0100
@@ -5067,7 +5067,7 @@
 EXFUN (Ffboundp, 1);
 EXFUN (Ffset, 2);
 EXFUN (Fintern, 2);
-EXFUN (Fintern_soft, 2);
+EXFUN (Fintern_soft, 3);
 EXFUN (Fkill_local_variable, 1);
 EXFUN (Fset, 2);
 EXFUN (Fset_default, 2);
--- 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;
 }