unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#17052: substitute-command-keys strips text properties
@ 2014-03-20 16:22 Juanma Barranquero
  2019-08-15  0:55 ` Lars Ingebrigtsen
  2020-11-17  1:37 ` bug#17052: substitute-command-keys strips text properties, bug#8911: huh? Drew Adams
  0 siblings, 2 replies; 17+ messages in thread
From: Juanma Barranquero @ 2014-03-20 16:22 UTC (permalink / raw)
  To: 17052

Package: emacs
Severity: wishlist

Currently, substitute-command-keys returns a string with text
properties stripped. This should be fixed.

One specific case where it matters is in docstrings of advised
functions, as discussed in the thread for bug#16993.





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

* bug#17052: substitute-command-keys strips text properties
  2014-03-20 16:22 bug#17052: substitute-command-keys strips text properties Juanma Barranquero
@ 2019-08-15  0:55 ` Lars Ingebrigtsen
  2019-08-15  1:34   ` Glenn Morris
  2020-11-17  1:37 ` bug#17052: substitute-command-keys strips text properties, bug#8911: huh? Drew Adams
  1 sibling, 1 reply; 17+ messages in thread
From: Lars Ingebrigtsen @ 2019-08-15  0:55 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: 17052

Juanma Barranquero <lekktu@gmail.com> writes:

> Currently, substitute-command-keys returns a string with text
> properties stripped. This should be fixed.
>
> One specific case where it matters is in docstrings of advised
> functions, as discussed in the thread for bug#16993.

(I'm going through old bug reports that have unfortunately gotten no
responses yet.)

Looks like this has been fixed sometime in the intervening years?

(substitute-command-keys (propertize "foo" 'face 'bold))
=> #("foo" 0 3 (face bold))

So I'm closing this bug report.  If this is still a problem, please
reopen.

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





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

* bug#17052: substitute-command-keys strips text properties
  2019-08-15  0:55 ` Lars Ingebrigtsen
@ 2019-08-15  1:34   ` Glenn Morris
  2019-08-15  1:58     ` Lars Ingebrigtsen
  2020-11-17  1:24     ` Stefan Kangas
  0 siblings, 2 replies; 17+ messages in thread
From: Glenn Morris @ 2019-08-15  1:34 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Juanma Barranquero, 17052

Lars Ingebrigtsen wrote:

> Looks like this has been fixed sometime in the intervening years?
>
> (substitute-command-keys (propertize "foo" 'face 'bold))
> => #("foo" 0 3 (face bold))

Nope, you need to use an example which does a substitution, eg

(substitute-command-keys (propertize "foo \\[find-file]" 'face 'bold))

The doc of substitute-command-keys used to mention this, but it was
somewhat prematurely removed in 049fac7.





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

* bug#17052: substitute-command-keys strips text properties
  2019-08-15  1:34   ` Glenn Morris
@ 2019-08-15  1:58     ` Lars Ingebrigtsen
  2019-08-15 16:46       ` Eli Zaretskii
  2020-11-17  1:24     ` Stefan Kangas
  1 sibling, 1 reply; 17+ messages in thread
From: Lars Ingebrigtsen @ 2019-08-15  1:58 UTC (permalink / raw)
  To: Glenn Morris; +Cc: Juanma Barranquero, 17052

Glenn Morris <rgm@gnu.org> writes:

> Lars Ingebrigtsen wrote:
>
>> Looks like this has been fixed sometime in the intervening years?
>>
>> (substitute-command-keys (propertize "foo" 'face 'bold))
>> => #("foo" 0 3 (face bold))
>
> Nope, you need to use an example which does a substitution, eg
>
> (substitute-command-keys (propertize "foo \\[find-file]" 'face 'bold))

Ah, I see.  I've now reopened the bug report again.

> The doc of substitute-command-keys used to mention this, but it was
> somewhat prematurely removed in 049fac7.

Heh, heh:

    (Fsubstitute_command_keys): Don't advertise the fact that
    text-properties are dropped, since we think it's a bug that we'll fix
    in 24.5.

Should I just put it back in the doc string, or do we still think that
we'll fix it?

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





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

* bug#17052: substitute-command-keys strips text properties
  2019-08-15  1:58     ` Lars Ingebrigtsen
