Commit ddb74b20 authored by Philipp Stephani's avatar Philipp Stephani

Add new variable to force new-style backquote interpretation.

* src/lread.c (syms_of_lread): Add new variable
'force-new-style-backquotes'.
(read_internal_start): Use it.

* test/src/lread-tests.el (lread-tests--force-new-style-backquotes):
New test.

* etc/NEWS: Document new variable.
parent 610dad11
......@@ -188,7 +188,8 @@ support, you should set 'eldoc-documentation-function' instead of
calling 'eldoc-message' directly.
** Old-style backquotes now generate an error. They have been
generating warnings for a decade.
generating warnings for a decade. To interpret old-style backquotes
as new-style, bind the new variable 'force-new-style-backquotes' to t.
* Lisp Changes in Emacs 27.1
......
......@@ -147,10 +147,10 @@ static ptrdiff_t prev_saved_doc_string_length;
/* This is the file position that string came from. */
static file_offset prev_saved_doc_string_position;
/* True means inside a new-style backquote
with no surrounding parentheses.
Fread initializes this to false, so we need not specbind it
or worry about what happens to it when there is an error. */
/* True means inside a new-style backquote with no surrounding
parentheses. Fread initializes this to the value of
`force_new_style_backquotes', so we need not specbind it or worry
about what happens to it when there is an error. */
static bool new_backquote_flag;
/* A list of file names for files being loaded in Fload. Used to
......@@ -2187,7 +2187,7 @@ read_internal_start (Lisp_Object stream, Lisp_Object start, Lisp_Object end)
Lisp_Object retval;
readchar_count = 0;
new_backquote_flag = 0;
new_backquote_flag = force_new_style_backquotes;
/* We can get called from readevalloop which may have set these
already. */
if (! HASH_TABLE_P (read_objects_map)
......@@ -5006,6 +5006,17 @@ Note that if you customize this, obviously it will not affect files
that are loaded before your customizations are read! */);
load_prefer_newer = 0;
DEFVAR_BOOL ("force-new-style-backquotes", force_new_style_backquotes,
doc: /* Non-nil means to always use the current syntax for backquotes.
If nil, `load' and `read' raise errors when encountering some
old-style variants of backquote and comma. If non-nil, these
constructs are always interpreted as described in the Info node
`(elisp)Backquotes', even if that interpretation is incompatible with
previous versions of Emacs. Setting this variable to non-nil makes
Emacs compatible with the behavior planned for Emacs 28. In Emacs 28,
this variable will become obsolete. */);
force_new_style_backquotes = false;
/* Vsource_directory was initialized in init_lread. */
DEFSYM (Qcurrent_load_list, "current-load-list");
......
......@@ -181,6 +181,14 @@ literals (Bug#20852)."
(list (concat (format-message "Loading `%s': " file-name)
"old-style backquotes detected!")))))))
(ert-deftest lread-tests--force-new-style-backquotes ()
(let ((data (should-error (read "(` (a b))"))))
(should (equal (cdr data)
'("Loading `nil': old-style backquotes detected!"))))
(should (equal (let ((force-new-style-backquotes t))
(read "(` (a b))"))
'(`(a b)))))
(ert-deftest lread-lread--substitute-object-in-subtree ()
(let ((x (cons 0 1)))
(setcar x x)
......
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