GNU bug report logs - #31649
26.1; cl-prin1 doesn't print #' and ignores print-quoted

Previous Next

Package: emacs;

Reported by: Gemini Lasswell <gazally <at> runbox.com>

Date: Wed, 30 May 2018 00:35:02 UTC

Severity: minor

Tags: fixed, patch

Found in version 26.1

Fixed in version 26.2

Done: Gemini Lasswell <gazally <at> runbox.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 31649 in the body.
You can then email your comments to 31649 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#31649; Package emacs. (Wed, 30 May 2018 00:35:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Gemini Lasswell <gazally <at> runbox.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 30 May 2018 00:35:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Gemini Lasswell <gazally <at> runbox.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 26.1; cl-prin1 doesn't print #' and ignores print-quoted
Date: Tue, 29 May 2018 17:34:19 -0700
[Message part 1 (text/plain, inline)]
CL printing doesn't observe the print variable print-quoted and always
prints #'foo as (function foo).

To reproduce, execute the following code (I used emacs -Q and IELM):

(let ((quoted-stuff '('a #'b `(,c ,@d))))
  (let ((print-quoted t))
    (cl-prin1 quoted-stuff) (terpri)
    (prin1 quoted-stuff) (terpri))
  (let ((print-quoted nil))
    (cl-prin1 quoted-stuff) (terpri)
    (prin1 quoted-stuff) (terpri)))

Results:
('a (function b) `(,c ,@d))
('a #'b `(,c ,@d))
('a (function b) `(,c ,@d))
((quote a) (function b) (\` ((\, c) (\,@ d))))

I expect cl-prin1 and prin1 to do the same thing in this example.

Here's a patch to make cl-prin1 behave like prin1:

[0001-Make-cl-print-respect-print-quoted.patch (text/plain, inline)]
From 99b24a7dc7472d04e6de43fb48f45869a272c26c Mon Sep 17 00:00:00 2001
From: Gemini Lasswell <gazally <at> runbox.com>
Date: Tue, 29 May 2018 11:41:09 -0700
Subject: [PATCH] Make cl-print respect print-quoted

* lisp/emacs-lisp/cl-print.el (cl-print-object) <cons>: Print quote
and its relatives as lists if print-quoted is nil. Add printing of
'function' as #'.
* test/lisp/emacs-lisp/cl-print-tests.el (cl-print-tests-5): New test.
---
 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 55e2bf8bd4..1eae8faf23 100644
--- a/lisp/emacs-lisp/cl-print.el
+++ b/lisp/emacs-lisp/cl-print.el
@@ -61,11 +61,16 @@ cl-print--depth
       (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 bfce4a16ce..404d323d0c 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))
-- 
2.16.2


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31649; Package emacs. (Tue, 05 Jun 2018 01:04:01 GMT) Full text and rfc822 format available.

Message #8 received at 31649 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> gmail.com>
To: Gemini Lasswell <gazally <at> runbox.com>
Cc: 31649 <at> debbugs.gnu.org
Subject: Re: bug#31649: 26.1;
 cl-prin1 doesn't print #' and ignores print-quoted
Date: Mon, 04 Jun 2018 21:03:36 -0400
severity 31649 minor
quit

Gemini Lasswell <gazally <at> runbox.com> writes:

> Subject: [PATCH] Make cl-print respect print-quoted

Looks good to me.  Just a minor nitpick about the message:

> * lisp/emacs-lisp/cl-print.el (cl-print-object) <cons>: Print quote
> and its relatives as lists if print-quoted is nil. Add printing of
                                                    ^
                                                    double space

I don't think "as lists" is the right description, maybe "with read
syntax".







Severity set to 'minor' from 'normal' Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Tue, 05 Jun 2018 01:04:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31649; Package emacs. (Tue, 05 Jun 2018 03:32:02 GMT) Full text and rfc822 format available.

Message #13 received at 31649 <at> debbugs.gnu.org (full text, mbox):

From: Gemini Lasswell <gazally <at> runbox.com>
To: Noam Postavsky <npostavs <at> gmail.com>
Cc: 31649 <at> debbugs.gnu.org
Subject: Re: bug#31649: 26.1;
 cl-prin1 doesn't print #' and ignores print-quoted
Date: Mon, 04 Jun 2018 20:31:44 -0700
Noam Postavsky <npostavs <at> gmail.com> writes:

>> * lisp/emacs-lisp/cl-print.el (cl-print-object) <cons>: Print quote
>> and its relatives as lists if print-quoted is nil. Add printing of
>                                                     ^
>                                                     double space
>
> I don't think "as lists" is the right description, maybe "with read
> syntax".

I'll fix the message. Should this go in master or emacs-26?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#31649; Package emacs. (Tue, 05 Jun 2018 11:52:01 GMT) Full text and rfc822 format available.

Message #16 received at 31649 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> gmail.com>
To: Gemini Lasswell <gazally <at> runbox.com>
Cc: 31649 <at> debbugs.gnu.org
Subject: Re: bug#31649: 26.1;
 cl-prin1 doesn't print #' and ignores print-quoted
Date: Tue, 05 Jun 2018 07:51:32 -0400
Gemini Lasswell <gazally <at> runbox.com> writes:

> Noam Postavsky <npostavs <at> gmail.com> writes:
>
>>> * lisp/emacs-lisp/cl-print.el (cl-print-object) <cons>: Print quote
>>> and its relatives as lists if print-quoted is nil. Add printing of
>>                                                     ^
>>                                                     double space
>>
>> I don't think "as lists" is the right description, maybe "with read
>> syntax".
>
> I'll fix the message. Should this go in master or emacs-26?

I'd call this a bug/deficiency in a new feature, so emacs-26.




Added tag(s) fixed. Request was from Gemini Lasswell <gazally <at> runbox.com> to control <at> debbugs.gnu.org. (Thu, 07 Jun 2018 15:49:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 26.2, send any further explanations to 31649 <at> debbugs.gnu.org and Gemini Lasswell <gazally <at> runbox.com> Request was from Gemini Lasswell <gazally <at> runbox.com> to control <at> debbugs.gnu.org. (Thu, 07 Jun 2018 15:51:01 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 06 Jul 2018 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 6 years and 344 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.