GNU bug report logs - #41814
defmethod cl-print-object is not entirely reliable

Previous Next

Package: emacs;

Reported by: akater <nuclearspace <at> gmail.com>

Date: Thu, 11 Jun 2020 20:29:01 UTC

Severity: normal

Tags: notabug

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

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 41814 in the body.
You can then email your comments to 41814 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#41814; Package emacs. (Thu, 11 Jun 2020 20:29:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to akater <nuclearspace <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 11 Jun 2020 20:29:01 GMT) Full text and rfc822 format available.

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

From: akater <nuclearspace <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: defmethod cl-print-object is not entirely reliable
Date: Thu, 11 Jun 2020 20:05:38 +0000
[Message part 1 (text/plain, inline)]
I'm on Emacs 28.0.50.  I believe cl-print-object method code is not used when it
should be.

emacs -Q

C-x b *scratch* RET

(require 'eieio) C-x C-e RET

(defclass test nil nil) C-x C-e RET

(defmethod cl-print-object ((x test) s) (princ "#<test>" s)) C-x C-e RET

(make-feature 'test) RET C-u C-x C-e

For me, this prints like a structure (?): #s(test)

Now,

C-x 3

M-x ielm RET

(make-feature 'test) RET

This does make use of cl-print-object method:

#<test>

Structure method seems to also be used in org-babel evaluations.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41814; Package emacs. (Fri, 12 Jun 2020 10:27:02 GMT) Full text and rfc822 format available.

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

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: akater <nuclearspace <at> gmail.com>
Cc: 41814 <at> debbugs.gnu.org
Subject: Re: bug#41814: defmethod cl-print-object is not entirely reliable
Date: Fri, 12 Jun 2020 12:26:20 +0200
akater <nuclearspace <at> gmail.com> writes:

> I'm on Emacs 28.0.50.  I believe cl-print-object method code is not
> used when it should be.

> (make-feature 'test) RET C-u C-x C-e
>
> For me, this prints like a structure (?): #s(test)

Yes, this doesn't use cl-print at all.  And I think that makes sense:
when inserting a value into a buffer, readability is important (that
doesn't make a difference in your case, though).

We have different printers now in Elisp, and implementing
cl-print-object only has an effect when cl-print is used.

I dunno if that fact could be better documented to avoid this kind of
confusion.

Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41814; Package emacs. (Mon, 06 Jul 2020 19:11:01 GMT) Full text and rfc822 format available.

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

From: akater <nuclearspace <at> gmail.com>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 41814 <at> debbugs.gnu.org
Subject: Re: bug#41814: defmethod cl-print-object is not entirely reliable
Date: Mon, 06 Jul 2020 19:01:12 +0000
Michael Heerdegen <michael_heerdegen <at> web.de> writes:

> Yes, this doesn't use cl-print at all.  And I think that makes sense:
> when inserting a value into a buffer, readability is important (that
> doesn't make a difference in your case, though).

I'm afraid I disagree.  Why would anyone write a printing method if they
didn't aim for better readability in the first place?

My example was an MWE.  This behaviour concerns me because I have
classes with plenty of slots, and I actually often return /a tree/ of
corrsponding objects.  It certainly looks less readable when cl-print is
not used.  The whole point of defining a printing method is to have
fine-tuned printed represntations.  If it's not actually used
[everywhere, of course] I just don't understand why it's there at all.

IELM, too, “inserts value into a buffer” so I don't really get this
distinction either.

I'd have my personal itch scratched if I could at least specify cl-print
use in Org blocks but this doesn't feel right at all.

Does Emacs have object inspector?  If not, I'd guess its lack is the
real reason behind the desire to keep overly detailed output in some
places.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41814; Package emacs. (Sun, 13 Jun 2021 11:24:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: akater <nuclearspace <at> gmail.com>, 41814 <at> debbugs.gnu.org
Subject: Re: bug#41814: defmethod cl-print-object is not entirely reliable
Date: Sun, 13 Jun 2021 13:23:33 +0200
Michael Heerdegen <michael_heerdegen <at> web.de> writes:

> Yes, this doesn't use cl-print at all.  And I think that makes sense:
> when inserting a value into a buffer, readability is important (that
> doesn't make a difference in your case, though).
>
> We have different printers now in Elisp, and implementing
> cl-print-object only has an effect when cl-print is used.

Yup -- I don't think there's a bug here.  The standard Emacs
eval/printing commands aren't affected by the cl print definitions, but
instead uses a slew of different things to DWIM the printing, and we
can't change that.

> I dunno if that fact could be better documented to avoid this kind of
> confusion.

I don't think anything in our documentation (as far as I know) should
lead anybody to think that doing something in cl-print should affect
`C-u C-x C-e', so I'm closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) notabug. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 13 Jun 2021 11:24:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 41814 <at> debbugs.gnu.org and akater <nuclearspace <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 13 Jun 2021 11:24:02 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. (Mon, 12 Jul 2021 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 281 days ago.

Previous Next


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