From 5281946fbf6b3cdbec5ce82e0057c71849faf4d2 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Tue, 27 Sep 2022 18:16:51 +0200 Subject: Make format-spec accept function substitutions * lisp/format-spec.el (format-spec): Accept a function producing the substitution for a character. * doc/lispref/strings.texi (Custom Format Strings): Document the above change. * test/lisp/format-spec-tests.el (format-spec/function): New test. Ref. https://lists.gnu.org/r/emacs-devel/2022-09/msg01875.html --- doc/lispref/strings.texi | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'doc/lispref/strings.texi') diff --git a/doc/lispref/strings.texi b/doc/lispref/strings.texi index 374381e5955..ba247a3edae 100644 --- a/doc/lispref/strings.texi +++ b/doc/lispref/strings.texi @@ -1293,6 +1293,11 @@ The order of specifications in @var{template} need not correspond to the order of associations in @var{spec-alist}. @end itemize +REPLACEMENT can also be a function taking no arguments, and returning +a string to be used for the replacement. It will only be called when +the corresponding LETTER is used in the TEMPLATE. This is useful, for +example, to avoid prompting for input unless it is needed. + The optional argument @var{ignore-missing} indicates how to handle specification characters in @var{template} that are not found in @var{spec-alist}. If it is @code{nil} or omitted, the function -- cgit v1.2.3