GNU bug report logs - #62847
29.0.90; Propertized space in Org Agenda's mode-name

Previous Next

Package: emacs;

Reported by: Gustavo Barros <gusbrs.2016 <at> gmail.com>

Date: Fri, 14 Apr 2023 23:05:02 UTC

Severity: normal

Found in version 29.0.90

Full log


View this message in rfc822 format

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Ihor Radchenko <yantar92 <at> posteo.net>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 62847 <at> debbugs.gnu.org, Gustavo Barros <gusbrs.2016 <at> gmail.com>
Subject: bug#62847: 29.0.90; Propertized space in Org Agenda's mode-name
Date: Sat, 15 Apr 2023 09:21:35 -0400
> So, it really looks like compilation problem.
>
> I am now looking into Elisp manual
>
>     2.9 Mutability
>     
>        When similar constants occur as parts of a program, the Lisp
>     interpreter might save time or space by reusing existing constants or
>     their components.  For example, ‘(eq "abc" "abc")’ returns ‘t’ if the
>     interpreter creates only one instance of the string literal ‘"abc"’, and
>     returns ‘nil’ if it creates two instances.  Lisp programs should be
>     written so that they work regardless of whether this optimization is in
>     use.
>
> So, it should be a good idea to avoid setting text properties in string
> constants in general.

Indeed, since it modifies the object, it's "undefined behavior" territory.

> -       (propertize "ALL" 'face 'org-agenda-structure-filter)
> +       (propertize
> +        (copy-sequence "ALL") ; Avoid modifying `eq' string constants.
> +        'face 'org-agenda-structure-filter)

`propertize` does not modify its string argument (it returns a new
string instead), so the `copy-sequence` here is a pure waste.

> -				(propertize " " 'display category-icon)
> +				(propertize
> +                                 (copy-sequence " ") ; Avoid modifying `eq' " ".
> +                                 'display category-icon)

Same here.

> -                     (org-add-props " " (org-plist-delete (text-properties-at 0 x)
> -                                                          'display)))
> +                     (org-add-props
> +                         (copy-sequence " ") ; Avoid modifying `eq' " ".
> +                         (org-plist-delete (text-properties-at 0 x)
> +                                           'display)))

This hunk fixes a real bug, OTOH.
Maybe you should use `(apply #'propertize` instead or `org-add-props`?


        Stefan





This bug report was last modified 2 years and 64 days ago.

Previous Next


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