@ 2019-08-15 16:46       ` Eli Zaretskii
  2019-08-15 22:42         ` Lars Ingebrigtsen
  0 siblings, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2019-08-15 16:46 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 17052, lekktu

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Date: Wed, 14 Aug 2019 18:58:57 -0700
> Cc: Juanma Barranquero <lekktu@gmail.com>, 17052@debbugs.gnu.org
> 
> > The doc of substitute-command-keys used to mention this, but it was
> > somewhat prematurely removed in 049fac7.
> 
> Heh, heh:
> 
>     (Fsubstitute_command_keys): Don't advertise the fact that
>     text-properties are dropped, since we think it's a bug that we'll fix
>     in 24.5.
> 
> Should I just put it back in the doc string, or do we still think that
> we'll fix it?

I don't think it matters (unless you want to fix this right now ;-).
We should document the situation and leave the bug open for the
possibility that someone would like to work on this.

Thanks.





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

* bug#17052: substitute-command-keys strips text properties
  2019-08-15 16:46       ` Eli Zaretskii
@ 2019-08-15 22:42         ` Lars Ingebrigtsen
  2019-08-16  6:47           ` Eli Zaretskii
  2019-08-18 17:08           ` Stefan Kangas
  0 siblings, 2 replies; 17+ messages in thread
From: Lars Ingebrigtsen @ 2019-08-15 22:42 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 17052, lekktu

Eli Zaretskii <eliz@gnu.org> writes:

>> Heh, heh:
>> 
>>     (Fsubstitute_command_keys): Don't advertise the fact that
>>     text-properties are dropped, since we think it's a bug that we'll fix
>>     in 24.5.
>> 
>> Should I just put it back in the doc string, or do we still think that
>> we'll fix it?
>
> I don't think it matters (unless you want to fix this right now ;-).

I had a look at that function now and, er, no.  :-)  Perhaps it should
be rewritten in Emacs Lisp?  Then it'd be pretty trivial to fix this
stuff.

> We should document the situation and leave the bug open for the
> possibility that someone would like to work on this.

Document the situation by just putting back into the doc string that it
doesn't copy text properties in some situations?

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





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

* bug#17052: substitute-command-keys strips text properties
  2019-08-15 22:42         ` Lars Ingebrigtsen
@ 2019-08-16  6:47           ` Eli Zaretskii
  2019-08-16  7:04             ` Lars Ingebrigtsen
  2019-08-18 17:08           ` Stefan Kangas
  1 sibling, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2019-08-16  6:47 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 17052, lekktu

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: rgm@gnu.org,  17052@debbugs.gnu.org,  lekktu@gmail.com
> Date: Thu, 15 Aug 2019 15:42:18 -0700
> 
> > We should document the situation and leave the bug open for the
> > possibility that someone would like to work on this.
> 
> Document the situation by just putting back into the doc string that it
> doesn't copy text properties in some situations?

That's what I meant, yes.  Is there a problem with that which I
missed?





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

* bug#17052: substitute-command-keys strips text properties
  2019-08-16  6:47           ` Eli Zaretskii
@ 2019-08-16  7:04             ` Lars Ingebrigtsen
  0 siblings, 0 replies; 17+ messages in thread
From: Lars Ingebrigtsen @ 2019-08-16  7:04 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 17052, lekktu

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Lars Ingebrigtsen <larsi@gnus.org>
>> Cc: rgm@gnu.org,  17052@debbugs.gnu.org,  lekktu@gmail.com
>> Date: Thu, 15 Aug 2019 15:42:18 -0700
>> 
>> > We should document the situation and leave the bug open for the
>> > possibility that someone would like to work on this.
>> 
>> Document the situation by just putting back into the doc string that it
>> doesn't copy text properties in some situations?
>
> That's what I meant, yes.  Is there a problem with that which I
> missed?

