GNU bug report logs - #78184
30.0.93; ansi-osc-apply-on-region should use end marker

Previous Next

Package: emacs;

Reported by: Troy Brown <brownts <at> troybrown.dev>

Date: Thu, 1 May 2025 11:49:01 UTC

Severity: normal

Found in version 30.0.93

Done: Eli Zaretskii <eliz <at> gnu.org>

Full log


Message #14 received at 78184 <at> debbugs.gnu.org (full text, mbox):

From: Matthias Meulien <orontee <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Troy Brown <brownts <at> troybrown.dev>, 78184 <at> debbugs.gnu.org
Subject: Re: bug#78184: 30.0.93; ansi-osc-apply-on-region should use end marker
Date: Thu, 8 May 2025 17:12:50 +0200
[Message part 1 (text/plain, inline)]
Troy analysis is right.  I was able to reproduce.  Please have a look to
the attached patch.

Le lun. 5 mai 2025 à 21:41, Matthias Meulien <orontee <at> gmail.com> a écrit :

> I'll have a look at the end of the week.
>
> Le sam. 3 mai 2025 à 11:46, Eli Zaretskii <eliz <at> gnu.org> a écrit :
>
>> > Date: Thu, 1 May 2025 07:47:56 -0400
>> > From:  Troy Brown via "Bug reports for GNU Emacs,
>> >  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>> >
>> > I've been running into an issue when using the ANSI OSC compilation
>> > filters, where part way through parsing input, I'll get an "args out
>> > of range" error on the call to `put-text-property`.  I believe this is
>> > because `ansi-osc-apply-on-region` uses `delete-region` and therefore
>> > the buffer can shrink from its original size.  Due to this shrinking,
>> > the use of "end", in the call to `put-text-property` can reside
>> > outside the current bounds of the buffer, causing the error.
>> >
>> > Looking at similar functionality in `ansi-color-apply-on-region`, I
>> > noticed that it creates a marker for "end" at the beginning of the
>> > function, avoiding this problem.  I believe the ANSI OSC package
>> > should use a similar approach and create a marker for "end".  It's
>> > also likely that a marker should be used in other functions within the
>> > package, such as `ansi-osc-filter-region`, although
>> > `re-search-forward` doesn't seem to be susceptible to the range issue
>> > that `put-text-property` is.
>> >
>> > Currently, I use the following advice to workaround the problem by
>> > ensuring that "end" is a marker before calling the original function:
>> >
>> > ```emacs
>> > (defun init.el/advice/ansi-osc-apply-on-region (oldfun &rest r)
>> >   (let ((start (car r))
>> >         (end (cadr r)))
>> >     (funcall oldfun start (copy-marker end))))
>> > (advice-add 'ansi-osc-apply-on-region :around
>> > #'init.el/advice/ansi-osc-apply-on-region)
>> > ```
>>
>> Matthias, any comments on this?
>>
>
>
> --
> Matthias
>


-- 
Matthias
[Message part 2 (text/html, inline)]
[0001-ansi-osc.el-Use-marker-bug-78184.patch (text/x-patch, attachment)]

This bug report was last modified 16 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.