diff options
author | Philipp <phst@google.com> | 2017-05-06 22:23:03 +0200 |
---|---|---|
committer | Philipp Stephani <phst@google.com> | 2017-05-13 12:32:29 +0200 |
commit | a1d461592172ca4c8aac0e4e923ef5e909cfb361 (patch) | |
tree | 7d972dbecad74eab4f7dfb37969ab0170c2870e1 | |
parent | 16004397f40d15d9db6b90632c236c804f38fc40 (diff) | |
download | emacs-a1d461592172ca4c8aac0e4e923ef5e909cfb361.tar.gz |
Make `old-style-backquotes' variable internal
* src/lread.c (load_warn_old_style_backquotes, Fload, read1)
(syms_of_lread): Rename `old-style-backquotes' to
`lread--old-style-backquotes', and clarify that it's for internal
use only.
* lisp/emacs-lisp/bytecomp.el (byte-compile-from-buffer): Rename
variable.
* test/src/lread-tests.el (lread-tests--old-style-backquotes): Add
unit test.
* emacs-lisp/bytecomp-tests.el
(bytecomp-tests--old-style-backquotes): Add unit test.
-rw-r--r-- | etc/NEWS | 5 | ||||
-rw-r--r-- | lisp/emacs-lisp/bytecomp.el | 4 | ||||
-rw-r--r-- | src/lread.c | 17 | ||||
-rw-r--r-- | test/lisp/emacs-lisp/bytecomp-tests.el | 15 | ||||
-rw-r--r-- | test/src/lread-tests.el | 9 |
5 files changed, 40 insertions, 10 deletions
@@ -907,6 +907,11 @@ which was sometimes numerically incorrect. For example, on a 64-bit host (max 1e16 10000000000000001) now returns its second argument instead of its first. ++++ +** The variable 'old-style-backquotes' has been made internal and +renamed to 'lread--old-style-backquotes'. No user code should use +this variable. + * Lisp Changes in Emacs 26.1 diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index daad93de182..e716eef10ad 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -2021,11 +2021,11 @@ 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* ((old-style-backquotes nil) + (let* ((lread--old-style-backquotes nil) (lread--unescaped-character-literals nil) (form (read inbuffer))) ;; Warn about the use of old-style backquotes. - (when 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.")) diff --git a/src/lread.c b/src/lread.c index 0e5b476a9a2..c03aad4f722 100644 --- a/src/lread.c +++ b/src/lread.c @@ -948,7 +948,7 @@ load_error_handler (Lisp_Object data) static void load_warn_old_style_backquotes (Lisp_Object file) { - if (!NILP (Vold_style_backquotes)) + if (!NILP (Vlread_old_style_backquotes)) { AUTO_STRING (format, "Loading `%s': old-style backquotes detected!"); CALLN (Fmessage, format, file); @@ -1216,7 +1216,7 @@ Return t if the file exists and loads successfully. */) version = -1; /* Check for the presence of old-style quotes and warn about them. */ - specbind (Qold_style_backquotes, Qnil); + 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 @@ -3040,7 +3040,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list) "(\`" anyway). */ if (!new_backquote_flag && first_in_list && next_char == ' ') { - Vold_style_backquotes = Qt; + Vlread_old_style_backquotes = Qt; goto default_label; } else @@ -3094,7 +3094,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list) } else { - Vold_style_backquotes = Qt; + Vlread_old_style_backquotes = Qt; goto default_label; } } @@ -4843,10 +4843,11 @@ 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 ("old-style-backquotes", Vold_style_backquotes, - doc: /* Set to non-nil when `read' encounters an old-style backquote. */); - Vold_style_backquotes = Qnil; - DEFSYM (Qold_style_backquotes, "old-style-backquotes"); + 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, diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el b/test/lisp/emacs-lisp/bytecomp-tests.el index 84004a9264a..d15bd8b6e65 100644 --- a/test/lisp/emacs-lisp/bytecomp-tests.el +++ b/test/lisp/emacs-lisp/bytecomp-tests.el @@ -530,6 +530,21 @@ literals (Bug#20852)." "`?\"', `?(', `?)', `?;', `?[', `?]' " "detected!")))))))) +(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-error-on-warn t) + (byte-compile-debug t) + (err (should-error (byte-compile-file source)))) + (should (equal (cdr err) + (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."))))))) + ;; Local Variables: ;; no-byte-compile: t ;; End: diff --git a/test/src/lread-tests.el b/test/src/lread-tests.el index 685ea682e29..98cbb6a301d 100644 --- a/test/src/lread-tests.el +++ b/test/src/lread-tests.el @@ -155,4 +155,13 @@ literals (Bug#20852)." (load "somelib" nil t) (should (string-suffix-p "/somelib.el" (caar load-history))))) +(ert-deftest lread-tests--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) + (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!"))))) + ;;; lread-tests.el ends here |