4.4 Modifying Strings

You can alter the contents of a mutable string via operations described in this section. See Mutability.

The most basic way to alter the contents of an existing string is with aset (see Functions that Operate on Arrays). (aset string idx char) stores char into string at character index idx. When string is a unibyte string (see Text Representations), char must be a single byte (0–255); when string is multibyte, both char and the previous character at idx must be ASCII (0–127).

To clear out a string that contained a password, use clear-string:

Function: clear-string string

This makes string a unibyte string, clears its contents to null characters, and removes all text properties. It may also change string’s length.