Mercurial > hg > xemacs-beta
changeset 5665:8593e614573a
Avoid signalling args-out-of-range errors, #'truncate-string-to-width
lisp/ChangeLog addition:
Avoid args-out-of-range errors, this function is regularly called
from menu code and with debug-on-signal non-nil, this can be very
irritating.
Don't bind ellipsis-len, we don't use it.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sat, 12 May 2012 18:12:13 +0100 |
parents | 00fd55d635fb |
children | daf5accfe973 |
files | lisp/ChangeLog lisp/subr.el |
diffstat | 2 files changed, 14 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/ChangeLog Sat May 12 17:51:05 2012 +0100 +++ b/lisp/ChangeLog Sat May 12 18:12:13 2012 +0100 @@ -3,6 +3,10 @@ * subr.el: * subr.el (truncate-string-to-width): Sync with GNU's version, use its test suite in mule-tests.el. + Avoid args-out-of-range errors, this function is regularly called + from menu code and with debug-on-signal non-nil, this can be very + irritating. + Don't bind ellipsis-len, we don't use it. 2012-05-12 Aidan Kehoe <kehoea@parhasard.net>
--- a/lisp/subr.el Sat May 12 17:51:05 2012 +0100 +++ b/lisp/subr.el Sat May 12 18:12:13 2012 +0100 @@ -1062,18 +1062,15 @@ (setq ellipsis "...")) (let ((str-len (length str)) (str-width (string-width str)) - (ellipsis-len (if ellipsis (length ellipsis) 0)) (ellipsis-width (if ellipsis (string-width ellipsis) 0)) (idx 0) (column 0) (head-padding "") (tail-padding "") ch last-column last-idx from-idx) - (condition-case nil - (while (< column start-column) - (setq ch (aref str idx) - column (+ column (char-width ch)) - idx (1+ idx))) - (args-out-of-range (setq idx str-len))) + (while (and (< column start-column) (< idx str-len)) + (setq ch (aref str idx) + column (+ column (char-width ch)) + idx (1+ idx))) (if (< column start-column) (if padding (make-string end-column padding) "") (when (and padding (> column start-column)) @@ -1084,14 +1081,12 @@ (> str-width ellipsis-width)) (setq end-column (- end-column ellipsis-width)) (setq ellipsis "")) - (condition-case nil - (while (< column end-column) - (setq last-column column - last-idx idx - ch (aref str idx) - column (+ column (char-width ch)) - idx (1+ idx))) - (args-out-of-range (setq idx str-len))) + (while (and (< column end-column) (< idx str-len)) + (setq last-column column + last-idx idx + ch (aref str idx) + column (+ column (char-width ch)) + idx (1+ idx))) (when (> column end-column) (setq column last-column idx last-idx))