No, I was just wondering whether you meant documenting it in some other
way since my question was

>>> Should I just put it back in the doc string, or do we still think that
>>> we'll fix it?

and your answer wasn't "just put it back in the doc string".  :-)

Which I'll now do, but leave the bug report open.

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





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

* bug#17052: substitute-command-keys strips text properties
  2019-08-15 22:42         ` Lars Ingebrigtsen
  2019-08-16  6:47           ` Eli Zaretskii
@ 2019-08-18 17:08           ` Stefan Kangas
  2019-08-18 17:19             ` Eli Zaretskii
  2019-08-18 17:19             ` Lars Ingebrigtsen
  1 sibling, 2 replies; 17+ messages in thread
From: Stefan Kangas @ 2019-08-18 17:08 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: lekktu, 8951, 17052

[In reply to Bug#17052 and cross-posting to Bug#8951.]

Lars Ingebrigtsen <larsi@gnus.org> writes:

> I had a look at that function now and, er, no.  :-)  Perhaps it should
> be rewritten in Emacs Lisp?  Then it'd be pretty trivial to fix this
> stuff.

The Fsubstitute_command_keys function is indeed a bit hairy, and I
agree that a conversion to Lisp is the most reasonable next step.

I've actually been working a patch to convert it to Lisp for Bug#8951,
but it's not finished yet.  The difficulty is that it has a couple of
helper functions that also needs to be lifted, which makes the job
bigger than just the function Fsubstitute_command_keys.

My goal is to get the Lisp version to produce the same output as the C
version, which currently seems to be a feasible goal.  Once it's in
Lisp it should be easier to make further improvements, fix bugs, etc.

Thanks,
Stefan Kangas





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

* bug#17052: substitute-command-keys strips text properties
  2019-08-18 17:08           ` Stefan Kangas
@ 2019-08-18 17:19             ` Eli Zaretskii
  2019-08-18 22:43               ` Lars Ingebrigtsen
  2019-08-18 17:19             ` Lars Ingebrigtsen
  1 sibling, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2019-08-18 17:19 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: lekktu, larsi, 8951, 17052

> From: Stefan Kangas <stefan@marxist.se>
> Date: Sun, 18 Aug 2019 19:08:18 +0200
> Cc: Eli Zaretskii <eliz@gnu.org>, 17052@debbugs.gnu.org, lekktu@gmail.com, 
> 	8951@debbugs.gnu.org
> 
> > I had a look at that function now and, er, no.  :-)  Perhaps it should
> > be rewritten in Emacs Lisp?  Then it'd be pretty trivial to fix this
> > stuff.
> 
> The Fsubstitute_command_keys function is indeed a bit hairy, and I
> agree that a conversion to Lisp is the most reasonable next step.
> 
> I've actually been working a patch to convert it to Lisp for Bug#8951,
> but it's not finished yet.  The difficulty is that it has a couple of
> helper functions that also needs to be lifted, which makes the job
> bigger than just the function Fsubstitute_command_keys.
> 
> My goal is to get the Lisp version to produce the same output as the C
> version, which currently seems to be a feasible goal.  Once it's in
> Lisp it should be easier to make further improvements, fix bugs, etc.

Maybe we should first talk a bit about why Lars you think it would be
"pretty trivial" to keep properties in Lisp, but not in C.  I'm
probably missing something very basic here, because I don't see why
it would be easier in Lisp.





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

* bug#17052: substitute-command-keys strips text properties
  2019-08-18 17:08           ` Stefan Kangas
  2019-08-18 17:19             ` Eli Zaretskii
@ 2019-08-18 17:19             ` Lars Ingebrigtsen
  1 sibling, 0 replies; 17+ messages in thread
From: Lars Ingebrigtsen @ 2019-08-18 17:19 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: lekktu, 8951, 17052

Stefan Kangas <stefan@marxist.se> writes:

