emacs-devel
[Top][All Lists]
Advanced

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

Re: master 188bd80: gnus-shorten-url: Improve and avoid args-out-of-rang


From: Stefan Monnier
Subject: Re: master 188bd80: gnus-shorten-url: Improve and avoid args-out-of-range error
Date: Mon, 13 Apr 2020 12:51:58 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> +;;;###autoload
> +(defun string-truncate-left (string length)
> +  "Truncate STRING to LENGTH, replacing initial surplus with \"...\"."
> +  (let ((strlen (length string)))
> +    (if (<= strlen length)
> +     string
> +      (setq length (max 0 (- length 3)))
> +      (concat "..." (substring string (max 0 (- strlen 1 length)))))))

This should of course rely on string-width rather than string-length,
but more importantly, it should obey `truncate-string-ellipsis` and
it should be "closer" to `truncate-string-to-width` (they should likely
be in the same file, and with similar sounding names).
Maybe it should even be merged with `truncate-string-to-width`.


        Stefan




reply via email to

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