Re-writing this answer gives another solution:
(format-spec "%a %a %a %b %b %b" (format-spec-make ?a "a" ?b "b")) Edit: Another format-spec solution:
As Malabarba gives another solution in comments:
(format-spec "%a %a %a %b %b %b" '((?a . "a") (?b . "b"))) Edit 2: Evaluation before substitution:
Here are examples with evaluation before substitution:
(let ( (a 1) (b 2) ) (message (format-spec "a = %a; b = %b" (format-spec-make ?a a ?b b))) ) ;; ⇒ a"a = 1; b = 12" (let ( (a 1) (b 2) ) (message (format-spec "a = %a; b = %b" `((?a . ,a) (?b . ,b)))) ) ;; ⇒ a"a = 1; b = 22"