all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* format padding and text properties
@ 2016-06-22  5:38 Eric Abrahamsen
  2016-06-22  6:08 ` tomas
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Abrahamsen @ 2016-06-22  5:38 UTC (permalink / raw)
  To: help-gnu-emacs

I'm trying to pad out a string that has had a face applied to it, and
it's not quite going as I'd hoped. In a nutshell:

(setq ss "bubba")
(put-text-property 0 (length ss) 'face 'my-face ss)
(format "%10s" ss)

--> #("      bubba" 0 5 (face my-face))

I'd like the face to stay with the actual string, not the spaces! Does
text property stickiness have anything to do with this? Does anyone have
any clever tips?

Using Emacs git...

Thanks!
Eric




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

* Re: format padding and text properties
  2016-06-22  5:38 Eric Abrahamsen
@ 2016-06-22  6:08 ` tomas
  2016-06-22  8:06   ` Eric Abrahamsen
  2016-06-22 15:05   ` Eli Zaretskii
  0 siblings, 2 replies; 10+ messages in thread
From: tomas @ 2016-06-22  6:08 UTC (permalink / raw)
  To: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, Jun 22, 2016 at 01:38:16PM +0800, Eric Abrahamsen wrote:
> I'm trying to pad out a string that has had a face applied to it, and
> it's not quite going as I'd hoped. In a nutshell:
> 
> (setq ss "bubba")
> (put-text-property 0 (length ss) 'face 'my-face ss)
> (format "%10s" ss)
> 
> --> #("      bubba" 0 5 (face my-face))
> 
> I'd like the face to stay with the actual string, not the spaces! Does
> text property stickiness have anything to do with this? Does anyone have
> any clever tips?

This is remarkable. I didn't even know that text properties made it
through format (admittedly in a strange way).

Learnt something new today :-)

regards
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAldqK10ACgkQBcgs9XrR2kaLlgCeKWgaxjgec2jD4zRnKIowTtV9
vl4An2hzEejXYD356p5U4CXAqWsP5BWg
=y28V
-----END PGP SIGNATURE-----



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

* Re: format padding and text properties
  2016-06-22  6:08 ` tomas
@ 2016-06-22  8:06   ` Eric Abrahamsen
  2016-06-22  8:21     ` tomas
  2016-06-22 15:05   ` Eli Zaretskii
  1 sibling, 1 reply; 10+ messages in thread
From: Eric Abrahamsen @ 2016-06-22  8:06 UTC (permalink / raw)
  To: help-gnu-emacs

<tomas@tuxteam.de> writes:

> On Wed, Jun 22, 2016 at 01:38:16PM +0800, Eric Abrahamsen wrote:
>> I'm trying to pad out a string that has had a face applied to it, and
>> it's not quite going as I'd hoped. In a nutshell:
>>
>> (setq ss "bubba")
>> (put-text-property 0 (length ss) 'face 'my-face ss)
>> (format "%10s" ss)
>>
>> --> #("      bubba" 0 5 (face my-face))
>>
>> I'd like the face to stay with the actual string, not the spaces! Does
>> text property stickiness have anything to do with this? Does anyone have
>> any clever tips?
>
> This is remarkable. I didn't even know that text properties made it
> through format (admittedly in a strange way).
>
> Learnt something new today :-)

So you're saying I shouldn't expect this to Just Work? :)




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

* Re: format padding and text properties
       [not found] <mailman.1975.1466573922.1216.help-gnu-emacs@gnu.org>
@ 2016-06-22  8:20 ` Lars Magne Ingebrigtsen
  2016-06-22  8:38   ` Eric Abrahamsen
  0 siblings, 1 reply; 10+ messages in thread
From: Lars Magne Ingebrigtsen @ 2016-06-22  8:20 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: help-gnu-emacs

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> (setq ss "bubba")
> (put-text-property 0 (length ss) 'face 'my-face ss)
> (format "%10s" ss)
>
> --> #("      bubba" 0 5 (face my-face))

Is this with an up-to-date trunk?  This should have been fixed a few
weeks ago:

commit 1c09423880e1c48d6ba02a196430e829d1d87d57
Author: Eli Zaretskii <eliz@gnu.org>
Date:   Thu Jun 9 16:52:08 2016 +0300

    Fix copying text properties by 'format'


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



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

* Re: format padding and text properties
  2016-06-22  8:06   ` Eric Abrahamsen
@ 2016-06-22  8:21     ` tomas
  0 siblings, 0 replies; 10+ messages in thread
From: tomas @ 2016-06-22  8:21 UTC (permalink / raw)
  To: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, Jun 22, 2016 at 04:06:21PM +0800, Eric Abrahamsen wrote:
> <tomas@tuxteam.de> writes:

[...]

> > Learnt something new today :-)
> 
> So you're saying I shouldn't expect this to Just Work? :)

You're over-estimating my chops, which is flattering :-)

I was just saying that *I* didn't expect that to Just Work. Let's
just wait until someone more knowledgeable chimes in (or until
I get a chance to RTFM: $DAYJOB has me in its claws at the moment)

regards
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAldqSpsACgkQBcgs9XrR2kb0gQCeLXevRDLDWB4YOSJYeGAgzN2+
drgAnjf4uVS+qkZJaSWrRstM+chwzDae
=uHsi
-----END PGP SIGNATURE-----



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

