Paste: Hooking into Factor's parse-time lookup
Author: | CapitalEx |
Mode: | factor |
Date: | Sun, 27 Aug 2023 20:14:26 |
Plain Text |
USING: accessors compiler.units kernel linked-sets literals
namespaces sets vocabs.loader vocabs.parser words ;
IN: hackery
: ?save-search ( word/f -- word/f )
dup [ "searched-words" get adjoin ] when* ;
CONSTANT: old-search-def [ manifest get search-manifest ]
CONSTANT: custom-search-def [ manifest get search-manifest ?save-search ]
: change-search-def ( quot -- )
'[ "search" "vocabs.parser" create-word _ define ]
with-compilation-unit ; inline
: replace-search-def ( -- )
custom-search-def change-search-def ;
: restore-search-def ( -- )
old-search-def change-search-def ;
: reload-and-track ( vocab -- words )
0 <linked-set> "searched-words"
[ reload "searched-words" get ] with-variable ;
: get-searched-words ( vocab -- words )
replace-search-def
reload-and-track
restore-search-def ;
New Annotation