From a415c8bccb917c247792c4ce8e77b2512b3414d6 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sun, 28 May 2017 17:01:05 -0400 Subject: cl-print: handle circular objects when `print-circle' is nil (Bug#27117) * lisp/emacs-lisp/cl-print.el (cl-print--currently-printing): New variable. (cl-print-object): When `print-circle' is nil, bind it to a list of objects that are currently printing to avoid printing the same object endlessly. * test/lisp/emacs-lisp/cl-print-tests.el (cl-print-circle): New test. --- test/lisp/emacs-lisp/cl-print-tests.el | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test/lisp/emacs-lisp') diff --git a/test/lisp/emacs-lisp/cl-print-tests.el b/test/lisp/emacs-lisp/cl-print-tests.el index 772601fe87d..dfbe18d7844 100644 --- a/test/lisp/emacs-lisp/cl-print-tests.el +++ b/test/lisp/emacs-lisp/cl-print-tests.el @@ -47,4 +47,12 @@ "\\`(#1=#s(foo 1 2 3) #1#)\\'" (cl-prin1-to-string (list x x))))))) +(ert-deftest cl-print-circle () + (let ((x '(#1=(a . #1#) #1#))) + (let ((print-circle nil)) + (should (string-match "\\`((a . #[0-9]) (a . #[0-9]))\\'" + (cl-prin1-to-string x)))) + (let ((print-circle t)) + (should (equal "(#1=(a . #1#) #1#)" (cl-prin1-to-string x)))))) + ;;; cl-print-tests.el ends here. -- cgit v1.2.3