From: Stefan Kangas Date: Fri, 13 Sep 2019 23:49:23 +0000 (+0200) Subject: Remove support for destructive splicing in elisp X-Git-Tag: emacs-27.0.90~1421 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=3cf8f9b1ec1a079f6cd1a127259414dcb0cf8672;p=emacs.git 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. --- diff --git a/etc/NEWS b/etc/NEWS index 09394432aa8..0a4ada3cc6c 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2005,6 +2005,19 @@ immediately. Type 'M-x so-long-commentary' for full documentation. * Incompatible 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 REGEXP in 'magic-mode-alist' is now matched case-sensitively. Likewise for 'magic-fallback-mode-alist'. diff --git a/src/lread.c b/src/lread.c index 151731a81d9..5000b38a015 100644 --- a/src/lread.c +++ b/src/lread.c @@ -3310,8 +3310,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 @@ this variable will become obsolete. */); 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 7e5aed82877..77ddd93efba 100644 --- a/src/print.c +++ b/src/print.c @@ -2076,8 +2076,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 48295b81fa3..7a8eae82cf9 100644 --- a/test/src/eval-tests.el +++ b/test/src/eval-tests.el @@ -169,4 +169,11 @@ are found on the stack and therefore not garbage collected." "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