Function: intern-soft

intern-soft is a function defined in lread.c.

Signature

(intern-soft NAME &optional OBARRAY)

Documentation

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. A second optional argument specifies the obarray to use; it defaults to the value of obarray.

Other relevant functions are documented in the symbol group.

View in manual

Probably introduced at or before Emacs version 21.1.

Shortdoc

;; symbol
(intern-soft "list")
    => list
  (intern-soft "Phooey!")
    => nil

Source Code

// Defined in /usr/src/emacs/src/lread.c
{
  register Lisp_Object tem, string;

  if (NILP (obarray)) obarray = Vobarray;
  obarray = check_obarray (obarray);

  if (!SYMBOLP (name))
    {
      char *longhand = NULL;
      ptrdiff_t longhand_chars = 0;
      ptrdiff_t longhand_bytes = 0;

      CHECK_STRING (name);
      string = name;
      tem = oblookup_considering_shorthand (obarray, SSDATA (string),
					    SCHARS (string), SBYTES (string),
					    &longhand, &longhand_chars,
					    &longhand_bytes);
      if (longhand)
	xfree (longhand);
      return FIXNUMP (tem) ? Qnil : tem;
    }
  else
    {
      /* If already a symbol, we don't do shorthand-longhand translation,
	 as promised in the docstring.  */
      Lisp_Object sym = maybe_remove_pos_from_symbol (name);
      string = XSYMBOL (name)->u.s.name;
      tem
	= oblookup (obarray, SSDATA (string), SCHARS (string), SBYTES (string));
      return BASE_EQ (sym, tem) ? name : Qnil;
    }
}