[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs-26 c6ef3c8: Make cl-print respect print-quoted (bug#
From: |
Gemini Lasswell |
Subject: |
[Emacs-diffs] emacs-26 c6ef3c8: Make cl-print respect print-quoted (bug#31649) |
Date: |
Thu, 7 Jun 2018 11:31:26 -0400 (EDT) |
branch: emacs-26
commit c6ef3c8321e4907a250eb0906274f6f59d5bfe0d
Author: Gemini Lasswell <address@hidden>
Commit: Gemini Lasswell <address@hidden>
Make cl-print respect print-quoted (bug#31649)
* lisp/emacs-lisp/cl-print.el (cl-print-object) <cons>: Observe
print-quoted when printing quote and its relatives. Add printing of
'function' as #'.
---
lisp/emacs-lisp/cl-print.el | 9 +++++++--
test/lisp/emacs-lisp/cl-print-tests.el | 10 ++++++++++
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/lisp/emacs-lisp/cl-print.el b/lisp/emacs-lisp/cl-print.el
index 780b9fb..66561ce 100644
--- a/lisp/emacs-lisp/cl-print.el
+++ b/lisp/emacs-lisp/cl-print.el
@@ -61,11 +61,16 @@ call other entry points instead, such as `cl-prin1'."
(princ "..." stream)
(let ((car (pop object))
(count 1))
- (if (and (memq car '(\, quote \` \,@ \,.))
+ (if (and print-quoted
+ (memq car '(\, quote function \` \,@ \,.))
(consp object)
(null (cdr object)))
(progn
- (princ (if (eq car 'quote) '\' car) stream)
+ (princ (cond
+ ((eq car 'quote) '\')
+ ((eq car 'function) "#'")
+ (t car))
+ stream)
(cl-print-object (car object) stream))
(princ "(" stream)
(cl-print-object car stream)
diff --git a/test/lisp/emacs-lisp/cl-print-tests.el
b/test/lisp/emacs-lisp/cl-print-tests.el
index bfce4a1..404d323 100644
--- a/test/lisp/emacs-lisp/cl-print-tests.el
+++ b/test/lisp/emacs-lisp/cl-print-tests.el
@@ -72,6 +72,16 @@
(should (equal "#s(cl-print-tests-struct :a (a (b (c ...))) :b nil :c nil
:d nil :e nil)"
(cl-prin1-to-string deep-struct)))))
+(ert-deftest cl-print-tests-5 ()
+ "CL printing observes `print-quoted'."
+ (let ((quoted-stuff '('a #'b `(,c ,@d))))
+ (let ((print-quoted t))
+ (should (equal "('a #'b `(,c ,@d))"
+ (cl-prin1-to-string quoted-stuff))))
+ (let ((print-quoted nil))
+ (should (equal "((quote a) (function b) (\\` ((\\, c) (\\,@ d))))"
+ (cl-prin1-to-string quoted-stuff))))))
+
(ert-deftest cl-print-circle ()
(let ((x '(#1=(a . #1#) #1#)))
(let ((print-circle nil))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] emacs-26 c6ef3c8: Make cl-print respect print-quoted (bug#31649),
Gemini Lasswell <=