From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Marcin Borkowski Newsgroups: gmane.emacs.help Subject: Re: How to replace format-like codes in a string? Date: Fri, 11 Nov 2016 13:19:45 +0100 Message-ID: <87k2ca6wf2.fsf@mbork.pl> References: <87mvh677a4.fsf@mbork.pl> <877f8afllx.fsf@fastmail.fm> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1478866876 18220 195.159.176.226 (11 Nov 2016 12:21:16 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 11 Nov 2016 12:21:16 +0000 (UTC) User-Agent: mu4e 0.9.17; emacs 26.0.50.3 Cc: Help Gnu Emacs mailing list To: Joost Kremers Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Nov 11 13:21:13 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c5ApK-0002mQ-PY for geh-help-gnu-emacs@m.gmane.org; Fri, 11 Nov 2016 13:21:02 +0100 Original-Received: from localhost ([::1]:52314 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c5ApN-00074L-VU for geh-help-gnu-emacs@m.gmane.org; Fri, 11 Nov 2016 07:21:05 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53223) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c5Any-0006TB-M9 for help-gnu-emacs@gnu.org; Fri, 11 Nov 2016 07:19:39 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c5Anr-0002Ea-SD for help-gnu-emacs@gnu.org; Fri, 11 Nov 2016 07:19:36 -0500 Original-Received: from mail.mojserwer.eu ([2a01:5e00:2:52::8]:45467) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c5Anr-0002EN-Km for help-gnu-emacs@gnu.org; Fri, 11 Nov 2016 07:19:31 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by mail.mojserwer.eu (Postfix) with ESMTP id 237DFE65DD; Fri, 11 Nov 2016 13:19:29 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mail.mojserwer.eu Original-Received: from mail.mojserwer.eu ([127.0.0.1]) by localhost (mail.mojserwer.eu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OZT5lBlRvQhh; Fri, 11 Nov 2016 13:19:26 +0100 (CET) Original-Received: from localhost (static-dwadziewiec-jedenpiec7.echostar.pl [109.232.29.157]) by mail.mojserwer.eu (Postfix) with ESMTPSA id 8F7F3E65D0; Fri, 11 Nov 2016 13:19:26 +0100 (CET) In-reply-to: <877f8afllx.fsf@fastmail.fm> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2a01:5e00:2:52::8 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:111711 Archived-At: On 2016-11-11, at 09:48, Joost Kremers 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