[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: RFC: String interpolation
From: |
Paul Eggert |
Subject: |
Re: RFC: String interpolation |
Date: |
Tue, 13 Dec 2016 10:05:42 -0800 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 |
On 12/13/2016 09:42 AM, Richard Stallman wrote:
We have seen various proposals for what string interpolation should do.
What spec does your patch implement?
It implements Lars's proposal here:
http://lists.gnu.org/archive/html/emacs-devel/2016-12/msg00504.html
His example:
(format "Altitude= %.2f%" (+ alt 100) ", direction = %.2f%" (- dir) ".")
might generate:
"Altitude= 400.57, direction = -240.93."
The idea is that if a format string's first conversion specifier is
followed by "%" and end-of-string, the value to be formatted is followed
by another format string that continues the first string. This is an
extension to the current behavior of 'format', where the trailing "%" is
an error.
Similar rules apply to other formatting functions like 'message'. For
example, this code in org-clock.el:
(message (concat "Clock stopped at %s after "
(org-minutes-to-clocksum-string (+ (* 60 h) m))
"%s")
te (if remove " => LINE REMOVED" ""))
could be rewritten this way:
(message "Clock stopped at %s%" te
" after %s%" (org-minutes-to-clocksum-string (+ (* 60 h)
m))
"%s" (if remove " => LINE REMOVED" ""))
- Re: RFC: String interpolation, (continued)
- Re: RFC: String interpolation, Paul Eggert, 2016/12/12
- Re: RFC: String interpolation, Lars Ingebrigtsen, 2016/12/12
- Re: RFC: String interpolation, Ted Zlatanov, 2016/12/12
- Re: RFC: String interpolation, Paul Eggert, 2016/12/12
- Re: RFC: String interpolation, Paul Eggert, 2016/12/12
- Re: RFC: String interpolation, Richard Stallman, 2016/12/13
- Re: RFC: String interpolation,
Paul Eggert <=
- Re: RFC: String interpolation, Lars Ingebrigtsen, 2016/12/13
- Re: RFC: String interpolation, Paul Eggert, 2016/12/13
- Re: RFC: String interpolation, John Wiegley, 2016/12/13
- Re: RFC: String interpolation, Lars Ingebrigtsen, 2016/12/13
- Re: RFC: String interpolation, Paul Eggert, 2016/12/13
- Re: RFC: String interpolation, John Wiegley, 2016/12/13
- RE: RFC: String interpolation, Drew Adams, 2016/12/13
- Re: RFC: String interpolation, Elias Mårtenson, 2016/12/13
- RE: RFC: String interpolation, Drew Adams, 2016/12/13
- Re: RFC: String interpolation, Elias Mårtenson, 2016/12/13