GNU bug report logs - #76018
31.0.50; wrap-prefix properties from visual-wrap-prefix-mode proliferate

Previous Next

Package: emacs;

Reported by: Kévin Le Gouguec <kevin.legouguec <at> gmail.com>

Date: Sun, 2 Feb 2025 17:51:02 UTC

Severity: normal

Found in version 31.0.50

Done: Jim Porter <jporterbugs <at> gmail.com>

Full log


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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Jim Porter <jporterbugs <at> gmail.com>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 76018 <at> debbugs.gnu.org, kevin.legouguec <at> gmail.com
Subject: Re: bug#76018: 31.0.50; wrap-prefix properties from
 visual-wrap-prefix-mode proliferate
Date: Tue, 27 May 2025 14:32:55 +0300
> Date: Mon, 26 May 2025 18:30:34 -0700
> From: Jim Porter <jporterbugs <at> gmail.com>
> 
> On 5/26/2025 5:11 PM, Jim Porter wrote:
> > Eli, what do you think? I've also moved an internal Eshell utility 
> > function ('eshell--append-text-property') to subr-x.el, since it would 
> > be useful for the visual-wrap code. I've updated the manual and NEWS to 
> > mention this function as well so that others can use it if they like.
> 
> After some further thought, I noticed that 'visual-wrap-prefix-mode' 
> doesn't clean up after itself properly. Attached is a fix, taking 
> advantage of a new function called 'remove-display-text-properties', 
> which does what you might expect.

OK, let's see if Stefan (CC'ed) has comments.

> --- a/lisp/visual-wrap.el
> +++ b/lisp/visual-wrap.el
> @@ -33,6 +33,8 @@
>  
>  ;;; Code:
>  
> +(require 'text-property-search)

Why did you need this 'require'?

> +@lisp
> +(add-display-text-property 1 8 'raise 0.5)
> +(add-display-text-property 4 8 'height 2.0)
> +(remove-display-text-property 2 6 'raise)
> +@end lisp

The lines inside @lisp..@end lisp should be in @group..@end group, to
prevent them from being split between pages in the printed version of
the manual.

> +      (if (not remove)
> +          ;; Apply `wrap-prefix' properties.
> +          (progn
> +            (put-text-property
> +             position (pos-eol) 'wrap-prefix
> +             (if (numberp next-line-prefix)
> +                 `(space :align-to (,next-line-prefix . width))
> +               next-line-prefix))
> +            ;; Make sure that when typing at the end of a line with
> +            ;; `wrap-prefix' set, we don't continue that property over
> +            ;; subsequent lines.  See bug#76018.
> +            (append-text-property position (pos-eol)
> +                                  'rear-nonsticky '(wrap-prefix)))
> +        ;; Remove `wrap-prefix' properties.
> +        (remove-text-properties position (pos-eol) '(wrap-prefix nil))
> +        (visual-wrap--remq-text-property position (pos-eol)
> +                                         'rear-nonsticky 'wrap-prefix)))))

This makes visual-wrap-mode incompatible with any other feature that
uses wrap-prefix, because all of those properties will be removed when
you turn off the mode, right?  If so, this subtlety should be at least
documented.

Thanks.




This bug report was last modified 6 days ago.

Previous Next


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