Re: [PATCH] * emms-mode-line.el: Use character width to display the track desc

Yoni Rabkin <[email protected]> Tue, 04 Feb 2025 15:23:47 -0500
Newsgroups gmane.emacs.emms.user
Message-ID <[email protected]>
Richard Sent <[email protected]> writes:

> ---
> Hi all,
>
> I found that emms-mode-line-playlist-current has a bug when dealing with
> track descriptions containing characters with a > 1 width.
>
> Consider this track description:
>
> (let ((foo "Hiroyuki Sawano - 澤野弘之 - KILL la KILL ORIGINAL SOUND TRACK - Kiる厭KiLL"))
>   (string-width foo) ;=>75
>   (length foo)) ;=>69
>
> It takes 75 columns to display due to the kanji. Yet when concatenating
> the string for display, we use character count, not width count.
>
> (seq-subseq track-desc 0 emms-mode-line-length-limit) ;limit=70 by default
> ;=> args-out-of-range as our string is only 69 characters long
>
>  emms-mode-line.el | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/emms-mode-line.el b/emms-mode-line.el
> index 7773f8f..a843a12 100644
> --- a/emms-mode-line.el
> +++ b/emms-mode-line.el
> @@ -64,9 +64,7 @@
>      (format emms-mode-line-format
>  	    (if (< (string-width track-desc) emms-mode-line-length-limit)
>  		track-desc
> -	      (concat
> -	       (seq-subseq track-desc 0 emms-mode-line-length-limit)
> -	       "...")))))
> +	      (truncate-string-to-width track-desc emms-mode-line-length-limit 0 nil t)))))
>  
>  
>  (define-obsolete-variable-alias 'emms-mode-line-active-p

applied; thank you

-- 
   "Cut your own wood and it will warm you twice"