/[emacs]/emacs/src/fns.c
ViewVC logotype

Diff of /emacs/src/fns.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.304 by kfstorm, Thu Mar 21 12:19:02 2002 UTC revision 1.305 by rms, Tue Mar 26 09:19:00 2002 UTC
# Line 1236  This function allows vectors as well as Line 1236  This function allows vectors as well as
1236    return res;    return res;
1237  }  }
1238    
1239    
1240    DEFUN ("substring-no-properties", Fsubstring_no_properties, Ssubstring_no_properties, 1, 3, 0,
1241           doc: /* Return a substring of STRING, without text properties.
1242    It starts at index FROM and ending before TO.
1243    TO may be nil or omitted; then the substring runs to the end of STRING.
1244    If FROM is nil or omitted, the substring starts at the beginning of STRING.
1245    If FROM or TO is negative, it counts from the end.
1246    
1247    With one argument, just copy STRING without its properties.  */)
1248         (string, from, to)
1249         Lisp_Object string;
1250         register Lisp_Object from, to;
1251    {
1252      int size, size_byte;
1253      int from_char, to_char;
1254      int from_byte, to_byte;
1255    
1256      CHECK_STRING (string);
1257    
1258      size = XSTRING (string)->size;
1259      size_byte = STRING_BYTES (XSTRING (string));
1260    
1261      if (NILP (from))
1262        from_char = from_byte = 0;
1263      else
1264        {
1265          CHECK_NUMBER (from);
1266          from_char = XINT (from);
1267          if (from_char < 0)
1268            from_char += size;
1269    
1270          from_byte = string_char_to_byte (string, from_char);
1271        }
1272    
1273      if (NILP (to))
1274        {
1275          to_char = size;
1276          to_byte = size_byte;
1277        }
1278      else
1279        {
1280          CHECK_NUMBER (to);
1281    
1282          to_char = XINT (to);
1283          if (to_char < 0)
1284            to_char += size;
1285    
1286          to_byte = string_char_to_byte (string, to_char);
1287        }
1288    
1289      if (!(0 <= from_char && from_char <= to_char && to_char <= size))
1290        args_out_of_range_3 (string, make_number (from_char),
1291                             make_number (to_char));
1292    
1293      return make_specified_string (XSTRING (string)->data + from_byte,
1294                                    to_char - from_char, to_byte - from_byte,
1295                                    STRING_MULTIBYTE (string));
1296    }
1297    
1298  /* Extract a substring of STRING, giving start and end positions  /* Extract a substring of STRING, giving start and end positions
1299     both in characters and in bytes.  */     both in characters and in bytes.  */
1300    
# Line 1941  It can be retrieved with `(get SYMBOL PR Line 2000  It can be retrieved with `(get SYMBOL PR
2000      = Fplist_put (XSYMBOL (symbol)->plist, propname, value);      = Fplist_put (XSYMBOL (symbol)->plist, propname, value);
2001    return value;    return value;
2002  }  }
2003    
2004    DEFUN ("lax-plist-get", Flax_plist_get, Slax_plist_get, 2, 2, 0,
2005           doc: /* Extract a value from a property list, comparing with `equal'.
2006    PLIST is a property list, which is a list of the form
2007    \(PROP1 VALUE1 PROP2 VALUE2...).  This function returns the value
2008    corresponding to the given PROP, or nil if PROP is not
2009    one of the properties on the list.  */)
2010         (plist, prop)
2011         Lisp_Object plist;
2012         Lisp_Object prop;
2013    {
2014      Lisp_Object tail;
2015      
2016      for (tail = plist;
2017           CONSP (tail) && CONSP (XCDR (tail));
2018           tail = XCDR (XCDR (tail)))
2019        {
2020          if (! NILP (Fequal (prop, XCAR (tail))))
2021            return XCAR (XCDR (tail));
2022    
2023          QUIT;
2024        }
2025    
2026      if (!NILP (tail))
2027        wrong_type_argument (Qlistp, prop);
2028      
2029      return Qnil;
2030    }
2031    
2032    DEFUN ("lax-plist-put", Flax_plist_put, Slax_plist_put, 3, 3, 0,
2033           doc: /* Change value in PLIST of PROP to VAL, comparing with `equal'.
2034    PLIST is a property list, which is a list of the form
2035    \(PROP1 VALUE1 PROP2 VALUE2 ...).  PROP is a symbol and VAL is any object.
2036    If PROP is already a property on the list, its value is set to VAL,
2037    otherwise the new PROP VAL pair is added.  The new plist is returned;
2038    use `(setq x (lax-plist-put x prop val))' to be sure to use the new value.
2039    The PLIST is modified by side effects.  */)
2040         (plist, prop, val)
2041         Lisp_Object plist;
2042         register Lisp_Object prop;
2043         Lisp_Object val;
2044    {
2045      register Lisp_Object tail, prev;
2046      Lisp_Object newcell;
2047      prev = Qnil;
2048      for (tail = plist; CONSP (tail) && CONSP (XCDR (tail));
2049           tail = XCDR (XCDR (tail)))
2050        {
2051          if (! NILP (Fequal (prop, XCAR (tail))))
2052            {
2053              Fsetcar (XCDR (tail), val);
2054              return plist;
2055            }
2056          
2057          prev = tail;
2058          QUIT;
2059        }
2060      newcell = Fcons (prop, Fcons (val, Qnil));
2061      if (NILP (prev))
2062        return newcell;
2063      else
2064        Fsetcdr (XCDR (prev), newcell);
2065      return plist;
2066    }
2067    
2068  DEFUN ("equal", Fequal, Sequal, 2, 2, 0,  DEFUN ("equal", Fequal, Sequal, 2, 2, 0,
2069         doc: /* Return t if two Lisp objects have similar structure and contents.         doc: /* Return t if two Lisp objects have similar structure and contents.
2070  They must have the same data type.  They must have the same data type.
# Line 5352  invoked by mouse clicks and mouse menu i Line 5475  invoked by mouse clicks and mouse menu i
5475    defsubr (&Sstring_as_unibyte);    defsubr (&Sstring_as_unibyte);
5476    defsubr (&Scopy_alist);    defsubr (&Scopy_alist);
5477    defsubr (&Ssubstring);    defsubr (&Ssubstring);
5478      defsubr (&Ssubstring_no_properties);
5479    defsubr (&Snthcdr);    defsubr (&Snthcdr);
5480    defsubr (&Snth);    defsubr (&Snth);
5481    defsubr (&Selt);    defsubr (&Selt);
# Line 5370  invoked by mouse clicks and mouse menu i Line 5494  invoked by mouse clicks and mouse menu i
5494    defsubr (&Sget);    defsubr (&Sget);
5495    defsubr (&Splist_put);    defsubr (&Splist_put);
5496    defsubr (&Sput);    defsubr (&Sput);
5497      defsubr (&Slax_plist_get);
5498      defsubr (&Slax_plist_put);
5499    defsubr (&Sequal);    defsubr (&Sequal);
5500    defsubr (&Sfillarray);    defsubr (&Sfillarray);
5501    defsubr (&Schar_table_subtype);    defsubr (&Schar_table_subtype);

Legend:
Removed from v.1.304  
changed lines
  Added in v.1.305

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26