* Re: format padding and text properties
  2016-06-22  8:20 ` format padding and text properties Lars Magne Ingebrigtsen
@ 2016-06-22  8:38   ` Eric Abrahamsen
  2016-06-22 15:03     ` Eli Zaretskii
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Abrahamsen @ 2016-06-22  8:38 UTC (permalink / raw)
  To: help-gnu-emacs

Lars Magne Ingebrigtsen <lmi@gnus.org> writes:

> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
>> (setq ss "bubba")
>> (put-text-property 0 (length ss) 'face 'my-face ss)
>> (format "%10s" ss)
>>
>> --> #("      bubba" 0 5 (face my-face))
>
> Is this with an up-to-date trunk?  This should have been fixed a few
> weeks ago:
>
> commit 1c09423880e1c48d6ba02a196430e829d1d87d57
> Author: Eli Zaretskii <eliz@gnu.org>
> Date:   Thu Jun 9 16:52:08 2016 +0300
>
>     Fix copying text properties by 'format'

Ah! No wonder the bug seemed to crop up out of nowhere.

The bad news is the problem still seems to be there. I pulled and built
the master branch this morning, and can see Eli's patch in git log.

"GNU Emacs 25.1.50.5 (x86_64-unknown-linux-gnu, GTK+ Version 3.20.6)
 of 2016-06-22"

Eric




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

* Re: format padding and text properties
  2016-06-22  8:38   ` Eric Abrahamsen
@ 2016-06-22 15:03     ` Eli Zaretskii
  2016-06-22 15:10       ` Eric Abrahamsen
  0 siblings, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2016-06-22 15:03 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Eric Abrahamsen <eric@ericabrahamsen.net>
> Date: Wed, 22 Jun 2016 16:38:40 +0800
> 
> > commit 1c09423880e1c48d6ba02a196430e829d1d87d57
> > Author: Eli Zaretskii <eliz@gnu.org>
> > Date:   Thu Jun 9 16:52:08 2016 +0300
> >
> >     Fix copying text properties by 'format'
> 
> Ah! No wonder the bug seemed to crop up out of nowhere.
> 
> The bad news is the problem still seems to be there.

It's not a problem, it's the intended behavior.

If you want to put the face only on the text, either change the format
to not produce padding, or append the faceless spaces afterwards.



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

* Re: format padding and text properties
  2016-06-22  6:08 ` tomas
  2016-06-22  8:06   ` Eric Abrahamsen
@ 2016-06-22 15:05   ` Eli Zaretskii
  2016-06-23  6:30     ` tomas
  1 sibling, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2016-06-22 15:05 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Wed, 22 Jun 2016 08:08:29 +0200
> From: <tomas@tuxteam.de>
> 
> This is remarkable. I didn't even know that text properties made it
> through format (admittedly in a strange way).

It's not strange: the entire text produced from 'format' inherits the
faces both from the string arguments and from the format descriptor.



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

* Re: format padding and text properties
  2016-06-22 15:03     ` Eli Zaretskii
@ 2016-06-22 15:10       ` Eric Abrahamsen
  0 siblings, 0 replies; 10+ messages in thread
From: Eric Abrahamsen @ 2016-06-22 15:10 UTC (permalink / raw)
  To: help-gnu-emacs

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Eric Abrahamsen <eric@ericabrahamsen.net>
>> Date: Wed, 22 Jun 2016 16:38:40 +0800
>> 
>> > commit 1c09423880e1c48d6ba02a196430e829d1d87d57
>> > Author: Eli Zaretskii <eliz@gnu.org>
>> > Date:   Thu Jun 9 16:52:08 2016 +0300
>> >
>> >     Fix copying text properties by 'format'
>> 
>> Ah! No wonder the bug seemed to crop up out of nowhere.
>> 
>> The bad news is the problem still seems to be there.
>
> It's not a problem, it's the intended behavior.
>
> If you want to put the face only on the text, either change the format
> to not produce padding, or append the faceless spaces afterwards.

Okay, good to know. I'll adjust my code accordingly.




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

* Re: format padding and text properties
  2016-06-22 15:05   ` Eli Zaretskii
@ 2016-06-23  6:30     ` tomas
  0 siblings, 0 replies; 10+ messages in thread
From: tomas @ 2016-06-23  6:30 UTC (permalink / raw)
  To: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, Jun 22, 2016 at 06:05:43PM +0300, Eli Zaretskii wrote:
> > Date: Wed, 22 Jun 2016 08:08:29 +0200
> > From: <tomas@tuxteam.de>
> > 
> > This is remarkable. I didn't even know that text properties made it
> > through format (admittedly in a strange way).
> 
> It's not strange: the entire text produced from 'format' inherits the
> faces both from the string arguments and from the format descriptor.

:-)

That's how miracles go: if you totally not expect something, then you
don't look it up in the docs...

Thanks y'all for teaching me something new.

Regards
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAldrgg8ACgkQBcgs9XrR2kb50gCdEdurTyNa7LksoUEorhsIyROi
yjoAnj1oLjxI8vlKvwvtZmoB+aZAFbRD
=rQF9
-----END PGP SIGNATURE-----



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

end of thread, other threads:[~2016-06-23  6:30 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.1975.1466573922.1216.help-gnu-emacs@gnu.org>
2016-06-22  8:20 ` format padding and text properties Lars Magne Ingebrigtsen
2016-06-22  8:38   ` Eric Abrahamsen
2016-06-22 15:03     ` Eli Zaretskii
2016-06-22 15:10       ` Eric Abrahamsen
2016-06-22  5:38 Eric Abrahamsen
2016-06-22  6:08 ` tomas
2016-06-22  8:06   ` Eric Abrahamsen
2016-06-22  8:21     ` tomas
2016-06-22 15:05   ` Eli Zaretskii
2016-06-23  6:30     ` tomas

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.