From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.devel Subject: Re: New pp (was: bug#25295: 26.0.50; Represent eieio objects using object-print in backtraces and edebug) Date: Sat, 11 Mar 2017 11:05:26 -0500 Message-ID: References: <87pokampa4.fsf@ericabrahamsen.net> <87innrc03h.fsf@users.sourceforge.net> <87k27w8j2l.fsf@users.sourceforge.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: blaine.gmane.org 1489248375 3791 195.159.176.226 (11 Mar 2017 16:06:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 11 Mar 2017 16:06:15 +0000 (UTC) Cc: Emacs developers To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Mar 11 17:06:09 2017 Return-path: Envelope-to: ged-emacs-devel@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 1cmjWs-0008GS-DY for ged-emacs-devel@m.gmane.org; Sat, 11 Mar 2017 17:06:02 +0100 Original-Received: from localhost ([::1]:43874 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cmjWy-0007Y0-AE for ged-emacs-devel@m.gmane.org; Sat, 11 Mar 2017 11:06:08 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41064) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cmjWL-0007Xg-6V for emacs-devel@gnu.org; Sat, 11 Mar 2017 11:05:30 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cmjWK-0001ZI-8F for emacs-devel@gnu.org; Sat, 11 Mar 2017 11:05:29 -0500 Original-Received: from mail-oi0-x231.google.com ([2607:f8b0:4003:c06::231]:32882) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cmjWK-0001Z6-1s for emacs-devel@gnu.org; Sat, 11 Mar 2017 11:05:28 -0500 Original-Received: by mail-oi0-x231.google.com with SMTP id 2so63013373oif.0 for ; Sat, 11 Mar 2017 08:05:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=zwsHc0bOKnyaKUSTXQW8EkzSq/T6rJgfB2uLOrxknFo=; b=FKnd7gWVJi/z9PI8vzACTvZSDL/YvtKCzXsVyJBfWahltjkAv2ZPq6D8r8zpgdIh8q cEhXKXO1aBVf1ywmJMEJH6ht4tlX7YxRT6fFV0kM3Oy+ILEFss5NzOWCefNNFMX/1kG9 nq+xpNNy07rn1jzrRJKoVHk3d8dd7zMGSc0FIMTxDlm8sEF+tLNjrJyWdMoDykqrwK+H +XHaCz/FauMrLRfOlwyg9B67Ho2ECbiMGBFubFtz+hHZGWLN0t4XHaxasYS5q21olfsp 3U//fQM0T9C9HC27iPMnCYvgE6JqWNRb/ubJNQlArOfSm7XfzyXWXFEb4onzh2+Pk9wv 251A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=zwsHc0bOKnyaKUSTXQW8EkzSq/T6rJgfB2uLOrxknFo=; b=tSb8bQ9iWpqZykJZaZ+dF4FCdEw4PP/pQGBqKI9Dy38JvMOIgcXX/Bc4heq6ANOvyS znhXrnhLqJM13bljFVKPwFXr5n2lfcfyfyRSowMsToVYRDmQzQ5KqSKLq+8OBTCjwnoY y2xTIkubF63j6iLocMDf9i1B7wERuB2K8PU1+KYCeLJMwVNy8O7l6deZjFW4VNIrxFgZ SAJN5EQ9q2iDpIXdFKykvxCy+JiG3fv0WkzsHDz1VhAAV1u9y7U5DPNpRH72kPnzTg7Y H6Z3GwqKwwWMtU80OQa+ZW/lpceYXReuNvGtP4JFqJdkrSfHqb3uEQvOvohNRPmqyPJM 2j4A== X-Gm-Message-State: AMke39k+cuZhOtnjvZQ8JKMTW79TTC1XqFYvYhjqI8UL0TbsxNlwpNqw4Vw1Pg4F+5XrLAtQFuGHJhe7bsEdZw== X-Received: by 10.202.89.139 with SMTP id n133mr12013825oib.70.1489248327227; Sat, 11 Mar 2017 08:05:27 -0800 (PST) Original-Received: by 10.157.80.172 with HTTP; Sat, 11 Mar 2017 08:05:26 -0800 (PST) In-Reply-To: X-Google-Sender-Auth: m-1vHg61Zb2oiRqyc5Iw2O6jlqg X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4003:c06::231 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:212909 Archived-At: On Sat, Mar 11, 2017 at 10:38 AM, Stefan Monnier wrote: >> +(defun pp-prin1 (object &optional stream) >> + (let ((cl-print-readably nil) >> + (stream (make-pp-state (or stream standard-output)))) >> + (pp--scan :open-block stream) >> + (prog1 (cl-prin1 object (cons :pprint stream)) > ^^^^^^^^^^^^^^^^^^^^^ > Why not just pass `stream' since it's a struct and we can hence dispatch > based on its type? Oh, hmm, that makes sense. I took a few wrong turns while implementing this, probably what happened is that when I decided to use (cons :pprint) I hadn't decided on a struct yet. > >> +;; fallback to standard `cl-print-object'. >> +(cl-defmethod cl-print-object (object (stream (head :pprint))) >> + (pp--scan (cl-prin1-to-string object) (cdr stream)) >> + object) > > Hmm... but if we use such a pseudo-stream here, doesn't it break all > calls to `princ' within other cl-print-object methods (i.e. forcing us > the override pretty much all existing cl-print-object methods with > a pprint-specific one)? It doesn't break anything, AFAIK, it just means that you don't get control over newlines vs spaces. So we would need pprint-specific methods for "big" structures only. Oh wait, did you possibly miss a close paren? Might be clearer this way: (cl-defmethod cl-print-object (object (pprint-state (head :pprint))) (pp--scan (cl-prin1-to-string object) (cdr pprint-state)) object)