1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-30 04:10:54 -08:00

Use %s to format strings instead of splicing them

If FOO might contain quotes that are part of a file or variable
name, the quotes should not be translated when showing FOO’s name
in a diagnostic.  So, for example, (message (concat (FOO ": bar")))
is not quite right, as it would translate FOO’s quotes.
Change it to (message "%s: bar" FOO) instead.
* lisp/allout.el (allout-process-exposed):
* lisp/calc/calc-ext.el (calc-do-prefix-help):
* lisp/calc/calc-store.el (calc-store-into):
* lisp/calendar/todo-mode.el (todo-category-completions):
* lisp/cedet/semantic/complete.el (semantic-completion-message):
* lisp/org/ob-latex.el (convert-pdf):
* lisp/org/org-crypt.el (org-crypt-check-auto-save):
* lisp/org/ox-latex.el (org-latex-compile):
* lisp/org/ox-man.el (org-man-compile):
* lisp/org/ox-odt.el (org-odt--export-wrap):
* lisp/org/ox-texinfo.el (org-texinfo-compile):
* lisp/progmodes/ruby-mode.el (ruby-in-ppss-context-p):
* lisp/progmodes/verilog-mode.el (verilog-batch-execute-func)
(verilog-signals-combine-bus, verilog-read-defines)
(verilog-getopt-file, verilog-expand-dirnames)
(verilog-modi-lookup, verilog-modi-modport-lookup-one):
* lisp/term/ns-win.el (ns-spi-service-call):
Use %s to avoid translating quotes of file names etc. in diagnostics.
This commit is contained in:
Paul Eggert 2015-09-20 09:40:35 -07:00
parent 2ad2f8b084
commit ab11a1cf27
14 changed files with 58 additions and 55 deletions

View file

@ -5562,9 +5562,8 @@ Defaults:
;; Specified but not a buffer -- get it:
(let ((got (get-buffer frombuf)))
(if (not got)
(error (concat "allout-process-exposed: source buffer "
frombuf
" not found."))
(error "allout-process-exposed: source buffer %s not found."
frombuf)
(setq frombuf got))))
;; not specified -- default it:
(setq frombuf (current-buffer)))

View file

@ -1327,9 +1327,8 @@ calc-kill calc-kill-region calc-yank))))
(setq calc-prefix-help-retry (= chr ??))
(if bnd
(call-interactively bnd)
(if key
(message (concat (key-description (vector key chr)) " is undefined"))
(message (concat (key-description (vector chr)) " is undefined")))))))
(message "%s is undefined"
(key-description (if key (vector key chr) (vector chr))))))))
;;;; Commands.

View file

@ -58,8 +58,8 @@
(let ((msg
(calc-store-value var (or calc-given-value (calc-top 1))
"" calc-given-value-flag)))
(message (concat "Stored to variable \"%s\"" msg)
(calc-var-name var)))))
(message "Stored to variable \"%s\"%s"
(calc-var-name var) msg))))
(setq var (calc-is-assignments (calc-top 1)))
(if var
(while var
@ -67,8 +67,8 @@
(calc-store-value (car (car var)) (cdr (car var))
(if (not (cdr var)) "")
(if (not (cdr var)) 1))))
(message (concat "Stored to variable \"%s\"" msg)
(calc-var-name (car (car var)))))
(message "Stored to variable \"%s\"%s"
(calc-var-name (car (car var))) msg))
(setq var (cdr var))))))))
(defun calc-store-plus (&optional var)
@ -422,8 +422,8 @@
(calc-var-name var1)))))
(if var2
(let ((msg (calc-store-value var2 value "")))
(message (concat "Variable \"%s\" copied to \"%s\"" msg)
(calc-var-name var1) (calc-var-name var2))))))))
(message "Variable \"%s\" copied to \"%s\"%s"
(calc-var-name var1) (calc-var-name var2) msg)))))))
(defvar calc-last-edited-variable nil)
(defun calc-edit-variable (&optional var)

View file

@ -5643,9 +5643,10 @@ have been removed."
(when deleted
(let ((pl (> (length deleted) 1))
(names (mapconcat (lambda (f) (concat "\"" f "\"")) deleted ", ")))
(message (concat "File" (if pl "s" "") " " names " ha" (if pl "ve" "s")
(message (concat "File" (if pl "s" "") " %s ha" (if pl "ve" "s")
" been deleted and removed from\n"
"the list of category completion files")))
"the list of category completion files")
names))
(todo-reevaluate-category-completions-files-defcustom)
(custom-set-default 'todo-category-completions-files
(symbol-value 'todo-category-completions-files))

View file

@ -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-message fmt args)))))
(apply 'message (concat "%s" fmt) (buffer-string) args)))
;;; ------------------------------------------------------------
;;; MINIBUFFER: Option Selection harnesses

View file

@ -183,7 +183,7 @@ This function is called by `org-babel-execute-src-block'."
"Generate a file from a pdf file using imagemagick."
(let ((cmd (concat "convert " im-in-options " " pdffile " "
im-out-options " " out-file)))
(message (concat "Converting pdffile file " cmd "..."))
(message "Converting pdffile file %s..." cmd)
(shell-command cmd)))
(defun org-babel-latex-tex-to-pdf (file)

View file

@ -133,9 +133,10 @@ See `org-crypt-disable-auto-save'."
(and
(eq org-crypt-disable-auto-save 'ask)
(y-or-n-p "org-decrypt: auto-save-mode may cause leakage. Disable it for current buffer? ")))
(message (concat "org-decrypt: Disabling auto-save-mode for " (or (buffer-file-name) (current-buffer))))
; The argument to auto-save-mode has to be "-1", since
; giving a "nil" argument toggles instead of disabling.
(message "org-decrypt: Disabling auto-save-mode for %s"
(or (buffer-file-name) (current-buffer)))
;; The argument to auto-save-mode has to be "-1", since
;; giving a "nil" argument toggles instead of disabling.
(auto-save-mode -1))
((eq org-crypt-disable-auto-save nil)
(message "org-decrypt: Decrypting entry with auto-save-mode enabled. This may cause leakage."))

