From a2d2cf693a9d0253c6afc4e144523e2a3b890492 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Sat, 14 Sep 2019 01:49:23 +0200 Subject: [PATCH] Remove support for destructive splicing in elisp * src/lread.c (read1): Don't handle destructive splicing in backquote expressions (e.g. ",."). (Bug#19790) (syms_of_lread): Remove Qcomma_dot. * src/print.c (print_object): Don't check for Qcomma_dot. * test/src/eval-tests.el (eval-tests-19790-backquote-comma-dot-substitution): New test. * etc/NEWS: Announce it. --- etc/NEWS | 13 +++++++++++++ src/lread.c | 3 --- src/print.c | 3 +-- test/src/eval-tests.el | 7 +++++++ 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 1bde9c442b..cc349abe2f 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2092,6 +2092,19 @@ valid event type. * Lisp Changes in Emacs 27.1 +--- +** Incomplete destructive splicing support has been removed. +Support for Common Lisp style destructive splicing (",.") was +incomplete and broken for a long time. It has now been removed. + +This means that backquote substitution now works for identifiers +starting with a period ("."). Consider the following example: + + (let ((.foo 42)) `,.foo) + +In the past, this would have incorrectly evaluated to '(\,\. foo)', +but will now instead evaluate to '42'. + +++ ** The new 'quit-window-hook' is now run first when executing the 'quit-window' command. diff --git a/src/lread.c b/src/lread.c index 6ae7a0d8ba..0551376aa6 100644 --- a/src/lread.c +++ b/src/lread.c @@ -3307,8 +3307,6 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list) if (ch == '@') comma_type = Qcomma_at; - else if (ch == '.') - comma_type = Qcomma_dot; else { if (ch >= 0) UNREAD (ch); @@ -5080,7 +5078,6 @@ syms_of_lread (void) DEFSYM (Qbackquote, "`"); DEFSYM (Qcomma, ","); DEFSYM (Qcomma_at, ",@"); - DEFSYM (Qcomma_dot, ",."); DEFSYM (Qinhibit_file_name_operation, "inhibit-file-name-operation"); DEFSYM (Qascii_character, "ascii-character"); diff --git a/src/print.c b/src/print.c index 7c3da68fc9..bb013e282d 100644 --- a/src/print.c +++ b/src/print.c @@ -2086,8 +2086,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag) else if (print_quoted && CONSP (XCDR (obj)) && NILP (XCDR (XCDR (obj))) && new_backquote_output && (EQ (XCAR (obj), Qcomma) - || EQ (XCAR (obj), Qcomma_at) - || EQ (XCAR (obj), Qcomma_dot))) + || EQ (XCAR (obj), Qcomma_at))) { print_object (XCAR (obj), printcharfun, false); new_backquote_output--; diff --git a/test/src/eval-tests.el b/test/src/eval-tests.el index 48295b81fa..7a8eae82cf 100644 --- a/test/src/eval-tests.el +++ b/test/src/eval-tests.el @@ -169,4 +169,11 @@ eval-tests-33014-redefine "Remove the Lisp reference to the byte-compiled object." (setf (symbol-function #'eval-tests-33014-func) nil)) +(defun eval-tests-19790-backquote-comma-dot-substitution () + "Regression test for Bug#19790. +Don't handle destructive splicing in backquote expressions (like +in Common Lisp). Instead, make sure substitution in backquote +expressions works for identifiers starting with period." + (should (equal (let ((.x 'identity)) (eval `(,.x 'ok))) 'ok))) + ;;; eval-tests.el ends here -- 2.20.1