-(or (fboundp 'truncate-string)
-(defun truncate-string (string width &optional start-column)
- "Truncate STRING to fit in WIDTH columns.
-Optional non-nil arg START-COLUMN specifies the starting column.
-\[emu-e20.el; MULE 2.3 emulating function]"
- (or start-column
- (setq start-column 0))
- (let ((max-width (string-width string))
- (len (length string))
- (from 0)
- (column 0)
- to-prev to ch b)
- (if (>= width max-width)
- (setq width max-width))
- (if (>= start-column width)
- ""
- (while (< column start-column)
- (setq ch (aref string from)
- column (+ column (char-width ch))
- from (if (= (setq b (charset-bytes ch)) 0)
- (1+ from)
- (+ from b)
- ))
- )
- (if (< width max-width)
- (progn
- (setq to from)
- (while (and (<= column width)
- (< to len))
- (setq ch (aref string to)
- column (+ column (char-width ch))
- to-prev to
- to (if (= (setq b (charset-bytes ch)) 0)
- (1+ to)
- (+ to b)
- ))
- )
- (setq to to-prev)))
- (substring string from to))))
-;;;
- )
-