emacs-devel
[Top][All Lists]
Advanced

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

Re: Erroneous changelog entry?


From: Kim F. Storm
Subject: Re: Erroneous changelog entry?
Date: 24 Jan 2002 11:04:47 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1

Juanma Barranquero <address@hidden> writes:

> During the 21.1 pretest I proposed something similar to:
> 
> (defun substring-no-properties (string &optional from to)
>   "Return a substring of STRING, with no text properties.
> The substring starts at index FROM and ends before TO.
> FROM defaults to the beginning of the STRING.
> 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."
>   (let ((str (substring string (or from 0) to)))
>     (set-text-properties 0 (length str) nil str)
>     str))
> 
> which is somewhat more general.

I agree.  I've written code which explicitly removes properties
after using substring.  Your function would be useful there.

However, it seems wasteful to me to copy the properties in the first
place.  What about adding a fourth argument NO_PROPERTIES to the
built-in substring which simply causes it to skip the call to
copy_text_properties when non-nil?

Then your function could be written as

 (defun substring-no-properties (string &optional from to)
    (substring string (or from 0) to t))

And Richard's function would be equally simple:

 (defun copy-without-properties (string)
   (substring string 0 nil t))

-- 
Kim F. Storm <address@hidden> http://www.cua.dk




reply via email to

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