> I've actually been working a patch to convert it to Lisp for Bug#8951,
> but it's not finished yet.  The difficulty is that it has a couple of
> helper functions that also needs to be lifted, which makes the job
> bigger than just the function Fsubstitute_command_keys.
>
> My goal is to get the Lisp version to produce the same output as the C
> version, which currently seems to be a feasible goal.  Once it's in
> Lisp it should be easier to make further improvements, fix bugs, etc.

Sounds great!

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





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

* bug#17052: substitute-command-keys strips text properties
  2019-08-18 17:19             ` Eli Zaretskii
@ 2019-08-18 22:43               ` Lars Ingebrigtsen
  2019-08-19 15:27                 ` Eli Zaretskii
  0 siblings, 1 reply; 17+ messages in thread
From: Lars Ingebrigtsen @ 2019-08-18 22:43 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: lekktu, Stefan Kangas, 8951, 17052

Eli Zaretskii <eliz@gnu.org> writes:

> Maybe we should first talk a bit about why Lars you think it would be
> "pretty trivial" to keep properties in Lisp, but not in C.  I'm
> probably missing something very basic here, because I don't see why
> it would be easier in Lisp.

Anything is easier in Lisp, surely.

But if you look at that function in particular, it's written in a very
C-ey fashion, what with copying over characters one by one etc.  It
could be rewritten (in C) to use the proper primitives we have that
preserve text properties (Fsubstring etc), but then you'd just end up
with a more long-winded version that would be Lisp-in-C, so we might as
well just rewrite it in Lisp.

It'll probably be a fraction of the code length.

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





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

* bug#17052: substitute-command-keys strips text properties
  2019-08-18 22:43               ` Lars Ingebrigtsen
@ 2019-08-19 15:27                 ` Eli Zaretskii
  0 siblings, 0 replies; 17+ messages in thread
From: Eli Zaretskii @ 2019-08-19 15:27 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: lekktu, stefan, 8951, 17052

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Cc: Stefan Kangas <stefan@marxist.se>,  17052@debbugs.gnu.org,
>   lekktu@gmail.com,  8951@debbugs.gnu.org
> Date: Sun, 18 Aug 2019 15:43:35 -0700
> 
> But if you look at that function in particular, it's written in a very
> C-ey fashion, what with copying over characters one by one etc.  It
> could be rewritten (in C) to use the proper primitives we have that
> preserve text properties (Fsubstring etc), but then you'd just end up
> with a more long-winded version that would be Lisp-in-C, so we might as
> well just rewrite it in Lisp.

AFAIU, the problematic parts are not those which copy characters one
by one, the problematic parts are those which _substitute_ one text
with another.  In that case, you need to adjust the text properties or
cons them out of thin air.





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

* bug#17052: substitute-command-keys strips text properties
  2019-08-15  1:34   ` Glenn Morris
  2019-08-15  1:58     ` Lars Ingebrigtsen
@ 2020-11-17  1:24     ` Stefan Kangas
  1 sibling, 0 replies; 17+ messages in thread
From: Stefan Kangas @ 2020-11-17  1:24 UTC (permalink / raw)
  To: Glenn Morris; +Cc: Juanma Barranquero, Lars Ingebrigtsen, 17052

close 17052 28.1
thanks

Glenn Morris <rgm@gnu.org> writes:

>> Looks like this has been fixed sometime in the intervening years?
>>
>> (substitute-command-keys (propertize "foo" 'face 'bold))
>> => #("foo" 0 3 (face bold))
>
> Nope, you need to use an example which does a substitution, eg
>
> (substitute-command-keys (propertize "foo \\[find-file]" 'face 'bold))

This was fixed by the recent rewrite of substitute-command-keys in Lisp.
I've added a test for this in commit 27655f9f38, and am therefore
closing this bug.

