GNU bug report logs - #8384
24.0.50; Yanking and text properties

Previous Next

Package: emacs;

Reported by: Stephen Berman <stephen.berman <at> gmx.net>

Date: Wed, 30 Mar 2011 22:27:02 UTC

Severity: minor

Found in version 24.0.50

Done: Chong Yidong <cyd <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 8384 in the body.
You can then email your comments to 8384 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8384; Package emacs. (Wed, 30 Mar 2011 22:27:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stephen Berman <stephen.berman <at> gmx.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 30 Mar 2011 22:27:02 GMT) Full text and rfc822 format available.

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

From: Stephen Berman <stephen.berman <at> gmx.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.0.50; Yanking and text properties
Date: Thu, 31 Mar 2011 00:26:14 +0200
1. emacs -Q
2. Enter text in a buffer and select it, e.g.: `C-x b a RET test C-SPC C-a' 
3. Put a face or display text property on the selected text, e.g.: `M-o b'
4. Put the propertized text on the kill ring: `C-SPC C-e M-w'.
5. Yank it in another buffer: `C-x b b RET C-y'
=> The yanked text in buffer b is propertized as in buffer a.

Now repeat steps 2 and 3, and instead of repeating step 4, double-click
on the text with mouse-1 to make it the primary selection, and instead
of repeating step 5, do `C-x b b RET <mouse-2>' to yank that selection.
=> The yanked text in buffer b is not propertized.

Is this difference between the two types of yanking a programming bug or
a feature (of the primary selection?) that is AFAICS undocumented and
hence a doc bug?  The comment by Glenn Morris in bug#8376
(http://permalink.gmane.org/gmane.emacs.bugs/45480) suggests the former,
namely, that yanking by C-y should also not preserve text properties.
Note, however, that mouse-yank-at-click behaves like C-y and not like
mouse-yank-primary.  (Or is it only font-locking, not face and display
properties, that aren't supposed to be preserved any more?  Note also
that if other text properties, e.g. invisible or intangible, are applied
in the first recipe, yanking with C-y does not preserve these.)

In GNU Emacs 24.0.50.1 (i686-suse-linux-gnu, GTK+ Version 2.20.1)
 of 2011-03-30 on escher
Windowing system distributor `The X.Org Foundation', version 11.0.10800000
configured using `configure  '--without-toolkit-scroll-bars' 'CFLAGS=-g -O2 -fno-optimize-sibling-calls''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=local
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8384; Package emacs. (Mon, 04 Apr 2011 20:54:02 GMT) Full text and rfc822 format available.

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

From: David De La Harpe Golden <david <at> harpegolden.net>
To: Stephen Berman <stephen.berman <at> gmx.net>
Cc: 8384 <at> debbugs.gnu.org
Subject: Re: bug#8384: 24.0.50; Yanking and text properties
Date: Mon, 04 Apr 2011 21:53:39 +0100
On 30/03/11 23:26, Stephen Berman wrote:
> 1. emacs -Q
> 2. Enter text in a buffer and select it, e.g.: `C-x b a RET test C-SPC C-a'
> 3. Put a face or display text property on the selected text, e.g.: `M-o b'
> 4. Put the propertized text on the kill ring: `C-SPC C-e M-w'.
> 5. Yank it in another buffer: `C-x b b RET C-y'
> =>  The yanked text in buffer b is propertized as in buffer a.
>
> Now repeat steps 2 and 3, and instead of repeating step 4, double-click
> on the text with mouse-1 to make it the primary selection, and instead
> of repeating step 5, do `C-x b b RET<mouse-2>' to yank that selection.
> =>  The yanked text in buffer b is not propertized.
>
> Is this difference between the two types of yanking a programming bug or
> a feature (of the primary selection?) that is AFAICS undocumented and
> hence a doc bug?

Hmm. I'd be inclined to consider the inconsistency a bug, - if C-w/M-y 
sequences are property-preserving intraprocess*, so too should be 
select/middleclick sequences, really.

* properties were always lost AFAIK once the data went "all the way 
outside" to other processes, though technically emacs Could Do Better 
there on several platforms via the multi-format support in relevant 
window system clipboad and selection protocols.

