unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: 18897@debbugs.gnu.org
Subject: bug#18897: [PATCH] using advice-add
Date: Wed, 29 Oct 2014 19:30:14 -0700	[thread overview]
Message-ID: <87a94effwp.fsf@ericabrahamsen.net> (raw)
In-Reply-To: <8738a6v4hs.fsf@ericabrahamsen.net>

[-- Attachment #1: Type: text/plain, Size: 63 bytes --]

Here's a patch that replaces the defalias with an advice-add.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Print-EIEIO-objects-correctly-when-edebugging.patch --]
[-- Type: text/x-diff, Size: 2654 bytes --]

From 6d80c0f46ca471d17415f6f1b5f8881c27f330b6 Mon Sep 17 00:00:00 2001
From: Eric Abrahamsen <eric@ericabrahamsen.net>
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)))
 
 \f
 ;;; Start of automatically extracted autoloads.
-- 
2.1.2


  parent reply	other threads:[~2014-10-30  2:30 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-29 23:30 bug#18897: 25.0.50; Use object-print for representing EIEIO objects during edebug Eric Abrahamsen
2014-10-30  2:29 ` bug#18897: [PATCH] using advice-add Eric Abrahamsen
2014-10-30  2:30 ` Eric Abrahamsen [this message]
2014-10-30  4:04   ` Stefan Monnier
2014-11-01 17:28 ` bug#18897: waiting Eric Abrahamsen
2014-11-01 17:43   ` Eli Zaretskii
2014-11-01 18:51     ` Eric Abrahamsen
2014-11-01 19:48       ` Eli Zaretskii
2014-11-01 21:47         ` Eric Abrahamsen
2014-11-02  3:34           ` Eli Zaretskii
2014-11-02  4:13             ` Eric Abrahamsen
2014-11-02 15:27               ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a94effwp.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=18897@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).