# HG changeset patch # User samer # Date 1432136904 -3600 # Node ID 9200668a075e0ffdabab561ee49eef629bb13f68 # Parent 5038e67f3a6d2794de4343f18d7ca1369d83b55c Moved persistent history stuff to a package. diff -r 5038e67f3a6d -r 9200668a075e .swiplrc --- a/.swiplrc Tue May 19 11:09:47 2015 +0100 +++ b/.swiplrc Wed May 20 16:48:24 2015 +0100 @@ -1,37 +1,4 @@ -:- op(200,fy,@). - -:- dynamic persistent_history_file/1. -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", 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(Interval), - at_halt(history_event('Halt',[])) - ). - -history_event(Msg,Args) :- - persistent_history_file(H), - get_time(Now), - format_time(string(Time),'%+',Now), - format(string(Info),Msg,Args), - format(atom(Line),'% ~w | ~s',[Time,Info]), - debug(history,'History event: ~s',[Line]), - rl_add_history(Line), - rl_write_history(H). - - -periodic_save_history(Interval) :- - persistent_history_file(H), - debug(history,'Saving history to "~s"...',[H]), - rl_write_history(H), - alarm(Interval,periodic_save_history(Interval),_,[remove(true)]). +:- op(200,fy,@). % Shouldn't really need this... colour_terminal :- stream_property(user_output, tty(true)), @@ -73,8 +40,7 @@ verify_certificate(_,_,_,_,_) :- format(user_error,'Accepting certificate\n',[]). -:- %persistent_history('.swipl_history'), - (colour_terminal -> load_files(library(ansi_term), [silent(true)]); true), +:- (colour_terminal -> load_files(library(ansi_term), [silent(true)]); true), set_prolog_flag(prompt_alternatives_on, determinism), set_prolog_flag(editor, '$EDITOR'), load_files(library(url), [silent(true)]),