[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dict-tree 76140ec 026/154: Converted function wrapping
From: |
Stefan Monnier |
Subject: |
[elpa] externals/dict-tree 76140ec 026/154: Converted function wrapping macros into functions |
Date: |
Mon, 14 Dec 2020 12:21:37 -0500 (EST) |
branch: externals/dict-tree
commit 76140ec7e9aaf660eadd4dd94077d87d2545ddfe
Author: Toby Cubitt <toby-predictive@dr-qubit.org>
Commit: tsc25 <toby-predictive@dr-qubit.org>
Converted function wrapping macros into functions
in part to avoid run-time dependency on cl package.
---
dict-tree.el | 92 +++++++++++++++++++++++++++++-------------------------------
1 file changed, 44 insertions(+), 48 deletions(-)
diff --git a/dict-tree.el b/dict-tree.el
index aed4814..082b4ec 100644
--- a/dict-tree.el
+++ b/dict-tree.el
@@ -264,10 +264,8 @@ If START or END is negative, it counts from the end."
&aux
(modified nil)
(trie (trie-create comparison-function))
- (insfun (eval (macroexpand
- `(dictree--wrap-insfun ,insert-function))))
- (rankfun (eval (macroexpand
- `(dictree--wrap-rankfun ,rank-function))))
+ (insfun (dictree--wrap-insfun insert-function))
+ (rankfun (dictree--wrap-rankfun rank-function))
(lookup-cache
(if lookup-cache-threshold
(make-hash-table :test 'equal)
@@ -316,10 +314,8 @@ If START or END is negative, it counts from the end."
:stack-createfun stack-createfun
:stack-popfun stack-popfun
:stack-emptyfun stack-emptyfun))
- (insfun (eval (macroexpand
- `(dictree--wrap-insfun ,insert-function))))
- (rankfun (eval (macroexpand
- `(dictree--wrap-rankfun ,rank-function))))
+ (insfun (dictree--wrap-insfun insert-function))
+ (rankfun (dictree--wrap-rankfun rank-function))
(lookup-cache
(if lookup-cache-threshold
(make-hash-table :test 'equal)
@@ -347,7 +343,6 @@ If START or END is negative, it counts from the end."
trie meta-dict-list)
-
(defstruct
(dictree--meta-dict
:named
@@ -375,9 +370,7 @@ If START or END is negative, it counts from the end."
((symbolp dic) (eval dic))
(t (error "Invalid object in DICTIONARY-LIST"))))
dictionary-list))
- (combfun (eval (macroexpand
- `(dictree--wrap-combfun
- ,combine-function))))
+ (combfun (dictree--wrap-combfun combine-function))
))
(:copier nil))
name filename autosave modified
@@ -404,6 +397,37 @@ If START or END is negative, it counts from the end."
(setq accumulate (cons (dictree--trie dict) accumulate))))
+(defun dictree--wrap-insfun (insfun) ; INTERNAL USE ONLY
+ ;; return wrapped insfun to deal with data wrapping
+ (byte-compile
+ `(lambda (new old)
+ ;; FIXME: should use (setf (dictree--cell-data old) ...) here, but can't
+ ;; figure out how to get that to be expanded at compile-time to
+ ;; avoid run-time dependency on 'cl package!!?!??!!!
+ (setcar old (,insfun (dictree--cell-data new)
+ (dictree--cell-data old)))
+ old)))
+
+(defun dictree--wrap-rankfun (rankfun) ; INTERNAL USE ONLY
+ ;; return wrapped rankfun to deal with data wrapping
+ (byte-compile
+ `(lambda (a b)
+ (,rankfun (cons (car a) (dictree--cell-data (cdr a)))
+ (cons (car b) (dictree--cell-data (cdr b)))))))
+
+(defun dictree--wrap-filter (filter) ; INTERNAL USE ONLY
+ ;; return wrapped filter function to deal with data wrapping
+ (byte-compile
+ `(lambda (key data) (,filter key (dictree--cell-data data)))))
+
+(defun dictree--wrap-combfun (combfun) ; INTERNAL USE ONLY
+ (byte-compile
+ `(lambda (cell1 cell2)
+ (cons (,combfun (dictree--cell-data cell1)
+ (dictree--cell-data cell2))
+ (append (list (dictree--cell-metadata cell1))
+ (list (dictree--cell-metadata cell2)))))))
+
(defmacro dictree--cell-create (data &optional meta-data)
;; INTERNAL USE ONLY
@@ -418,30 +442,6 @@ If START or END is negative, it counts from the end."
(defmacro dictree--cell-plist (cell) ; INTERNAL USE ONLY
`(cdr ,cell))
-(defmacro dictree--wrap-insfun (insfun) ; INTERNAL USE ONLY
- ;; return wrapped insfun to deal with data wrapping
- `(lambda (new old)
- (setf (dictree--cell-data old)
- (,insfun (dictree--cell-data new)
- (dictree--cell-data old)))
- old))
-
-(defmacro dictree--wrap-rankfun (rankfun) ; INTERNAL USE ONLY
- ;; return wrapped rankfun to deal with data wrapping
- `(lambda (a b)
- (,rankfun (cons (car a) (dictree--cell-data (cdr a)))
- (cons (car b) (dictree--cell-data (cdr b))))))
-
-(defmacro dictree--wrap-filter (filter) ; INTERNAL USE ONLY
- ;; return wrapped filter function to deal with data wrapping
- `(lambda (key data) (,filter key (dictree--cell-data data))))
-
-(defmacro dictree--wrap-combfun (combfun) ; INTERNAL USE ONLY
- `(lambda (cell1 cell2)
- (cons (,combfun (dictree--cell-data cell1)
- (dictree--cell-data cell2))
- (append (list (dictree--cell-metadata cell1))
- (list (dictree--cell-metadata cell2))))))
;; Construct and return a completion cache entry
(defalias 'dictree--cache-create 'cons) ; INTERNAL USE ONLY
@@ -459,7 +459,6 @@ If START or END is negative, it counts from the end."
(defalias 'dictree--set-cache-maxnum 'setcdr) ; INTERNAL USE ONLY
-
(defun dictree--merge (list1 list2 cmpfun &optional combfun maxnum)
;; Destructively merge together sorted lists LIST1 and LIST2 of completions,
;; sorting elements according to CMPFUN. For non-null MAXNUM, only the first
@@ -989,8 +988,7 @@ becomes the new association for KEY."
(trie-insert
(dictree--trie dict) key (dictree--cell-create data)
(or (and insert-function
- (eval (macroexpand
- `(dictree--wrap-insfun ,insert-function))))
+ (dictree--wrap-insfun insert-function))
(dictree--insfun dict))))
;; update dictionary's caches
(dictree--update-cache dict key newdata)
@@ -1732,7 +1730,7 @@ Returns nil if the stack is empty."
(dictree--do-query
query-type dic arg rank-function maxnum reverse
(when filter
- (eval (macroexpand `(dictree--wrap-filter ,filter)))))))
+ (dictree--wrap-filter filter)))))
;; if there's a cached result with enough completions, use it
@@ -1751,8 +1749,8 @@ Returns nil if the stack is empty."
(or (null (dictree--cache-maxnum cache))
(> (dictree--cache-maxnum cache) maxnum)))
(setcdr (nthcdr (1- maxnum) completions) nil)))
-
-
+
+
(t ;; if there was nothing useful in the cache, do query and time it
(let (time)
(setq time (float-time))
@@ -1787,11 +1785,10 @@ Returns nil if the stack is empty."
(dictree--merge
completions cmpl
(if rank-function
- (eval (macroexpand `(dictree--wrap-rankfun ,rank-function)))
+ (dictree--wrap-rankfun rank-function)
`(lambda (a b)
- (,(eval (macroexpand
- `(trie-construct-sortfun
- ,(dictree-comparison-function (car dict)))))
+ (,(trie-construct-sortfun
+ (dictree-comparison-function (car dict)))
(car a) (car b))))
nil maxnum)))
completions))
@@ -1842,8 +1839,7 @@ Returns nil if the stack is empty."
;; Note: could use a dictree-stack here too - would it be more efficient?
(funcall (dictree--query-triefun query-type)
(dictree--trie dict) arg
- (when rank-function
- (eval (macroexpand `(dictree--wrap-rankfun ,rank-function))))
+ (when rank-function (dictree--wrap-rankfun rank-function))
maxnum reverse filter)))
- [elpa] externals/dict-tree 47f8163 010/154: Made saving dictionaries to compiled or uncomiled forms a customization option., (continued)
- [elpa] externals/dict-tree 47f8163 010/154: Made saving dictionaries to compiled or uncomiled forms a customization option., Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 9e6d0f2 017/154: Fixed bug when deleting non-existent entries., Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 4cd369d 027/154: Avoid breaking setf abstraction in dictree--wrap-insfun., Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 9827131 016/154: Fixed unwrapped rank-function bug in dictree--query, Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 87bb7e8 019/154: Allow custom write and load functions when saving and dumping dictionaries;, Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 2978fc7 024/154: ...and already a bug-fix to the new cache updating code, Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 7d9b258 033/154: Improved handling of dictionary file names in dictree-load, Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree f46da76 008/154: Minor bug fixes., Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 405d11b 023/154: Implemented the other cache and cache-update policies, Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 57d59eb 021/154: Bug-fixes to predictive-auto-learn and read-dict., Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 76140ec 026/154: Converted function wrapping macros into functions,
Stefan Monnier <=
- [elpa] externals/dict-tree 9120845 032/154: Make weird variable names used to avoid dynamic scoping bugs more consistent, Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 6c21fcb 038/154: Fix dictree--query and dictree-complete to return results in correct format, Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 8a575f6 039/154: Added new trie functions to dictree--create-custom., Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 3a18a06 042/154: Modified dictree-populate-from-file to read linearly by default,, Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree ca2c562 050/154: Bug-fix to dictree-complete, Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree e1a9f19 051/154: Documentation updates related to wildcard searches and predictive features that make use of them, Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree bf4002d 063/154: Bug-fixes to dictree--write-dict-code; allow loading non-matching filenames in read-dict, Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 6d9921e 067/154: Updated docstrings for regexp-related functions and others., Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree d88b867 002/154: Version 0.10.3 of the predictive completion package., Stefan Monnier, 2020/12/14
- [elpa] externals/dict-tree 7b52ebd 005/154: Version 0.13.1 of the predictive completion package., Stefan Monnier, 2020/12/14