comparison src/editfns.c @ 92236:996d2de63762

(Fformat): Doc fix.
author Chong Yidong <cyd@stupidchicken.com>
date Tue, 26 Feb 2008 16:36:52 +0000
parents 606f2d163a64
children f0f1c359cd43
comparison
equal deleted inserted replaced
92235:7c712622e514 92236:996d2de63762
3511 3511
3512 DEFUN ("format", Fformat, Sformat, 1, MANY, 0, 3512 DEFUN ("format", Fformat, Sformat, 1, MANY, 0,
3513 doc: /* Format a string out of a format-string and arguments. 3513 doc: /* Format a string out of a format-string and arguments.
3514 The first argument is a format control string. 3514 The first argument is a format control string.
3515 The other arguments are substituted into it to make the result, a string. 3515 The other arguments are substituted into it to make the result, a string.
3516 It may contain %-sequences meaning to substitute the next argument. 3516
3517 The format control string may contain %-sequences meaning to substitute
3518 the next available argument:
3519
3517 %s means print a string argument. Actually, prints any object, with `princ'. 3520 %s means print a string argument. Actually, prints any object, with `princ'.
3518 %d means print as number in decimal (%o octal, %x hex). 3521 %d means print as number in decimal (%o octal, %x hex).
3519 %X is like %x, but uses upper case. 3522 %X is like %x, but uses upper case.
3520 %e means print a number in exponential notation. 3523 %e means print a number in exponential notation.
3521 %f means print a number in decimal-point notation. 3524 %f means print a number in decimal-point notation.
3522 %g means print a number in exponential notation 3525 %g means print a number in exponential notation
3523 or decimal-point notation, whichever uses fewer characters. 3526 or decimal-point notation, whichever uses fewer characters.
3524 %c means print a number as a single character. 3527 %c means print a number as a single character.
3525 %S means print any object as an s-expression (using `prin1'). 3528 %S means print any object as an s-expression (using `prin1').
3526 The argument used for %d, %o, %x, %e, %f, %g or %c must be a number. 3529
3530 The argument used for %d, %o, %x, %e, %f, %g or %c must be a number.
3527 Use %% to put a single % into the output. 3531 Use %% to put a single % into the output.
3528 3532
3529 The basic structure of a %-sequence is 3533 A %-sequence may contain optional flag, width, and precision
3530 % <flags> <width> <precision> character 3534 specifiers, as follows:
3531 where flags is [-+ #0]+, width is [0-9]+, and precision is .[0-9]+ 3535
3536 %<flags><width><precision>character
3537
3538 where flags is [+ #-0]+, width is [0-9]+, and precision is .[0-9]+
3539
3540 The + flag character inserts a + before any positive number, while a
3541 space inserts a space before any positive number; these flags only
3542 affect %d, %e, %f, and %g sequences, and the + flag takes precedence.
3543 The # flag means to use an alternate display form for %o, %x, %X, %e,
3544 %f, and %g sequences. The - and 0 flags affect the width specifier,
3545 as described below.
3546
3547 The width specifier supplies a lower limit for the length of the
3548 printed representation. The padding, if any, normally goes on the
3549 left, but it goes on the right if the - flag is present. The padding
3550 character is normally a space, but it is 0 if the 0 flag is present.
3551 The - flag takes precedence over the 0 flag.
3552
3553 For %e, %f, and %g sequences, the number after the "." in the
3554 precision specifier says how many decimal places to show; if zero, the
3555 decimal point itself is omitted. For %s and %S, the precision
3556 specifier truncates the string to the given width.
3532 3557
3533 usage: (format STRING &rest OBJECTS) */) 3558 usage: (format STRING &rest OBJECTS) */)
3534 (nargs, args) 3559 (nargs, args)
3535 int nargs; 3560 int nargs;
3536 register Lisp_Object *args; 3561 register Lisp_Object *args;