From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Gemini Lasswell Newsgroups: gmane.emacs.bugs Subject: bug#31649: 26.1; cl-prin1 doesn't print #' and ignores print-quoted Date: Tue, 29 May 2018 17:34:19 -0700 Message-ID: <87muwi56d0.fsf@runbox.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1527640389 12446 195.159.176.226 (30 May 2018 00:33:09 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 30 May 2018 00:33:09 +0000 (UTC) To: 31649@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed May 30 02:33:05 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fNp32-000398-Qh for geb-bug-gnu-emacs@m.gmane.org; Wed, 30 May 2018 02:33:05 +0200 Original-Received: from localhost ([::1]:35595 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fNp59-0001jf-Th for geb-bug-gnu-emacs@m.gmane.org; Tue, 29 May 2018 20:35:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38654) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fNp4z-0001j1-Ux for bug-gnu-emacs@gnu.org; Tue, 29 May 2018 20:35:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fNp4w-0002gD-Kb for bug-gnu-emacs@gnu.org; Tue, 29 May 2018 20:35:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:46575) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fNp4w-0002g5-Ft for bug-gnu-emacs@gnu.org; Tue, 29 May 2018 20:35:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fNp4w-0003RG-A8 for bug-gnu-emacs@gnu.org; Tue, 29 May 2018 20:35:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Gemini Lasswell Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 30 May 2018 00:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 31649 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.152764048813184 (code B ref -1); Wed, 30 May 2018 00:35:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 30 May 2018 00:34:48 +0000 Original-Received: from localhost ([127.0.0.1]:54471 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fNp4i-0003QZ-8V for submit@debbugs.gnu.org; Tue, 29 May 2018 20:34:48 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:47647) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fNp4g-0003QM-Lk for submit@debbugs.gnu.org; Tue, 29 May 2018 20:34:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fNp4a-0002Wn-Fo for submit@debbugs.gnu.org; Tue, 29 May 2018 20:34:41 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:56951) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fNp4a-0002Wf-Bz for submit@debbugs.gnu.org; Tue, 29 May 2018 20:34:40 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38617) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fNp4Z-0001hk-1N for bug-gnu-emacs@gnu.org; Tue, 29 May 2018 20:34:40 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fNp4V-0002Uo-NK for bug-gnu-emacs@gnu.org; Tue, 29 May 2018 20:34:39 -0400 Original-Received: from aibo.runbox.com ([91.220.196.211]:53316) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fNp4V-0002TW-An for bug-gnu-emacs@gnu.org; Tue, 29 May 2018 20:34:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=rbselector1; h=Content-Type:MIME-Version:Message-ID:Date:Subject:To:From; bh=TG0ne1wd9uwdKV/JwarqnICByhPJNJTLR+RC5bLB3Zo=; b=QkFhhHKUPWNLUsoZc+Y7Xf4qt ZD3Su5HuNh3YETHDCf7XFFmu5SSU14/AdH0hPn54lzhRb2WT9f0BInfksrH42u5CsbIW31D3WMSz+ DtzX2tM0NXK/sw/1j4r3dVpPWz0AzpEC+Va0n20IqOJa7CUgmzWIKuyuKOME2dFukTz9uWYa7c0IR MZVUOTqUBA01kzM59qR0iH0X8nu6NzgUofA82c1ERfvbzVTqseFOeA4l78ZMfievkYgMqqmYHZv4y H2Wptx0g2/rmOVViHRJ4XWcbE++tcxSuAWP6T8Z3OVT0/awpJ3+VkKKHg+8ogcpSztX15uMyo0YRO O7WqyZn4Q==; Original-Received: from [10.9.9.212] (helo=mailfront12.runbox.com) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1fNp4R-0005nP-PQ for bug-gnu-emacs@gnu.org; Wed, 30 May 2018 02:34:31 +0200 Original-Received: from c-24-22-244-161.hsd1.wa.comcast.net ([24.22.244.161] helo=chinook) by mailfront12.runbox.com with esmtpsa (uid:179284 ) (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) id 1fNp4P-0003K9-Ky for bug-gnu-emacs@gnu.org; Wed, 30 May 2018 02:34:30 +0200 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:146726 Archived-At: --=-=-= Content-Type: text/plain 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: --=-=-= Content-Type: text/plain Content-Disposition: inline; filename=0001-Make-cl-print-respect-print-quoted.patch >From 99b24a7dc7472d04e6de43fb48f45869a272c26c Mon Sep 17 00:00:00 2001 From: Gemini Lasswell 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) : 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 --=-=-=--