Emacs Lisp: Format String
(format STRING &rest OBJECTS)
- Convert lisp objects into a string. It takes a input string, and several other arguments of lisp objects, and output a string.
- The format control string may contain placeholders
%c. The placeholders are replaced by argument to format.
- Different placeholders means convert the argument to a string in particular way.
(format "Name: %s, age: %d" "jane" 25) ;; "Name: jane, age: 25"
string. Converted by
princ. [see Emacs Lisp: Print, Output]
- number in decimal.
- number converted to octal notation.
- number converted to hexadecimal notation.
%x, but uses upper case.
- number in exponential notation.
- number in decimal-point notation.
- number in exponential notation or decimal-point notation, whichever uses fewer characters.
- number as a single character.
any object in lisp syntax (using
prin1). [see Emacs Lisp: Print, Output]
(info "(elisp) Formatting Strings")