emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] 06/16: * packages/trie/trie.el (edebug-prin1, edebug-prin1-to-str


From: Stefan Monnier
Subject: [elpa] 06/16: * packages/trie/trie.el (edebug-prin1, edebug-prin1-to-string): Use advice-add when available.
Date: Wed, 15 Oct 2014 21:05:55 +0000

monnier pushed a commit to branch master
in repository elpa.

commit 7e2200f74dbe63ad8d2bc00f85cb5b84a41b8d05
Author: Stefan Monnier <address@hidden>
Date:   Wed Oct 15 16:35:25 2014 -0400

    * packages/trie/trie.el (edebug-prin1, edebug-prin1-to-string): Use
    advice-add when available.
---
 packages/trie/trie.el |   52 ++++++++++++++++++++++++++++++------------------
 1 files changed, 32 insertions(+), 20 deletions(-)

diff --git a/packages/trie/trie.el b/packages/trie/trie.el
index 894aa60..d428fda 100644
--- a/packages/trie/trie.el
+++ b/packages/trie/trie.el
@@ -1,6 +1,6 @@
 ;;; trie.el --- Trie data structure
 
-;; Copyright (C) 2008-2010, 2012  Free Software Foundation, Inc
+;; Copyright (C) 2008-2010, 2012, 2014  Free Software Foundation, Inc
 
 ;; Author: Toby Cubitt <address@hidden>
 ;; Version: 0.2.6
@@ -1871,29 +1871,41 @@ elements that matched the corresponding groups, in 
order."
 ;;           "]")))
    ))
 
-
-(when (fboundp 'ad-define-subr-args)
-  (ad-define-subr-args 'edebug-prin1 '(object &optional printcharfun)))
-
-(defadvice edebug-prin1
-  (around trie activate compile preactivate)
+(defun trie--edebug-prin1 (orig object &optional printcharfun)
   (let ((pretty (trie--edebug-pretty-print object)))
     (if pretty
        (progn
          (prin1 pretty printcharfun)
-         (setq ad-return-value pretty))
-    ad-do-it)))
-
-
-(when (fboundp 'ad-define-subr-args)
-  (ad-define-subr-args 'edebug-prin1-to-string '(object &optional noescape)))
-
-(defadvice edebug-prin1-to-string
-  (around trie activate compile preactivate)
-  (let ((pretty (trie--edebug-pretty-print object)))
-    (if pretty
-       (setq ad-return-value pretty)
-      ad-do-it)))
+          pretty)
+      (funcall orig object printcharfun))))
+
+(defun trie--edebug-prin1-to-string (orig object &optional noescape)
+  (or (trie--edebug-pretty-print object)
+      (funcall orig object noescape)))
+
+(if (fboundp 'advice-add)
+    (progn
+      (advice-add 'edebug-prin1 :around #'trie--edebug-prin1)
+      (advice-add 'edebug-prin1-to-string
+                  :around #'trie--edebug-prin1-to-string))
+
+  (when (fboundp 'ad-define-subr-args)
+    (ad-define-subr-args 'edebug-prin1 '(object &optional printcharfun)))
+
+  (defadvice edebug-prin1
+      (around trie activate compile preactivate)
+    (setq ad-return-value
+          (trie--edebug-prin1 (lambda (object printcharfun) ad-do-it)
+                              object printcharfun)))
+
+  (when (fboundp 'ad-define-subr-args)
+    (ad-define-subr-args 'edebug-prin1-to-string '(object &optional noescape)))
+
+  (defadvice edebug-prin1-to-string
+      (around trie activate compile preactivate)
+    (setq ad-return-value
+          (trie--edebug-prin1-to-string (lambda (object noescape) ad-do-it)
+                                        object noescape))))
 
 
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]