aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorAndreas Schwab2015-08-23 13:43:34 +0200
committerAndreas Schwab2015-08-23 16:33:39 +0200
commit6b1765e05db432007ede6f1af3744e71063a728b (patch)
treef8e0b1cf2b8238a292b6896cf664079765f53861 /doc
parent0b0c9565d050bfecc581b342c40b719917395896 (diff)
downloademacs-6b1765e05db432007ede6f1af3744e71063a728b.tar.gz
emacs-6b1765e05db432007ede6f1af3744e71063a728b.zip
Revert "Extend ‘format’ to translate curved quotes"
This reverts commit 244c801689d2f7a80480d83cd7d092d4762ebe08.
Diffstat (limited to 'doc')
-rw-r--r--doc/lispref/help.texi12
-rw-r--r--doc/lispref/strings.texi69
2 files changed, 30 insertions, 51 deletions
diff --git a/doc/lispref/help.texi b/doc/lispref/help.texi
index ab1696e6712..ca8ae3f314a 100644
--- a/doc/lispref/help.texi
+++ b/doc/lispref/help.texi
@@ -347,11 +347,19 @@ and @samp{\=\=} puts @samp{\=} into the output.
347@strong{Please note:} Each @samp{\} must be doubled when written in a 347@strong{Please note:} Each @samp{\} must be doubled when written in a
348string in Emacs Lisp. 348string in Emacs Lisp.
349 349
350@defvar text-quoting-style
350@cindex curved quotes 351@cindex curved quotes
351@cindex curly quotes 352@cindex curly quotes
352The value of the @code{text-quoting-style} variable specifies the style 353The value of this variable specifies the style
353@code{substitute-command-keys} uses when generating left and right 354@code{substitute-command-keys} uses when generating left and right
354quotes. @xref{Formatting Strings}, for more information. 355quotes. If the variable's value is @code{curve}, the style is
356@t{‘like this’} with curved single quotes. If the value is
357@code{straight}, the style is @t{'like this'} with straight
358apostrophes. If the value is @code{grave}, the style is @t{`like
359this'} with grave accent and apostrophe. The default value @code{nil}
360acts like @code{curve} if curved single quotes are displayable, and
361like @code{grave} otherwise.
362@end defvar
355 363
356@defun substitute-command-keys string 364@defun substitute-command-keys string
357This function scans @var{string} for the above special sequences and 365This function scans @var{string} for the above special sequences and
diff --git a/doc/lispref/strings.texi b/doc/lispref/strings.texi
index 8de1473b83d..580eb43acca 100644
--- a/doc/lispref/strings.texi
+++ b/doc/lispref/strings.texi
@@ -805,27 +805,22 @@ formatting feature described here; they differ from @code{format} only
805in how they use the result of formatting. 805in how they use the result of formatting.
806 806
807@defun format string &rest objects 807@defun format string &rest objects
808This function returns a string that is equivalent to copying 808This function returns a new string that is made by copying
809@var{string} and then replacing any format specification 809@var{string} and then replacing any format specification
810in the copy with encodings of the corresponding @var{objects}. The 810in the copy with encodings of the corresponding @var{objects}. The
811arguments @var{objects} are the computed values to be formatted. 811arguments @var{objects} are the computed values to be formatted.
812 812
813The characters in @var{string}, other than the format specifications, 813The characters in @var{string}, other than the format specifications,
814are copied directly into the output, including their text properties, 814are copied directly into the output, including their text properties,
815if any. If the output equals @var{string}, this function may return 815if any.
816@var{string} itself rather than a new copy.
817@end defun 816@end defun
818 817
819@cindex @samp{%} in format 818@cindex @samp{%} in format
820@cindex format specification 819@cindex format specification
821@cindex curved quotes
822@cindex curly quotes
823 A format specification is a sequence of characters beginning with a 820 A format specification is a sequence of characters beginning with a
824@samp{%} or is a curved single quotation mark. Except for @samp{%%} 821@samp{%}. Thus, if there is a @samp{%d} in @var{string}, the
825and quotation marks, each format specification says how to represent 822@code{format} function replaces it with the printed representation of
826one of the arguments @var{objects}. For example, if there 823one of the values to be formatted (one of the arguments @var{objects}).
827is a @samp{%d} in @var{string}, the @code{format} function replaces it
828with the decimal representation of the integer to be formatted.
829For example: 824For example:
830 825
831@example 826@example
@@ -835,12 +830,11 @@ For example:
835@end group 830@end group
836@end example 831@end example
837 832
838 Since @code{format} interprets @samp{%}, @samp{‘} and @samp{’} 833 Since @code{format} interprets @samp{%} characters as format
839characters as format
840specifications, you should @emph{never} pass an arbitrary string as 834specifications, you should @emph{never} pass an arbitrary string as
841the first argument. This is particularly true when the string is 835the first argument. This is particularly true when the string is
842generated by some Lisp code. Unless the string is @emph{known} to 836generated by some Lisp code. Unless the string is @emph{known} to
843never include any of the three special characters, pass @code{"%s"}, described 837never include any @samp{%} characters, pass @code{"%s"}, described
844below, as the first argument, and the string as the second, like this: 838below, as the first argument, and the string as the second, like this:
845 839
846@example 840@example
@@ -914,27 +908,17 @@ is shorter.
914Replace the specification with a single @samp{%}. This format 908Replace the specification with a single @samp{%}. This format
915specification is unusual in that it does not use a value. For example, 909specification is unusual in that it does not use a value. For example,
916@code{(format "%% %d" 30)} returns @code{"% 30"}. 910@code{(format "%% %d" 30)} returns @code{"% 30"}.
917
918@item ‘
919@itemx ’
920@cindex curved quotes
921@cindex curly quotes
922Replace the specification with a left or right quote, respectively.
923Although typically a curved single quotation mark stands for itself,
924other quoting styles are available as per the variable
925@samp{text-quoting-style} described below.
926@end table 911@end table
927 912
928 Any other format character after @samp{%} results in an @samp{Invalid format 913 Any other format character results in an @samp{Invalid format
929operation} error. 914operation} error.
930 915
931 Here are several examples, which assume the typical quoting style 916 Here are several examples:
932where curved single quotes stand for themselves:
933 917
934@example 918@example
935@group 919@group
936(format "The name of this buffer is %s." (buffer-name)) 920(format "The name of this buffer is %s." (buffer-name))
937 @result{} "The name of this buffer is strings.texi." 921 @result{} "The name of this buffer is strings.texi."
938 922
939(format "The buffer object prints as %qs." (current-buffer)) 923(format "The buffer object prints as %qs." (current-buffer))
940 @result{} "The buffer object prints as ‘strings.texi’." 924 @result{} "The buffer object prints as ‘strings.texi’."
@@ -948,7 +932,7 @@ where curved single quotes stand for themselves:
948 932
949@cindex field width 933@cindex field width
950@cindex padding 934@cindex padding
951 A @samp{%} specification can have a @dfn{width}, which is a decimal number 935 A specification can have a @dfn{width}, which is a decimal number
952between the @samp{%} and the specification character. If the printed 936between the @samp{%} and the specification character. If the printed
953representation of the object contains fewer characters than this 937representation of the object contains fewer characters than this
954width, @code{format} extends it with padding. The width specifier is 938width, @code{format} extends it with padding. The width specifier is
@@ -964,7 +948,7 @@ the width specifier normally consists of spaces inserted on the left:
964If the width is too small, @code{format} does not truncate the 948If the width is too small, @code{format} does not truncate the
965object's printed representation. Thus, you can use a width to specify 949object's printed representation. Thus, you can use a width to specify
966a minimum spacing between columns with no risk of losing information. 950a minimum spacing between columns with no risk of losing information.
967In the following two examples, @samp{%7s} specifies a minimum width 951In the following three examples, @samp{%7s} specifies a minimum width
968of 7. In the first case, the string inserted in place of @samp{%7s} 952of 7. In the first case, the string inserted in place of @samp{%7s}
969has only 3 letters, and needs 4 blank spaces as padding. In the 953has only 3 letters, and needs 4 blank spaces as padding. In the
970second case, the string @code{"specification"} is 13 letters wide but 954second case, the string @code{"specification"} is 13 letters wide but
@@ -972,12 +956,12 @@ is not truncated.
972 956
973@example 957@example
974@group 958@group
975(format "The word %7s has %d letters in it." 959(format "The word '%7s' has %d letters in it."
976 "foo" (length "foo")) 960 "foo" (length "foo"))
977 @result{} "The word foo has 3 letters in it." 961 @result{} "The word ' foo' has 3 letters in it."
978(format "The word %7s has %d letters in it." 962(format "The word '%7s' has %d letters in it."
979 "specification" (length "specification")) 963 "specification" (length "specification"))
980 @result{} "The word specification has 13 letters in it." 964 @result{} "The word 'specification' has 13 letters in it."
981@end group 965@end group
982@end example 966@end example
983 967
@@ -1022,14 +1006,14 @@ variable @samp{text-quoting-style} described below.
1022(format "%q-6d is padded on the right" 123) 1006(format "%q-6d is padded on the right" 123)
1023 @result{} "‘123 ’ is padded on the right" 1007 @result{} "‘123 ’ is padded on the right"
1024 1008
1025(format "The word %-7s actually has %d letters in it." 1009(format "The word '%-7s' actually has %d letters in it."
1026 "foo" (length "foo")) 1010 "foo" (length "foo"))
1027 @result{} "The word foo actually has 3 letters in it." 1011 @result{} "The word 'foo ' actually has 3 letters in it."
1028@end group 1012@end group
1029@end example 1013@end example
1030 1014
1031@cindex precision in format specifications 1015@cindex precision in format specifications
1032 The @samp{%} specification characters allow an optional @dfn{precision} 1016 All the specification characters allow an optional @dfn{precision}
1033before the character (after the width, if present). The precision is 1017before the character (after the width, if present). The precision is
1034a decimal-point @samp{.} followed by a digit-string. For the 1018a decimal-point @samp{.} followed by a digit-string. For the
1035floating-point specifications (@samp{%e}, @samp{%f}, @samp{%g}), the 1019floating-point specifications (@samp{%e}, @samp{%f}, @samp{%g}), the
@@ -1040,19 +1024,6 @@ shows only the first three characters of the representation for
1040@var{object}. Precision has no effect for other specification 1024@var{object}. Precision has no effect for other specification
1041characters. 1025characters.
1042 1026
1043@defvar text-quoting-style
1044@cindex curved quotes
1045@cindex curly quotes
1046This variable specifies the style @code{format} uses when generating
1047left and right quotes. If the value is @code{curve}, the style is
1048@t{‘like this’} with curved single quotes. If the value is
1049@code{straight}, the style is @t{'like this'} with straight
1050apostrophes. If the value is @code{grave}, the style is @t{`like
1051this'} with grave accent and apostrophe. The default value @code{nil}
1052acts like @code{curve} if curved single quotes are displayable, and
1053like @code{grave} otherwise.
1054@end defvar
1055
1056@node Case Conversion 1027@node Case Conversion
1057@section Case Conversion in Lisp 1028@section Case Conversion in Lisp
1058@cindex upper case 1029@cindex upper case