Fix some uses of %s for non-strings/names

* lisp/files.el (normal-mode, set-auto-mode--apply-alist):
* lisp/gnus/nnimap.el (nnimap-command):
* lisp/emacs-lisp/bytecomp.el (bytecomp--check-cus-type):
Prefer %S over %s for arbitrary sexps and lists.
This commit is contained in:
Stefan Monnier 2025-02-14 11:25:52 -05:00
parent b967891088
commit 300bae4f7c
4 changed files with 20 additions and 17 deletions

View file

@ -5275,11 +5275,11 @@ FORM is used to provide location, `bytecomp--cus-function' and
(and tl
(progn
(bytecomp--cus-warn
tl "misplaced %s keyword in `%s' type" (car tl) head)
tl "misplaced %S keyword in `%S' type" (car tl) head)
t))))))
((memq head '(choice radio))
(unless tail
(bytecomp--cus-warn type "`%s' without any types inside" head))
(bytecomp--cus-warn type "`%S' without any types inside" head))
(let ((clauses tail)
(constants nil)
(tags nil))
@ -5287,7 +5287,7 @@ FORM is used to provide location, `bytecomp--cus-function' and
(let* ((ty (car clauses))
(ty-head (car-safe ty)))
(when (and (eq ty-head 'other) (cdr clauses))
(bytecomp--cus-warn ty "`other' not last in `%s'" head))
(bytecomp--cus-warn ty "`other' not last in `%S'" head))
(when (memq ty-head '(const other))
(let ((ty-tail (cdr ty))
(val nil))
@ -5299,13 +5299,13 @@ FORM is used to provide location, `bytecomp--cus-function' and
(setq val (car ty-tail)))
(when (member val constants)
(bytecomp--cus-warn
ty "duplicated value in `%s': `%S'" head val))
ty "duplicated value in `%S': `%S'" head val))
(push val constants)))
(let ((tag (and (consp ty) (plist-get (cdr ty) :tag))))
(when (stringp tag)
(when (member tag tags)
(bytecomp--cus-warn
ty "duplicated :tag string in `%s': %S" head tag))
ty "duplicated :tag string in `%S': %S" head tag))
(push tag tags)))
(bytecomp--check-cus-type ty))
(setq clauses (cdr clauses)))))
@ -5317,7 +5317,7 @@ FORM is used to provide location, `bytecomp--cus-function' and
(bytecomp--check-cus-type ty)))
((memq head '(list group vector set repeat))
(unless tail
(bytecomp--cus-warn type "`%s' without type specs" head))
(bytecomp--cus-warn type "`%S' without type specs" head))
(dolist (ty tail)
(bytecomp--check-cus-type ty)))
((memq head '(alist plist))
@ -5333,21 +5333,21 @@ FORM is used to provide location, `bytecomp--cus-function' and
(val (car tail)))
(cond
((or (> n 1) (and value-tag tail))
(bytecomp--cus-warn type "`%s' with too many values" head))
(bytecomp--cus-warn type "`%S' with too many values" head))
(value-tag
(setq val (cadr value-tag)))
;; ;; This is a useful check but it results in perhaps
;; ;; a bit too many complaints.
;; ((null tail)
;; (bytecomp--cus-warn
;; type "`%s' without value is implicitly nil" head))
;; type "`%S' without value is implicitly nil" head))
)
(when (memq (car-safe val) '(quote function))
(bytecomp--cus-warn type "`%s' with quoted value: %S" head val))))
(bytecomp--cus-warn type "`%S' with quoted value: %S" head val))))
((eq head 'quote)
(bytecomp--cus-warn type "type should not be quoted: %s" (cadr type)))
(bytecomp--cus-warn type "type should not be quoted: %S" (cadr type)))
((memq head invalid-types)
(bytecomp--cus-warn type "`%s' is not a valid type" head))
(bytecomp--cus-warn type "`%S' is not a valid type" head))
((or (not (symbolp head)) (keywordp head))
(bytecomp--cus-warn type "irregular type `%S'" head))
)))
@ -5355,9 +5355,9 @@ FORM is used to provide location, `bytecomp--cus-function' and
(bytecomp--cus-warn type "irregular type `%S'" type))
((memq type '( list cons group vector choice radio const other
function-item variable-item set repeat restricted-sexp))
(bytecomp--cus-warn type "`%s' without arguments" type))
(bytecomp--cus-warn type "`%S' without arguments" type))
((memq type invalid-types)
(bytecomp--cus-warn type "`%s' is not a valid type" type))
(bytecomp--cus-warn type "`%S' is not a valid type" type))
)))
(defun bytecomp--check-cus-face-spec (spec)

View file

@ -2970,13 +2970,13 @@ the local variables spec."
(let ((enable-local-variables (or (not find-file) enable-local-variables)))
;; FIXME this is less efficient than it could be, since both
;; s-a-m and h-l-v may parse the same regions, looking for "mode:".
(with-demoted-errors "File mode specification error: %s"
(with-demoted-errors "File mode specification error: %S"
(set-auto-mode))
;; `delay-mode-hooks' being non-nil will have prevented the major
;; mode's call to `run-mode-hooks' from calling
;; `hack-local-variables'. In that case, call it now.
(when delay-mode-hooks
(with-demoted-errors "File local-variables error: %s"
(with-demoted-errors "File local-variables error: %S"
(hack-local-variables 'no-mode))))
;; Turn font lock off and on, to make sure it takes account of
;; whatever file local variables are relevant to it.
@ -3517,7 +3517,7 @@ extra checks should be done."
alist name case-insensitive-p))
(when (and dir-local mode
(not (set-auto-mode--dir-local-valid-p mode)))
(message "Ignoring invalid mode `%s'" mode)
(message "Ignoring invalid mode `%S'" mode)
(setq mode nil))
(when mode
(set-auto-mode-0 mode keep-mode-if-same)

View file

@ -2004,7 +2004,7 @@ Return the server's response to the SELECT or EXAMINE command."
(cons t response)
(nnheader-report 'nnimap "%s"
(mapconcat (lambda (a)
(format "%s" a))
(format "%S" a))
(car response) " "))
nil)))

View file

@ -1550,6 +1550,9 @@ else cover the whole buffer."
(defvar whitespace-style)
(defvar whitespace-trailing-regexp)
;; Prevent applying `view-read-only' to diff-mode buffers (bug#75993).
;; We don't derive from `special-mode' because that would inhibit the
;; `self-insert-command' binding of normal keys.
(put 'diff-mode 'mode-class 'special)
;;;###autoload
(define-derived-mode diff-mode fundamental-mode "Diff"