[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/trie 4b24754 008/111: Converted function wrapping macro
From: |
Stefan Monnier |
Subject: |
[elpa] externals/trie 4b24754 008/111: Converted function wrapping macros into functions |
Date: |
Mon, 14 Dec 2020 11:35:09 -0500 (EST) |
branch: externals/trie
commit 4b247542a6f54ece3215faaea25933a558e544a9
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.
---
trie.el | 60 ++++++++++++++++++++++++++++++++----------------------------
1 file changed, 32 insertions(+), 28 deletions(-)
diff --git a/trie.el b/trie.el
index 4f44ba8..55816e4 100644
--- a/trie.el
+++ b/trie.el
@@ -195,6 +195,33 @@ If START or END is negative, it counts from the end."
;;; ================================================================
+;;; Miscelaneous macros
+
+(defun trie-construct-sortfun (cmpfun &optional reverse)
+ "Construct function to compare key sequences, based on a CMPFUN
+that compares individual elements of the sequence. Order is
+reversed if REVERSE is non-nil."
+ (if reverse
+ (byte-compile
+ `(lambda (a b)
+ (let (cmp)
+ (catch 'compared
+ (dotimes (i (min (length a) (length b)))
+ (cond ((,cmpfun (elt b i) (elt a i)) (throw 'compared t))
+ ((,cmpfun (elt a i) (elt b i)) (throw 'compared nil))))
+ (< (length a) (length b))))))
+ (byte-compile
+ `(lambda (a b)
+ (let (cmp)
+ (catch 'compared
+ (dotimes (i (min (length a) (length b)))
+ (cond ((,cmpfun (elt a i) (elt b i)) (throw 'compared t))
+ ((,cmpfun (elt b i) (elt a i)) (throw 'compared nil))))
+ (< (length a) (length b))))))))
+
+
+
+;;; ================================================================
;;; Internal functions only for use within the trie package
@@ -407,10 +434,9 @@ If START or END is negative, it counts from the end."
(setq prefix (list prefix))
(setq prefix
(sort prefix
- (eval (macroexpand
- `(trie-construct-sortfun
- ,(trie--comparison-function trie)
- ,(not reverse)))))))
+ (trie-construct-sortfun
+ (trie--comparison-function trie)
+ (not reverse)))))
(dolist (pfx prefix)
(when (setq node (trie--node-find trie pfx))
(push (cons pfx (funcall (trie--stack-createfun trie)
@@ -481,27 +507,6 @@ If START or END is negative, it counts from the end."
-(defmacro trie-construct-sortfun (cmpfun &optional reverse)
- "Construct function to compare key sequences, based on a CMPFUN
-that compares individual elements of the sequence. Order is
-reversed if REVERSE is non-nil."
- (if reverse
- `(lambda (a b)
- (let (cmp)
- (catch 'compared
- (dotimes (i (min (length a) (length b)))
- (cond ((,cmpfun (elt b i) (elt a i)) (throw 'compared t))
- ((,cmpfun (elt a i) (elt b i)) (throw 'compared nil))))
- (< (length a) (length b)))))
- `(lambda (a b)
- (let (cmp)
- (catch 'compared
- (dotimes (i (min (length a) (length b)))
- (cond ((,cmpfun (elt a i) (elt b i)) (throw 'compared t))
- ((,cmpfun (elt b i) (elt a i)) (throw 'compared nil))))
- (< (length a) (length b)))))))
-
-
(defmacro trie--complete-construct-accumulator (maxnum filter)
;; Does what it says on the tin! | sed -e 's/on/in/' -e 's/tin/macro name/'
`(cond
@@ -1063,9 +1068,8 @@ included in the results, and does not count towards
MAXNUM."
;; sort list of prefixes if sorting completions lexically
(when (null rankfun)
(setq prefix
- (sort prefix (eval (macroexpand
- `(trie-construct-sortfun
- ,(trie--comparison-function trie))))))))
+ (sort prefix (trie-construct-sortfun
+ (trie--comparison-function trie))))))
;; construct function to accumulate completions (might as well save a few
;; cycles in the `trie--mapc' call by constructing different functions
- [elpa] externals/trie f676ea0 091/111: Fix off-by-1 bug in Lewenstein distance queries., (continued)
- [elpa] externals/trie f676ea0 091/111: Fix off-by-1 bug in Lewenstein distance queries., Stefan Monnier, 2020/12/14
- [elpa] externals/trie eef13c4 079/111: Document fuzzy matching functions and bump version number., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 77aafc9 108/111: Fix byte-compilation errors and warnings., Stefan Monnier, 2020/12/14
- [elpa] externals/trie b6ba36b 002/111: Minor improvements to trie-complete[-ordered], Stefan Monnier, 2020/12/14
- [elpa] externals/trie 503b286 004/111: Make bare avl trees which don't store cmpfun with tree, Stefan Monnier, 2020/12/14
- [elpa] externals/trie 0162b74 003/111: Added trie-stacks implementation., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 45569c2 007/111: Added optional TEST function to trie-delete, Stefan Monnier, 2020/12/14
- [elpa] externals/trie 45accae 019/111: Bug-fix in trie--do-delete, Stefan Monnier, 2020/12/14
- [elpa] externals/trie 4f11b37 022/111: Docstring, change log, and version number updates, Stefan Monnier, 2020/12/14
- [elpa] externals/trie 510844e 035/111: trivial variable name change, Stefan Monnier, 2020/12/14
- [elpa] externals/trie 4b24754 008/111: Converted function wrapping macros into functions,
Stefan Monnier <=
- [elpa] externals/trie a17e6df 056/111: Minor bug-fixes to [trie/dict-tree]--edebug-pretty-print, Stefan Monnier, 2020/12/14
- [elpa] externals/trie 3b61c64 065/111: More minor whitespace and commentary changes., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 19e6dbe 010/111: Make weird variable names used to avoid dynamic scoping bugs more consistent, Stefan Monnier, 2020/12/14
- [elpa] externals/trie ae8bf27 036/111: minor code tidying, Stefan Monnier, 2020/12/14
- [elpa] externals/trie 0c21bf4 073/111: Add note to self to use cust-print pretty-printing instead of advice., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 490c011 025/111: Bug fixes to trie--wildcard-stack-repopulate, Stefan Monnier, 2020/12/14
- [elpa] externals/trie f398b8e 063/111: Updated copyright attribution and license (GPL2 -> GPL3)., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 14fa4ee 075/111: Code cleanup., Stefan Monnier, 2020/12/14
- [elpa] externals/trie 1e246d0 009/111: Bug-fix to remove setf inside backquote construct from trie-insert, Stefan Monnier, 2020/12/14
- [elpa] externals/trie ecf872e 061/111: Updated Package-Version, Package-Requires, and Keywords package headers., Stefan Monnier, 2020/12/14