aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Stephani2017-10-03 16:14:54 +0200
committerPhilipp Stephani2017-10-08 18:52:37 +0200
commit9613690f6e51e2f2aa2bcbbede3e209d08cfaaad (patch)
tree27bd9ddc57a7ae5ba7361d246b4bfec8f4aad043
parentf4995e7d36b576d9ed629b45dd3b09ba6d28cce7 (diff)
downloademacs-9613690f6e51e2f2aa2bcbbede3e209d08cfaaad.tar.gz
emacs-9613690f6e51e2f2aa2bcbbede3e209d08cfaaad.zip
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.
-rw-r--r--etc/NEWS3
-rw-r--r--lisp/emacs-lisp/bytecomp.el8
-rw-r--r--src/lread.c32
-rw-r--r--test/lisp/emacs-lisp/bytecomp-tests.el11
-rw-r--r--test/src/lread-tests.el10
5 files changed, 18 insertions, 46 deletions
diff --git a/etc/NEWS b/etc/NEWS
index f961928ffdf..75a98d15003 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -77,6 +77,9 @@ them through 'format' first. Even that is discouraged: for ElDoc
77support, you should set 'eldoc-documentation-function' instead of 77support, you should set 'eldoc-documentation-function' instead of
78calling 'eldoc-message' directly. 78calling 'eldoc-message' directly.
79 79
80** Old-style backquotes now generate an error. They have been
81generating warnings for a decade.
82
80 83
81* Lisp Changes in Emacs 27.1 84* Lisp Changes in Emacs 27.1
82 85
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 590db570c56..45fa188d6c8 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -2048,14 +2048,8 @@ With argument ARG, insert value in current buffer after the form."
2048 (not (eobp))) 2048 (not (eobp)))
2049 (setq byte-compile-read-position (point) 2049 (setq byte-compile-read-position (point)
2050 byte-compile-last-position byte-compile-read-position) 2050 byte-compile-last-position byte-compile-read-position)
2051 (let* ((lread--old-style-backquotes nil) 2051 (let* ((lread--unescaped-character-literals nil)
2052 (lread--unescaped-character-literals nil)
2053 (form (read inbuffer))) 2052 (form (read inbuffer)))
2054 ;; Warn about the use of old-style backquotes.
2055 (when lread--old-style-backquotes
2056 (byte-compile-warn "!! The file uses old-style backquotes !!
2057This functionality has been obsolete for more than 10 years already
2058and will be removed soon. See (elisp)Backquote in the manual."))
2059 (when lread--unescaped-character-literals 2053 (when lread--unescaped-character-literals
2060 (byte-compile-warn 2054 (byte-compile-warn
2061 "unescaped character literals %s detected!" 2055 "unescaped character literals %s detected!"
diff --git a/src/lread.c b/src/lread.c
index 6bc93b14817..c073fc4ce6d 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -1003,14 +1003,11 @@ load_error_handler (Lisp_Object data)
1003 return Qnil; 1003 return Qnil;
1004} 1004}
1005 1005
1006static void 1006static _Noreturn void
1007load_warn_old_style_backquotes (Lisp_Object file) 1007load_error_old_style_backquotes (void)
1008{ 1008{
1009 if (!NILP (Vlread_old_style_backquotes)) 1009 AUTO_STRING (format, "Loading `%s': old-style backquotes detected!");
1010 { 1010 xsignal1 (Qerror, CALLN (Fformat_message, format, Vload_file_name));
1011 AUTO_STRING (format, "Loading `%s': old-style backquotes detected!");
1012 CALLN (Fmessage, format, file);
1013 }
1014} 1011}
1015 1012
1016static void 1013static void
@@ -1282,10 +1279,6 @@ Return t if the file exists and loads successfully. */)
1282 1279
1283 version = -1; 1280 version = -1;
1284 1281
1285 /* Check for the presence of old-style quotes and warn about them. */
1286 specbind (Qlread_old_style_backquotes, Qnil);
1287 record_unwind_protect (load_warn_old_style_backquotes, file);
1288
1289 /* Check for the presence of unescaped character literals and warn 1282 /* Check for the presence of unescaped character literals and warn
1290 about them. */ 1283 about them. */
1291 specbind (Qlread_unescaped_character_literals, Qnil); 1284 specbind (Qlread_unescaped_character_literals, Qnil);
@@ -3178,10 +3171,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
3178 first_in_list exception (old-style can still be obtained via 3171 first_in_list exception (old-style can still be obtained via
3179 "(\`" anyway). */ 3172 "(\`" anyway). */
3180 if (!new_backquote_flag && first_in_list && next_char == ' ') 3173 if (!new_backquote_flag && first_in_list && next_char == ' ')
3181 { 3174 load_error_old_style_backquotes ();
3182 Vlread_old_style_backquotes = Qt;
3183 goto default_label;
3184 }
3185 else 3175 else
3186 { 3176 {
3187 Lisp_Object value; 3177 Lisp_Object value;
@@ -3232,10 +3222,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
3232 return list2 (comma_type, value); 3222 return list2 (comma_type, value);
3233 } 3223 }
3234 else 3224 else
3235 { 3225 load_error_old_style_backquotes ();
3236 Vlread_old_style_backquotes = Qt;
3237 goto default_label;
3238 }
3239 } 3226 }
3240 case '?': 3227 case '?':
3241 { 3228 {
@@ -3423,7 +3410,6 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
3423 row. */ 3410 row. */
3424 FALLTHROUGH; 3411 FALLTHROUGH;
3425 default: 3412 default:
3426 default_label:
3427 if (c <= 040) goto retry; 3413 if (c <= 040) goto retry;
3428 if (c == NO_BREAK_SPACE) 3414 if (c == NO_BREAK_SPACE)
3429 goto retry; 3415 goto retry;
@@ -4996,12 +4982,6 @@ variables, this must be set in the first line of a file. */);
4996 doc: /* List of buffers being read from by calls to `eval-buffer' and `eval-region'. */); 4982 doc: /* List of buffers being read from by calls to `eval-buffer' and `eval-region'. */);
4997 Veval_buffer_list = Qnil; 4983 Veval_buffer_list = Qnil;
4998 4984
4999 DEFVAR_LISP ("lread--old-style-backquotes", Vlread_old_style_backquotes,
5000 doc: /* Set to non-nil when `read' encounters an old-style backquote.
5001For internal use only. */);
5002 Vlread_old_style_backquotes = Qnil;
5003 DEFSYM (Qlread_old_style_backquotes, "lread--old-style-backquotes");
5004
5005 DEFVAR_LISP ("lread--unescaped-character-literals", 4985 DEFVAR_LISP ("lread--unescaped-character-literals",
5006 Vlread_unescaped_character_literals, 4986 Vlread_unescaped_character_literals,
5007 doc: /* List of deprecated unescaped character literals encountered by `read'. 4987 doc: /* List of deprecated unescaped character literals encountered by `read'.
diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el b/test/lisp/emacs-lisp/bytecomp-tests.el
index 30d2a4753cf..1f85c269780 100644
--- a/test/lisp/emacs-lisp/bytecomp-tests.el
+++ b/test/lisp/emacs-lisp/bytecomp-tests.el
@@ -534,23 +534,18 @@ literals (Bug#20852)."
534 534
535(ert-deftest bytecomp-tests--old-style-backquotes () 535(ert-deftest bytecomp-tests--old-style-backquotes ()
536 "Check that byte compiling warns about old-style backquotes." 536 "Check that byte compiling warns about old-style backquotes."
537 (should (boundp 'lread--old-style-backquotes))
538 (bytecomp-tests--with-temp-file source 537 (bytecomp-tests--with-temp-file source
539 (write-region "(` (a b))" nil source) 538 (write-region "(` (a b))" nil source)
540 (bytecomp-tests--with-temp-file destination 539 (bytecomp-tests--with-temp-file destination
541 (let* ((byte-compile-dest-file-function (lambda (_) destination)) 540 (let* ((byte-compile-dest-file-function (lambda (_) destination))
542 (byte-compile-error-on-warn t) 541 (byte-compile-debug t)
543 (byte-compile-debug t) 542 (err (should-error (byte-compile-file source))))
544 (err (should-error (byte-compile-file source))))
545 (should (equal (cdr err) 543 (should (equal (cdr err)
546 (list "!! The file uses old-style backquotes !! 544 '("Loading `nil': old-style backquotes detected!")))))))
547This functionality has been obsolete for more than 10 years already
548and will be removed soon. See (elisp)Backquote in the manual.")))))))
549 545
550 546
551(ert-deftest bytecomp-tests-function-put () 547(ert-deftest bytecomp-tests-function-put ()
552 "Check `function-put' operates during compilation." 548 "Check `function-put' operates during compilation."
553 (should (boundp 'lread--old-style-backquotes))
554 (bytecomp-tests--with-temp-file source 549 (bytecomp-tests--with-temp-file source
555 (dolist (form '((function-put 'bytecomp-tests--foo 'foo 1) 550 (dolist (form '((function-put 'bytecomp-tests--foo 'foo 1)
556 (function-put 'bytecomp-tests--foo 'bar 2) 551 (function-put 'bytecomp-tests--foo 'bar 2)
diff --git a/test/src/lread-tests.el b/test/src/lread-tests.el
index ac730b4f005..3f41982eba1 100644
--- a/test/src/lread-tests.el
+++ b/test/src/lread-tests.el
@@ -173,13 +173,13 @@ literals (Bug#20852)."
173 (should (string-suffix-p "/somelib.el" (caar load-history))))) 173 (should (string-suffix-p "/somelib.el" (caar load-history)))))
174 174
175(ert-deftest lread-tests--old-style-backquotes () 175(ert-deftest lread-tests--old-style-backquotes ()
176 "Check that loading warns about old-style backquotes." 176 "Check that loading doesn't accept old-style backquotes."
177 (lread-tests--with-temp-file file-name 177 (lread-tests--with-temp-file file-name
178 (write-region "(` (a b))" nil file-name) 178 (write-region "(` (a b))" nil file-name)
179 (should (equal (load file-name nil :nomessage :nosuffix) t)) 179 (let ((data (should-error (load file-name nil :nomessage :nosuffix))))
180 (should (equal (lread-tests--last-message) 180 (should (equal (cdr data)
181 (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-lread--substitute-object-in-subtree () 184(ert-deftest lread-lread--substitute-object-in-subtree ()
185 (let ((x (cons 0 1))) 185 (let ((x (cons 0 1)))