Local Library

From Gwen Morse's Wiki
Jump to: navigation, search
;;;; Routines to maintain a local library, allow /require-style loading, and
;;;; generally make life a keener place to be.
;;;; Load the main file from the normal library, then use /requirelocal to
;;;; read in files from the local library. Local libraries should call
;;;; /~loadedlocal when starting. Searches are done in the directory stored
;;;; in LOCALLIBDIR, which defaults to ~/locallib if no value is previously
;;;; set.
;;;; Written by Joel Baker (lucifer at lightbearer dot com), derived from 
;;;; the TF standard libraries.

;;;; Caveat from Gwen: this is less useful now that most people don't use shell
;;;; accounts with a single system-wide installation of Tinyfugue.
;;;; For people who like to keep "standard libraries" separate from user-defined
;;;; stuff it's still useful. 

/if /test LOCALLIBDIR =~ ""%; /then \
    /set LOCALLIBDIR=~/tf/locallib%; \

/set _loaded_local_libs=

/def -i ~loadedlocal = \
    /if /test _loaded_local_libs !/ "*{%{1}}*"%; /then \
        /set _loaded_local_libs=%{_loaded_local_libs} %{1}%;\

/def -i requirelocal = \
    /if /test _loaded_local_libs !/ "*{%{1}}*"%; /then \
        /load %{LOCALLIBDIR}/%{1}%;\