Subject: bug#76455: [PATCH] Allow truncate flymake end-of-line diagnostic summary

From: Elijah Gabe Pérez <[email-masked]>
Date: Fri, 21 Feb 2025 11:07:29 -0600

Eli Zaretskii <[email-masked]> writes:

>> From: Elijah Gabe Pérez <[email-masked]>
>> Date: Thu, 20 Feb 2025 22:49:37 -0600
>> 
>> This patch allow to user set a limit for
>> `flymake-show-diagnostics-at-end-of-line' summary text.
>> 
>> This way you can shorten long messages like:
>> 
>> (message ) ‘message’ called with 0 arguments, but requires 1 or more
>>            error message^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>> 
>> to...
>> 
>> (message ) ‘message’ called with 0 arguments...
>>            error message^^^^^^^^^^^^^^^^^^^^^^^
>> 
>> This is related to bug#74691, which I also have this problem.
>
> Would it make sense to use string-truncate-left instead of reinventing
> what it does?

The problem is that `string-truncate-left' only truncate from left and
not from right.

If I eval this:
   (string-truncate-left "‘message’ called with 0 arguments, but requires 1 or more" 30)
returns:
  "...nts, but requires 1 or more"

But I think this would be more appropriate:
  "‘message’ called with 0 arg..."

Maybe the way to achieve this would be something like this:

  (string-reverse
    (string-truncate-left
      (string-reverse
        "‘message’ called with 0 arguments, but requires 1 or more") 20))

but this is very ugly imo.

That's why I decided to use `substring',
unless there is a "string-truncate-right" that can I use.

-- 
                                                   - E.G via GNU Emacs.