Raise an error when detecting old-style backquotes.
They have been deprecated for a decade now. * src/lread.c (Fload): Don't use record_unwind_protect to warn about old-style backquotes any more. They now generate a hard error. (read1): Signal an error when detecting old-style backquotes. Remove unused label. (syms_of_lread): Remove unused internal variable 'lread--old-style-backquotes'. (load_error_old_style_backquotes): Rename from 'load_warn_oldstyle_backquotes'. Signal an error. * lisp/emacs-lisp/bytecomp.el (byte-compile-from-buffer): Remove check from byte compiler. It isn't triggered any more. * test/src/lread-tests.el (lread-tests--old-style-backquotes): Adapt unit test. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--old-style-backquotes) (bytecomp-tests-function-put): Adapt unit tests. * etc/NEWS: Document change.
This commit is contained in:
parent
f4995e7d36
commit
9613690f6e
5 changed files with 18 additions and 46 deletions
3
etc/NEWS
3
etc/NEWS
|
@ -77,6 +77,9 @@ them through 'format' first. Even that is discouraged: for ElDoc
|
||||||
support, you should set 'eldoc-documentation-function' instead of
|
support, you should set 'eldoc-documentation-function' instead of
|
||||||
calling 'eldoc-message' directly.
|
calling 'eldoc-message' directly.
|
||||||
|
|
||||||
|
** Old-style backquotes now generate an error. They have been
|
||||||
|
generating warnings for a decade.
|
||||||
|
|
||||||
|
|
||||||
* Lisp Changes in Emacs 27.1
|
* Lisp Changes in Emacs 27.1
|
||||||
|
|
||||||
|
|
|
@ -2048,14 +2048,8 @@ With argument ARG, insert value in current buffer after the form."
|
||||||
(not (eobp)))
|
(not (eobp)))
|
||||||
(setq byte-compile-read-position (point)
|
(setq byte-compile-read-position (point)
|
||||||
byte-compile-last-position byte-compile-read-position)
|
byte-compile-last-position byte-compile-read-position)
|
||||||
(let* ((lread--old-style-backquotes nil)
|
(let* ((lread--unescaped-character-literals nil)
|
||||||
(lread--unescaped-character-literals nil)
|
|
||||||
(form (read inbuffer)))
|
(form (read inbuffer)))
|
||||||
;; Warn about the use of old-style backquotes.
|
|
||||||
(when lread--old-style-backquotes
|
|
||||||
(byte-compile-warn "!! The file uses old-style backquotes !!
|
|
||||||
This functionality has been obsolete for more than 10 years already
|
|
||||||
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!"
|
||||||
|
|
32
src/lread.c
32
src/lread.c
|
@ -1003,14 +1003,11 @@ load_error_handler (Lisp_Object data)
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static _Noreturn void
|
||||||
load_warn_old_style_backquotes (Lisp_Object file)
|
load_error_old_style_backquotes (void)
|
||||||
{
|
{
|
||||||
if (!NILP (Vlread_old_style_backquotes))
|
AUTO_STRING (format, "Loading `%s': old-style backquotes detected!");
|
||||||
{
|
xsignal1 (Qerror, CALLN (Fformat_message, format, Vload_file_name));
|
||||||
AUTO_STRING (format, "Loading `%s': old-style backquotes detected!");
|
|
||||||
CALLN (Fmessage, format, file);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1282,10 +1279,6 @@ Return t if the file exists and loads successfully. */)
|
||||||
|
|
||||||
version = -1;
|
version = -1;
|
||||||
|
|
||||||
/* Check for the presence of old-style quotes and warn about them. */
|
|
||||||
specbind (Qlread_old_style_backquotes, Qnil);
|
|
||||||
record_unwind_protect (load_warn_old_style_backquotes, file);
|
|
||||||
|
|
||||||
/* Check for the presence of unescaped character literals and warn
|
/* Check for the presence of unescaped character literals and warn
|
||||||
about them. */
|
about them. */
|
||||||
specbind (Qlread_unescaped_character_literals, Qnil);
|
specbind (Qlread_unescaped_character_literals, Qnil);
|
||||||
|
@ -3178,10 +3171,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
|
||||||
first_in_list exception (old-style can still be obtained via
|
first_in_list exception (old-style can still be obtained via
|
||||||
"(\`" anyway). */
|
"(\`" anyway). */
|
||||||
if (!new_backquote_flag && first_in_list && next_char == ' ')
|
if (!new_backquote_flag && first_in_list && next_char == ' ')
|
||||||
{
|
load_error_old_style_backquotes ();
|
||||||
Vlread_old_style_backquotes = Qt;
|
|
||||||
goto default_label;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Lisp_Object value;
|
Lisp_Object value;
|
||||||
|
@ -3232,10 +3222,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
|
||||||
return list2 (comma_type, value);
|
return list2 (comma_type, value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
load_error_old_style_backquotes ();
|
||||||
Vlread_old_style_backquotes = Qt;
|
|
||||||
goto default_label;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
case '?':
|
case '?':
|
||||||
{
|
{
|
||||||
|
@ -3423,7 +3410,6 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
|
||||||
row. */
|
row. */
|
||||||
FALLTHROUGH;
|
FALLTHROUGH;
|
||||||
default:
|
default:
|
||||||
default_label:
|
|
||||||
if (c <= 040) goto retry;
|
if (c <= 040) goto retry;
|
||||||
if (c == NO_BREAK_SPACE)
|
if (c == NO_BREAK_SPACE)
|
||||||
goto retry;
|
goto retry;
|
||||||
|
@ -4996,12 +4982,6 @@ variables, this must be set in the first line of a file. */);
|
||||||
doc: /* List of buffers being read from by calls to `eval-buffer' and `eval-region'. */);
|
doc: /* List of buffers being read from by calls to `eval-buffer' and `eval-region'. */);
|
||||||
Veval_buffer_list = Qnil;
|
Veval_buffer_list = Qnil;
|
||||||
|
|
||||||
DEFVAR_LISP ("lread--old-style-backquotes", Vlread_old_style_backquotes,
|
|
||||||
doc: /* Set to non-nil when `read' encounters an old-style backquote.
|
|
||||||
For internal use only. */);
|
|
||||||
Vlread_old_style_backquotes = Qnil;
|
|
||||||
DEFSYM (Qlread_old_style_backquotes, "lread--old-style-backquotes");
|
|
||||||
|
|
||||||
DEFVAR_LISP ("lread--unescaped-character-literals",
|
DEFVAR_LISP ("lread--unescaped-character-literals",
|
||||||
Vlread_unescaped_character_literals,
|
Vlread_unescaped_character_literals,
|
||||||
doc: /* List of deprecated unescaped character literals encountered by `read'.
|
doc: /* List of deprecated unescaped character literals encountered by `read'.
|
||||||
|
|
|
@ -534,23 +534,18 @@ literals (Bug#20852)."
|
||||||
|
|
||||||
(ert-deftest bytecomp-tests--old-style-backquotes ()
|
(ert-deftest bytecomp-tests--old-style-backquotes ()
|
||||||
"Check that byte compiling warns about old-style backquotes."
|
"Check that byte compiling warns about old-style backquotes."
|
||||||
(should (boundp 'lread--old-style-backquotes))
|
|
||||||
(bytecomp-tests--with-temp-file source
|
(bytecomp-tests--with-temp-file source
|
||||||
(write-region "(` (a b))" nil source)
|
(write-region "(` (a b))" nil source)
|
||||||
(bytecomp-tests--with-temp-file destination
|
(bytecomp-tests--with-temp-file destination
|
||||||
(let* ((byte-compile-dest-file-function (lambda (_) destination))
|
(let* ((byte-compile-dest-file-function (lambda (_) destination))
|
||||||
(byte-compile-error-on-warn t)
|
(byte-compile-debug t)
|
||||||
(byte-compile-debug t)
|
(err (should-error (byte-compile-file source))))
|
||||||
(err (should-error (byte-compile-file source))))
|
|
||||||
(should (equal (cdr err)
|
(should (equal (cdr err)
|
||||||
(list "!! The file uses old-style backquotes !!
|
'("Loading `nil': old-style backquotes detected!")))))))
|
||||||
This functionality has been obsolete for more than 10 years already
|
|
||||||
and will be removed soon. See (elisp)Backquote in the manual.")))))))
|
|
||||||
|
|
||||||
|
|
||||||
(ert-deftest bytecomp-tests-function-put ()
|
(ert-deftest bytecomp-tests-function-put ()
|
||||||
"Check `function-put' operates during compilation."
|
"Check `function-put' operates during compilation."
|
||||||
(should (boundp 'lread--old-style-backquotes))
|
|
||||||
(bytecomp-tests--with-temp-file source
|
(bytecomp-tests--with-temp-file source
|
||||||
(dolist (form '((function-put 'bytecomp-tests--foo 'foo 1)
|
(dolist (form '((function-put 'bytecomp-tests--foo 'foo 1)
|
||||||
(function-put 'bytecomp-tests--foo 'bar 2)
|
(function-put 'bytecomp-tests--foo 'bar 2)
|
||||||
|
|
|
@ -173,13 +173,13 @@ literals (Bug#20852)."
|
||||||
(should (string-suffix-p "/somelib.el" (caar load-history)))))
|
(should (string-suffix-p "/somelib.el" (caar load-history)))))
|
||||||
|
|
||||||
(ert-deftest lread-tests--old-style-backquotes ()
|
(ert-deftest lread-tests--old-style-backquotes ()
|
||||||
"Check that loading warns about old-style backquotes."
|
"Check that loading doesn't accept old-style backquotes."
|
||||||
(lread-tests--with-temp-file file-name
|
(lread-tests--with-temp-file file-name
|
||||||
(write-region "(` (a b))" nil file-name)
|
(write-region "(` (a b))" nil file-name)
|
||||||
(should (equal (load file-name nil :nomessage :nosuffix) t))
|
(let ((data (should-error (load file-name nil :nomessage :nosuffix))))
|
||||||
(should (equal (lread-tests--last-message)
|
(should (equal (cdr data)
|
||||||
(concat (format-message "Loading `%s': " file-name)
|
(list (concat (format-message "Loading `%s': " file-name)
|
||||||
"old-style backquotes detected!")))))
|
"old-style backquotes detected!")))))))
|
||||||
|
|
||||||
(ert-deftest lread-lread--substitute-object-in-subtree ()
|
(ert-deftest lread-lread--substitute-object-in-subtree ()
|
||||||
(let ((x (cons 0 1)))
|
(let ((x (cons 0 1)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue