Commit 16004397 authored by Philipp Stephani's avatar Philipp Stephani

Improve unescaped character literal warnings

* src/lread.c (load_warn_unescaped_character_literals)
(syms_of_lread):
lisp/emacs-lisp/bytecomp.el (byte-compile-from-buffer): Improve
formatting of unescaped character literal warnings.

* test/src/lread-tests.el (lread-tests--unescaped-char-literals):
test/lisp/emacs-lisp/bytecomp-tests.el
(bytecomp-tests--unescaped-char-literals): Adapt unit tests.
parent 0e09d00f
...@@ -2032,7 +2032,7 @@ and will be removed soon. See (elisp)Backquote in the manual.")) ...@@ -2032,7 +2032,7 @@ and will be removed soon. See (elisp)Backquote in the manual."))
(when lread--unescaped-character-literals (when lread--unescaped-character-literals
(byte-compile-warn (byte-compile-warn
"unescaped character literals %s detected!" "unescaped character literals %s detected!"
(mapconcat #'string (mapconcat (lambda (char) (format "`?%c'" char))
(sort lread--unescaped-character-literals #'<) (sort lread--unescaped-character-literals #'<)
", "))) ", ")))
(byte-compile-toplevel-file-form form))) (byte-compile-toplevel-file-form form)))
......
...@@ -963,9 +963,11 @@ load_warn_unescaped_character_literals (Lisp_Object file) ...@@ -963,9 +963,11 @@ load_warn_unescaped_character_literals (Lisp_Object file)
AUTO_STRING (format, AUTO_STRING (format,
"Loading `%s': unescaped character literals %s detected!"); "Loading `%s': unescaped character literals %s detected!");
AUTO_STRING (separator, ", "); AUTO_STRING (separator, ", ");
AUTO_STRING (inner_format, "`?%c'");
CALLN (Fmessage, CALLN (Fmessage,
format, file, format, file,
Fmapconcat (Qstring, Fmapconcat (list3 (Qlambda, list1 (Qchar),
list3 (Qformat, inner_format, Qchar)),
Fsort (Vlread_unescaped_character_literals, Qlss), Fsort (Vlread_unescaped_character_literals, Qlss),
separator)); separator));
} }
...@@ -4855,6 +4857,8 @@ For internal use only. */); ...@@ -4855,6 +4857,8 @@ For internal use only. */);
"lread--unescaped-character-literals"); "lread--unescaped-character-literals");
DEFSYM (Qlss, "<"); DEFSYM (Qlss, "<");
DEFSYM (Qchar, "char");
DEFSYM (Qformat, "format");
DEFVAR_BOOL ("load-prefer-newer", load_prefer_newer, DEFVAR_BOOL ("load-prefer-newer", load_prefer_newer,
doc: /* Non-nil means `load' prefers the newest version of a file. doc: /* Non-nil means `load' prefers the newest version of a file.
......
...@@ -527,7 +527,8 @@ literals (Bug#20852)." ...@@ -527,7 +527,8 @@ literals (Bug#20852)."
(err (should-error (byte-compile-file source)))) (err (should-error (byte-compile-file source))))
(should (equal (cdr err) (should (equal (cdr err)
(list (concat "unescaped character literals " (list (concat "unescaped character literals "
"\", (, ), ;, [, ] detected!")))))))) "`?\"', `?(', `?)', `?;', `?[', `?]' "
"detected!"))))))))
;; Local Variables: ;; Local Variables:
;; no-byte-compile: t ;; no-byte-compile: t
......
...@@ -140,7 +140,7 @@ literals (Bug#20852)." ...@@ -140,7 +140,7 @@ literals (Bug#20852)."
(should (equal (lread-tests--last-message) (should (equal (lread-tests--last-message)
(concat (format-message "Loading `%s': " file-name) (concat (format-message "Loading `%s': " file-name)
"unescaped character literals " "unescaped character literals "
"\", (, ), ;, [, ] detected!"))))) "`?\"', `?(', `?)', `?;', `?[', `?]' detected!")))))
(ert-deftest lread-test-bug26837 () (ert-deftest lread-test-bug26837 ()
"Test for http://debbugs.gnu.org/26837 ." "Test for http://debbugs.gnu.org/26837 ."
......
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