1/*  File:    swi/settings.pl
    2    Author:  Roy Ratcliffe
    3    Created: Jun 15 2021
    4    Purpose: SWI Settings
    5
    6Copyright (c) 2021, Roy Ratcliffe, Northumberland, United Kingdom
    7
    8Permission is hereby granted, free of charge,  to any person obtaining a
    9copy  of  this  software  and    associated   documentation  files  (the
   10"Software"), to deal in  the   Software  without  restriction, including
   11without limitation the rights to  use,   copy,  modify,  merge, publish,
   12distribute, sublicense, and/or sell  copies  of   the  Software,  and to
   13permit persons to whom the Software is   furnished  to do so, subject to
   14the following conditions:
   15
   16    The above copyright notice and this permission notice shall be
   17    included in all copies or substantial portions of the Software.
   18
   19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT  WARRANTY OF ANY KIND, EXPRESS
   20OR  IMPLIED,  INCLUDING  BUT  NOT   LIMITED    TO   THE   WARRANTIES  OF
   21MERCHANTABILITY, FITNESS FOR A PARTICULAR   PURPOSE AND NONINFRINGEMENT.
   22IN NO EVENT SHALL THE AUTHORS  OR   COPYRIGHT  HOLDERS BE LIABLE FOR ANY
   23CLAIM, DAMAGES OR OTHER LIABILITY,  WHETHER   IN  AN ACTION OF CONTRACT,
   24TORT OR OTHERWISE, ARISING FROM,  OUT  OF   OR  IN  CONNECTION  WITH THE
   25SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
   26
   27*/
   28
   29:- module(swi_settings,
   30          [ local_settings_file/1,              % -LocalFile:atom
   31            setting/3                           % :Name,?Value,:Goal
   32          ]).   33:- meta_predicate setting(:, ?, :).   34:- ensure_loaded(library(settings)).
 local_settings_file(-LocalFile:atom) is semidet
Breaks the module interface by asking for the current local settings file from the settings module. The local_file/1 dynamic predicate retains the path of the current local file based on loading. Loading a new settings file using load_settings/1 pushes a new local file without replacing the old one, so that the next save_settings/0 keeps saving to the original file.
Arguments:
LocalFile- is the absolute path of the local settings file to be utilised by the next save_settings/1 predicate call.
   48local_settings_file(LocalFile) :- once(settings:local_file(LocalFile)).
 setting(:Name, ?Value, :Goal) is semidet
Semi-deterministic version of setting/2. Succeeds only if Value succeeds for Goal; fails otherwise. Calls Goal with Value.

Take the following example where you only want the setting predicate to succeed when it does not match the empty atom.

setting(http:public_host, A, \==(''))
   60setting(Name, Value, Goal) :- setting(Name, Value), call(Goal, Value)