diff options
| author | Gemini Lasswell | 2018-05-29 11:41:09 -0700 |
|---|---|---|
| committer | Gemini Lasswell | 2018-06-07 08:27:43 -0700 |
| commit | c6ef3c8321e4907a250eb0906274f6f59d5bfe0d (patch) | |
| tree | b841c43da3cb7fd786504f6175e53b03857b8646 | |
| parent | 26b52ac40e78cb7ac3df3bf87e514ad137f0ce10 (diff) | |
| download | emacs-c6ef3c8321e4907a250eb0906274f6f59d5bfe0d.tar.gz emacs-c6ef3c8321e4907a250eb0906274f6f59d5bfe0d.zip | |
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 #'.
| -rw-r--r-- | lisp/emacs-lisp/cl-print.el | 9 | ||||
| -rw-r--r-- | 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 780b9fb3fe9..66561ce2644 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'." | |||
| 61 | (princ "..." stream) | 61 | (princ "..." stream) |
| 62 | (let ((car (pop object)) | 62 | (let ((car (pop object)) |
| 63 | (count 1)) | 63 | (count 1)) |
| 64 | (if (and (memq car '(\, quote \` \,@ \,.)) | 64 | (if (and print-quoted |
| 65 | (memq car '(\, quote function \` \,@ \,.)) | ||
| 65 | (consp object) | 66 | (consp object) |
| 66 | (null (cdr object))) | 67 | (null (cdr object))) |
| 67 | (progn | 68 | (progn |
| 68 | (princ (if (eq car 'quote) '\' car) stream) | 69 | (princ (cond |
| 70 | ((eq car 'quote) '\') | ||
| 71 | ((eq car 'function) "#'") | ||
| 72 | (t car)) | ||
| 73 | stream) | ||
| 69 | (cl-print-object (car object) stream)) | 74 | (cl-print-object (car object) stream)) |
| 70 | (princ "(" stream) | 75 | (princ "(" stream) |
| 71 | (cl-print-object car stream) | 76 | (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 bfce4a16cec..404d323d0c1 100644 --- a/test/lisp/emacs-lisp/cl-print-tests.el +++ b/test/lisp/emacs-lisp/cl-print-tests.el | |||
| @@ -72,6 +72,16 @@ | |||
| 72 | (should (equal "#s(cl-print-tests-struct :a (a (b (c ...))) :b nil :c nil :d nil :e nil)" | 72 | (should (equal "#s(cl-print-tests-struct :a (a (b (c ...))) :b nil :c nil :d nil :e nil)" |
| 73 | (cl-prin1-to-string deep-struct))))) | 73 | (cl-prin1-to-string deep-struct))))) |
| 74 | 74 | ||
| 75 | (ert-deftest cl-print-tests-5 () | ||
| 76 | "CL printing observes `print-quoted'." | ||
| 77 | (let ((quoted-stuff '('a #'b `(,c ,@d)))) | ||
| 78 | (let ((print-quoted t)) | ||
| 79 | (should (equal "('a #'b `(,c ,@d))" | ||
| 80 | (cl-prin1-to-string quoted-stuff)))) | ||
| 81 | (let ((print-quoted nil)) | ||
| 82 | (should (equal "((quote a) (function b) (\\` ((\\, c) (\\,@ d))))" | ||
| 83 | (cl-prin1-to-string quoted-stuff)))))) | ||
| 84 | |||
| 75 | (ert-deftest cl-print-circle () | 85 | (ert-deftest cl-print-circle () |
| 76 | (let ((x '(#1=(a . #1#) #1#))) | 86 | (let ((x '(#1=(a . #1#) #1#))) |
| 77 | (let ((print-circle nil)) | 87 | (let ((print-circle nil)) |