1:- module(logicmoo_logtalk,[ensure_LOGTALKUSER/0,load_logtalk/0]).    2
    3%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    4% LOAD LOGTALK
    5%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    6
    7logtalk_home(LTH):- getenv('LOGTALKHOME',LTH),!.
    8logtalk_home(LTH):- absolute_directory(pack(logtalk), Directory0),
    9  atom_concat(Directory0,'/logtalk-*',Directory1),
   10  expand_file_name(Directory1,[LTH]),!.
   11
   12skip_logtalk:- app_argv('--nologtalk'),!.
   13skip_logtalk:- \+ app_argv1('--logtalk'),!.
   14skip_logtalk:- \+ logtalk_home(_), !.
   15skip_logtalk:- logtalk_home(LTH), \+ exists_directory(LTH),!.
   16
   17had_LOGTALKUSER :- getenv('LOGTALKUSER', _Location),getenv('LOGTALKHOME', _Location2).
   18
   19ensure_LOGTALKUSER:- had_LOGTALKUSER,!.
   20ensure_LOGTALKUSER:- skip_logtalk, !, dmsg("Skipping logtalk").
   21% ensure_LOGTALKUSER:- user:use_module(library(logtalk)).
   22ensure_LOGTALKUSER:- logtalk_home(LTH),
   23   setenv('LOGTALKHOME', LTH),
   24   setenv('LOGTALKUSER', LTH),!.
   25
   26:- multifile(logtalk:'$lgt_current_engine_'/4).   27:- volatile(logtalk:'$lgt_current_engine_'/4).   28load_logtalk(system):- load_logtalk('/usr/share/logtalk').
   29load_logtalk(LTH):- atom_concat(LTH,'/integration/logtalk_swi',Init),
   30  exists_source(Init),!,logtalk:ensure_loaded(Init),!,listing(logtalk:'$lgt_default_flag'/2).
   31load_logtalk(LTH):-  dmsg("Skipping logtalk="+LTH).
   32
   33load_logtalk:- current_predicate(logtalk:'$lgt_default_flag'/2).
   34load_logtalk:- skip_logtalk, !, dmsg("Skipping logtalk").
   35load_logtalk:- logtalk_home(LTH), \+ exists_directory(LTH),!,dmsg("Skipping logtalk").
   36load_logtalk:- had_LOGTALKUSER,!,
   37   dmsg("Installing logtalk"),
   38   load_logtalk(system).
   39load_logtalk:- ensure_LOGTALKUSER,
   40   logtalk_home(LTH),
   41   dmsg("Logtalk installed"=LTH),
   42   load_logtalk(LTH).
   43
   44:- dmsg("Loading logtalk").   45:- before_boot(ensure_LOGTALKUSER).   46:- before_boot(load_logtalk).   47
   48% :- if( (( \+ prolog_load_context(reload,true) ))).
   49
   50:- module_transparent(logtalk:'::'/1).   51:- logtalk:export(logtalk:'::'/1).   52:- user:import(logtalk:'::'/1).   53
   54:- module_transparent(logtalk:'::'/2).   55:- logtalk:export(logtalk:'::'/2).   56:- user:import(logtalk:'::'/2).   57:- baseKB:import(logtalk:'::'/2).   58
   59%user:'::'(X,Y):- logtalk:'::'(X,Y).
   60%user:'::'(X):- logtalk:'::'(X).
   61
   62:-op(200,fy,user:'--').   63:-op(600,fy,user:'::').   64:-op(600,xfy,user:'::').   65:-op(200,fy,user:'++').   66:-op(600,fy,user:'^^').   67
   68
   69% :- endif.
   70:- fixup_exports.