View file

@ -2876,8 +2876,8 @@ Return PDF file name or an error if it couldn't be produced."
;; Check for process failure. Provide collected errors if
;; possible.
(if (not (file-exists-p pdffile))
(error (concat (format "PDF file %s wasn't produced" pdffile)
(when errors (concat ": " errors))))
(error "PDF file %s wasn't produced%s" pdffile
(if errors (concat ": " errors) ""))
;; Else remove log files, when specified, and signal end of
;; process to user, along with any error encountered.
(when (and (not snippet) org-latex-remove-logfiles)

View file

@ -1219,8 +1219,8 @@ Return PDF file name or an error if it couldn't be produced."
;; Check for process failure. Provide collected errors if
;; possible.
(if (not (file-exists-p pdffile))
(error (concat (format "PDF file %s wasn't produced" pdffile)
(when errors (concat ": " errors))))
(error "PDF file %s wasn't produced%s" pdffile
(if errors (concat ": " errors) ""))
;; Else remove log files, when specified, and signal end of
;; process to user, along with any error encountered.
(when org-man-remove-logfiles

View file

@ -4089,8 +4089,8 @@ contextual information."
nil standard-output nil (cdr cmd)))))
(or (zerop exitcode)
(error (concat "Unable to create OpenDocument file."
(format " Zip failed with error (%s)"
err-string)))))
" Zip failed with error (%s)")
err-string)))
cmds)))
;; Move the zip file from temporary work directory to
;; user-mandated location.

View file