> The comment by Glenn Morris in bug#8376
> (http://permalink.gmane.org/gmane.emacs.bugs/45480) suggests the former,
> namely, that yanking by C-y should also not preserve text properties.
> Note, however, that mouse-yank-at-click behaves like C-y and not like
> mouse-yank-primary.  (Or is it only font-locking, not face and display
> properties,

I think it's only the font-locking if I'm understanding the arguments 
correctly (which I may presently not), the font-locking properties are 
after all dynamic things, not something the user sets - i.e. if you 
yanked some python code into a python docstring (or some entirely 
separate sphinx rst file) you presumably wouldn't want them preserved, 
the correct thing to do is let the inserted text be rehighlighted 
according to the locally applicable rules if any.

I guess it would also be possible to "freeze" font-locking into static 
face properties. Not something I'd personally want to happen unless I 
asked for it - though consider too the way word processors now tend to 
offer "paste special..." options (related to the aforementioned multi 
format support), i.e. there are nowadays established ways for apps to 
offer both formatted and unformatted variants of text to paste in on our 
three major window systems.  The development work involved is nontrivial 
though, at least in my estimation.







Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8384; Package emacs. (Tue, 05 Apr 2011 05:17:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: David De La Harpe Golden <david <at> harpegolden.net>
Cc: 8384 <at> debbugs.gnu.org, stephen.berman <at> gmx.net
Subject: Re: bug#8384: 24.0.50; Yanking and text properties
Date: Tue, 05 Apr 2011 01:16:42 -0400
> Date: Mon, 04 Apr 2011 21:53:39 +0100
> From: David De La Harpe Golden <david <at> harpegolden.net>
> Cc: 8384 <at> debbugs.gnu.org
> 
> > Now repeat steps 2 and 3, and instead of repeating step 4, double-click
> > on the text with mouse-1 to make it the primary selection, and instead
> > of repeating step 5, do `C-x b b RET<mouse-2>' to yank that selection.
> > =>  The yanked text in buffer b is not propertized.
> >
> > Is this difference between the two types of yanking a programming bug or
> > a feature (of the primary selection?) that is AFAICS undocumented and
> > hence a doc bug?
> 
> Hmm. I'd be inclined to consider the inconsistency a bug, - if C-w/M-y 
> sequences are property-preserving intraprocess*, so too should be 
> select/middleclick sequences, really.

It could be a bug, or it could be a side effect of the implementation,
because the text we select with a mouse is treated very differently
from the text we put on the kill ring.

However, since we have an internal alist where we store all our
selections, we should be able in principle to paste local selections
with all their text properties.  Would someone please trace through
x-own-selection-internal when selecting, and then through
x-get-selection-internal when pasting with the mouse, and see why the
local selections we store in Vselection_alist lose their text
properties?

> * properties were always lost AFAIK once the data went "all the way 
> outside" to other processes, though technically emacs Could Do Better 
> there on several platforms via the multi-format support in relevant 
> window system clipboad and selection protocols.

Right, but since we keep our local copy of the selection, which in
this case should be a string, we don't necessarily _need_ to lose the
text properties.

> > The comment by Glenn Morris in bug#8376
> > (http://permalink.gmane.org/gmane.emacs.bugs/45480) suggests the former,
> > namely, that yanking by C-y should also not preserve text properties.
> > Note, however, that mouse-yank-at-click behaves like C-y and not like
> > mouse-yank-primary.  (Or is it only font-locking, not face and display
> > properties,
> 
> I think it's only the font-locking if I'm understanding the arguments 
> correctly

It's only about font-lock, and thus not relevant to this discussion.

> I guess it would also be possible to "freeze" font-locking into static 
> face properties.

At first glance, this doesn't make sense to me.  If the target buffer
has font-lock enabled, it will delete/override such faces on the spot
anyway.  So to support such a feature, someone should first present a
convincing use case.

> though consider too the way word processors now tend to offer "paste
> special..." options

AFAIU, "Paste special" options are for _reformatting_ the selection
into an equivalent (for some value of ``equivalent''), but different
formatting.  E.g., reformat text with colors into the equivalent HTML
representation.  That includes stripping all the formatting as one of
the possibilities.  But it does not include _addition_ of formatting,
so seems unrelated to converting the fontification properties to
hard-coded colors.

Anyway, this last issue is not related to this bug report, so it
should get its own thread.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#8384; Package emacs. (Tue, 07 Aug 2012 05:02:02 GMT) Full text and rfc822 format available.

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

From: Chong Yidong <cyd <at> gnu.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 8384 <at> debbugs.gnu.org, stephen.berman <at> gmx.net,
	David De La Harpe Golden <david <at> harpegolden.net>
Subject: Re: bug#8384: 24.0.50; Yanking and text properties
Date: Tue, 07 Aug 2012 12:53:53 +0800
Eli Zaretskii <eliz <at> gnu.org> writes:

>> > Is this difference between the two types of yanking a programming bug or
>> > a feature (of the primary selection?) that is AFAICS undocumented and
>> > hence a doc bug?
>> 
>> Hmm. I'd be inclined to consider the inconsistency a bug, - if C-w/M-y 
>> sequences are property-preserving intraprocess*, so too should be 
>> select/middleclick sequences, really.
>
> It could be a bug, or it could be a side effect of the implementation,
> because the text we select with a mouse is treated very differently
> from the text we put on the kill ring.

It just involves replacing buffer-substring-no-properties with
buffer-substring in deactivate-mark.  I agree that this inconsistency
with C-w/M-w might as well be fixed, so I did that in the trunk.




bug closed, send any further explanations to 8384 <at> debbugs.gnu.org and Stephen Berman <stephen.berman <at> gmx.net> Request was from Chong Yidong <cyd <at> gnu.org> to control <at> debbugs.gnu.org. (Tue, 07 Aug 2012 05:03:01 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 04 Sep 2012 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 11 years and 243 days ago.

Previous Next


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