From bf2aec075564c4349648db94281295b673595461 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Tue, 5 Dec 2023 12:28:33 -0800 Subject: [PATCH] readline: adding a with-history combinator. --- extra/readline/readline.factor | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/extra/readline/readline.factor b/extra/readline/readline.factor index 784e43daba..0d5f1c5928 100644 --- a/extra/readline/readline.factor +++ b/extra/readline/readline.factor @@ -1,7 +1,8 @@ ! Copyright (C) 2011 Erik Charlebois. ! See https://factorcode.org/license.txt for BSD license. USING: alien.data alien.libraries alien.strings compiler.units -destructors io.encodings.utf8 kernel libc sequences words ; +continuations destructors io.encodings.utf8 kernel libc +sequences words ; QUALIFIED: readline.ffi IN: readline @@ -31,3 +32,7 @@ IN: readline ] ( -- alien ) define-temp ] with-compilation-unit execute( -- alien ) readline.ffi:set-rl_completion_entry_function ; + +:: with-history ( path quot -- ) + path readline.ffi:read_history io-error + quot [ path readline.ffi:write_history io-error ] finally ; inline -- 2.34.1