all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* add-face-text-property destructively modified properties
@ 2019-10-09 18:14 Lars Ingebrigtsen
  2019-10-09 21:45 ` Stefan Monnier
  2019-10-10  6:51 ` Eli Zaretskii
  0 siblings, 2 replies; 8+ messages in thread
From: Lars Ingebrigtsen @ 2019-10-09 18:14 UTC (permalink / raw)
  To: emacs-devel

Up until yesterday, using this function on copies of strings would
modify the original string:

(progn
  (setq str1 (propertize "foo" 'face '(underline highlight)))
  (setq str2 (concat str1))
  (add-face-text-property 0 3 'foobar t str2)
  (pp str1 (current-buffer)))
->

#("foo" 0 3
  (face
   (underline highlight foobar)))

This didn't seem right to me, so I modified it to not do that, but only
modify str2 when I told it to modify str2.

Eli wanted comments about whether anybody thinks this is a surprising
change.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: add-face-text-property destructively modified properties
  2019-10-09 18:14 add-face-text-property destructively modified properties Lars Ingebrigtsen
@ 2019-10-09 21:45 ` Stefan Monnier
  2019-10-11  7:57   ` Lars Ingebrigtsen
  2019-10-10  6:51 ` Eli Zaretskii
  1 sibling, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2019-10-09 21:45 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: emacs-devel

> Up until yesterday, using this function on copies of strings would
> modify the original string:

Indeed.  There was an open bug report about that (sorry, don't have the
bug-nb at hand).

> Eli wanted comments about whether anybody thinks this is a surprising
> change.

I think it was a plain bug.  The old behavior was
definitely surprising. 

What is surprising about the change is that it took so long to come ;-)


        Stefan




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: add-face-text-property destructively modified properties
  2019-10-09 18:14 add-face-text-property destructively modified properties Lars Ingebrigtsen
  2019-10-09 21:45 ` Stefan Monnier
@ 2019-10-10  6:51 ` Eli Zaretskii
  2019-10-10 12:56   ` Stefan Monnier
  1 sibling, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2019-10-10  6:51 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: emacs-devel

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Date: Wed, 09 Oct 2019 20:14:26 +0200
> 
> (progn
>   (setq str1 (propertize "foo" 'face '(underline highlight)))
>   (setq str2 (concat str1))
>   (add-face-text-property 0 3 'foobar t str2)
>   (pp str1 (current-buffer)))
> ->
> 
> #("foo" 0 3
>   (face
>    (underline highlight foobar)))
> 
> This didn't seem right to me, so I modified it to not do that, but only
> modify str2 when I told it to modify str2.
> 
> Eli wanted comments about whether anybody thinks this is a surprising
> change.

Mostly whether people think this could break something, as we had this
behavior for quite some time, I think.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: add-face-text-property destructively modified properties
  2019-10-10  6:51 ` Eli Zaretskii
@ 2019-10-10 12:56   ` Stefan Monnier
  0 siblings, 0 replies; 8+ messages in thread
From: Stefan Monnier @ 2019-10-10 12:56 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Lars Ingebrigtsen, emacs-devel

> Mostly whether people think this could break something, as we had this
> behavior for quite some time, I think.

It's always possible, of course, but I'd be *very* surprised.


        Stefan




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: add-face-text-property destructively modified properties
  2019-10-09 21:45 ` Stefan Monnier
@ 2019-10-11  7:57   ` Lars Ingebrigtsen
  2019-10-11 13:25     ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Lars Ingebrigtsen @ 2019-10-11  7:57 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> Up until yesterday, using this function on copies of strings would
>> modify the original string:
>
> Indeed.  There was an open bug report about that (sorry, don't have the
> bug-nb at hand).

Yup; it was that bug report that made me change the behaviour.

>> Eli wanted comments about whether anybody thinks this is a surprising
>> change.
>
> I think it was a plain bug.  The old behavior was
> definitely surprising. 
>
> What is surprising about the change is that it took so long to come ;-)

When I added add-face-text-property, it was for shr, which only uses it
for buffers where this isn't a problem (I think...?), so I probably
didn't even consider how this would work in strings.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: add-face-text-property destructively modified properties
  2019-10-11  7:57   ` Lars Ingebrigtsen
@ 2019-10-11 13:25     ` Stefan Monnier
  2019-10-12 21:32       ` Lars Ingebrigtsen
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2019-10-11 13:25 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: emacs-devel

> When I added add-face-text-property, it was for shr, which only uses it
> for buffers where this isn't a problem (I think...?),

I'm pretty sure the problem can occur in buffers as well.
E.g. if you (put-text-property X Y 'face '(a b c d)) at variable places
(hence using the exact same list object as `face` property at various
places) and then use add-face-text-property on some of those places.
[ both within a given buffer and between different buffers.  ]


        Stefan




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: add-face-text-property destructively modified properties
  2019-10-11 13:25     ` Stefan Monnier
@ 2019-10-12 21:32       ` Lars Ingebrigtsen
  2019-10-13 14:31         ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Lars Ingebrigtsen @ 2019-10-12 21:32 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> When I added add-face-text-property, it was for shr, which only uses it
>> for buffers where this isn't a problem (I think...?),
>
> I'm pretty sure the problem can occur in buffers as well.
> E.g. if you (put-text-property X Y 'face '(a b c d)) at variable places
> (hence using the exact same list object as `face` property at various
> places) and then use add-face-text-property on some of those places.
> [ both within a given buffer and between different buffers.  ]

Ah, yes, that's true.  Mixing and matching put-text-property with
add-face-text-property could also lead to similar problems as in
strings.

But can `buffer-substring' give us the same problems, or are the text
properties deep-copied in that case?

(I've now changed add-face-text-property to be non-destructive when
changing buffer face properties, too.)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: add-face-text-property destructively modified properties
  2019-10-12 21:32       ` Lars Ingebrigtsen
@ 2019-10-13 14:31         ` Stefan Monnier
  0 siblings, 0 replies; 8+ messages in thread
From: Stefan Monnier @ 2019-10-13 14:31 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: emacs-devel

> But can `buffer-substring' give us the same problems, or are the text
> properties deep-copied in that case?

I don't think they *can* be deep-copied (at least not without breaking
code).


        Stefan




^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-10-13 14:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-09 18:14 add-face-text-property destructively modified properties Lars Ingebrigtsen
2019-10-09 21:45 ` Stefan Monnier
2019-10-11  7:57   ` Lars Ingebrigtsen
2019-10-11 13:25     ` Stefan Monnier
2019-10-12 21:32       ` Lars Ingebrigtsen
2019-10-13 14:31         ` Stefan Monnier
2019-10-10  6:51 ` Eli Zaretskii
2019-10-10 12:56   ` Stefan Monnier

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.