]> git.eshelyaron.com Git - emacs.git/commitdiff
Improve unescaped character literal warnings
authorPhilipp Stephani <phst@google.com>
Sat, 13 May 2017 10:28:48 +0000 (12:28 +0200)
committerPhilipp Stephani <phst@google.com>
Sat, 13 May 2017 10:28:48 +0000 (12:28 +0200)
* 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.

lisp/emacs-lisp/bytecomp.el
src/lread.c
test/lisp/emacs-lisp/bytecomp-tests.el
test/src/lread-tests.el

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