* How to replace format-like codes in a string?
@ 2016-11-11 8:25 Marcin Borkowski
2016-11-11 8:48 ` Joost Kremers
0 siblings, 1 reply; 4+ messages in thread
From: Marcin Borkowski @ 2016-11-11 8:25 UTC (permalink / raw)
To: Help Gnu Emacs mailing list
Hi list,
I want to write a function like `format', which gets a string with some
codes embedded (like "%a", "%b" etc., and "%%" to get a percentage
sign), and convert them to something (say, "%a" to the value of var-a,
"%b" to var-b etc.). Is there any facility in Elisp to help with that
or do I have to do a search-and-replace manually?
Best,
--
Marcin Borkowski
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to replace format-like codes in a string?
2016-11-11 8:25 How to replace format-like codes in a string? Marcin Borkowski
@ 2016-11-11 8:48 ` Joost Kremers
2016-11-11 12:19 ` Marcin Borkowski
0 siblings, 1 reply; 4+ messages in thread
From: Joost Kremers @ 2016-11-11 8:48 UTC (permalink / raw)
To: Marcin Borkowski; +Cc: Help Gnu Emacs mailing list
On Fri, Nov 11 2016, Marcin Borkowski wrote:
> I want to write a function like `format', which gets a string
> with some
> codes embedded (like "%a", "%b" etc., and "%%" to get a
> percentage
> sign), and convert them to something (say, "%a" to the value of
> var-a,
> "%b" to var-b etc.). Is there any facility in Elisp to help
> with that
> or do I have to do a search-and-replace manually?
See `format-spec' and `format-spec-make'.
--
Joost Kremers
Life has its moments
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to replace format-like codes in a string?
2016-11-11 8:48 ` Joost Kremers
@ 2016-11-11 12:19 ` Marcin Borkowski
2016-11-13 10:29 ` Joost Kremers
0 siblings, 1 reply; 4+ messages in thread
From: Marcin Borkowski @ 2016-11-11 12:19 UTC (permalink / raw)
To: Joost Kremers; +Cc: Help Gnu Emacs mailing list
On 2016-11-11, at 09:48, Joost Kremers <joostkremers@fastmail.fm> wrote:
> On Fri, Nov 11 2016, Marcin Borkowski wrote:
>> I want to write a function like `format', which gets a string
>> with some
>> codes embedded (like "%a", "%b" etc., and "%%" to get a
>> percentage
>> sign), and convert them to something (say, "%a" to the value of
>> var-a,
>> "%b" to var-b etc.). Is there any facility in Elisp to help
>> with that
>> or do I have to do a search-and-replace manually?
>
> See `format-spec' and `format-spec-make'.
Thanks a lot! That was exactly what I needed. (I mean, `format-spec';
I'm not sure why I would need `format-spec-make', assuming that I can
just use backquote and comma.)
Best,
--
Marcin Borkowski
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to replace format-like codes in a string?
2016-11-11 12:19 ` Marcin Borkowski
@ 2016-11-13 10:29 ` Joost Kremers
0 siblings, 0 replies; 4+ messages in thread
From: Joost Kremers @ 2016-11-13 10:29 UTC (permalink / raw)
To: Marcin Borkowski; +Cc: Help Gnu Emacs mailing list
On Fri, Nov 11 2016, Marcin Borkowski wrote:
>> See `format-spec' and `format-spec-make'.
>
> Thanks a lot! That was exactly what I needed. (I mean,
> `format-spec';
> I'm not sure why I would need `format-spec-make', assuming that
> I can
> just use backquote and comma.)
Yes, I wondered the same thing. But I thought I'd mention it
anyway. :-)
--
Joost Kremers
Life has its moments
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-11-13 10:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-11 8:25 How to replace format-like codes in a string? Marcin Borkowski
2016-11-11 8:48 ` Joost Kremers
2016-11-11 12:19 ` Marcin Borkowski
2016-11-13 10:29 ` Joost Kremers
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).