Subject: bug#76018: 31.0.50; wrap-prefix properties from visual-wrap-prefix-mode proliferate

From: Kévin Le Gouguec <[email-masked]>
Date: Tue, 04 Feb 2025 20:37:17 +0100

Kévin Le Gouguec <[email-masked]> writes:

> Jim Porter <[email-masked]> writes:
>
>> On 2/2/2025 9:50 AM, Kévin Le Gouguec wrote:
>>> Expectation: continuation lines for the "second line of [words…]" should
>>> not have any indentation.
>>> Observation: text on that second line has these properties:
>>>      There are text properties here:
>>>        fontified            t
>>>        wrap-prefix          (space :align-to (2 . width))
>>
>> Do you know if this is a recent regression, or if it's been this way since visual-wrap-prefix-mode was merged into Emacs? I've made a bunch of changes to the mode relatively recently, but the wrap-prefix part is mostly the same as before, aside from some different methods to calculate the width.
>
> Barring methodological errors, a smoketest using adaptive-wrap (0.8)
> suggests that it did not have this bug; the text properties on the
> second line are:
>
>     There are text properties here:
>       fontified            t
>       wrap-prefix          ""
>
> That's all I have for now; can try to bisect later!

After checking that 2024-01-27 "Import ELPA package adaptive-wrap as
visual-wrap" (6667d6c19c3) is "good" too, I got a bisection going -
testing each step after 'make bootstrap'.  Results:

    $ git bisect start HEAD 6667d6c19c3934871ed54d89dc153efc72f947de -- lisp/visual-wrap.el
    Bisecting: 7 revisions left to test after this (roughly 3 steps)
    [b86bc02096c65517b9a29c20635ece100864fc62] Introduce a global variant of visual-wrap-prefix-mode

    $ git bisect good
    Bisecting: 3 revisions left to test after this (roughly 2 steps)
    [55aad592e177dc2c503ebe9ad2a46e227683315e] Improve computation of indent depth in SHR and 'visual-wrap-prefix-mode'

    $ git bisect bad
    Bisecting: 1 revision left to test after this (roughly 1 step)
    [135da3556bb34bb20a01e02b30bc949c1a45b6cd] Be more careful about aligning prefix lines in 'visual-wrap-prefix-mode'

    $ git bisect bad
    Bisecting: 0 revisions left to test after this (roughly 0 steps)
    [f70a6ea0ea86ef461e40d20664a75a92d02679ea] Add support for variable-pitch fonts in 'visual-wrap-prefix-mode'

    $ git bisect bad
    f70a6ea0ea86ef461e40d20664a75a92d02679ea is the first bad commit
    commit f70a6ea0ea86ef461e40d20664a75a92d02679ea (HEAD)
    Author: Jim Porter <[email-masked]>
    Date:   Sat Jul 27 20:48:38 2024 -0700

        Add support for variable-pitch fonts in 'visual-wrap-prefix-mode'

        * lisp/emacs-lisp/subr-x.el (string-pixel-width): Allow passing BUFFER
        to use the face remappings from that buffer when calculating the width.

        * lisp/visual-wrap.el (visual-wrap--prefix): Rename to...
        (visual-wrap--adjust-prefix): ... this, and support PREFIX as a number.
        (visual-wrap-fill-context-prefix): Make obsolete in favor of...
        (visual-wrap--content-prefix): ... this.
        (visual-wrap-prefix-function): Extract inside of loop into...
        (visual-wrap--apply-to-line): ... this.

        * doc/lispref/display.texi (Size of Displayed Text): Update
        documentation for 'string-pixel-width'.

        * etc/NEWS: Announce this change.

     doc/lispref/display.texi  |   6 +++--
     etc/NEWS                  |  12 +++++++++
     lisp/emacs-lisp/subr-x.el |  11 +++++++--
     lisp/visual-wrap.el       | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------
     4 files changed, 102 insertions(+), 40 deletions(-)

Have not delved into the diff yet.