Commit fbb5531f authored by Paul Eggert's avatar Paul Eggert
Browse files

More-conservative ‘format’ quote restyling

Instead of restyling curved quotes for every call to ‘format’,
create a new function ‘format-message’ that does the restyling,
and using the new function instead of ‘format’ only in contexts
where this seems appropriate.
Problem reported by Dmitry Gutov and Andreas Schwab in:
http://lists.gnu.org/archive/html/emacs-devel/2015-08/msg00826.html
http://lists.gnu.org/archive/html/emacs-devel/2015-08/msg00827.html
* doc/lispref/commands.texi (Using Interactive):
* doc/lispref/control.texi (Signaling Errors, Signaling Errors):
* doc/lispref/display.texi (Displaying Messages, Progress):
* doc/lispref/elisp.texi:
* doc/lispref/help.texi (Keys in Documentation):
* doc/lispref/minibuf.texi (Minibuffer Misc):
* doc/lispref/strings.texi (Formatting Strings):
* etc/NEWS:
Document the changes.
* lisp/abbrev.el (expand-region-abbrevs):
* lisp/apropos.el (apropos-library):
* lisp/calc/calc-ext.el (calc-record-message)
(calc-user-function-list):
* lisp/calc/calc-help.el (calc-describe-key, calc-full-help):
* lisp/calc/calc-lang.el (math-read-big-balance):
* lisp/calc/calc-store.el (calc-edit-variable):
* lisp/calc/calc-units.el (math-build-units-table-buffer):
* lisp/calc/calc-yank.el (calc-edit-mode):
* lisp/calendar/icalendar.el (icalendar-export-region)
(icalendar--add-diary-entry):
* lisp/cedet/mode-local.el (mode-local-print-binding)
(mode-local-describe-bindings-2):
* lisp/cedet/semantic/complete.el (semantic-completion-message):
* lisp/cedet/semantic/edit.el (semantic-parse-changes-failed):
* lisp/cedet/semantic/wisent/comp.el (wisent-log):
* lisp/cedet/srecode/insert.el (srecode-insert-show-error-report):
* lisp/descr-text.el (describe-text-properties-1, describe-char):
* lisp/dframe.el (dframe-message):
* lisp/dired-aux.el (dired-query):
* lisp/emacs-lisp/byte-opt.el (byte-compile-log-lap-1):
* lisp/emacs-lisp/bytecomp.el (byte-compile-log)
(byte-compile-log-file, byte-compile-warn, byte-compile-form):
* lisp/emacs-lisp/cconv.el (cconv-convert, cconv--analyze-use)
(cconv-analyze-form):
* lisp/emacs-lisp/check-declare.el (check-declare-warn):
* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
* lisp/emacs-lisp/cl-macs.el (cl-symbol-macrolet):
* lisp/emacs-lisp/edebug.el (edebug-format):
* lisp/emacs-lisp/eieio-core.el (eieio-oref):
* lisp/emacs-lisp/eldoc.el (eldoc-minibuffer-message)
(eldoc-message):
* lisp/emacs-lisp/elint.el (elint-file, elint-log):
* lisp/emacs-lisp/find-func.el (find-function-library):
* lisp/emacs-lisp/macroexp.el (macroexp--obsolete-warning):
* lisp/emacs-lisp/map-ynp.el (map-y-or-n-p):
* lisp/emacs-lisp/nadvice.el (advice--make-docstring):
* lisp/emacs-lisp/package.el (package-compute-transaction)
(package-install-button-action, package-delete-button-action)
(package-menu--list-to-prompt):
* lisp/emacs-lisp/timer.el (timer-event-handler):
* lisp/emacs-lisp/warnings.el (lwarn, warn):
* lisp/emulation/viper-cmd.el:
(viper-toggle-parse-sexp-ignore-comments)
(viper-kill-buffer, viper-brac-function):
* lisp/emulation/viper-macs.el (viper-record-kbd-macro):
* lisp/facemenu.el (facemenu-add-new-face):
* lisp/faces.el (face-documentation, read-face-name)
(face-read-string, read-face-font, describe-face):
* lisp/files.el (find-alternate-file, hack-local-variables)
(hack-one-local-variable--obsolete, write-file)
(basic-save-buffer, delete-directory):
* lisp/format.el (format-write-file, format-find-file)
(format-insert-file):
* lisp/help-fns.el (help-fns--key-bindings)
(help-fns--compiler-macro, help-fns--obsolete)
(help-fns--interactive-only, describe-function-1)
(describe-variable):
* lisp/help.el (describe-mode):
* lisp/info-xref.el (info-xref-output):
* lisp/info.el (Info-virtual-index-find-node)
(Info-virtual-index, info-apropos):
* lisp/international/kkc.el (kkc-error):
* lisp/international/mule-cmds.el:
(select-safe-coding-system-interactively)
(select-safe-coding-system, describe-input-method):
* lisp/international/mule-conf.el (code-offset):
* lisp/international/mule-diag.el (describe-character-set)
(list-input-methods-1):
* lisp/international/quail.el (quail-error):
* lisp/minibuffer.el (minibuffer-message):
* lisp/mpc.el (mpc--debug):
* lisp/msb.el (msb--choose-menu):
* lisp/net/ange-ftp.el (ange-ftp-message):
* lisp/net/gnutls.el (gnutls-message-maybe):
* lisp/net/newst-backend.el (newsticker--sentinel-work):
* lisp/net/newst-treeview.el (newsticker--treeview-load):
* lisp/net/nsm.el (nsm-query-user):
* lisp/net/rlogin.el (rlogin):
* lisp/net/soap-client.el (soap-warning):
* lisp/net/tramp.el (tramp-debug-message):
* lisp/nxml/nxml-outln.el (nxml-report-outline-error):
* lisp/nxml/nxml-parse.el (nxml-parse-error):
* lisp/nxml/rng-cmpct.el (rng-c-error):
* lisp/nxml/rng-match.el (rng-compile-error):
* lisp/nxml/rng-uri.el (rng-uri-error):
* lisp/obsolete/iswitchb.el (iswitchb-possible-new-buffer):
* lisp/org/org-ctags.el:
(org-ctags-ask-rebuild-tags-file-then-find-tag):
* lisp/proced.el (proced-log):
* lisp/progmodes/ebnf2ps.el (ebnf-log):
* lisp/progmodes/flymake.el (flymake-log):
* lisp/progmodes/vhdl-mode.el (vhdl-warning-when-idle):
* lisp/replace.el (occur-1):
* lisp/simple.el (execute-extended-command)
(undo-outer-limit-truncate, define-alternatives):
* lisp/startup.el (command-line):
* lisp/subr.el (error, user-error, add-to-list):
* lisp/tutorial.el (tutorial--describe-nonstandard-key)
(tutorial--find-changed-keys):
* src/callint.c (Fcall_interactively):
* src/editfns.c (Fmessage, Fmessage_box):
Restyle the quotes of format strings intended for use as a
diagnostic, when restyling seems appropriate.
* lisp/subr.el (format-message): New function.
* src/doc.c (Finternal__text_restyle): New function.
(syms_of_doc): Define it.
parent a5fd059f
......@@ -211,7 +211,7 @@ argument.
The prompt string can use @samp{%} to include previous argument values
(starting with the first argument) in the prompt. This is done using
@code{format} (@pxref{Formatting Strings}). For example, here is how
@code{format-message} (@pxref{Formatting Strings}). For example, here is how
you could read the name of an existing buffer followed by a new name to
give to that buffer:
......
......@@ -990,7 +990,7 @@ should not end with any sort of punctuation.
@defun error format-string &rest args
This function signals an error with an error message constructed by
applying @code{format} (@pxref{Formatting Strings}) to
applying @code{format-message} (@pxref{Formatting Strings}) to
@var{format-string} and @var{args}.
These examples show typical uses of @code{error}:
......@@ -1009,7 +1009,7 @@ These examples show typical uses of @code{error}:
@code{error} works by calling @code{signal} with two arguments: the
error symbol @code{error}, and a list containing the string returned by
@code{format}.
@code{format-message}.
@strong{Warning:} If you want to use your own string as an error message
verbatim, don't just write @code{(error @var{string})}. If @var{string}
......
......@@ -247,7 +247,7 @@ messages in the echo area.
@defun message format-string &rest arguments
This function displays a message in the echo area.
@var{format-string} is a format string, and @var{arguments} are the
objects for its format specifications, like in the @code{format}
objects for its format specifications, like in the @code{format-message}
function (@pxref{Formatting Strings}). The resulting formatted string
is displayed in the echo area; if it contains @code{face} text
properties, it is displayed with the specified faces (@pxref{Faces}).
......@@ -375,7 +375,7 @@ reporting very fast.
When this progress reporter is subsequently used, it will display
@var{message} in the echo area, followed by progress percentage.
@var{message} is treated as a simple string. If you need it to depend
on a filename, for instance, use @code{format} before calling this
on a filename, for instance, use @code{format-message} before calling this
function.
The arguments @var{min-value} and @var{max-value} should be numbers
......
......@@ -375,6 +375,7 @@ Strings and Characters
* Text Comparison:: Comparing characters or strings.
* String Conversion:: Converting to and from characters and strings.
* Formatting Strings:: @code{format}: Emacs's analogue of @code{printf}.
* Text Restyling:: Text style conversion function.
* Case Conversion:: Case conversion functions.
* Case Tables:: Customizing case conversion.
......
......@@ -350,8 +350,7 @@ string in Emacs Lisp.
@defvar text-quoting-style
@cindex curved quotes
@cindex curly quotes
The value of this variable specifies the style
@code{substitute-command-keys} uses when generating left and right
The value of this variable specifies the style used to generate text
quotes. If the variable's value is @code{curve}, the style is
@t{‘like this’} with curved single quotes. If the value is
@code{straight}, the style is @t{'like this'} with straight
......
......@@ -2413,7 +2413,7 @@ arrives, whichever comes first. The variable
@code{minibuffer-message-timeout} specifies the number of seconds to
wait in the absence of input. It defaults to 2. If @var{args} is
non-@code{nil}, the actual message is obtained by passing @var{string}
and @var{args} through @code{format}. @xref{Formatting Strings}.
and @var{args} through @code{format-message}. @xref{Formatting Strings}.
@end defun
@deffn Command minibuffer-inactive-mode
......
......@@ -801,7 +801,7 @@ they appear; it is called a @dfn{format string}.
Formatting is often useful for computing messages to be displayed. In
fact, the functions @code{message} and @code{error} provide the same
formatting feature described here; they differ from @code{format} only
formatting feature described here; they differ from @code{format-message} only
in how they use the result of formatting.
@defun format string &rest objects
......@@ -815,6 +815,12 @@ are copied directly into the output, including their text properties,
if any.
@end defun
@defun format-message string &rest objects
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}.
@end defun
@cindex @samp{%} in format
@cindex format specification
A format specification is a sequence of characters beginning with a
......
......@@ -916,6 +916,12 @@ value of ‘text-quoting-style’. Doc strings in source code can use
either curved quotes or grave accent and apostrophe. As before,
isolated apostrophes and characters preceded by \= are output as-is.
+++
** Message-issuing functions ‘error’, ‘message’, etc. now convert quotes.
They use the new ‘format-message’ function instead of plain ‘format’,
so that they now follow user preference as per ‘text-quoting-style’ if
their format argument contains curved quotes.
+++
** The character classes [:alpha:] and [:alnum:] in regular expressions
now match multibyte characters using Unicode character properties.
......@@ -1038,6 +1044,10 @@ key works) by typing ‘A-[’ and ‘A-]’. As described above under
text-quoting-style, the user can specify how to display doc string
quotes.
+++
** New function format-message is like format and also converts
curved quotes as per text-quoting-style.
+++
** New format flag q
The new q flag causes format to quote the output representation as
......
......@@ -399,7 +399,7 @@ A prefix argument means don't query; expand all abbrevs."
(buffer-substring-no-properties
(save-excursion (forward-word -1) (point))
pnt)))
(if (or noquery (y-or-n-p (format "Expand ‘%s’? " string)))
(if (or noquery (y-or-n-p (format-message "Expand ‘%s’? " string)))
(expand-abbrev)))))))
;;; Abbrev properties.
......
......@@ -681,8 +681,8 @@ the output includes key-bindings of commands."
(apropos-symbols-internal
symbols apropos-do-all
(concat
(format (substitute-command-keys
"Library `%s' provides: %s\nand requires: %s")
(format-message
"Library %s provides: %s\nand requires: %s"
file
(mapconcat 'apropos-library-button
(or provides '(nil)) " and ")
......
......@@ -1245,7 +1245,7 @@ calc-kill calc-kill-region calc-yank))))
(defun calc-record-message (tag &rest args)
(let ((msg (apply 'format args)))
(let ((msg (apply #'format-message args)))
(message "%s" msg)
(calc-record msg tag))
(calc-clear-command-flag 'clear-message))
......@@ -1957,7 +1957,7 @@ calc-kill calc-kill-region calc-yank))))
(desc
(if (symbolp func)
(if (= (logand kind 3) 0)
(format "‘%c’ = %s" key name)
(format-message "‘%c’ = %s" key name)
(if pos
(format "%s%c%s"
(downcase (substring name 0 pos))
......
......@@ -239,7 +239,7 @@ C-w Describe how there is no warranty for Calc."
(setq prompts (substring prompts 0 (match-beginning 0))))
(if (string-match "\\` +" prompts)
(setq prompts (substring prompts (match-end 0))))
(setq msg (format
(setq msg (format-message
"%s: %s%s‘%s’%s%s %s%s"
(if (string-match
"\\`\\(calc-[-a-zA-Z0-9]+\\) *\\(.*\\)\\'"
......@@ -400,8 +400,9 @@ C-w Describe how there is no warranty for Calc."
(princ "GNU Emacs Calculator.\n")
(princ " By Dave Gillespie.\n")
(princ (format " %s\n\n" emacs-copyright))
(princ (format "Type ‘h s’ for a more detailed summary.\n"))
(princ (format "Or type ‘h i’ to read the full Calc manual on-line.\n\n"))
(princ (format-message "Type ‘h s’ for a more detailed summary.\n"))
(princ (format-message
"Or type ‘h i’ to read the full Calc manual on-line.\n\n"))
(princ "Basic keys:\n")
(let* ((calc-full-help-flag t))
(mapc (function (lambda (x) (princ (format
......@@ -415,10 +416,10 @@ C-w Describe how there is no warranty for Calc."
(if (car msgs)
(princ
(if (eq (nth 2 msgs) ?v)
(format
(format-message
"\n‘v’ or ‘V’ prefix (vector/matrix) keys: \n")
(if (nth 2 msgs)
(format
(format-message
"\n‘%c’ prefix (%s) keys:\n"
(nth 2 msgs)
(or (cdr (assq (nth 2 msgs)
......
......@@ -2508,7 +2508,8 @@ order to Calc's."
(while (> count 0)
(if (>= h len)
(if what
(math-read-big-error nil v (format "Unmatched ‘%s’" what))
(math-read-big-error nil v (format-message
"Unmatched ‘%s’" what))
(setq count 0))
(if (memq (aref line h) '(?\( ?\[))
(setq count (1+ count))
......
......@@ -442,7 +442,8 @@
(setq calc-last-edited-variable var)
(calc-edit-mode (list 'calc-finish-stack-edit (list 'quote var))
t
(format "Editing variable %s" (calc-var-name var)))
(format-message
"Editing variable %s" (calc-var-name var)))
(and value
(insert (math-format-nice-expr value (frame-width)) "\n")))))
(calc-show-edit-buffer))
......
......@@ -1622,7 +1622,7 @@ If COMP or STD is non-nil, put that in the units table instead."
(while (eq (car (car (setq uptr (cdr uptr)))) 0)))
(insert "\n\n")
(insert
(format
(format-message
(concat
"(**) When in TeX or LaTeX display mode, the TeX specific unit\n"
"names will not use the ‘tex’ prefix; the unit name for a\n"
......
......@@ -603,9 +603,9 @@ To cancel the edit, simply kill the *Calc Edit* buffer."
(insert (propertize
(concat
(or title title "Calc Edit Mode. ")
(format "Press ‘C-c C-c’")
(format-message "Press ‘C-c C-c’")
(if allow-ret "" " or RET")
(format " to finish, ‘C-x k RET’ to cancel.\n\n"))
(format-message " to finish, ‘C-x k RET’ to cancel.\n\n"))
'font-lock-face 'italic 'read-only t 'rear-nonsticky t 'front-sticky t))
(make-local-variable 'calc-edit-top)
(setq calc-edit-top (point))))
......
......@@ -1118,10 +1118,10 @@ FExport diary data into iCalendar file: ")
(setq found-error t)
(save-current-buffer
(set-buffer (get-buffer-create "*icalendar-errors*"))
(insert (format "Error in line %d -- %s: %s\n"
(count-lines (point-min) (point))
error-val
entry-main))))))
(insert (format-message "Error in line %d -- %s: ‘%s’\n"
(count-lines (point-min) (point))
error-val
entry-main))))))
;; we're done, insert everything into the file
(save-current-buffer
......@@ -2473,8 +2473,8 @@ SUMMARY is not nil it must be a string that gives the summary of the
entry. In this case the user will be asked whether he wants to insert
the entry."
(when (or (not summary)
(y-or-n-p (format "Add appointment for %s to diary? "
summary)))
(y-or-n-p (format-message "Add appointment for ‘%s’ to diary? "
summary)))
(when summary
(setq non-marking
(y-or-n-p (format "Make appointment non-marking? "))))
......
......@@ -629,10 +629,9 @@ SYMBOL is a function that can be overridden."
(defun mode-local-print-binding (symbol)
"Print the SYMBOL binding."
(let ((value (symbol-value symbol)))
(princ (format (substitute-command-keys "\n ‘%s’ value is\n ")
symbol))
(princ (format-message "\n ‘%s’ value is\n " symbol))
(if (and value (symbolp value))
(princ (format (substitute-command-keys "‘%s’") value))
(princ (format-message "‘%s’" value))
(let ((pt (point)))
(pp value)
(save-excursion
......@@ -690,7 +689,7 @@ SYMBOL is a function that can be overridden."
)
((symbolp buffer-or-mode)
(setq mode buffer-or-mode)
(princ (format (substitute-command-keys "‘%s’\n") buffer-or-mode))
(princ (format-message "‘%s’\n" buffer-or-mode))
)
((signal 'wrong-type-argument
(list 'buffer-or-mode buffer-or-mode))))
......@@ -700,7 +699,7 @@ SYMBOL is a function that can be overridden."
(while mode
(setq table (get mode 'mode-local-symbol-table))
(when table
(princ (format (substitute-command-keys "\n- From ‘%s’\n") mode))
(princ (format-message "\n- From ‘%s’\n" mode))
(mode-local-print-bindings table))
(setq mode (get-mode-local-parent mode)))))
......
......@@ -156,7 +156,7 @@ Presumably if you call this you will insert something new there."
"Display the string FMT formatted with ARGS at the end of the minibuffer."
(if semantic-complete-inline-overlay
(apply 'message fmt args)
(message (concat (buffer-string) (apply 'format fmt args)))))
(message (concat (buffer-string) (apply #'format-message fmt args)))))
;;; ------------------------------------------------------------
;;; MINIBUFFER: Option Selection harnesses
......
......@@ -463,11 +463,11 @@ See `semantic-edits-change-leaf-tag' for details on parents."
(defun semantic-parse-changes-failed (&rest args)
"Signal that Semantic failed to parse changes.
That is, display a message by passing all ARGS to `format', then throw
That is, display a message by passing all ARGS to `format-message', then throw
a 'semantic-parse-changes-failed exception with value t."
(when semantic-edits-verbose-flag
(message "Semantic parse changes failed: %S"
(apply 'format args)))
(apply #'format-message args)))
(throw 'semantic-parse-changes-failed t))
(defsubst semantic-edits-incremental-fail ()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment