[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dict-tree 168cdb5 072/154: Improved edebug-prin1 advice
From: |
Stefan Monnier |
Subject: |
[elpa] externals/dict-tree 168cdb5 072/154: Improved edebug-prin1 advice |
Date: |
Mon, 14 Dec 2020 12:21:47 -0500 (EST) |
branch: externals/dict-tree
commit 168cdb53aa2bef5825289461195dacd7ac050eb4
Author: Toby Cubitt <toby-predictive@dr-qubit.org>
Commit: Toby S. Cubitt <toby-predictive@dr-qubit.org>
Improved edebug-prin1 advice
---
dict-tree.el | 85 ++++++++++++++++++++++++++++++++++++------------------------
1 file changed, 51 insertions(+), 34 deletions(-)
diff --git a/dict-tree.el b/dict-tree.el
index f6047b3..ba1cf44 100644
--- a/dict-tree.el
+++ b/dict-tree.el
@@ -2378,7 +2378,7 @@ both forms. See `dictree-write'.
Interactively, DICT is read from the mini-buffer."
(interactive (list (read-dict "Dictionary: ")))
- (let* ((filename (dictree--filename dict)))
+ (let* ((filename (dictree-filename dict)))
;; if dictionary has no associated file, prompt for one
(unless (and filename (> (length filename) 0))
@@ -2386,12 +2386,12 @@ Interactively, DICT is read from the mini-buffer."
(read-file-name
(format "Save dictionary %s to file\
(leave blank to NOT save): "
- (dictree--name dict))
+ (dictree-name dict))
nil "")))
;; if filename is blank, don't save
(if (string= filename "")
- (message "Dictionary %s NOT saved" (dictree--name dict))
+ (message "Dictionary %s NOT saved" (dictree-name dict))
;; otherwise write dictionary to file
(setf (dictree-filename dict) filename)
(dictree-write dict filename t compilation))))
@@ -2425,7 +2425,7 @@ and OVERWRITE is the prefix argument."
(if (and (interactive-p) (string= filename ""))
(progn
- (message "Dictionary %s NOT written" (dictree--name dict))
+ (message "Dictionary %s NOT written" (dictree-name dict))
nil) ; indicate dictionary wasn't written
(let (dictname buff tmpfile)
@@ -2489,7 +2489,7 @@ and OVERWRITE is the prefix argument."
;; if writing to a different name, unload dictionary under old
;; name and reload it under new one
(setf (dictree-modified dict) nil)
- (setf (dictree--filename dict) filename)
+ (setf (dictree-filename dict) filename)
(unless (string= dictname (dictree-name dict))
(dictree-unload dict)
(dictree-load filename)))
@@ -2877,7 +2877,7 @@ is the prefix argument."
;; --- convert caches for writing to file ---
;; convert lookup cache hash table to an alist, if it exists
- (when (dictree--lookup-cache-threshold dict)
+ (when (dictree--meta-dict-lookup-cache-threshold dict)
(maphash (lambda (key val)
(push (cons key (mapcar 'car val)) lookup-alist))
(dictree--meta-dict-lookup-cache dict))
@@ -2931,11 +2931,11 @@ is the prefix argument."
;; --- write to file ---
;; generate the structure to save
- (setq tmpdict (dictree-create))
+ (setq tmpdict (dictree-meta-dict-create nil))
(setf (dictree--meta-dict-name tmpdict) dictname
(dictree--meta-dict-filename tmpdict) filename
(dictree--meta-dict-autosave tmpdict)
- (dictree--autosave dict)
+ (dictree--meta-dict-autosave dict)
(dictree--meta-dict-modified tmpdict) nil
(dictree--meta-dict-combine-function tmpdict)
(dictree--meta-dict-combine-function dict)
@@ -2958,20 +2958,25 @@ is the prefix argument."
(dictree--meta-dict-complete-ranked-cache-threshold tmpdict)
(dictree--meta-dict-complete-ranked-cache-threshold dict)
(dictree--meta-dict-dictlist tmpdict)
- (dictree--meta-dict-dictlist dict)
+ (mapcar (lambda (dic) (intern (dictree-name dic)))
+ (dictree--meta-dict-dictlist dict))
(dictree--meta-dict-meta-dict-list tmpdict) nil)
;; write lisp code that generates the dictionary object
- (insert "(eval-when-compile (require 'cl))\n")
- (insert "(require 'dict-tree)\n")
- (mapc (lambda (name) (insert "(require '" name ")\n"))
- (dictree--meta-dict-dictlist tmpdict))
- (insert "(defvar " dictname " nil \"Dictionary " dictname ".\")\n")
- (insert "(setq " dictname " '" (prin1-to-string tmpdict) ")\n")
- (insert "(dictree--meta-dict-dictlist\n"
- " " dictname "\n"
- " (mapcar (lambda (name) (eval (intern-soft name)))\n"
- " (dictree--meta-dict-dictlist " dictname " )))\n")
+ (insert "(eval-when-compile (require 'cl))\n"
+ "(require 'dict-tree)\n")
+ (mapc
+ (lambda (dic)
+ (insert "(unless (dictree-load " (dictree-filename dic) ")\n"
+ " (error \"Failed to load dictionary \\\""
+ (dictree-name dic) "\\\" required by meta-dict \\\""
+ dictname "\n"))
+ (dictree--meta-dict-dictlist dict))
+ (insert "(defvar " dictname " nil \"Dictionary " dictname ".\")\n"
+ "(setq " dictname " '" (prin1-to-string tmpdict) ")\n"
+ "(setf (dictree--meta-dict-dictlist " dictname ")\n"
+ " (mapcar 'eval (dictree--meta-dict-dictlist "
+ dictname ")))\n")
(when hashcode (insert hashcode))
(insert "(unless (memq " dictname " dictree-loaded-list)"
" (push " dictname " dictree-loaded-list))\n")
@@ -3020,12 +3025,13 @@ are created when using a trie that is not
self-balancing, see
(message "No file specified; dictionary %s NOT populated"
(dictree-name dict))
- (unless key-loadfun
- (setq key-loadfun (dictree--key-loadfun dict)))
- (unless data-loadfun
- (setq data-loadfun (dictree--data-loadfun dict)))
- (unless plist-loadfun
- (setq plist-loadfun (dictree--plist-loadfun dict)))
+ (unless (dictree--meta-dict-p dict)
+ (unless key-loadfun
+ (setq key-loadfun (dictree--key-loadfun dict)))
+ (unless data-loadfun
+ (setq data-loadfun (dictree--data-loadfun dict)))
+ (unless plist-loadfun
+ (setq plist-loadfun (dictree--plist-loadfun dict))))
(save-excursion
(let ((buff (find-file-noselect file)))
@@ -3358,25 +3364,36 @@ extension, suitable for passing to `load-library'."
(require 'advice))
+(defun dictree--edebug-pretty-print (object)
+ (cond
+ ((dictree-p object)
+ (concat "#<dict-tree \"" (dictree-name object) "\">"))
+ ((and object (listp object))
+ (concat "(" (mapconcat 'dictree--edebug-pretty-print object " ")
+ ")"))
+ (t (prin1-to-string object))))
+
+
(ad-define-subr-args 'edebug-prin1 '(object &optional printcharfun))
(defadvice edebug-prin1
(around dictree activate compile preactivate)
- (if (dictree-p object)
- (let ((pretty (concat "#<dict-tree " (dictree-name object) ">")))
- (prin1 pretty printcharfun)
- (setq ad-return-value pretty))
- ad-do-it))
+ (let ((pretty (dictree--edebug-pretty-print object)))
+ (if pretty
+ (progn
+ (prin1 pretty printcharfun)
+ (setq ad-return-value pretty))
+ ad-do-it)))
(ad-define-subr-args 'edebug-prin1-to-string '(object &optional noescape))
(defadvice edebug-prin1-to-string
(around dictree activate compile preactivate)
- (if (dictree-p object)
- (setq ad-return-value
- (concat "#<dict-tree " (dictree-name object) ">"))
- ad-do-it))
+ (let ((pretty (dictree--edebug-pretty-print object)))
+ (if pretty
+ (setq ad-return-value pretty)
+ ad-do-it)))
- [elpa] externals/dict-tree d325841 009/154: Dictionaries are now saved in both compiled and uncompiled forms., (continued)
- [elpa] externals/dict-tree d325841 009/154: Dictionaries are now saved in both compiled and uncompiled forms., Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 753904c 034/154: Added functions for pushing things onto dictree and trie stacks, Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree b3eb0f1 031/154: Bug-fix to dictree-insert, Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 0774b51 048/154: Added support for wildcard searches, Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 06f5039 055/154: Bug-fix to 'resultfun' feature in dictree--query and dictree--do-query, Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 9e9d7e9 056/154: Added dictree-clear-caches for doing the obvious, Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 32bb6e2 061/154: Replaced wildcard searches with more powerful and efficient regexp searches., Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree aa22866 062/154: minor fix: added tNFA to required packages, Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree c53e4b8 064/154: Bumped copyright year, Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 61f0ce6 068/154: Bug-fix in dictree--query, Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 168cdb5 072/154: Improved edebug-prin1 advice,
Stefan Monnier <=
- [elpa] externals/dict-tree 8810d3e 076/154: Bug-fixes to edebug pretty-print functions., Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree c1eeabe 081/154: Made dictionary auto-saving more robust against dictionary save failures., Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 2666377 084/154: Fixed implementation of 'both cache policy., Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 5cc5449 091/154: Fixed obsolete functions and other compiler warnings., Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 0ea66e7 090/154: Added fboundp guard around ad-define-subr-args (removed in Emacs-24)., Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree cfdc73d 099/154: Fixed calls to dictree-create-meta-dict., Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 2a1d749 098/154: Minor change to package description, to match other data structure packages., Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 7ab8f94 095/154: Updated copyright attribution and license (GPL2 -> GPL3)., Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 09b388f 108/154: Add note to self to use cust-print pretty-printing instead of advice., Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree d96b1c5 097/154: More minor whitespace and commentary changes., Stefan Monnier, 2020/12/14