emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Alternative to substring-no-properties


From: Juanma Barranquero
Subject: Re: Alternative to substring-no-properties
Date: Mon, 28 Jan 2002 11:42:52 +0100

On 28 Jan 2002 01:38:28 +0100, address@hidden (Kim F. Storm) wrote:

> Some days ago, I proposed to add an optional argument NO_PROPERTIES to
> the existing substring function rather than adding the new
> substring-no-properties function.  If the arg in non-nil, substring
> would not copy the text propertiesof the substring.

Something like the patch included?

Supposing your suggestion is accepted, I've thought of making also the
FROM parameter optional, with a default of 0, but although it'd be a
compatible change it is not that useful, as

  (substring str)

would be the identity function (and so supposedly not used very often)
and

  (substring nil nil t)

(the copy-without-properties equivalent) already needs to specify the
full complement of arguments...



                                                           /L/e/k/t/u


Index: fns.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/fns.c,v
retrieving revision 1.303
diff -u -r1.303 fns.c
--- fns.c       13 Nov 2001 11:55:47 -0000      1.303
+++ fns.c       28 Jan 2002 10:26:24 -0000
@@ -1165,15 +1165,16 @@
   return alist;
 }
 
-DEFUN ("substring", Fsubstring, Ssubstring, 2, 3, 0,
+DEFUN ("substring", Fsubstring, Ssubstring, 2, 4, 0,
        doc: /* Return a substring of STRING, starting at index FROM and ending 
before TO.
 TO may be nil or omitted; then the substring runs to the end of STRING.
 If FROM or TO is negative, it counts from the end.
+Properties are copied unless NO-PROPERTIES is non-nil.
 
 This function allows vectors as well as strings.  */)
-     (string, from, to)
+     (string, from, to, no_properties)
      Lisp_Object string;
-     register Lisp_Object from, to;
+     register Lisp_Object from, to, no_properties;
 {
   Lisp_Object res;
   int size;
@@ -1226,8 +1227,9 @@
       res = make_specified_string (XSTRING (string)->data + from_byte,
                                   to_char - from_char, to_byte - from_byte,
                                   STRING_MULTIBYTE (string));
-      copy_text_properties (make_number (from_char), make_number (to_char),
-                           string, make_number (0), res, Qnil);
+      if (NILP (no_properties))
+        copy_text_properties (make_number (from_char), make_number (to_char),
+                              string, make_number (0), res, Qnil);
     }
   else
     res = Fvector (to_char - from_char,




reply via email to

[Prev in Thread] Current Thread [Next in Thread]