GNU bug report logs -
#62847
29.0.90; Propertized space in Org Agenda's mode-name
Previous Next
Full log
Message #47 received at 62847 <at> debbugs.gnu.org (full text, mbox):
15 apr. 2023 kl. 13.45 skrev Eli Zaretskii <eliz <at> gnu.org>:
>>> So maybe replace " " with (copy-sequence " ").
>>
>> But that should not be necessary, right?
Ideally not -- setting properties on literal strings should indeed be avoided for a variety of reasons, one being that the byte compiler shares equal string literals:
(defun ff ()
(list "abc" (let ((s "abc"))
(put-text-property 0 3 'aa 'bb s)
s)))
(ff)
-> ("abc" #("abc" 0 3 (aa bb))) ; interpreted
-> (#("abc" 0 3 (aa bb)) #("abc" 0 3 (aa bb))) ; byte-compiled
`org-agenda-set-mode-name` uses the literal " " twice so if either is modified the other will appear to be, too. Where this setting of properties is done I have no idea
There is currently no automatic sharing of string literals between byte-code functions but this may change, and I've no idea what the native compiler is up to in this respect.
`propertize` is safe because it makes a copy of its string argument, so there shouldn't be any reason to copy that argument explicitly.
`org-add-props` calls `add-text-properties` and is clearly destructive.
Interpreted code is less affected by the problem because literals aren't shared throughout a function, but trouble can still occur:
(defun hh (x)
(let ((s "abc"))
(when x
(put-text-property 0 3 'aa 'bb s))
s))
(hh nil) -> "abc"
(hh t) -> #("abc" 0 3 (aa bb))
(hh nil) -> #("abc" 0 3 (aa bb))
...
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.