From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.bugs Subject: bug#28587: 26.0.60; Don't write object name strings in object-write method Date: Wed, 08 Nov 2017 12:01:45 -0800 Message-ID: <87o9octu8m.fsf@ericabrahamsen.net> References: <87efqvg5tw.fsf@ericabrahamsen.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1510171453 17397 195.159.176.226 (8 Nov 2017 20:04:13 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 8 Nov 2017 20:04:13 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux) Cc: 28587@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Nov 08 21:04:08 2017 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 1eCWZx-0004GN-T8 for geb-bug-gnu-emacs@m.gmane.org; Wed, 08 Nov 2017 21:04:06 +0100 Original-Received: from localhost ([::1]:33721 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCWa3-000276-LA for geb-bug-gnu-emacs@m.gmane.org; Wed, 08 Nov 2017 15:04:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49495) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCWZy-00026w-0f for bug-gnu-emacs@gnu.org; Wed, 08 Nov 2017 15:04:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eCWZu-0002Qh-RP for bug-gnu-emacs@gnu.org; Wed, 08 Nov 2017 15:04:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:50246) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eCWZu-0002QX-KN for bug-gnu-emacs@gnu.org; Wed, 08 Nov 2017 15:04:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eCWZu-00046E-6L for bug-gnu-emacs@gnu.org; Wed, 08 Nov 2017 15:04:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eric Abrahamsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 08 Nov 2017 20:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28587 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 28587-submit@debbugs.gnu.org id=B28587.151017141215715 (code B ref 28587); Wed, 08 Nov 2017 20:04:02 +0000 Original-Received: (at 28587) by debbugs.gnu.org; 8 Nov 2017 20:03:32 +0000 Original-Received: from localhost ([127.0.0.1]:58927 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eCWZP-00045N-7j for submit@debbugs.gnu.org; Wed, 08 Nov 2017 15:03:32 -0500 Original-Received: from mail.ericabrahamsen.net ([50.56.99.223]:39227) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eCWZN-00045F-JW for 28587@debbugs.gnu.org; Wed, 08 Nov 2017 15:03:29 -0500 Original-Received: from localhost (71-212-22-173.tukw.qwest.net [71.212.22.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: eric@ericabrahamsen.net) by mail.ericabrahamsen.net (Postfix) with ESMTPSA id 883B8C0087; Wed, 8 Nov 2017 20:03:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mail.ericabrahamsen.net; s=mail; t=1510171408; bh=b+csTT+qudYJsW0KktwrcYEh0YHbazxKmlaM4S1tsik=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=Pa5LNxeXy/h39v8v3Mea5rBCMColF8YifascHNKMdsijkc1c03NJXS8e8k/iUrnO1 yB9nmQQNZJXO5v7qtArqjYvcJZt6YinvWejwJRUNgyxwExU15zXMAVuccDZKpfOpd6 hci92GUrzmXl2WlJs4SQUj9H3RCYyvUdqoMj1nDc= In-Reply-To: (Stefan Monnier's message of "Sat, 21 Oct 2017 23:29:00 -0400") 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:139627 Archived-At: --=-=-= Content-Type: text/plain On 10/21/17 23:29 PM, Stefan Monnier wrote: [...] > This is more problematic since data generated with this hunk will be > incompatible with an Emacs which doesn't have the other hunk applied. > So I think this should be conditional on a defcustom and by default this > defcustom should cause the code to still behave as before. So where we're at now is, the previous chunk has gone into both master and emacs-26. The next patch (below) would only go into master, so as to be more conservative about what's emitted. Everything defaults to current behavior. This patch does two things: permits omission of the object name strings, and permits shutting off indentation (which helps a lot for shrinking the file size). In a previous version I had `eieio-print-depth' do double duty as a boolean and an integer; this version has a separate defvar for controlling whether indentation is printed at all. `eieio-print-depth' still gets incremented; someone might find that useful. Eric --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Provide-more-control-over-writing-of-objects-in-obje.patch >From b75d0469dc986a73cbac6351537c30e535ce2890 Mon Sep 17 00:00:00 2001 From: Eric Abrahamsen Date: Wed, 8 Nov 2017 11:58:31 -0800 Subject: [PATCH] Provide more control over writing of objects in object-write * lisp/emacs-lisp/eieio.el (eieio-print-indentation, eieio-print-object-name): New variables controlling whether an object name is printed for each object, and whether an object's contents are indented or not. Object names are obsoleted; omitting indentation reduces the size of persistence files. --- lisp/emacs-lisp/eieio.el | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/lisp/emacs-lisp/eieio.el b/lisp/emacs-lisp/eieio.el index ca91c5a871..e07392d8c9 100644 --- a/lisp/emacs-lisp/eieio.el +++ b/lisp/emacs-lisp/eieio.el @@ -847,7 +847,17 @@ 'constructor (princ (object-print object) stream)) (defvar eieio-print-depth 0 - "When printing, keep track of the current indentation depth.") + "The current indentation depth while printing. +Ignored if `eieio-print-indentation' is nil.") + +(defvar eieio-print-indentation t + "When non-nil, indent contents of printed objects.") + +(defvar eieio-print-object-name t + "When non-nil write the object name in `object-write'. +Does not affect objects subclassing `eieio-named'. Writing +object names is deprecated as of Emacs 24.4; consider setting +this to nil.") (cl-defgeneric object-write (this &optional comment) "Write out object THIS to the current stream. @@ -860,9 +870,10 @@ eieio-print-depth If optional COMMENT is non-nil, include comments when outputting this object." (when comment - (princ ";; Object ") - (princ (eieio-object-name-string this)) - (princ "\n") + (when eieio-print-object-name + (princ ";; Object ") + (princ (eieio-object-name-string this)) + (princ "\n")) (princ comment) (princ "\n")) (let* ((cl (eieio-object-class this)) @@ -871,11 +882,13 @@ eieio-print-depth ;; It should look like this: ;; ( ... ) ;; Each slot's slot is writen using its :writer. - (princ (make-string (* eieio-print-depth 2) ? )) + (when eieio-print-indentation + (princ (make-string (* eieio-print-depth 2) ? ))) (princ "(") (princ (symbol-name (eieio--class-constructor (eieio-object-class this)))) - (princ " ") - (prin1 (eieio-object-name-string this)) + (when eieio-print-object-name + (princ " ") + (prin1 (eieio-object-name-string this))) (princ "\n") ;; Loop over all the public slots (let ((slots (eieio--class-slots cv)) @@ -889,7 +902,8 @@ eieio-print-depth (unless (or (not i) (equal v (cl--slot-descriptor-initform slot))) (unless (bolp) (princ "\n")) - (princ (make-string (* eieio-print-depth 2) ? )) + (when eieio-print-indentation + (princ (make-string (* eieio-print-depth 2) ? ))) (princ (symbol-name i)) (if (alist-get :printer (cl--slot-descriptor-props slot)) ;; Use our public printer @@ -904,7 +918,7 @@ eieio-print-depth "\n" " ")) (eieio-override-prin1 v)))))))) (princ ")") - (when (= eieio-print-depth 0) + (when (zerop eieio-print-depth) (princ "\n")))) (defun eieio-override-prin1 (thing) @@ -923,14 +937,16 @@ eieio-list-prin1 (progn (princ "'") (prin1 list)) - (princ (make-string (* eieio-print-depth 2) ? )) + (when eieio-print-indentation + (princ (make-string (* eieio-print-depth 2) ? ))) (princ "(list") (let ((eieio-print-depth (1+ eieio-print-depth))) (while list (princ "\n") (if (eieio-object-p (car list)) (object-write (car list)) - (princ (make-string (* eieio-print-depth 2) ? )) + (when eieio-print-indentation + (princ (make-string (* eieio-print-depth) ? ))) (eieio-override-prin1 (car list))) (setq list (cdr list)))) (princ ")"))) -- 2.15.0 --=-=-=--