Yes, if I fix that one issue with the patch then all the rest works correctly and fixes the problem.
Thank you.

-Troy Hinckley
On Jul 8, 2024 at 12:42 PM -0500, Eli Zaretskii <eliz@gnu.org>, wrote:
Date: Mon, 8 Jul 2024 12:04:07 -0500
From: Troy Hinckley <troyhinckley@dabrev.com>
Cc: 71896@debbugs.gnu.org

The proposed patch throws an error when `last’ is “” because (substring “” -1) produces (args-out-of-range “” -
1 nil).

Is that the only problem with the patch? That is, if this is
trivially fixed, does all the rest work correctly and fixes the
problems?