diff options
| author | Stefan Monnier | 2020-02-14 11:18:00 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2020-02-14 11:18:00 -0500 |
| commit | 2e81e5733db3b8b88a246d08671b828654cd6950 (patch) | |
| tree | 551cb441c6fb6fa9e473f29c571b7fa9c0d62209 | |
| parent | d737e497a82431b2ca4debb7a68c5422cb5a7929 (diff) | |
| download | emacs-2e81e5733db3b8b88a246d08671b828654cd6950.tar.gz emacs-2e81e5733db3b8b88a246d08671b828654cd6950.zip | |
* src/lread.c: Remove old-style backquotes support
(new_backquote_flag): Delete variable.
(load_error_old_style_backquotes): Delete function.
(force_new_style_backquotes): Delete variable.
(read_internal_start): Don't obey it any more.
| -rw-r--r-- | etc/NEWS | 2 | ||||
| -rw-r--r-- | src/lread.c | 102 |
2 files changed, 15 insertions, 89 deletions
| @@ -173,6 +173,8 @@ by mistake and were not useful to Lisp code. | |||
| 173 | 173 | ||
| 174 | * Lisp Changes in Emacs 28.1 | 174 | * Lisp Changes in Emacs 28.1 |
| 175 | 175 | ||
| 176 | ** Remove final remaining traces of old-style backquotes | ||
| 177 | |||
| 176 | ** The module header 'emacs-module.h' now contains type aliases | 178 | ** The module header 'emacs-module.h' now contains type aliases |
| 177 | 'emacs_function' and 'emacs_finalizer' for module functions and | 179 | 'emacs_function' and 'emacs_finalizer' for module functions and |
| 178 | finalizers, respectively. | 180 | finalizers, respectively. |
diff --git a/src/lread.c b/src/lread.c index 69dd73912bc..c124d5a1d8f 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -152,12 +152,6 @@ static ptrdiff_t prev_saved_doc_string_length; | |||
| 152 | /* This is the file position that string came from. */ | 152 | /* This is the file position that string came from. */ |
| 153 | static file_offset prev_saved_doc_string_position; | 153 | static file_offset prev_saved_doc_string_position; |
| 154 | 154 | ||
| 155 | /* True means inside a new-style backquote with no surrounding | ||
| 156 | parentheses. Fread initializes this to the value of | ||
| 157 | `force_new_style_backquotes', so we need not specbind it or worry | ||
| 158 | about what happens to it when there is an error. */ | ||
| 159 | static bool new_backquote_flag; | ||
| 160 | |||
| 161 | /* A list of file names for files being loaded in Fload. Used to | 155 | /* A list of file names for files being loaded in Fload. Used to |
| 162 | check for recursive loads. */ | 156 | check for recursive loads. */ |
| 163 | 157 | ||
| @@ -1035,18 +1029,6 @@ load_error_handler (Lisp_Object data) | |||
| 1035 | return Qnil; | 1029 | return Qnil; |
| 1036 | } | 1030 | } |
| 1037 | 1031 | ||
| 1038 | static AVOID | ||
| 1039 | load_error_old_style_backquotes (void) | ||
| 1040 | { | ||
| 1041 | if (NILP (Vload_file_name)) | ||
| 1042 | xsignal1 (Qerror, build_string ("Old-style backquotes detected!")); | ||
| 1043 | else | ||
| 1044 | { | ||
| 1045 | AUTO_STRING (format, "Loading `%s': old-style backquotes detected!"); | ||
| 1046 | xsignal1 (Qerror, CALLN (Fformat_message, format, Vload_file_name)); | ||
| 1047 | } | ||
| 1048 | } | ||
| 1049 | |||
| 1050 | static void | 1032 | static void |
| 1051 | load_warn_unescaped_character_literals (Lisp_Object file) | 1033 | load_warn_unescaped_character_literals (Lisp_Object file) |
| 1052 | { | 1034 | { |
| @@ -2283,7 +2265,6 @@ read_internal_start (Lisp_Object stream, Lisp_Object start, Lisp_Object end) | |||
| 2283 | Lisp_Object retval; | 2265 | Lisp_Object retval; |
| 2284 | 2266 | ||
| 2285 | readchar_count = 0; | 2267 | readchar_count = 0; |
| 2286 | new_backquote_flag = force_new_style_backquotes; | ||
| 2287 | /* We can get called from readevalloop which may have set these | 2268 | /* We can get called from readevalloop which may have set these |
| 2288 | already. */ | 2269 | already. */ |
| 2289 | if (! HASH_TABLE_P (read_objects_map) | 2270 | if (! HASH_TABLE_P (read_objects_map) |
| @@ -3271,70 +3252,24 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list) | |||
| 3271 | return list2 (Qquote, read0 (readcharfun)); | 3252 | return list2 (Qquote, read0 (readcharfun)); |
| 3272 | 3253 | ||
| 3273 | case '`': | 3254 | case '`': |
| 3274 | { | 3255 | return list2 (Qbackquote, read0 (readcharfun)); |
| 3275 | int next_char = READCHAR; | ||
| 3276 | UNREAD (next_char); | ||
| 3277 | /* Transition from old-style to new-style: | ||
| 3278 | If we see "(`" it used to mean old-style, which usually works | ||
| 3279 | fine because ` should almost never appear in such a position | ||
| 3280 | for new-style. But occasionally we need "(`" to mean new | ||
| 3281 | style, so we try to distinguish the two by the fact that we | ||
| 3282 | can either write "( `foo" or "(` foo", where the first | ||
| 3283 | intends to use new-style whereas the second intends to use | ||
| 3284 | old-style. For Emacs-25, we should completely remove this | ||
| 3285 | first_in_list exception (old-style can still be obtained via | ||
| 3286 | "(\`" anyway). */ | ||
| 3287 | if (!new_backquote_flag && first_in_list && next_char == ' ') | ||
| 3288 | load_error_old_style_backquotes (); | ||
| 3289 | else | ||
| 3290 | { | ||
| 3291 | Lisp_Object value; | ||
| 3292 | bool saved_new_backquote_flag = new_backquote_flag; | ||
| 3293 | |||
| 3294 | new_backquote_flag = 1; | ||
| 3295 | value = read0 (readcharfun); | ||
| 3296 | new_backquote_flag = saved_new_backquote_flag; | ||
| 3297 | 3256 | ||
| 3298 | return list2 (Qbackquote, value); | ||
| 3299 | } | ||
| 3300 | } | ||
| 3301 | case ',': | 3257 | case ',': |
| 3302 | { | 3258 | { |
| 3303 | int next_char = READCHAR; | 3259 | Lisp_Object comma_type = Qnil; |
| 3304 | UNREAD (next_char); | 3260 | Lisp_Object value; |
| 3305 | /* Transition from old-style to new-style: | 3261 | int ch = READCHAR; |
| 3306 | It used to be impossible to have a new-style , other than within | ||
| 3307 | a new-style `. This is sufficient when ` and , are used in the | ||
| 3308 | normal way, but ` and , can also appear in args to macros that | ||
| 3309 | will not interpret them in the usual way, in which case , may be | ||
| 3310 | used without any ` anywhere near. | ||
| 3311 | So we now use the same heuristic as for backquote: old-style | ||
| 3312 | unquotes are only recognized when first on a list, and when | ||
| 3313 | followed by a space. | ||
| 3314 | Because it's more difficult to peek 2 chars ahead, a new-style | ||
| 3315 | ,@ can still not be used outside of a `, unless it's in the middle | ||
| 3316 | of a list. */ | ||
| 3317 | if (new_backquote_flag | ||
| 3318 | || !first_in_list | ||
| 3319 | || (next_char != ' ' && next_char != '@')) | ||
| 3320 | { | ||
| 3321 | Lisp_Object comma_type = Qnil; | ||
| 3322 | Lisp_Object value; | ||
| 3323 | int ch = READCHAR; | ||
| 3324 | |||
| 3325 | if (ch == '@') | ||
| 3326 | comma_type = Qcomma_at; | ||
| 3327 | else | ||
| 3328 | { | ||
| 3329 | if (ch >= 0) UNREAD (ch); | ||
| 3330 | comma_type = Qcomma; | ||
| 3331 | } | ||
| 3332 | 3262 | ||
| 3333 | value = read0 (readcharfun); | 3263 | if (ch == '@') |
| 3334 | return list2 (comma_type, value); | 3264 | comma_type = Qcomma_at; |
| 3335 | } | ||
| 3336 | else | 3265 | else |
| 3337 | load_error_old_style_backquotes (); | 3266 | { |
| 3267 | if (ch >= 0) UNREAD (ch); | ||
| 3268 | comma_type = Qcomma; | ||
| 3269 | } | ||
| 3270 | |||
| 3271 | value = read0 (readcharfun); | ||
| 3272 | return list2 (comma_type, value); | ||
| 3338 | } | 3273 | } |
| 3339 | case '?': | 3274 | case '?': |
| 3340 | { | 3275 | { |
| @@ -5065,17 +5000,6 @@ Note that if you customize this, obviously it will not affect files | |||
| 5065 | that are loaded before your customizations are read! */); | 5000 | that are loaded before your customizations are read! */); |
| 5066 | load_prefer_newer = 0; | 5001 | load_prefer_newer = 0; |
| 5067 | 5002 | ||
| 5068 | DEFVAR_BOOL ("force-new-style-backquotes", force_new_style_backquotes, | ||
| 5069 | doc: /* Non-nil means to always use the current syntax for backquotes. | ||
| 5070 | If nil, `load' and `read' raise errors when encountering some | ||
| 5071 | old-style variants of backquote and comma. If non-nil, these | ||
| 5072 | constructs are always interpreted as described in the Info node | ||
| 5073 | `(elisp)Backquote', even if that interpretation is incompatible with | ||
| 5074 | previous versions of Emacs. Setting this variable to non-nil makes | ||
| 5075 | Emacs compatible with the behavior planned for Emacs 28. In Emacs 28, | ||
| 5076 | this variable will become obsolete. */); | ||
| 5077 | force_new_style_backquotes = false; | ||
| 5078 | |||
| 5079 | /* Vsource_directory was initialized in init_lread. */ | 5003 | /* Vsource_directory was initialized in init_lread. */ |
| 5080 | 5004 | ||
| 5081 | DEFSYM (Qcurrent_load_list, "current-load-list"); | 5005 | DEFSYM (Qcurrent_load_list, "current-load-list"); |