[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 6abff55: Revert "Raise an error when detecting old-
From: |
Philipp Stephani |
Subject: |
[Emacs-diffs] master 6abff55: Revert "Raise an error when detecting old-style backquotes." |
Date: |
Mon, 9 Oct 2017 10:08:39 -0400 (EDT) |
branch: master
commit 6abff55b5514515c5a28397b34aee478926af232
Author: Philipp Stephani <address@hidden>
Commit: Philipp Stephani <address@hidden>
Revert "Raise an error when detecting old-style backquotes."
This reverts commit 9613690f6e51e2f2aa2bcbbede3e209d08cfaaad.
---
etc/NEWS | 3 ---
lisp/emacs-lisp/bytecomp.el | 8 +++++++-
src/lread.c | 32 ++++++++++++++++++++++++++------
test/lisp/emacs-lisp/bytecomp-tests.el | 11 ++++++++---
test/src/lread-tests.el | 10 +++++-----
5 files changed, 46 insertions(+), 18 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 0f4c6ae..2332ba4 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -87,9 +87,6 @@ them through 'format' first. Even that is discouraged: for
ElDoc
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.
-
* Lisp Changes in Emacs 27.1
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 45fa188..590db57 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -2048,8 +2048,14 @@ With argument ARG, insert value in current buffer after
the form."
(not (eobp)))
(setq byte-compile-read-position (point)
byte-compile-last-position byte-compile-read-position)
- (let* ((lread--unescaped-character-literals nil)
+ (let* ((lread--old-style-backquotes nil)
+ (lread--unescaped-character-literals nil)
(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
(byte-compile-warn
"unescaped character literals %s detected!"
diff --git a/src/lread.c b/src/lread.c
index c073fc4..6bc93b1 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -1003,11 +1003,14 @@ load_error_handler (Lisp_Object data)
return Qnil;
}
-static _Noreturn void
-load_error_old_style_backquotes (void)
+static void
+load_warn_old_style_backquotes (Lisp_Object file)
{
- AUTO_STRING (format, "Loading `%s': old-style backquotes detected!");
- xsignal1 (Qerror, CALLN (Fformat_message, format, Vload_file_name));
+ if (!NILP (Vlread_old_style_backquotes))
+ {
+ AUTO_STRING (format, "Loading `%s': old-style backquotes detected!");
+ CALLN (Fmessage, format, file);
+ }
}
static void
@@ -1279,6 +1282,10 @@ Return t if the file exists and loads successfully. */)
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
about them. */
specbind (Qlread_unescaped_character_literals, Qnil);
@@ -3171,7 +3178,10 @@ read1 (Lisp_Object readcharfun, int *pch, bool
first_in_list)
first_in_list exception (old-style can still be obtained via
"(\`" anyway). */
if (!new_backquote_flag && first_in_list && next_char == ' ')
- load_error_old_style_backquotes ();
+ {
+ Vlread_old_style_backquotes = Qt;
+ goto default_label;
+ }
else
{
Lisp_Object value;
@@ -3222,7 +3232,10 @@ read1 (Lisp_Object readcharfun, int *pch, bool
first_in_list)
return list2 (comma_type, value);
}
else
- load_error_old_style_backquotes ();
+ {
+ Vlread_old_style_backquotes = Qt;
+ goto default_label;
+ }
}
case '?':
{
@@ -3410,6 +3423,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool
first_in_list)
row. */
FALLTHROUGH;
default:
+ default_label:
if (c <= 040) goto retry;
if (c == NO_BREAK_SPACE)
goto retry;
@@ -4982,6 +4996,12 @@ 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'. */);
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",
Vlread_unescaped_character_literals,
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 1f85c26..30d2a47 100644
--- a/test/lisp/emacs-lisp/bytecomp-tests.el
+++ b/test/lisp/emacs-lisp/bytecomp-tests.el
@@ -534,18 +534,23 @@ literals (Bug#20852)."
(ert-deftest bytecomp-tests--old-style-backquotes ()
"Check that byte compiling warns about old-style backquotes."
+ (should (boundp 'lread--old-style-backquotes))
(bytecomp-tests--with-temp-file source
(write-region "(` (a b))" nil source)
(bytecomp-tests--with-temp-file destination
(let* ((byte-compile-dest-file-function (lambda (_) destination))
- (byte-compile-debug t)
- (err (should-error (byte-compile-file source))))
+ (byte-compile-error-on-warn t)
+ (byte-compile-debug t)
+ (err (should-error (byte-compile-file source))))
(should (equal (cdr err)
- '("Loading `nil': old-style backquotes detected!")))))))
+ (list "!! 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.")))))))
(ert-deftest bytecomp-tests-function-put ()
"Check `function-put' operates during compilation."
+ (should (boundp 'lread--old-style-backquotes))
(bytecomp-tests--with-temp-file source
(dolist (form '((function-put 'bytecomp-tests--foo 'foo 1)
(function-put 'bytecomp-tests--foo 'bar 2)
diff --git a/test/src/lread-tests.el b/test/src/lread-tests.el
index 3f41982..ac730b4 100644
--- a/test/src/lread-tests.el
+++ b/test/src/lread-tests.el
@@ -173,13 +173,13 @@ literals (Bug#20852)."
(should (string-suffix-p "/somelib.el" (caar load-history)))))
(ert-deftest lread-tests--old-style-backquotes ()
- "Check that loading doesn't accept old-style backquotes."
+ "Check that loading warns about old-style backquotes."
(lread-tests--with-temp-file file-name
(write-region "(` (a b))" nil file-name)
- (let ((data (should-error (load file-name nil :nomessage :nosuffix))))
- (should (equal (cdr data)
- (list (concat (format-message "Loading `%s': " file-name)
- "old-style backquotes detected!")))))))
+ (should (equal (load file-name nil :nomessage :nosuffix) t))
+ (should (equal (lread-tests--last-message)
+ (concat (format-message "Loading `%s': " file-name)
+ "old-style backquotes detected!")))))
(ert-deftest lread-lread--substitute-object-in-subtree ()
(let ((x (cons 0 1)))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 6abff55: Revert "Raise an error when detecting old-style backquotes.",
Philipp Stephani <=