emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r107560: Warn against using `length'


From: Eli Zaretskii
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r107560: Warn against using `length' to compute display width of a string.
Date: Sat, 10 Mar 2012 11:55:54 +0200
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 107560
fixes bug(s): http://debbugs.gnu.org/10978
committer: Eli Zaretskii <address@hidden>
branch nick: trunk
timestamp: Sat 2012-03-10 11:55:54 +0200
message:
  Warn against using `length' to compute display width of a string.
  
   doc/lispref/strings.texi (String Basics):
   doc/lispref/sequences.texi (Sequence Functions): Mention that `length' is
   not appropriate for computing the string width on display; add a
   cross-reference to the description of `string-width'.  (Bug#10978)
modified:
  doc/lispref/ChangeLog
  doc/lispref/sequences.texi
  doc/lispref/strings.texi
=== modified file 'doc/lispref/ChangeLog'
--- a/doc/lispref/ChangeLog     2012-03-10 09:30:21 +0000
+++ b/doc/lispref/ChangeLog     2012-03-10 09:55:54 +0000
@@ -1,5 +1,10 @@
 2012-03-10  Eli Zaretskii  <address@hidden>
 
+       * strings.texi (String Basics):
+       * sequences.texi (Sequence Functions): Mention that `length' is
+       not appropriate for computing the string width on display; add a
+       cross-reference to the description of `string-width'.  (Bug#10978)
+
        * eval.texi (Autoloading): Minor change of wording.
 
 2012-03-10  Chong Yidong  <address@hidden>

=== modified file 'doc/lispref/sequences.texi'
--- a/doc/lispref/sequences.texi        2012-01-23 04:23:50 +0000
+++ b/doc/lispref/sequences.texi        2012-03-10 09:55:54 +0000
@@ -108,6 +108,11 @@
 @noindent
 See also @code{string-bytes}, in @ref{Text Representations}.
 
+If you need to compute the width of a string on display, you should
+use @code{string-width} (@pxref{Width}), not @code{length}, since
address@hidden only counts the number of characters, but does not
+account for the display width of each character.
+
 @defun elt sequence index
 @cindex elements of sequences
 This function returns the element of @var{sequence} indexed by

=== modified file 'doc/lispref/strings.texi'
--- a/doc/lispref/strings.texi  2012-01-23 04:23:50 +0000
+++ b/doc/lispref/strings.texi  2012-03-10 09:55:54 +0000
@@ -51,7 +51,9 @@
 operate on them with the general array and sequence functions.
 (@xref{Sequences Arrays Vectors}.)  For example, you can access or
 change individual characters in a string using the functions @code{aref}
-and @code{aset} (@pxref{Array Functions}).
+and @code{aset} (@pxref{Array Functions}).  However, note that
address@hidden should @emph{not} be used for computing the width of a
+string on display; use @code{string-width} (@pxref{Width}) instead.
 
   There are two text representations for address@hidden characters in
 Emacs strings (and in buffers): unibyte and multibyte (@pxref{Text


reply via email to

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