diff options
| author | Andreas Schwab | 2015-08-23 13:43:34 +0200 |
|---|---|---|
| committer | Andreas Schwab | 2015-08-23 16:33:39 +0200 |
| commit | 6b1765e05db432007ede6f1af3744e71063a728b (patch) | |
| tree | f8e0b1cf2b8238a292b6896cf664079765f53861 /doc | |
| parent | 0b0c9565d050bfecc581b342c40b719917395896 (diff) | |
| download | emacs-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.texi | 12 | ||||
| -rw-r--r-- | doc/lispref/strings.texi | 69 |
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 |
| 348 | string in Emacs Lisp. | 348 | string 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 |
| 352 | The value of the @code{text-quoting-style} variable specifies the style | 353 | The 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 |
| 354 | quotes. @xref{Formatting Strings}, for more information. | 355 | quotes. 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 | ||
| 358 | apostrophes. If the value is @code{grave}, the style is @t{`like | ||
| 359 | this'} with grave accent and apostrophe. The default value @code{nil} | ||
| 360 | acts like @code{curve} if curved single quotes are displayable, and | ||
| 361 | like @code{grave} otherwise. | ||
| 362 | @end defvar | ||
| 355 | 363 | ||
| 356 | @defun substitute-command-keys string | 364 | @defun substitute-command-keys string |
| 357 | This function scans @var{string} for the above special sequences and | 365 | This 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 | |||
| 805 | in how they use the result of formatting. | 805 | in how they use the result of formatting. |
| 806 | 806 | ||
| 807 | @defun format string &rest objects | 807 | @defun format string &rest objects |
| 808 | This function returns a string that is equivalent to copying | 808 | This 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 |
| 810 | in the copy with encodings of the corresponding @var{objects}. The | 810 | in the copy with encodings of the corresponding @var{objects}. The |
| 811 | arguments @var{objects} are the computed values to be formatted. | 811 | arguments @var{objects} are the computed values to be formatted. |
| 812 | 812 | ||
| 813 | The characters in @var{string}, other than the format specifications, | 813 | The characters in @var{string}, other than the format specifications, |
| 814 | are copied directly into the output, including their text properties, | 814 | are copied directly into the output, including their text properties, |
| 815 | if any. If the output equals @var{string}, this function may return | 815 | if 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 |
| 825 | and quotation marks, each format specification says how to represent | 822 | @code{format} function replaces it with the printed representation of |
| 826 | one of the arguments @var{objects}. For example, if there | 823 | one of the values to be formatted (one of the arguments @var{objects}). |
| 827 | is a @samp{%d} in @var{string}, the @code{format} function replaces it | ||
| 828 | with the decimal representation of the integer to be formatted. | ||
| 829 | For example: | 824 | For 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 |
| 839 | characters as format | ||
| 840 | specifications, you should @emph{never} pass an arbitrary string as | 834 | specifications, you should @emph{never} pass an arbitrary string as |
| 841 | the first argument. This is particularly true when the string is | 835 | the first argument. This is particularly true when the string is |
| 842 | generated by some Lisp code. Unless the string is @emph{known} to | 836 | generated by some Lisp code. Unless the string is @emph{known} to |
| 843 | never include any of the three special characters, pass @code{"%s"}, described | 837 | never include any @samp{%} characters, pass @code{"%s"}, described |
| 844 | below, as the first argument, and the string as the second, like this: | 838 | below, as the first argument, and the string as the second, like this: |
| 845 | 839 | ||
| 846 | @example | 840 | @example |
| @@ -914,27 +908,17 @@ is shorter. | |||
| 914 | Replace the specification with a single @samp{%}. This format | 908 | Replace the specification with a single @samp{%}. This format |
| 915 | specification is unusual in that it does not use a value. For example, | 909 | specification 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 | ||
| 922 | Replace the specification with a left or right quote, respectively. | ||
| 923 | Although typically a curved single quotation mark stands for itself, | ||
| 924 | other 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 |
| 929 | operation} error. | 914 | operation} error. |
| 930 | 915 | ||
| 931 | Here are several examples, which assume the typical quoting style | 916 | Here are several examples: |
| 932 | where 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 |
| 952 | between the @samp{%} and the specification character. If the printed | 936 | between the @samp{%} and the specification character. If the printed |
| 953 | representation of the object contains fewer characters than this | 937 | representation of the object contains fewer characters than this |
| 954 | width, @code{format} extends it with padding. The width specifier is | 938 | width, @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: | |||
| 964 | If the width is too small, @code{format} does not truncate the | 948 | If the width is too small, @code{format} does not truncate the |
| 965 | object's printed representation. Thus, you can use a width to specify | 949 | object's printed representation. Thus, you can use a width to specify |
| 966 | a minimum spacing between columns with no risk of losing information. | 950 | a minimum spacing between columns with no risk of losing information. |
| 967 | In the following two examples, @samp{%7s} specifies a minimum width | 951 | In the following three examples, @samp{%7s} specifies a minimum width |
| 968 | of 7. In the first case, the string inserted in place of @samp{%7s} | 952 | of 7. In the first case, the string inserted in place of @samp{%7s} |
| 969 | has only 3 letters, and needs 4 blank spaces as padding. In the | 953 | has only 3 letters, and needs 4 blank spaces as padding. In the |
| 970 | second case, the string @code{"specification"} is 13 letters wide but | 954 | second 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} |
| 1033 | before the character (after the width, if present). The precision is | 1017 | before the character (after the width, if present). The precision is |
| 1034 | a decimal-point @samp{.} followed by a digit-string. For the | 1018 | a decimal-point @samp{.} followed by a digit-string. For the |
| 1035 | floating-point specifications (@samp{%e}, @samp{%f}, @samp{%g}), the | 1019 | floating-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 |
| 1041 | characters. | 1025 | characters. |
| 1042 | 1026 | ||
| 1043 | @defvar text-quoting-style | ||
| 1044 | @cindex curved quotes | ||
| 1045 | @cindex curly quotes | ||
| 1046 | This variable specifies the style @code{format} uses when generating | ||
| 1047 | left 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 | ||
| 1050 | apostrophes. If the value is @code{grave}, the style is @t{`like | ||
| 1051 | this'} with grave accent and apostrophe. The default value @code{nil} | ||
| 1052 | acts like @code{curve} if curved single quotes are displayable, and | ||
| 1053 | like @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 |