1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-07 06:50:23 -08:00

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.
This commit is contained in:
Paul Eggert 2015-08-23 22:38:02 -07:00
parent a5fd059f72
commit fbb5531fa1
87 changed files with 390 additions and 292 deletions

View file

@ -192,7 +192,7 @@
;; (if (aref byte-code-vector 0)
;; (error "The old version of the disassembler is loaded. Reload new-bytecomp as well"))
(byte-compile-log-1
(apply 'format format
(apply #'format-message format
(let (c a)
(mapcar (lambda (arg)
(if (not (consp arg))

View file

@ -973,7 +973,7 @@ Each function's symbol gets added to `byte-compile-noruntime-functions'."
(print-level 4)
(print-length 4))
(byte-compile-log-1
(format
(format-message
,format-string
,@(mapcar
(lambda (x) (if (symbolp x) (list 'prin1-to-string x) x))
@ -1120,7 +1120,8 @@ Each function's symbol gets added to `byte-compile-noruntime-functions'."
pt)
(when dir
(unless was-same
(insert (format "Leaving directory %s\n" default-directory))))
(insert (format-message "Leaving directory %s\n"
default-directory))))
(unless (bolp)
(insert "\n"))
(setq pt (point-marker))
@ -1135,8 +1136,8 @@ Each function's symbol gets added to `byte-compile-noruntime-functions'."
(when dir
(setq default-directory dir)
(unless was-same
(insert (format "Entering directory %s\n"
default-directory))))
(insert (format-message "Entering directory %s\n"
default-directory))))
(setq byte-compile-last-logged-file byte-compile-current-file
byte-compile-last-warned-form nil)
;; Do this after setting default-directory.
@ -1154,7 +1155,7 @@ Each function's symbol gets added to `byte-compile-noruntime-functions'."
(defun byte-compile-warn (format &rest args)
"Issue a byte compiler warning; use (format FORMAT ARGS...) for message."
(setq format (apply 'format format args))
(setq format (apply #'format-message format args))
(if byte-compile-error-on-warn
(error "%s" format) ; byte-compile-file catches and logs it
(byte-compile-log-warning format t :warning)))
@ -2979,7 +2980,7 @@ for symbols generated by the byte compiler itself."
(`(',var . ,_)
(when (assq var byte-compile-lexical-variables)
(byte-compile-log-warning
(format "%s cannot use lexical var %s" fn var)
(format-message "%s cannot use lexical var %s" fn var)
nil :error)))))
(when (macroexp--const-symbol-p fn)
(byte-compile-warn "%s called as a function" fn))
@ -2991,8 +2992,8 @@ for symbols generated by the byte compiler itself."
(format "; %s" interactive-only))
((and (symbolp 'interactive-only)
(not (eq interactive-only t)))
(format "; use %s instead."
interactive-only))
(format-message "; use %s instead."
interactive-only))
(t "."))))
(if (eq (car-safe (symbol-function (car form))) 'macro)
(byte-compile-log-warning

View file

@ -300,7 +300,8 @@ places where they originally did not directly appear."
(prog1 binder (setq binder (list binder)))
(when (cddr binder)
(byte-compile-log-warning
(format "Malformed %S binding: %S" letsym binder)))
(format-message "Malformed %S binding: %S"
letsym binder)))
(setq value (cadr binder))
(car binder)))
(new-val
@ -545,7 +546,7 @@ FORM is the parent form that binds this var."
(`((,(and var (guard (eq ?_ (aref (symbol-name var) 0)))) . ,_)
,_ ,_ ,_ ,_)
(byte-compile-log-warning
(format "%s %S not left unused" varkind var))))
(format-message "%s %S not left unused" varkind var))))
(pcase vardata
(`((,var . ,_) nil ,_ ,_ nil)
;; FIXME: This gives warnings in the wrong order, with imprecise line
@ -557,8 +558,8 @@ FORM is the parent form that binds this var."
(eq ?_ (aref (symbol-name var) 0))
;; As a special exception, ignore "ignore".
(eq var 'ignored))
(byte-compile-log-warning (format "Unused lexical %s %S"
varkind var))))
(byte-compile-log-warning (format-message "Unused lexical %s %S"
varkind var))))
;; If it's unused, there's no point converting it into a cons-cell, even if
;; it's captured and mutated.
(`(,binder ,_ t t ,_)
@ -678,7 +679,7 @@ and updates the data stored in ENV."
;; ((and `(quote ,v . ,_) (guard (assq v env)))
;; (byte-compile-log-warning
;; (format "Possible confusion variable/symbol for %S" v)))
;; (format-message "Possible confusion variable/symbol for %S" v)))
(`(quote . ,_) nil) ; quote form
(`(function . ,_) nil) ; same as quote

View file

@ -279,8 +279,8 @@ TYPE is a string giving the nature of the error. Warning is displayed in
entry))
(warning-fill-prefix " "))
(display-warning 'check-declare
(format "said %s was defined in %s: %s"
fn (file-name-nondirectory fnfile) type)
(format-message "said %s was defined in %s: %s"
fn (file-name-nondirectory fnfile) type)
nil check-declare-warning-buffer)))
(declare-function compilation-forget-errors "compile" ())

View file

@ -1714,7 +1714,7 @@ function,command,variable,option or symbol." ms1))))))
e t))
(if (checkdoc-autofix-ask-replace
(match-beginning 1) (match-end 1)
(format
(format-message
"If this is the argument %s, it should appear as %s. Fix? "
(car args) (upcase (car args)))
(upcase (car args)) t)
@ -1740,7 +1740,7 @@ function,command,variable,option or symbol." ms1))))))
(insert "."))
nil)
(checkdoc-create-error
(format
(format-message
"Argument %s should appear (as %s) in the doc string"
(car args) (upcase (car args)))
s (marker-position e)))
@ -1824,16 +1824,16 @@ Replace with \"%s\"? " original replace)
(setq found (intern-soft ms))
(or (boundp found) (fboundp found)))
(progn
(setq msg (format "Add quotes around Lisp symbol %s? "
ms))
(setq msg (format-message
"Add quotes around Lisp symbol %s? " ms))
(if (checkdoc-autofix-ask-replace
(match-beginning 1) (+ (match-beginning 1)
(length ms))
msg (concat "" ms "") t)
(setq msg nil)
(setq msg
(format "Lisp symbol %s should appear in quotes"
ms))))))
(format-message
"Lisp symbol %s should appear in quotes" ms))))))
(if msg
(checkdoc-create-error msg (match-beginning 1)
(+ (match-beginning 1)

View file

@ -2101,8 +2101,8 @@ by EXPANSION, and (setq NAME ...) will act like (setf EXPANSION ...).
macroexpand-all-environment))))
(if (or (null (cdar bindings)) (cl-cddar bindings))
(macroexp--warn-and-return
(format "Malformed cl-symbol-macrolet binding: %S"
(car bindings))
(format-message "Malformed cl-symbol-macrolet binding: %S"
(car bindings))
expansion)
expansion)))
(fset 'macroexpand previous-macroexpand))))))

View file

@ -3373,7 +3373,7 @@ Return the result of the last expression."
(defalias 'edebug-prin1 'prin1)
(defalias 'edebug-print 'print)
(defalias 'edebug-prin1-to-string 'prin1-to-string)
(defalias 'edebug-format 'format)
(defalias 'edebug-format 'format-message)
(defalias 'edebug-message 'message)
(defun edebug-eval-expression (expr)

View file

@ -733,7 +733,7 @@ Argument FN is the function calling this verifier."
((and (or `',name (and name (pred keywordp)))
(guard (not (memq name eieio--known-slot-names))))
(macroexp--warn-and-return
(format "Unknown slot %S" name) exp 'compile-only))
(format-message "Unknown slot %S" name) exp 'compile-only))
(_ exp)))))
(cl-check-type slot symbol)
(cl-check-type obj (or eieio-object class))

View file

@ -261,7 +261,7 @@ Otherwise work like `message'."
mode-line-format)))
(setq eldoc-mode-line-string
(when (stringp format-string)
(apply 'format format-string args)))
(apply #'format-message format-string args)))
(force-mode-line-update)))
(apply 'message format-string args)))
@ -274,7 +274,7 @@ Otherwise work like `message'."
;; eldoc-last-message so eq test above might succeed on
;; subsequent calls.
((null (cdr args)) (car args))
(t (apply 'format args))))
(t (apply #'format-message args))))
;; In emacs 19.29 and later, and XEmacs 19.13 and later, all messages
;; are recorded in a log. Do not put eldoc messages in that log since
;; they are Legion.

View file

@ -249,9 +249,9 @@ This environment can be passed to `macroexpand'."
(elint-set-mode-line t)
(with-current-buffer elint-log-buffer
(unless (string-equal default-directory dir)
(elint-log-message (format " \nLeaving directory %s"
default-directory) t)
(elint-log-message (format "Entering directory %s" dir) t)
(elint-log-message (format-message " \nLeaving directory %s"
default-directory) t)
(elint-log-message (format-message "Entering directory %s" dir) t)
(setq default-directory dir))))
(let ((str (format "Linting file %s" file)))
(message "%s..." str)
@ -982,7 +982,7 @@ Does basic handling of `featurep' tests."
(line-beginning-position))))
0) ; unknown position
type
(apply 'format string args))))
(apply #'format-message string args))))
(defun elint-error (string &rest args)
"Report a linting error.

View file

@ -367,10 +367,11 @@ message about the whole chain of aliases."
(not verbose)
(setq aliases (if aliases
(concat aliases
(format ", which is an alias for %s"
(symbol-name def)))
(format "%s is an alias for %s"
function (symbol-name def)))))
(format-message
", which is an alias for %s"
(symbol-name def)))
(format-message "%s is an alias for %s"
function (symbol-name def)))))
(setq function (find-function-advised-original function)
def (find-function-advised-original function)))
(if aliases

View file

@ -146,11 +146,12 @@ and also to avoid outputting the warning during normal execution."
(defun macroexp--obsolete-warning (fun obsolescence-data type)
(let ((instead (car obsolescence-data))
(asof (nth 2 obsolescence-data)))
(format "%s is an obsolete %s%s%s" fun type
(if asof (concat " (as of " asof ")") "")
(cond ((stringp instead) (concat "; " instead))
(instead (format "; use %s instead." instead))
(t ".")))))
(format-message
"%s is an obsolete %s%s%s" fun type
(if asof (concat " (as of " asof ")") "")
(cond ((stringp instead) (concat "; " instead))
(instead (format-message "; use %s instead." instead))
(t ".")))))
(defun macroexpand-1 (form &optional environment)
"Perform (at most) one step of macroexpansion."

View file

@ -198,7 +198,8 @@ Returns the number of actions taken."
(objects (if help (nth 1 help) "objects"))
(action (if help (nth 2 help) "act on")))
(concat
(format "Type SPC or y to %s the current %s;
(format-message "\
Type SPC or y to %s the current %s;
DEL or n to skip the current %s;
RET or q to give up on the %s (skip all remaining %s);
C-g to quit (cancel the whole command);

View file

@ -95,7 +95,7 @@ Each element has the form (WHERE BYTECODE STACK) where:
(propertize (format "%s advice: " where)
'face 'warning)
(let ((fun (advice--car flist)))
(if (symbolp fun) (format "%S" fun)
(if (symbolp fun) (format-message "%S" fun)
(let* ((name (cdr (assq 'name (advice--props flist))))
(doc (documentation fun t))
(usage (help-split-fundoc doc function)))

View file

@ -1592,11 +1592,12 @@ SEEN is used internally to detect infinite recursion."
(unless problem
(setq problem
(if (stringp disabled)
(format "Package %s held at version %s, but version %s required"
next-pkg disabled
(package-version-join next-version))
(format "Required package %s is disabled"
next-pkg)))))
(format-message
"Package %s held at version %s, but version %s required"
next-pkg disabled
(package-version-join next-version))
(format-message "Required package %s is disabled"
next-pkg)))))
(t (setq found pkg-desc)))))
(unless found
(cond
@ -2365,16 +2366,16 @@ Otherwise no newline is inserted."
(defun package-install-button-action (button)
(let ((pkg-desc (button-get button 'package-desc)))
(when (y-or-n-p (format "Install package %s? "
(package-desc-full-name pkg-desc)))
(when (y-or-n-p (format-message "Install package %s? "
(package-desc-full-name pkg-desc)))
(package-install pkg-desc nil)
(revert-buffer nil t)
(goto-char (point-min)))))
(defun package-delete-button-action (button)
(let ((pkg-desc (button-get button 'package-desc)))
(when (y-or-n-p (format "Delete package %s? "
(package-desc-full-name pkg-desc)))
(when (y-or-n-p (format-message "Delete package %s? "
(package-desc-full-name pkg-desc)))
(package-delete pkg-desc)
(revert-buffer nil t)
(goto-char (point-min)))))
@ -3077,8 +3078,8 @@ prompt (see `package-menu--prompt-transaction-p')."
(length packages)
(mapconcat #'package-desc-full-name packages ", ")))
;; Exactly 1
(t (format "package %s"
(package-desc-full-name (car packages))))))
(t (format-message "package %s"
(package-desc-full-name (car packages))))))
(defun package-menu--prompt-transaction-p (delete install upgrade)
"Prompt the user about DELETE, INSTALL, and UPGRADE.

View file

@ -324,7 +324,8 @@ This function is called, by name, directly by the C code."
(apply (timer--function timer) (timer--args timer)))
(error (message "Error running timer%s: %S"
(if (symbolp (timer--function timer))
(format " %s" (timer--function timer)) "")
(format-message " %s" (timer--function timer))
"")
err)))
(when (and retrigger
;; If the timer's been canceled, don't "retrigger" it

View file

@ -316,7 +316,7 @@ See also `warning-series', `warning-prefix-function' and
(defun lwarn (type level message &rest args)
"Display a warning message made from (format MESSAGE ARGS...).
\\<special-mode-map>
Aside from generating the message with `format',
Aside from generating the message with `format-message',
this is equivalent to `display-warning'.
TYPE is the warning type: either a custom group name (a symbol),
@ -332,15 +332,15 @@ LEVEL should be either :debug, :warning, :error, or :emergency
:error -- invalid data or circumstances.
:warning -- suspicious data or circumstances.
:debug -- info for debugging only."
(display-warning type (apply 'format message args) level))
(display-warning type (apply #'format-message message args) level))
;;;###autoload
(defun warn (message &rest args)
"Display a warning message made from (format MESSAGE ARGS...).
Aside from generating the message with `format',
Aside from generating the message with `format-message',
this is equivalent to `display-warning', using
`emacs' as the type and `:warning' as the level."
(display-warning 'emacs (apply 'format message args)))
(display-warning 'emacs (apply #'format-message message args)))
(provide 'warnings)