From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Philipp Newsgroups: gmane.emacs.devel Subject: [PATCH] Make `old-style-backquotes' variable internal Date: Sat, 6 May 2017 23:14:20 +0200 Message-ID: <20170506211420.61134-1-phst@google.com> References: NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1494105318 8362 195.159.176.226 (6 May 2017 21:15:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 6 May 2017 21:15:18 +0000 (UTC) Cc: Philipp To: monnier@iro.umontreal.ca, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat May 06 23:15:08 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d772h-0001xu-O0 for ged-emacs-devel@m.gmane.org; Sat, 06 May 2017 23:15:07 +0200 Original-Received: from localhost ([::1]:52735 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d772n-0007Od-38 for ged-emacs-devel@m.gmane.org; Sat, 06 May 2017 17:15:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52833) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d7728-0007OH-UB for emacs-devel@gnu.org; Sat, 06 May 2017 17:14:34 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d7723-0002CW-Tx for emacs-devel@gnu.org; Sat, 06 May 2017 17:14:32 -0400 Original-Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:34198) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d7723-0002BG-KU for emacs-devel@gnu.org; Sat, 06 May 2017 17:14:27 -0400 Original-Received: by mail-wr0-x244.google.com with SMTP id 6so3796069wrb.1 for ; Sat, 06 May 2017 14:14:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=QDYPHjJ6L+KNx34PHkv4WBXnZdX8EIez2DWIgYynQgg=; b=IsqszyJ0jeLICY9HsFoKCsmMqKvF9QJ6B1ed0XuNiWe0iDtfMyvgUYbZye1js5n1nG nFYsmig90lsHg1YBsh6Vqn1k4QyD1Nsdu8l2UynqdinJOawXEcm16642OwkMNzId6d1l TTG93K6qZhhZAYjTGy9LTFGSviSK1utXyZscb4W4EZ1J5CGaXocqoysdtcI+i20sNsiq 9Bi2tnTdTuAxpZNUXySJYTGbIptlZbbWDVNt7bPpDX12kTIENkWDUzYMKSEJMKITi/Ui 3H5tpfRt63uq3fQvBQ5t64RSYlruh4qyF2Tl2yjjydPXYxMbCuw6CL40m7SULwcA8nBc eDdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=QDYPHjJ6L+KNx34PHkv4WBXnZdX8EIez2DWIgYynQgg=; b=i126jDrccRrM7yKP5WZZ+N8vpt1juQKhepaUTp6cRREci4rDP1T4jHtwb94FvYscFX XlFq3Bn8rtb3+AS+Y5duPEZV489uYAY9p5lZD3ipeBX5JgxjGd5+DGgBPkF5arFQD3kR 1ik0zs0aM3mlwGtzo4US8lX5KQpwWLzLBgEIOP+qZ544bgGrTkv5GGend3/v8obb9H0n buhwkM1BSbH4036D+TdgROshmfegygcSRHv9IncnMZA1e4VXEqJgrojHX8YKWzAY5ngI JpVdyuPw+0K1OJXv633D60NXPB91TBvDX9ACgc3CJiIz21SnohyvlVJqh7GquyiO4Rtb Zb6A== X-Gm-Message-State: AN3rC/4v0O15FkeDB/0ZbLBv7hk6bgZw4DWL9F1g3URuy87AGQX9I7xd lTogG5EizX6tMw== X-Received: by 10.223.176.184 with SMTP id i53mr35353995wra.53.1494105266561; Sat, 06 May 2017 14:14:26 -0700 (PDT) Original-Received: from p.cm.cablesurf.de (46.128.198.151.dynamic.cablesurf.de. [46.128.198.151]) by smtp.gmail.com with ESMTPSA id a24sm10342142wra.17.2017.05.06.14.14.25 (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 06 May 2017 14:14:25 -0700 (PDT) X-Google-Original-From: Philipp X-Mailer: git-send-email 2.12.2 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::244 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:214636 Archived-At: * 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. --- lisp/emacs-lisp/bytecomp.el | 4 ++-- src/lread.c | 17 +++++++++-------- test/lisp/emacs-lisp/bytecomp-tests.el | 15 +++++++++++++++ test/src/lread-tests.el | 9 +++++++++ 4 files changed, 35 insertions(+), 10 deletions(-) diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 25102548a9..3fd3f5a1b8 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -2026,11 +2026,11 @@ byte-compile-from-buffer (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 6467043b1d..3cf8ef5a4e 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); @@ -1214,7 +1214,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 @@ -3037,7 +3037,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 @@ -3091,7 +3091,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list) } else { - Vold_style_backquotes = Qt; + Vlread_old_style_backquotes = Qt; goto default_label; } } @@ -4840,10 +4840,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 3624904753..a83c998a59 100644 --- a/test/lisp/emacs-lisp/bytecomp-tests.el +++ b/test/lisp/emacs-lisp/bytecomp-tests.el @@ -529,6 +529,21 @@ bytecomp-tests--with-temp-file (list (concat "unescaped character literals " "\", (, ), ;, [, ] 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 84342348d4..e45d184cad 100644 --- a/test/src/lread-tests.el +++ b/test/src/lread-tests.el @@ -142,4 +142,13 @@ lread-tests--last-message "unescaped character literals " "\", (, ), ;, [, ] detected!"))))) +(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 -- 2.12.2