diff options
| author | Philipp Stephani | 2017-05-13 12:28:48 +0200 |
|---|---|---|
| committer | Philipp Stephani | 2017-05-13 12:28:48 +0200 |
| commit | 16004397f40d15d9db6b90632c236c804f38fc40 (patch) | |
| tree | 96d42386b6d82f52c71724dd2148adb88eed0c52 | |
| parent | 0e09d00f29e370ecfe2f2b22acff7b98c448bc30 (diff) | |
| download | emacs-16004397f40d15d9db6b90632c236c804f38fc40.tar.gz emacs-16004397f40d15d9db6b90632c236c804f38fc40.zip | |
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.
| -rw-r--r-- | lisp/emacs-lisp/bytecomp.el | 2 | ||||
| -rw-r--r-- | src/lread.c | 6 | ||||
| -rw-r--r-- | test/lisp/emacs-lisp/bytecomp-tests.el | 3 | ||||
| -rw-r--r-- | test/src/lread-tests.el | 2 |
4 files changed, 9 insertions, 4 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 201733ff033..daad93de182 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el | |||
| @@ -2032,7 +2032,7 @@ and will be removed soon. See (elisp)Backquote in the manual.")) | |||
| 2032 | (when lread--unescaped-character-literals | 2032 | (when lread--unescaped-character-literals |
| 2033 | (byte-compile-warn | 2033 | (byte-compile-warn |
| 2034 | "unescaped character literals %s detected!" | 2034 | "unescaped character literals %s detected!" |
| 2035 | (mapconcat #'string | 2035 | (mapconcat (lambda (char) (format "`?%c'" char)) |
| 2036 | (sort lread--unescaped-character-literals #'<) | 2036 | (sort lread--unescaped-character-literals #'<) |
| 2037 | ", "))) | 2037 | ", "))) |
| 2038 | (byte-compile-toplevel-file-form form))) | 2038 | (byte-compile-toplevel-file-form form))) |
diff --git a/src/lread.c b/src/lread.c index f0ad0c28e56..0e5b476a9a2 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -963,9 +963,11 @@ load_warn_unescaped_character_literals (Lisp_Object file) | |||
| 963 | AUTO_STRING (format, | 963 | AUTO_STRING (format, |
| 964 | "Loading `%s': unescaped character literals %s detected!"); | 964 | "Loading `%s': unescaped character literals %s detected!"); |
| 965 | AUTO_STRING (separator, ", "); | 965 | AUTO_STRING (separator, ", "); |
| 966 | AUTO_STRING (inner_format, "`?%c'"); | ||
| 966 | CALLN (Fmessage, | 967 | CALLN (Fmessage, |
| 967 | format, file, | 968 | format, file, |
| 968 | Fmapconcat (Qstring, | 969 | Fmapconcat (list3 (Qlambda, list1 (Qchar), |
| 970 | list3 (Qformat, inner_format, Qchar)), | ||
| 969 | Fsort (Vlread_unescaped_character_literals, Qlss), | 971 | Fsort (Vlread_unescaped_character_literals, Qlss), |
| 970 | separator)); | 972 | separator)); |
| 971 | } | 973 | } |
| @@ -4855,6 +4857,8 @@ For internal use only. */); | |||
| 4855 | "lread--unescaped-character-literals"); | 4857 | "lread--unescaped-character-literals"); |
| 4856 | 4858 | ||
| 4857 | DEFSYM (Qlss, "<"); | 4859 | DEFSYM (Qlss, "<"); |
| 4860 | DEFSYM (Qchar, "char"); | ||
| 4861 | DEFSYM (Qformat, "format"); | ||
| 4858 | 4862 | ||
| 4859 | DEFVAR_BOOL ("load-prefer-newer", load_prefer_newer, | 4863 | DEFVAR_BOOL ("load-prefer-newer", load_prefer_newer, |
| 4860 | doc: /* Non-nil means `load' prefers the newest version of a file. | 4864 | doc: /* Non-nil means `load' prefers the newest version of a file. |
diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el b/test/lisp/emacs-lisp/bytecomp-tests.el index 3624904753c..84004a9264a 100644 --- a/test/lisp/emacs-lisp/bytecomp-tests.el +++ b/test/lisp/emacs-lisp/bytecomp-tests.el | |||
| @@ -527,7 +527,8 @@ literals (Bug#20852)." | |||
| 527 | (err (should-error (byte-compile-file source)))) | 527 | (err (should-error (byte-compile-file source)))) |
| 528 | (should (equal (cdr err) | 528 | (should (equal (cdr err) |
| 529 | (list (concat "unescaped character literals " | 529 | (list (concat "unescaped character literals " |
| 530 | "\", (, ), ;, [, ] detected!")))))))) | 530 | "`?\"', `?(', `?)', `?;', `?[', `?]' " |
| 531 | "detected!")))))))) | ||
| 531 | 532 | ||
| 532 | ;; Local Variables: | 533 | ;; Local Variables: |
| 533 | ;; no-byte-compile: t | 534 | ;; no-byte-compile: t |
diff --git a/test/src/lread-tests.el b/test/src/lread-tests.el index 0427fe64e4a..685ea682e29 100644 --- a/test/src/lread-tests.el +++ b/test/src/lread-tests.el | |||
| @@ -140,7 +140,7 @@ literals (Bug#20852)." | |||
| 140 | (should (equal (lread-tests--last-message) | 140 | (should (equal (lread-tests--last-message) |
| 141 | (concat (format-message "Loading `%s': " file-name) | 141 | (concat (format-message "Loading `%s': " file-name) |
| 142 | "unescaped character literals " | 142 | "unescaped character literals " |
| 143 | "\", (, ), ;, [, ] detected!"))))) | 143 | "`?\"', `?(', `?)', `?;', `?[', `?]' detected!"))))) |
| 144 | 144 | ||
| 145 | (ert-deftest lread-test-bug26837 () | 145 | (ert-deftest lread-test-bug26837 () |
| 146 | "Test for http://debbugs.gnu.org/26837 ." | 146 | "Test for http://debbugs.gnu.org/26837 ." |