[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/trie d99fb00 055/111: Simplified advice-based edebug pr
From: |
Stefan Monnier |
Subject: |
[elpa] externals/trie d99fb00 055/111: Simplified advice-based edebug pretty-printing of tries and dictionaries. |
Date: |
Mon, 14 Dec 2020 11:35:19 -0500 (EST) |
branch: externals/trie
commit d99fb00e849075bb1f7afdb7bbf86f60f8314739
Author: Toby S. Cubitt <toby-predictive@dr-qubit.org>
Commit: Toby S. Cubitt <toby-predictive@dr-qubit.org>
Simplified advice-based edebug pretty-printing of tries and dictionaries.
---
trie.el | 61 ++++++++++++++++++++++++++++---------------------------------
1 file changed, 28 insertions(+), 33 deletions(-)
diff --git a/trie.el b/trie.el
index 7dce69d..e3d3c71 100644
--- a/trie.el
+++ b/trie.el
@@ -1244,8 +1244,8 @@ element stored in the trie.)"
;; -------------------
;; For queries ranked in anything other than lexical order, we use a
;; partial heap-sort to find the k=MAXNUM highest ranked matches among
-;; the n possibile matches. This has worst-case time complexity O(n log
-;; k), and is both simple and elegant. An optimal algorithm
+;; the n possibile matches. This has worst-case time complexity
+;; O(n log k), and is both simple and elegant. An optimal algorithm
;; (e.g. partial quick-sort discarding the irrelevant partition at each
;; step) would have complexity O(n + k log k), but is probably not worth
;; the extra coding effort, and would have worse space complexity unless
@@ -1889,7 +1889,7 @@ elements that matched the corresponding groups, in order."
;; -----
;; We advise the `edebug-prin1' and `edebug-prin1-to-string' functions
-;; (actually, aliases) so that they pring "#<trie>" instead of the full
+;; (actually, aliases) so that they print "#<trie>" instead of the full
;; print form for tries.
;;
;; This is because, if left to its own devices, edebug hangs for ages
@@ -1897,14 +1897,18 @@ elements that matched the corresponding groups, in
order."
;; long time for it to finish, or kill Emacs entirely. (Even C-g C-g
;; fails!)
;;
+;; We do this also for lists of tries, since those occur quite often,
+;; but not for other sequence types or deeper nested structures, to keep
+;; the implementation as simple as possible.
+;;
;; 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.
+;; FIXME: We could use `cedet-edebug-prin1-extensions' instead of advice
+;; when `cedet-edebug' is loaded, though I believe the current
+;; implementation still works in that case.
(eval-when-compile
@@ -1915,33 +1919,24 @@ elements that matched the corresponding groups, in
order."
(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))))
+ ((let ((tlist object) (test t))
+ (while (or (trie-p (car-safe tlist))
+ (and tlist (setq test nil)))
+ (setq tlist (cdr tlist)))
+ test)
+ (concat "(" (mapconcat (lambda (dummy) "#<trie>") object " ") ")"))
+ ;; ((vectorp object)
+ ;; (let ((pretty "[") (len (length object)))
+ ;; (dotimes (i (1- len))
+ ;; (setq pretty
+ ;; (concat pretty
+ ;; (if (trie-p (aref object i))
+ ;; "#<trie>" (prin1-to-string (aref object i))) " ")))
+ ;; (concat pretty
+ ;; (if (trie-p (aref object (1- len)))
+ ;; "#<trie>" (prin1-to-string (aref object (1- len))))
+ ;; "]")))
+ ))
(ad-define-subr-args 'edebug-prin1 '(object &optional printcharfun))
- [elpa] externals/trie f930fe9 027/111: Documentation updates related to wildcard searches and predictive features that make use of them, (continued)
- [elpa] externals/trie f930fe9 027/111: Documentation updates related to wildcard searches and predictive features that make use of them, Stefan Monnier, 2020/12/14
- [elpa] externals/trie 46369a7 026/111: Added trie-wildcard-match function, Stefan Monnier, 2020/12/14
- [elpa] externals/trie 7823234 095/111: Fix bug in trie-fuzzy-complete that meant it didn't return minimum prefix distance in some cases., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 5fa968c 093/111: Fix byte-compiler warning., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 87d5786 102/111: Allow trie-fuzzy-match/complete to take lists of multiple prefixes/strings., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 71f8273 098/111: Significantly improve efficiency of trie-fuzzy-complete., Stefan Monnier, 2020/12/14
- [elpa] externals/trie c2b5e26 105/111: Myriad bug fixes and code refactoring in new fuzzy and ngram completion., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 63da3b1 111/111: * trie.el: Fix header which likely suffered a `M-q` accident, Stefan Monnier, 2020/12/14
- [elpa] externals/trie ff5e05f 040/111: Bumped copyright year, Stefan Monnier, 2020/12/14
- [elpa] externals/trie 2281926 020/111: Minor code reformatting and rearrangement, Stefan Monnier, 2020/12/14
- [elpa] externals/trie d99fb00 055/111: Simplified advice-based edebug pretty-printing of tries and dictionaries.,
Stefan Monnier <=
- [elpa] externals/trie b4d81bf 064/111: Trivial whitespace tidying., Stefan Monnier, 2020/12/14
- [elpa] externals/trie d45e9d5 062/111: Added autoload cookies., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 1c2790d 038/111: Replaced wildcard searches with more powerful and efficient regexp searches., Stefan Monnier, 2020/12/14
- [elpa] externals/trie bbfecae 085/111: Do lexbind test at compile-time instead of load-time., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 5e8e73f 081/111: Fix data wrapping handling in fuzzy query functions., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 2a9d7ec 099/111: Port efficiency improvements to trie-fuzzy-match., Stefan Monnier, 2020/12/14
- [elpa] externals/trie a2554d6 094/111: Fix function symbol quoting., Stefan Monnier, 2020/12/14
- [elpa] externals/trie c6ddbb9 096/111: Bump version numbers., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 94a1a86 087/111: Bump version numbers since we've added iterator generators., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 4001f61 097/111: Fix corresponding bug in trie-fuzzy-complete-stack., Stefan Monnier, 2020/12/14