[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/trie 160f092 054/111: Revert "Replaced advice with cede
From: |
Stefan Monnier |
Subject: |
[elpa] externals/trie 160f092 054/111: Revert "Replaced advice with cedet-edebug.el for pretty-printing" |
Date: |
Mon, 14 Dec 2020 11:35:19 -0500 (EST) |
branch: externals/trie
commit 160f092b8da39f87b6747d6cff3c37a2effd477d
Author: Toby S. Cubitt <toby-predictive@dr-qubit.org>
Commit: Toby S. Cubitt <toby-predictive@dr-qubit.org>
Revert "Replaced advice with cedet-edebug.el for pretty-printing"
This reverts commit 5e3702f1a02de5594bcd5cd363e399e3020b6302.
---
trie.el | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 73 insertions(+), 9 deletions(-)
diff --git a/trie.el b/trie.el
index e43dbc9..7dce69d 100644
--- a/trie.el
+++ b/trie.el
@@ -1883,23 +1883,87 @@ elements that matched the corresponding groups, in
order."
;; ----------------------------------------------------------------
-;; Pretty-print tries during edebug
+;; Pretty-print tries during edebug
-;; We use `cedet-edebug-add-print-override' from cedet-edebug.el to make
-;; edebug print "#<trie>" instead of the full print form for
-;; tries. (This is cleaner than using aliases or advice.)
+;; Note:
+;; -----
+
+;; We advise the `edebug-prin1' and `edebug-prin1-to-string' functions
+;; (actually, aliases) so that they pring "#<trie>" instead of the full
+;; print form for tries.
;;
;; This is because, if left to its own devices, edebug hangs for ages
;; whilst printing large tries, and you either have to wait for a *very*
;; long time for it to finish, or kill Emacs entirely. (Even C-g C-g
-;; fails!) Since the print form of a trie is practically
-;; incomprehensible anyway, we don't lose much by doing this.
+;; fails!)
+;;
+;; Since the print form of a trie is practically incomprehensible
+;; anyway, we don't lose much by doing this. If you *really* want to
+;; print tries in full whilst edebugging, despite this warning, disable
+;; the advice.
+;;
+;; FIXME: Should use `cedet-edebug-prin1-extensions' instead of advice
+;; when `cedet-edebug' is loaded, though I believe this still
+;; works in that case.
+
+
+(eval-when-compile
+ (require 'edebug)
+ (require 'advice))
+
+
+(defun trie--edebug-pretty-print (object)
+ (cond
+ ((trie-p object) "#<trie>")
+ ((consp object)
+ (if (consp (cdr object))
+ (let ((pretty "("))
+ (while object
+ (setq pretty
+ (concat pretty
+ (trie--edebug-pretty-print
+ (if (atom object)
+ (prog1
+ (trie--edebug-pretty-print object)
+ (setq object nil))
+ (pop object)))
+ (when object " "))))
+ (concat pretty ")"))
+ (concat "(" (trie--edebug-pretty-print (car object))
+ " . " (trie--edebug-pretty-print (cdr object)) ")")))
+ ((vectorp object)
+ (let ((pretty "[") (len (length object)))
+ (dotimes (i (1- len))
+ (setq pretty
+ (concat pretty
+ (trie--edebug-pretty-print (aref object i))
+ " ")))
+ (concat pretty
+ (trie--edebug-pretty-print (aref object (1- len)))
+ "]")))
+ (t (prin1-to-string object))))
+
+
+(ad-define-subr-args 'edebug-prin1 '(object &optional printcharfun))
+
+(defadvice edebug-prin1
+ (around trie activate compile preactivate)
+ (let ((pretty (trie--edebug-pretty-print object)))
+ (if pretty
+ (progn
+ (prin1 pretty printcharfun)
+ (setq ad-return-value pretty))
+ ad-do-it)))
-(require 'cedet-edebug)
-(defun trie-pretty-print (trie) "#<trie>")
+(ad-define-subr-args 'edebug-prin1-to-string '(object &optional noescape))
-(cedet-edebug-add-print-override 'trie-p 'trie-pretty-print)
+(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)))
- [elpa] branch externals/trie created (now 63da3b1), Stefan Monnier, 2020/12/14
- [elpa] externals/trie 1697b5f 001/111: trie.el re-implements tstree.el using AVL trees, Stefan Monnier, 2020/12/14
- [elpa] externals/trie 5a0883f 005/111: Fixed bug in trie-complete when passed list of prefixes., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 4dc003b 006/111: Fixed bug when deleting non-existent entries., Stefan Monnier, 2020/12/14
- [elpa] externals/trie d998322 011/111: Made trie--terminator symbol into a configurable defconst., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 6cdaed0 046/111: Removed left-over debugging code and other minor tidying., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 160f092 054/111: Revert "Replaced advice with cedet-edebug.el for pretty-printing",
Stefan Monnier <=
- [elpa] externals/trie defa7e0 053/111: Replaced advice with cedet-edebug.el for pretty-printing, Stefan Monnier, 2020/12/14
- [elpa] externals/trie af10bd5 043/111: Bug-fix in trie--do-regexp-search, Stefan Monnier, 2020/12/14
- [elpa] externals/trie 58c6685 014/111: Replaced bare avl-trees, Stefan Monnier, 2020/12/14
- [elpa] externals/trie 9f5b6c2 060/111: Simplified persistent-storage code for tries and dict-trees., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 6aa6701 033/111: Added optional RESULTFUN argument to trie query functions,, Stefan Monnier, 2020/12/14
- [elpa] externals/trie 2345832 047/111: Advised edebug-prin1 and edebug-prin1-to-string to prevent edebug hanging, Stefan Monnier, 2020/12/14
- [elpa] externals/trie e1be744 030/111: Bug-fix in trie--do-wildcard-search, Stefan Monnier, 2020/12/14
- [elpa] externals/trie e00ae36 058/111: Trivial docstring and comment fixes., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 153d2d4 048/111: Require advice when compiling, Stefan Monnier, 2020/12/14
- [elpa] externals/trie 6d76748 028/111: Allow "]" to be included in a negated character alternatives, by placing immediately after the "[^"., Stefan Monnier, 2020/12/14