From: Paul Eggert Date: Sun, 20 Sep 2015 16:40:35 +0000 (-0700) Subject: Use %s to format strings instead of splicing them X-Git-Tag: emacs-25.0.90~1224^2~69 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ab11a1cf27ebe3791df45cccde3c851affd184dd;p=emacs.git 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. --- diff --git a/lisp/allout.el b/lisp/allout.el index bbd69cd8347..5273fe2b433 100644 --- a/lisp/allout.el +++ b/lisp/allout.el @@ -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))) diff --git a/lisp/calc/calc-ext.el b/lisp/calc/calc-ext.el index 83722e761b0..933c446875e 100644 --- a/lisp/calc/calc-ext.el +++ b/lisp/calc/calc-ext.el @@ -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. diff --git a/lisp/calc/calc-store.el b/lisp/calc/calc-store.el index 3d8c865c7bf..21209c66677 100644 --- a/lisp/calc/calc-store.el +++ b/lisp/calc/calc-store.el @@ -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) diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el index 527548f78b6..27ca17b4e4f 100644 --- a/lisp/calendar/todo-mode.el +++ b/lisp/calendar/todo-mode.el @@ -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)) diff --git a/lisp/cedet/semantic/complete.el b/lisp/cedet/semantic/complete.el index d32b2c4f001..9b7882c7acd 100644 --- a/lisp/cedet/semantic/complete.el +++ b/lisp/cedet/semantic/complete.el @@ -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 diff --git a/lisp/org/ob-latex.el b/lisp/org/ob-latex.el index d0a413f1172..811c9ef92c6 100644 --- a/lisp/org/ob-latex.el +++ b/lisp/org/ob-latex.el @@ -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) diff --git a/lisp/org/org-crypt.el b/lisp/org/org-crypt.el index f527673cbd4..2b3445e47cd 100644 --- a/lisp/org/org-crypt.el +++ b/lisp/org/org-crypt.el @@ -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.")) diff --git a/lisp/org/ox-latex.el b/lisp/org/ox-latex.el index 91a864eee6e..51f7b17a8bf 100644 --- a/lisp/org/ox-latex.el +++ b/lisp/org/ox-latex.el @@ -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) diff --git a/lisp/org/ox-man.el b/lisp/org/ox-man.el index d7adcd5486d..09ad1866c0e 100644 --- a/lisp/org/ox-man.el +++ b/lisp/org/ox-man.el @@ -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 diff --git a/lisp/org/ox-odt.el b/lisp/org/ox-odt.el index 1ee201ba23f..9abda33f59d 100644 --- a/lisp/org/ox-odt.el +++ b/lisp/org/ox-odt.el @@ -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. diff --git a/lisp/org/ox-texinfo.el b/lisp/org/ox-texinfo.el index 5130329d4b4..67daf6f979e 100644 --- a/lisp/org/ox-texinfo.el +++ b/lisp/org/ox-texinfo.el @@ -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 diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index a5efb934a22..09338860c75 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -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 diff --git a/lisp/progmodes/verilog-mode.el b/lisp/progmodes/verilog-mode.el index 85733e16190..489094b2e4f 100644 --- a/lisp/progmodes/verilog-mode.el +++ b/lisp/progmodes/verilog-mode.el @@ -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 diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el index a21c105fb98..373f81238a2 100644 --- a/lisp/term/ns-win.el +++ b/lisp/term/ns-win.el @@ -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.