From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.bugs Subject: bug#18897: [PATCH] using advice-add Date: Wed, 29 Oct 2014 19:29:47 -0700 Message-ID: <87bnouffxg.fsf@ericabrahamsen.net> References: <8738a6v4hs.fsf@ericabrahamsen.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1414635988 31809 80.91.229.3 (30 Oct 2014 02:26:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 30 Oct 2014 02:26:28 +0000 (UTC) To: 18897@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Oct 30 03:26:22 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XjfRH-0002sp-SB for geb-bug-gnu-emacs@m.gmane.org; Thu, 30 Oct 2014 03:26:16 +0100 Original-Received: from localhost ([::1]:50286 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XjfRH-0002nh-Fv for geb-bug-gnu-emacs@m.gmane.org; Wed, 29 Oct 2014 22:26:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34730) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XjfR9-0002nI-HA for bug-gnu-emacs@gnu.org; Wed, 29 Oct 2014 22:26:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XjfR4-0008Lz-G2 for bug-gnu-emacs@gnu.org; Wed, 29 Oct 2014 22:26:07 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:47510) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XjfR4-0008Lt-C3 for bug-gnu-emacs@gnu.org; Wed, 29 Oct 2014 22:26:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XjfR3-0000IE-RG for bug-gnu-emacs@gnu.org; Wed, 29 Oct 2014 22:26:01 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <8738a6v4hs.fsf@ericabrahamsen.net> Resent-From: Eric Abrahamsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 30 Oct 2014 02:26:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18897 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 18897-submit@debbugs.gnu.org id=B18897.14146359101006 (code B ref 18897); Thu, 30 Oct 2014 02:26:01 +0000 Original-Received: (at 18897) by debbugs.gnu.org; 30 Oct 2014 02:25:10 +0000 Original-Received: from localhost ([127.0.0.1]:39605 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XjfQD-0000G9-O2 for submit@debbugs.gnu.org; Wed, 29 Oct 2014 22:25:10 -0400 Original-Received: from mail-pd0-f174.google.com ([209.85.192.174]:47220) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XjfQB-0000Fa-DC for 18897@debbugs.gnu.org; Wed, 29 Oct 2014 22:25:08 -0400 Original-Received: by mail-pd0-f174.google.com with SMTP id p10so4151548pdj.19 for <18897@debbugs.gnu.org>; Wed, 29 Oct 2014 19:25:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:user-agent:date:message-id :mime-version:content-type; bh=Ul9/VlFR2nwt4aTuaENEHmPxIubQjfO/Ys4jCXRBnmE=; b=l0xMnNvW10ifr5hY/MF5cWIbajKFimJBADegrjTi/mYtol68cjrT7oo47yVzOJjO/D MtizbJ/L3kPN6ZnLQS+vUpOht8rXapoH040ddNMg38r0w0QiNS42grzx5hiY1rIYHls3 LtafUh4fvUc3puW74ZjEojtd2Kqwvney4YJJTrZwXrBGCj6BlRg6u6O8KJ9HYZa44omB mmq/6AcmL9jIoNo+iZTIjxCRPGXoeeOjRQvZl2XJMKXxgLddQUDellhB+QPj/GNvk2x6 7h8HMgDmMSD+OWDvzSEA5rul/AJ86PEq08KCmgiIInG1/LTAKSnoFXCOjUhOOu5UudPe ygHw== X-Gm-Message-State: ALoCoQk7W3kM5fmyPPqcgRzPtsepjCffg1n13QJ97GiuOReBAyxsX3hGuVP80fOUwyUhsDH8TW8a X-Received: by 10.68.197.41 with SMTP id ir9mr14229267pbc.116.1414635900832; Wed, 29 Oct 2014 19:25:00 -0700 (PDT) Original-Received: from localhost ([2601:8:b280:6b4:226:82ff:fe96:715a]) by mx.google.com with ESMTPSA id xf9sm5559531pab.2.2014.10.29.19.24.59 for <18897@debbugs.gnu.org> (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Oct 2014 19:24:59 -0700 (PDT) User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.4 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:95281 --=-=-= Content-Type: text/plain Here's a patch that replaces the defalias with an advice-add. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Print-EIEIO-objects-correctly-when-edebugging.patch >From 6d80c0f46ca471d17415f6f1b5f8881c27f330b6 Mon Sep 17 00:00:00 2001 From: Eric Abrahamsen Date: Wed, 29 Oct 2014 19:24:07 -0700 Subject: [PATCH] Print EIEIO objects correctly when edebugging * lisp/emacs-lisp/eieio.el (eieio-edebug-prin1-to-string): Modify function for use as advice. (edebug-setup-hook): Add `eieio-edebug-prin1-to-string' as advice on `edebug-prin1-to-string'. This will prevent objects containing large data structures from hammering Emacs during pretty-printing. eieio.el came with controls for printing EIEIO objects during edebugging sessions, but the controls weren't hooked up all the way. --- lisp/emacs-lisp/eieio.el | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/lisp/emacs-lisp/eieio.el b/lisp/emacs-lisp/eieio.el index d7c60dc..543d640 100644 --- a/lisp/emacs-lisp/eieio.el +++ b/lisp/emacs-lisp/eieio.el @@ -853,17 +853,19 @@ of `eq'." ;;; Interfacing with edebug ;; -(defun eieio-edebug-prin1-to-string (object &optional noescape) +(defun eieio-edebug-prin1-to-string (print-function object &optional noescape) "Display EIEIO OBJECT in fancy format. -Overrides the edebug default. -Optional argument NOESCAPE is passed to `prin1-to-string' when appropriate." + +Used as advice around `edebug-prin1-to-string', held in the +variable PRINT-FUNCTION. Optional argument NOESCAPE is passed to +`prin1-to-string' when appropriate." (cond ((class-p object) (eieio-class-name object)) ((eieio-object-p object) (object-print object)) ((and (listp object) (or (class-p (car object)) (eieio-object-p (car object)))) (concat "(" (mapconcat #'eieio-edebug-prin1-to-string object " ") ")")) - (t (prin1-to-string object noescape)))) + (t (funcall print-function object noescape)))) (add-hook 'edebug-setup-hook (lambda () @@ -887,14 +889,8 @@ Optional argument NOESCAPE is passed to `prin1-to-string' when appropriate." (def-edebug-spec class-constructor form) (def-edebug-spec generic-p form) (def-edebug-spec with-slots (list list def-body)) - ;; I suspect this isn't the best way to do this, but when - ;; cust-print was used on my system all my objects - ;; appeared as "#1 =" which was not useful. This allows - ;; edebug to print my objects in the nice way they were - ;; meant to with `object-print' and `class-name' - ;; (defalias 'edebug-prin1-to-string 'eieio-edebug-prin1-to-string) - ) - ) + (advice-add #'edebug-prin1-to-string + :around #'eieio-edebug-prin1-to-string))) ;;; Start of automatically extracted autoloads. -- 2.1.2 --=-=-=--