# HG changeset patch # User samer # Date 1427287811 0 # Node ID 7117e6ef044589413fc257be543ce40006cac402 # Parent e487c33c89ae6c663d710108911e3a6c407c4137 Adjustable persistent history saving frequency diff -r e487c33c89ae -r 7117e6ef0445 .plrc --- a/.plrc Wed Mar 25 12:40:42 2015 +0000 +++ b/.plrc Wed Mar 25 12:50:11 2015 +0000 @@ -1,17 +1,18 @@ :- op(200,fy,@). :- dynamic persistent_history_file/1. -persistent_history(H) :- +persistent_history(H) :- persistent_history(H,60). +persistent_history(H,Interval) :- ( persistent_history_file(H) -> true ; persistent_history_file(H1) -> throw(persistent_history_mismatch(H1,H)) - ; debug(history,'Will use persistent history in "~s".',[H]), + ; debug(history,'Will use persistent history in "~s", saving every ~d seconds.',[H,Interval]), prolog_history(disable), (exists_file(H) -> rl_read_history(H); true), assert(persistent_history_file(H)), current_prolog_flag(os_argv,ARGV), atomics_to_string(ARGV," ",Command), history_event('Start: ~s',[Command]), - periodic_save_history, + periodic_save_history(Interval), at_halt(history_event('Halt',[])) ). @@ -25,10 +26,12 @@ rl_add_history(Line), rl_write_history(H). -periodic_save_history(H) :- + +periodic_save_history(Interval) :- + persistent_history_file(H), debug(history,'Saving history to "~s"...',[H]), rl_write_history(H), - alarm(60,periodic_save_history(H),_,[remove(true)]). + alarm(Interval,periodic_save_history(Interval),_,[remove(true)]). colour_terminal :- stream_property(user_output, tty(true)),