changeset 48:7117e6ef0445

Adjustable persistent history saving frequency
author samer
date Wed, 25 Mar 2015 12:50:11 +0000
parents e487c33c89ae
children f28a47a759a2
files .plrc
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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)),