d=getenv("TEXMACS_PATH");
if (length(d) > 0)
    # Add the following directories to Octave's ``load path'':
    #   - ${TEXMACS_PATH}/plugins/octave/octave/tm
    #   - ${TEXMACS_PATH}/plugins/octave/octave/plot
    #   - ${TEXMACS_PATH}/plugins/octave/octave/polynomial
    if (exist ("OCTAVE_VERSION") == 5)
        # As of Octave version 3, "instead of setting the built-in variable
        # LOADPATH, you must use addpath [...] to manipulate the function
        # search path." [1]
        fsep=filesep();
        prefix=[d,fsep,"plugins",fsep,"octave",fsep,"octave",fsep];
        addpath ([prefix,"tm"],         "-end");
        addpath ([prefix,"plot"],       "-end");
        addpath ([prefix,"polynomial"], "-end");
        # NB: filesep() is used above for portability.
    else
        LOADPATH=[LOADPATH,                              \
                  [d,"/plugins/octave/octave/tm:"],      \
                  [d,"/plugins/octave/octave/plot:"],    \
                  [d,"/plugins/octave/octave/polynomial:"]];
    endif

    # Customize the command-line prompt.
    if (exist ("OCTAVE_VERSION") == 5)
        # As of Octave version 3, "all built-in variables have been converted
        # to functions." [1]
        PS1("\\002channel:prompt\\005octave> \\005");
        PS2("\\002channel:prompt\\005> \\005");
    else
        PS1="\\002channel:prompt\\005octave> \\005";
        PS2="\\002channel:prompt\\005> \\005";
    endif

    # Define some global variables.
    global TMSTRUCT=0;
    global TMCOLORS=["black"; "red"; "magenta"; "orange"; "green"; "blue";];
    global TMCOLIDX=rows(TMCOLORS);
endif

# [1] <http://www.gnu.org/software/octave/NEWS-3.html>
