diff options
| author | Philipp Stephani | 2017-12-29 21:50:55 +0100 |
|---|---|---|
| committer | Philipp Stephani | 2018-01-07 14:16:02 +0100 |
| commit | ddb74b2027802ab4416bd8cdb1757a209dd7a63b (patch) | |
| tree | 938556910293db86bd2b074bba9a292339f6ce70 | |
| parent | 610dad1102cba5fa6111050d30c734b51bcdb77d (diff) | |
| download | emacs-ddb74b2027802ab4416bd8cdb1757a209dd7a63b.tar.gz emacs-ddb74b2027802ab4416bd8cdb1757a209dd7a63b.zip | |
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.
| -rw-r--r-- | etc/NEWS | 3 | ||||
| -rw-r--r-- | src/lread.c | 21 | ||||
| -rw-r--r-- | test/src/lread-tests.el | 8 |
3 files changed, 26 insertions, 6 deletions
| @@ -188,7 +188,8 @@ support, you should set 'eldoc-documentation-function' instead of | |||
| 188 | calling 'eldoc-message' directly. | 188 | calling 'eldoc-message' directly. |
| 189 | 189 | ||
| 190 | ** Old-style backquotes now generate an error. They have been | 190 | ** Old-style backquotes now generate an error. They have been |
| 191 | generating warnings for a decade. | 191 | generating warnings for a decade. To interpret old-style backquotes |
| 192 | as new-style, bind the new variable 'force-new-style-backquotes' to t. | ||
| 192 | 193 | ||
| 193 | 194 | ||
| 194 | * Lisp Changes in Emacs 27.1 | 195 | * Lisp Changes in Emacs 27.1 |
diff --git a/src/lread.c b/src/lread.c index da40e99a5e6..d675b563916 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -147,10 +147,10 @@ static ptrdiff_t prev_saved_doc_string_length; | |||
| 147 | /* This is the file position that string came from. */ | 147 | /* This is the file position that string came from. */ |
| 148 | static file_offset prev_saved_doc_string_position; | 148 | static file_offset prev_saved_doc_string_position; |
| 149 | 149 | ||
| 150 | /* True means inside a new-style backquote | 150 | /* True means inside a new-style backquote with no surrounding |
| 151 | with no surrounding parentheses. | 151 | parentheses. Fread initializes this to the value of |
| 152 | Fread initializes this to false, so we need not specbind it | 152 | `force_new_style_backquotes', so we need not specbind it or worry |
| 153 | or worry about what happens to it when there is an error. */ | 153 | about what happens to it when there is an error. */ |
| 154 | static bool new_backquote_flag; | 154 | static bool new_backquote_flag; |
| 155 | 155 | ||
| 156 | /* A list of file names for files being loaded in Fload. Used to | 156 | /* 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) | |||
| 2187 | Lisp_Object retval; | 2187 | Lisp_Object retval; |
| 2188 | 2188 | ||
| 2189 | readchar_count = 0; | 2189 | readchar_count = 0; |
| 2190 | new_backquote_flag = 0; | 2190 | new_backquote_flag = force_new_style_backquotes; |
| 2191 | /* We can get called from readevalloop which may have set these | 2191 | /* We can get called from readevalloop which may have set these |
| 2192 | already. */ | 2192 | already. */ |
| 2193 | if (! HASH_TABLE_P (read_objects_map) | 2193 | if (! HASH_TABLE_P (read_objects_map) |
| @@ -5006,6 +5006,17 @@ Note that if you customize this, obviously it will not affect files | |||
| 5006 | that are loaded before your customizations are read! */); | 5006 | that are loaded before your customizations are read! */); |
| 5007 | load_prefer_newer = 0; | 5007 | load_prefer_newer = 0; |
| 5008 | 5008 | ||
| 5009 | DEFVAR_BOOL ("force-new-style-backquotes", force_new_style_backquotes, | ||
| 5010 | doc: /* Non-nil means to always use the current syntax for backquotes. | ||
| 5011 | If nil, `load' and `read' raise errors when encountering some | ||
| 5012 | old-style variants of backquote and comma. If non-nil, these | ||
| 5013 | constructs are always interpreted as described in the Info node | ||
| 5014 | `(elisp)Backquotes', even if that interpretation is incompatible with | ||
| 5015 | previous versions of Emacs. Setting this variable to non-nil makes | ||
| 5016 | Emacs compatible with the behavior planned for Emacs 28. In Emacs 28, | ||
| 5017 | this variable will become obsolete. */); | ||
| 5018 | force_new_style_backquotes = false; | ||
| 5019 | |||
| 5009 | /* Vsource_directory was initialized in init_lread. */ | 5020 | /* Vsource_directory was initialized in init_lread. */ |
| 5010 | 5021 | ||
| 5011 | DEFSYM (Qcurrent_load_list, "current-load-list"); | 5022 | DEFSYM (Qcurrent_load_list, "current-load-list"); |
diff --git a/test/src/lread-tests.el b/test/src/lread-tests.el index e2d4eaa63c7..693c6c09bf3 100644 --- a/test/src/lread-tests.el +++ b/test/src/lread-tests.el | |||
| @@ -181,6 +181,14 @@ literals (Bug#20852)." | |||
| 181 | (list (concat (format-message "Loading `%s': " file-name) | 181 | (list (concat (format-message "Loading `%s': " file-name) |
| 182 | "old-style backquotes detected!"))))))) | 182 | "old-style backquotes detected!"))))))) |
| 183 | 183 | ||
| 184 | (ert-deftest lread-tests--force-new-style-backquotes () | ||
| 185 | (let ((data (should-error (read "(` (a b))")))) | ||
| 186 | (should (equal (cdr data) | ||
| 187 | '("Loading `nil': old-style backquotes detected!")))) | ||
| 188 | (should (equal (let ((force-new-style-backquotes t)) | ||
| 189 | (read "(` (a b))")) | ||
| 190 | '(`(a b))))) | ||
| 191 | |||
| 184 | (ert-deftest lread-lread--substitute-object-in-subtree () | 192 | (ert-deftest lread-lread--substitute-object-in-subtree () |
| 185 | (let ((x (cons 0 1))) | 193 | (let ((x (cons 0 1))) |
| 186 | (setcar x x) | 194 | (setcar x x) |