A configuration parameter is always evaluated within a configuration context. Each context is associated with a configuration file (although the file does not necessarily need to exist).
Each configuration context may have a parent context. If, when looking up a parameter, it has no value set in the selected context, the parent context is checked, and so on.
Three special contexts are always automatically defined: the default context, the system context and the user context. The user context is the default parent context for all other configuration contexts, including newly-created ones.
Normally, you shouldn’t create a configuration context directly; you should obtain the configuration context associated with a path.
path-config-context looks for a configuration file named
geda.conf. If path is not a directory, it is truncated,
and then a file named geda.conf is looked for in that
directory. If none is found, the parent directory is checked, and so
on until a configuration file is found or the filesystem root is
reached. If no configuration file was found, the returned context
will be associated with a geda.conf in the same directory as
Warning: Do not assume that the configuration file associated
with the context returned by
path-config-context is located in
the directory specified by path.
The default context is not associated with any physical path or on-disk configuration file, and has no parent context. It contains the default configuration used when no configuration file can be loaded.
Note: Normally, the default context should be populated with
built-in default configuration settings on start-up, before loading
any further configuration files. This approach is strongly
recommended, because it means that configuration parameters can then
be safely read without having to use
config-has-key? to check if they are set (see Configuration groups and keys).
The system context is used for system-wide configuration. Its parent context is the default context. It is located:
XDG_CONFIG_DIRSfor a gEDA/geda-system.conf file.
The user context is used for user-specific configuration, and is
loaded from gEDA/geda-user.conf in
Its parent context is the system context.
Other than the default context, all configuration contexts are associated with an on-disk configuration file.
Return the filename of the configuration file associated with the context cfg. For some contexts (including the default context), this will return ‘#f’.
Attempt to load configuration parameters for the context cfg from its associated file.
Determine whether the context cfg has been successfully loaded from file.
Attempt to save configuration parameters for the context cfg to its associated file.
Determine whether the context cfg has been altered since it was last synchronised with the on-disk version by loading or saving it.
A configuration context may have a parent context, from which it inherits configuration values. Configuration inheritance loops are not permitted.
See Configuration inheritance.
Return the parent context of the context cfg, if it has one.
Sets parent as the parent context of cfg. If parent is ‘#f’, sets cfg as having no parent context.
Note: Normally, application code should avoid using this function; keeping to the default configuration inheritance structure is recommended in order to ensure consistent behaviour of all libgeda applications.
Some configuration parameters are dangerous; in particular, parameters that may lead to arbitrary code execution need to be handled carefully. Such settings might include:
Configuration contexts can be flagged as being trusted. This allows code that needs to access such dangerous parameters to determine whether the value has been obtained from a safe source.
By default, the default context, system context and user context are trusted, and all other contexts untrusted.
Test whether cfg is a trusted configuration context.
Set whether the configuration context cfg should be trusted as a source for dangerous configuration parameters.
Warning: You should not set a configuration context as trusted unless you are certain that it originated from a safe source (e.g. by interacting with the user to verify it).
If cfg is trusted, returns cfg; otherwise, returns the first parent context of cfg that is a trusted context. If no trusted context can be found, returns ‘#f’.