@ -1534,8 +1534,8 @@ Return INFO file name or an error if it couldn't be produced."
;; Check for process failure. Provide collected errors if
;; possible.
(if (not (file-exists-p infofile))
(error (concat (format "INFO file %s wasn't produced" infofile)
(when errors (concat ": " errors))))
(error "INFO file %s wasn't produced%s" infofile
(if errors (concat ": " errors) ""))
;; Else remove log files, when specified, and signal end of
;; process to user, along with any error encountered.
(when org-texinfo-remove-logfiles

View file

@ -2007,7 +2007,8 @@ It will be properly highlighted even when the call omits parens.")
(t
(error (concat
"Internal error on `ruby-in-ppss-context-p': "
"context name `" (symbol-name context) "' is unknown"))))
"context name `%s' is unknown")
context)))
t)))
(defvar ruby-font-lock-syntax-table

View file

@ -5301,8 +5301,8 @@ Save the result unless optional NO-SAVE is t."
(save-excursion
(if (not (file-exists-p (buffer-file-name buf)))
(error
(concat "File not found: " (buffer-file-name buf))))
(message (concat "Processing " (buffer-file-name buf)))
"File not found: %s" (buffer-file-name buf)))
(message "Processing %s" (buffer-file-name buf))
(set-buffer buf)
(funcall funref)
(when (and (not no-save)
@ -8074,9 +8074,9 @@ Duplicate signals are also removed. For example A[2] and A[1] become A[2:1]."
(when (and sv-busstring
(not (equal sv-busstring (verilog-sig-bits sig))))
(when nil ; Debugging
(message (concat "Warning, can't merge into single bus "
sv-name bus
", the AUTOs may be wrong")))
(message (concat "Warning, can't merge into single bus %s%s"
", the AUTOs may be wrong")
sv-name bus))
(setq buswarn ", Couldn't Merge"))
(if (verilog-sig-comment sig) (setq combo ", ..."))
(setq sv-memory (or sv-memory (verilog-sig-memory sig))
@ -9325,8 +9325,8 @@ warning message, you need to add to your init file:
(let ((fns (verilog-library-filenames filename (buffer-file-name))))
(if fns
(set-buffer (find-file-noselect (car fns)))
(error (concat (verilog-point-text)
": Can't find verilog-read-defines file: " filename)))))
(error "%s: Can't find verilog-read-defines file: %s"
(verilog-point-text) filename))))
(when recurse
(goto-char (point-min))
(while (re-search-forward "^\\s-*`include\\s-+\\([^ \t\n\f]+\\)" nil t)
@ -9507,8 +9507,8 @@ Some macros and such are also found and included. For dinotrace.el."
line)
(if fns
(set-buffer (find-file-noselect (car fns)))
(error (concat (verilog-point-text)
": Can't find verilog-getopt-file -f file: " filename)))
(error "%s: Can't find verilog-getopt-file -f file: %s"
(verilog-point-text) filename))
(goto-char (point-min))
(while (not (eobp))
(setq line (buffer-substring (point) (point-at-eol)))
@ -9710,7 +9710,8 @@ Or, just the existing dirnames themselves if there are no wildcards."
;; Note this function is performance critical.
;; Do not call anything that requires disk access that cannot be cached.
(interactive)
(unless dirnames (error "`verilog-library-directories' should include at least '.'"))
(unless dirnames
(error "`verilog-library-directories' should include at least `.'"))
(setq dirnames (reverse dirnames)) ; not nreverse
(let ((dirlist nil)
pattern dirfile dirfiles dirname root filename rest basefile)
@ -9889,17 +9890,18 @@ Return modi if successful, else print message unless IGNORE-ERROR is true."
(if (not (setq mif (verilog-module-inside-filename-p realname (car filenames))))
(setq filenames (cdr filenames))))
;; mif has correct form to become later elements of modi
(cond (mif (setq modi mif))
(t (setq modi nil)
(or ignore-error
(error (concat (verilog-point-text)
": Can't locate " module " module definition"
(if (not (equal module realname))
(concat " (Expanded macro to " realname ")")
"")
"\n Check the verilog-library-directories variable."
"\n I looked in (if not listed, doesn't exist):\n\t"
(mapconcat 'concat orig-filenames "\n\t"))))))
(setq modi mif)
(or mif ignore-error
(error
(concat
"%s: Can't locate %s module definition%s"
"\n Check the verilog-library-directories variable."
"\n I looked in (if not listed, doesn't exist):\n\t%s")
(verilog-point-text) module
(if (not (equal module realname))
(concat " (Expanded macro to " realname ")")
"")
(mapconcat 'concat orig-filenames "\n\t")))
(when (eval-when-compile (fboundp 'make-hash-table))
(unless verilog-modi-lookup-cache
(setq verilog-modi-lookup-cache
@ -10001,11 +10003,11 @@ Report errors unless optional IGNORE-ERROR."
(let* ((realname (verilog-symbol-detick name t))
(modport (assoc name (verilog-decls-get-modports (verilog-modi-get-decls modi)))))
(or modport ignore-error
(error (concat (verilog-point-text)
": Can't locate " name " modport definition"
(if (not (equal name realname))
(concat " (Expanded macro to " realname ")")
""))))
(error "%s: Can't locate %s modport definition%s"
(verilog-point-text) name
(if (not (equal name realname))
(concat " (Expanded macro to " realname ")")
"")))
(let* ((decls (verilog-modport-decls modport))
(clks (verilog-modport-clockings modport)))
;; Now expand any clocking's

View file

@ -243,7 +243,7 @@ The properties returned may include `top', `left', `height', and `width'."
(insert ns-input-spi-arg))
((string-equal ns-input-spi-name "mail-to")
(compose-mail ns-input-spi-arg))
(t (error (concat "Service " ns-input-spi-name " not recognized")))))
(t (error "Service %s not recognized" ns-input-spi-name))))
;; Composed key sequence handling for Nextstep system input methods.