1:- module('$pac$', []).    2:- set_prolog_flag(encoding, utf8).    3:- set_prolog_flag(optimise, true).    4:- set_prolog_flag(qcompile, auto).    5:- set_prolog_flag(editor, emacsclient).    6:- set_prolog_flag(history, 0).    7:- setenv('EDITOR', emacsclient).    8
    9:- use_module(library(macros)).   10
   11#define(local_cgi_config, '/.config/cgi-config').
   12
   13:- dynamic user:file_search_path/2.   14:- multifile user:file_search_path/2.   15
   16:- use_module('setup-aux').   17
   18pac_directories(
   19		[	(pac_root : []) -
   20			 [	test:test,
   21				:(prolog) -
   22					[	pac		: pac,
   23						util	: util,
   24						zdd		: zdd,
   25						tmp		: tmp,
   26						gb		: "util/grobner",
   27						other	: other
   28					]]]
   29			   ).
   30
   31setup_root_home_user(Dir):-
   32	split_string(Dir, /, '',  [_, Root, User|_]),
   33	atomic_list_concat([/,Root,/,User], Home),
   34	setenv(home, Home),
   35	setenv(user, User),
   36	setenv(pac_root, Dir).
   37%
   38setup_cgi_config:-
   39	getenv(home, H),
   40	atom_concat(H, #local_cgi_config, Mod),
   41	atom_concat(Mod, ".pl", Modpl),
   42	(	exists_file(Modpl) ->
   43		use_module(Mod),
   44		cgi_eqns(Eqns),
   45		maplist(setup_env, Eqns)
   46	;	true
   47	),
   48	pac_directories(DirStr),
   49	mk_file_search_path(DirStr).
   50
   51:-  prolog_load_context(directory, Dir),
   52	setup_root_home_user(Dir),
   53	setup_cgi_config.   54
   55% :- set_prolog_flag(color_term, false).
   56% :- set_stream(user_input, tty(true)).
   57% :- set_prolog_flag(tty_control, false).
   58
   59user: enable_pac_query	:- set_prolog_flag(pac, true).
   60user: disable_pac_query	:- set_prolog_flag(pac, false).
   61user: chk_pac_query	:- current_prolog_flag(pac, true).
   62
   63user: enable_odict	:- set_prolog_flag(odict, true).
   64user: disable_odict	:- set_prolog_flag(odict, false).
   65user: chk_odict		:- current_prolog_flag(odict, true).
   66
   67:- use_module([
   68		library(clpfd),
   69		library(dif),
   70		library(lists),
   71		library(sort),
   72		library(ordsets),
   73		library(url),
   74		library(ugraphs),
   75		library(readutil),
   76		library(apply),
   77   		library(apply_macros)
   78	      ]).   79
   80%
   81user: expand_query(X, Y, Z, Z) :- user:chk_pac_query, !,
   82	'$current_typein_module'(C),
   83	pac:expand_query(C, X, Y).
   84user: expand_query(X, X, Z, Z).
   85
   86:- use_module(pac('expand-pac')).   87
   88:- user:enable_pac_query.   89:- user:enable_odict.