(For posterity, the root cause for this was that `princ' does not
preserve text properties.  The code now uses `insert' instead.)





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

* bug#17052: substitute-command-keys strips text properties, bug#8911: huh?
  2014-03-20 16:22 bug#17052: substitute-command-keys strips text properties Juanma Barranquero
  2019-08-15  0:55 ` Lars Ingebrigtsen
@ 2020-11-17  1:37 ` Drew Adams
  2020-11-17  2:34   ` Stefan Kangas
  1 sibling, 1 reply; 17+ messages in thread
From: Drew Adams @ 2020-11-17  1:37 UTC (permalink / raw)
  To: Stefan Kangas, Glenn Morris; +Cc: Juanma Barranquero, Lars Ingebrigtsen, 17052

> close 17052 28.1
> thanks

I don't understand the relation between this bug, #17052,
and bug #8911.  Half of the messages in the 8911 thread
are about 17052, and the subjects seem quite different.

But it looks like 8911 is still open (wishlist).  Is that
correct?  Why/how did these two bugs get overlapped or
combined?





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

* bug#17052: substitute-command-keys strips text properties, bug#8911: huh?
  2020-11-17  1:37 ` bug#17052: substitute-command-keys strips text properties, bug#8911: huh? Drew Adams
@ 2020-11-17  2:34   ` Stefan Kangas
  2020-11-17  3:00     ` Drew Adams
  0 siblings, 1 reply; 17+ messages in thread
From: Stefan Kangas @ 2020-11-17  2:34 UTC (permalink / raw)
  To: Drew Adams, Glenn Morris; +Cc: Juanma Barranquero, Lars Ingebrigtsen, 17052

Drew Adams <drew.adams@oracle.com> writes:

> I don't understand the relation between this bug, #17052,
> and bug #8911.  Half of the messages in the 8911 thread
> are about 17052, and the subjects seem quite different.
>
> But it looks like 8911 is still open (wishlist).  Is that
                    ^^^^ you probably mean 8951
> correct?  Why/how did these two bugs get overlapped or
> combined?

It was my perhaps ill-advised attempt to combine the discussions about
the Lisp conversion of `substitute-command-keys'.

(FWIW, I intend to look into Bug#8951 soon-ish.)





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

* bug#17052: substitute-command-keys strips text properties, bug#8911: huh?
  2020-11-17  2:34   ` Stefan Kangas
@ 2020-11-17  3:00     ` Drew Adams
  0 siblings, 0 replies; 17+ messages in thread
From: Drew Adams @ 2020-11-17  3:00 UTC (permalink / raw)
  To: Stefan Kangas, Glenn Morris; +Cc: Juanma Barranquero, Lars Ingebrigtsen, 17052

> > I don't understand the relation between this bug, #17052,
> > and bug #8911.  Half of the messages in the 8911 thread
> > are about 17052, and the subjects seem quite different.
> >
> > But it looks like 8911 is still open (wishlist).  Is that correct?
>                     ^^^^ you probably mean 8951

Yes, sorry; I meant 8951.

> > Why/how did these two bugs get overlapped or combined?
> 
> It was my perhaps ill-advised attempt to combine the discussions about
> the Lisp conversion of `substitute-command-keys'.
> 
> (FWIW, I intend to look into Bug#8951 soon-ish.)





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

end of thread, other threads:[~2020-11-17  3:00 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-20 16:22 bug#17052: substitute-command-keys strips text properties Juanma Barranquero
2019-08-15  0:55 ` Lars Ingebrigtsen
2019-08-15  1:34   ` Glenn Morris
2019-08-15  1:58     ` Lars Ingebrigtsen
2019-08-15 16:46       ` Eli Zaretskii
2019-08-15 22:42         ` Lars Ingebrigtsen
2019-08-16  6:47           ` Eli Zaretskii
2019-08-16  7:04             ` Lars Ingebrigtsen
2019-08-18 17:08           ` Stefan Kangas
2019-08-18 17:19             ` Eli Zaretskii
2019-08-18 22:43               ` Lars Ingebrigtsen
2019-08-19 15:27                 ` Eli Zaretskii
2019-08-18 17:19             ` Lars Ingebrigtsen
2020-11-17  1:24     ` Stefan Kangas
2020-11-17  1:37 ` bug#17052: substitute-command-keys strips text properties, bug#8911: huh? Drew Adams
2020-11-17  2:34   ` Stefan Kangas
2020-11-17  3:00     ` Drew Adams

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).