Width
=====
Since not all characters have the same width, these functions let you
check the width of a character. Note:Primitive Indent, and Note:Screen Lines, for related functions.
- Function: char-width char
This function returns the width in columns of the character CHAR,
if it were displayed in the current buffer and the selected window.
- Function: string-width string
This function returns the width in columns of the string STRING,
if it were displayed in the current buffer and the selected window.
- Function: truncate-string-to-width string width &optional
start-column padding
This function returns the part of STRING that fits within WIDTH
columns, as a new string.
If STRING does not reach WIDTH, then the result ends where STRING
ends. If one multi-column character in STRING extends across the
column WIDTH, that character is not included in the result. Thus,
the result can fall short of WIDTH but cannot go beyond it.
The optional argument START-COLUMN specifies the starting column.
If this is non-`nil', then the first START-COLUMN columns of the
string are omitted from the value. If one multi-column character
in STRING extends across the column START-COLUMN, that character
is not included.
The optional argument PADDING, if non-`nil', is a padding
character added at the beginning and end of the result string, to
extend it to exactly WIDTH columns. The padding character is used
at the end of the result if it falls short of WIDTH. It is also
used at the beginning of the result if one multi-column character
in STRING extends across the column START-COLUMN.
(truncate-string-to-width "\tab\t" 12 4)
=> "ab"
(truncate-string-to-width "\tab\t" 12 4 ?\ )
=> " ab "