summaryrefslogtreecommitdiff
path: root/doc/lispref/strings.texi
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2015-08-25 18:41:31 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2015-08-25 19:00:20 -0700
commit71781c31a4860e56434643296eaa303ca43386bb (patch)
tree271e4e378ac38caa3212d8e2025186715b5e1802 /doc/lispref/strings.texi
parentef4c2eac6c6e1df8f40efde52d737d911cf2dcf9 (diff)
downloademacs-71781c31a4860e56434643296eaa303ca43386bb.tar.gz
emacs-71781c31a4860e56434643296eaa303ca43386bb.tar.bz2
emacs-71781c31a4860e56434643296eaa303ca43386bb.zip
format-message now curves ` and '
That way, the caller doesn’t have to use curved quotes to get diagnostics that match the text-quoting-style preferences. Suggested by Dmitry Gutov in: http://lists.gnu.org/archive/html/emacs-devel/2015-08/msg00893.html This means we no longer need %qs, so remove that format. While we’re at it, fix an unlikely bug and lessen the pressure on the garbage collector by processing the string once rather than twice in the usual case. * doc/lispref/strings.texi (Formatting Strings): * etc/NEWS: Document this. * lisp/subr.el (format-message): Remove; now done in C. * src/callint.c (Fcall_interactively): * src/editfns.c (Fmessage, Fmessage_box): Use Fformat_message instead of Finternal__text_restyle followed by Fformat. * src/doc.c (LSQM, RSQM): Remove; all uses changed to use uLSQM and uRSQM. (Fsubstitute_command_keys): Prefer AUTO_STRING to build_string when pure ASCII now suffices. Fix unlikely bug when parsing unibyte string containing non-ASCII bytes. Use inline code rather than memcpy, as it’s a tiny number of bytes. (Finternal__text_restyle): Remove; no longer used. (syms_of_doc): Don’t declare it. * src/editfns.c (Fformat): Rewrite in terms of new function ‘styled_format’. (Fformat_message): New function, moved here from subr.el. (styled_format): New function, with the old guts of Fformat, except it now optionally transliterates quotes, and it transliterates traditional grave accent and apostrophe quoting as well. Remove recently-added q flag; no longer needed or used. (syms_of_editfns): Define format-message. * src/lisp.h (uLSQM0, uLSQM1, uLSQM2, uRSQM0, uRSQM1, uRSQM2): Remove; no longer need to be global symbols. * src/xdisp.c (vadd_to_log): Use Fformat_message, not Fformat, so that callers can use `%s'. * src/image.c (image_size_error, xbm_load_image, xbm_load) (xpm_load, pbm_load, png_load_body, jpeg_load_body, tiff_load) (gif_load, imagemagick_load_image, imagemagick_load, svg_load) (svg_load_image, gs_load, x_kill_gs_process): * src/lread.c (load_warn_old_style_backquotes): * src/xfaces.c (load_pixmap): * src/xselect.c (x_clipboard_manager_error_1): Use `%s' instead of %qs in formats.
Diffstat (limited to 'doc/lispref/strings.texi')
-rw-r--r--doc/lispref/strings.texi36
1 files changed, 18 insertions, 18 deletions
diff --git a/doc/lispref/strings.texi b/doc/lispref/strings.texi
index 326359e1da0..08e8e877a9f 100644
--- a/doc/lispref/strings.texi
+++ b/doc/lispref/strings.texi
@@ -816,9 +816,13 @@ if any.
@end defun
@defun format-message string &rest objects
+@cindex curved quotes
+@cindex curly quotes
This function acts like @code{format}, except it also converts any
-curved quotes in @var{string} as per the value of
-@code{text-quoting-style}. @xref{Keys in Documentation}.
+curved single quotes in @var{string} as per the value of
+@code{text-quoting-style}, and treats grave accent (@t{`}) and
+apostrophe (@t{'}) as if they were curved single quotes. @xref{Keys
+in Documentation}.
@end defun
@cindex @samp{%} in format
@@ -919,20 +923,23 @@ specification is unusual in that it does not use a value. For example,
Any other format character results in an @samp{Invalid format
operation} error.
- Here are several examples:
+ Here are several examples, which assume the typical
+@code{text-quoting-style} settings:
@example
@group
-(format "The name of this buffer is %s." (buffer-name))
- @result{} "The name of this buffer is strings.texi."
-
-(format "The buffer object prints as %qs." (current-buffer))
- @result{} "The buffer object prints as ‘strings.texi’."
-
(format "The octal value of %d is %o,
and the hex value is %x." 18 18 18)
@result{} "The octal value of 18 is 22,
and the hex value is 12."
+
+(format-message
+ "The name of this buffer is ‘%s’." (buffer-name))
+ @result{} "The name of this buffer is ‘strings.texi’."
+
+(format-message
+ "The buffer object prints as `%s'." (current-buffer))
+ @result{} "The buffer object prints as ‘strings.texi’."
@end group
@end example
@@ -1001,20 +1008,13 @@ specifier, if any, to be inserted on the right rather than the left.
If both @samp{-} and @samp{0} are present, the @samp{0} flag is
ignored.
-@cindex curved quotes
-@cindex curly quotes
- The flag @samp{q} quotes the printed representation as per the
-variable @samp{text-quoting-style}. @xref{Keys in Documentation}.
-Typically it uses curved single quotes @t{‘like this’} as in the
-following example.
-
@example
@group
(format "%06d is padded on the left with zeros" 123)
@result{} "000123 is padded on the left with zeros"
-(format "%q-6d is padded on the right" 123)
- @result{} "‘123 ’ is padded on the right"
+(format "'%-6d' is padded on the right" 123)
+ @result{} "'123 ' is padded on the right"
(format "The word '%-7s' actually has %d letters in it."
"foo" (length "foo"))