unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Mattias Engdegård" <mattiase@acm.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Ihor Radchenko <yantar92@posteo.net>,
	62847@debbugs.gnu.org, Stefan Monnier <monnier@iro.umontreal.ca>,
	gusbrs.2016@gmail.com
Subject: bug#62847: 29.0.90; Propertized space in Org Agenda's mode-name
Date: Sat, 15 Apr 2023 15:15:12 +0200	[thread overview]
Message-ID: <7C9FAA71-595D-47BD-B1DB-3256CF90CA63@acm.org> (raw)
In-Reply-To: <83cz45cqrw.fsf@gnu.org>

15 apr. 2023 kl. 13.45 skrev Eli Zaretskii <eliz@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))
...







  reply	other threads:[~2023-04-15 13:15 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-14 23:04 bug#62847: 29.0.90; Propertized space in Org Agenda's mode-name Gustavo Barros
2023-04-15  9:38 ` Ihor Radchenko
2023-04-15  9:49   ` Eli Zaretskii
2023-04-15 10:02     ` Ihor Radchenko
2023-04-15 10:24       ` Eli Zaretskii
2023-04-15 10:40         ` Ihor Radchenko
2023-04-15 10:55           ` Eli Zaretskii
2023-04-15 11:28             ` Gustavo Barros
2023-04-15 11:44             ` Ihor Radchenko
2023-04-15 11:49               ` Gustavo Barros
2023-04-15 12:08                 ` Ihor Radchenko
2023-04-15 13:21                   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-16 11:23                     ` Ihor Radchenko
2023-04-16 11:49                       ` Gustavo Barros
2023-04-15 11:38           ` Eli Zaretskii
2023-04-15 11:44             ` Ihor Radchenko
2023-04-15 11:45               ` Eli Zaretskii
2023-04-15 13:15                 ` Mattias Engdegård [this message]
2023-04-16 11:29                   ` Ihor Radchenko
2023-04-16 12:02                     ` Mattias Engdegård
2023-04-16 12:17                       ` Ihor Radchenko
2023-04-16 12:58                         ` Eli Zaretskii
2023-04-16 13:14                           ` Ihor Radchenko
2023-04-16 14:43                             ` Eli Zaretskii
2023-04-16 14:52                               ` Ihor Radchenko
2023-04-16 15:17                                 ` Eli Zaretskii
2023-04-16 14:51                       ` Mattias Engdegård
2023-04-16 14:53                         ` Mattias Engdegård
2023-04-16 12:38 ` Daniel Mendler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7C9FAA71-595D-47BD-B1DB-3256CF90CA63@acm.org \
    --to=mattiase@acm.org \
    --cc=62847@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=gusbrs.2016@gmail.com \
    --cc=monnier@iro.umontreal.ca \
    --cc=yantar92@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).