Back to index

texmacs  1.0.7.15
Functions | Variables
init_texmacs.cpp File Reference
#include "boot.hpp"
#include "file.hpp"
#include "sys_utils.hpp"
#include "analyze.hpp"
#include "convert.hpp"
#include "merge_sort.hpp"
#include "drd_std.hpp"
#include "language.hpp"

Go to the source code of this file.

Functions

void setup_tex ()
void init_tex ()
static url get_env_path (string which)
static void set_env_path (string which, url val)
static url get_env_path (string which, url def)
static url plugin_path (string which)
scheme_tree plugin_list ()
static void init_main_paths ()
static void make_dir (url which)
static void init_user_dirs ()
static void init_guile ()
static void init_env_vars ()
static void init_misc ()
static void init_deprecated ()
string get_setting (string var, string def)
void set_setting (string var, string val)
void setup_texmacs ()
void init_texmacs ()
void init_plugins ()

Variables

tree texmacs_settings = tuple ()
int install_status = 0
bool use_which = false
bool use_locate = false

Function Documentation

static url get_env_path ( string  which) [static]

Definition at line 34 of file init_texmacs.cpp.

                            {
  return url ("$" * which);
}

Here is the caller graph for this function:

static url get_env_path ( string  which,
url  def 
) [static]

Definition at line 46 of file init_texmacs.cpp.

                                     {
  url val= get_env_path (which);
  if (is_none (val) || (val->t == "")) {
    set_env_path (which, def);
    return def;
  }
  return val;
}

Here is the call graph for this function:

string get_setting ( string  var,
string  def 
)

Definition at line 314 of file init_texmacs.cpp.

                                     {
  int i, n= N (texmacs_settings);
  for (i=0; i<n; i++)
    if (is_tuple (texmacs_settings[i], var, 1)) {
      return scm_unquote (as_string (texmacs_settings[i][1]));
    }
  return def;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void init_deprecated ( ) [static]

Definition at line 296 of file init_texmacs.cpp.

                   {
#ifndef OS_WIN32
  // Check for Macaulay 2
  if (get_env ("M2HOME") == "")
    if (exists_in_path ("M2")) {
      string where= concretize (resolve_in_path ("M2"));
      string s    = var_eval_system ("grep 'M2HOME=' " * where);
      string dir  = s (search_forwards ("=", s) + 1, N(s));
      if (dir != "") set_env ("M2HOME", dir);
    }
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void init_env_vars ( ) [static]

Definition at line 209 of file init_texmacs.cpp.

                 {
  // Handle binary, library and guile paths for plugins
  url bin_path= get_env_path ("PATH") | plugin_path ("bin");
  set_env_path ("PATH", bin_path);
  url lib_path= get_env_path ("LD_LIBRARY_PATH") | plugin_path ("lib");
  set_env_path ("LD_LIBRARY_PATH", lib_path);

  // Get TeXmacs style and package paths
  url style_root=
    get_env_path ("TEXMACS_STYLE_ROOT",
                "$TEXMACS_HOME_PATH/styles:$TEXMACS_PATH/styles" |
                plugin_path ("styles"));
  url package_root=
    get_env_path ("TEXMACS_PACKAGE_ROOT",
                "$TEXMACS_HOME_PATH/packages:$TEXMACS_PATH/packages" |
                plugin_path ("packages"));
  url all_root= style_root | package_root;
  url style_path=
    get_env_path ("TEXMACS_STYLE_PATH",
                expand (complete (all_root * url_wildcard (), "dr")));
  url text_root=
    get_env_path ("TEXMACS_TEXT_ROOT",
                "$TEXMACS_HOME_PATH/texts:$TEXMACS_PATH/texts" |
                plugin_path ("texts"));
  url text_path=
    get_env_path ("TEXMACS_TEXT_PATH",
                expand (complete (text_root * url_wildcard (), "dr")));

  // Get other data paths
  (void) get_env_path ("TEXMACS_FILE_PATH",text_path | style_path);
  (void) set_env_path ("TEXMACS_DOC_PATH",
                     get_env_path ("TEXMACS_DOC_PATH") |
                     "$TEXMACS_HOME_PATH/doc:$TEXMACS_PATH/doc" |
                     plugin_path ("doc"));
  (void) set_env_path ("TEXMACS_SECURE_PATH",
                     get_env_path ("TEXMACS_SECURE_PATH") |
                     "$TEXMACS_PATH:$TEXMACS_HOME_PATH");
  (void) get_env_path ("TEXMACS_PATTERN_PATH",
                     "$TEXMACS_HOME_PATH/misc/patterns" |
                     url ("$TEXMACS_PATH/misc/patterns") |
                     plugin_path ("misc/patterns"));
  (void) get_env_path ("TEXMACS_PIXMAP_PATH",
                     "$TEXMACS_HOME_PATH/misc/pixmaps" |
                     url ("$TEXMACS_PATH/misc/pixmaps/modern/24x24/main") |
                     url ("$TEXMACS_PATH/misc/pixmaps/modern/20x20/mode") |
                     url ("$TEXMACS_PATH/misc/pixmaps/modern/16x16/focus") |
                     url ("$TEXMACS_PATH/misc/pixmaps/traditional/--x17") |
                     plugin_path ("misc/pixmaps"));
  (void) get_env_path ("TEXMACS_DIC_PATH",
                     "$TEXMACS_HOME_PATH/langs/natural/dic" |
                     url ("$TEXMACS_PATH/langs/natural/dic") |
                     plugin_path ("langs/natural/dic"));
#ifdef OS_WIN32
  set_env ("TEXMACS_SOURCE_PATH", "");
#else
  set_env ("TEXMACS_SOURCE_PATH", TEXMACS_SOURCES);
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void init_guile ( ) [static]

Definition at line 152 of file init_texmacs.cpp.

              {
  url guile_path= "$TEXMACS_PATH/progs:$GUILE_LOAD_PATH";
  if (!exists (guile_path * "init-texmacs.scm")) {
    cerr << "\nTeXmacs]\n";
    cerr << "TeXmacs] Installation problem: please send a bug report.\n";
    cerr << "TeXmacs] The initialization file init-texmacs.scm"
        << " could not be found.\n";
    cerr << "TeXmacs] Please check the values of the environment variables\n";
    cerr << "TeXmacs] TEXMACS_PATH and GUILE_LOAD_PATH."
        << " init-texmacs.scm should\n";
    cerr << "TeXmacs] be readable and in the directory $TEXMACS_PATH/progs\n";
    cerr << "TeXmacs] or in the directory $GUILE_LOAD_PATH\n";
    cerr << "TeXmacs]\n";
    FAILED ("guile could not be found");
  }

  /*
  if (!exists ("$GUILE_LOAD_PATH/ice-9/boot-9.scm")) {
    int i;
    string guile_data    = var_eval_system ("guile-config info datadir");
    string guile_version = var_eval_system ("guile --version");
    for (i=0; i<N(guile_version); i++)
      if (guile_version[i] == '\n') break;
    guile_version= guile_version (0, i);
    for (i=N(guile_version); i>0; i--)
      if (guile_version[i-1] == ' ') break;
    guile_version= guile_version (i, N (guile_version));
    if (guile_version == "") {
      var_eval_system ("guile-config info top_srcdir");
      for (i=N(guile_version); i>0; i--)
       if (guile_version[i-1] == '-') break;
      guile_version= guile_version (i, N (guile_version));
      for (i=0; i<N(guile_version); i++)
       if ((guile_version[i] == '/') || (guile_version[i] == '\\')) {
         guile_version= guile_version (0, i);
         break;
       }
    }
    url guile_dir= url_system (guile_data) * url ("guile", guile_version);
    guile_path= guile_path | guile_dir;
    set_env_path ("GUILE_LOAD_PATH", guile_path);
    if (!exists ("$GUILE_LOAD_PATH/ice-9/boot-9.scm")) {
      cerr << "\nGUILE_LOAD_PATH=" << guile_path << "\n";
      FAILED ("guile seems not to be installed on your system");
    }
  }
  */

  guile_path= guile_path | "$TEXMACS_HOME_PATH/progs" | plugin_path ("progs");
  set_env_path ("GUILE_LOAD_PATH", guile_path);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void init_main_paths ( ) [static]

Definition at line 83 of file init_texmacs.cpp.

                   {
#ifdef __MINGW32__
  if (is_none (get_env_path ("TEXMACS_HOME_PATH", get_env ("APPDATA") * "/TeXmacs"))) {
#else
  if (is_none (get_env_path ("TEXMACS_HOME_PATH", "~/.TeXmacs"))) {
#endif
    cerr << "\nTeXmacs]\n";
    cerr << "TeXmacs] Installation problem: please send a bug report.\n";
    cerr << "TeXmacs] 'TEXMACS_HOME_PATH' could not be set to '~/.TeXmacs'.\n";
    cerr << "TeXmacs] You may try to set this environment variable manually\n";
    cerr << "TeXmacs]\n";
    FAILED ("installation problem");
    exit (1);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void init_misc ( ) [static]

Definition at line 273 of file init_texmacs.cpp.

             {
  // Test whether 'which' works
#if defined(__MINGW__) || defined(__MINGW32__) || defined (OS_WIN32)
  use_which = false;
#else
  use_which = (var_eval_system ("which texmacs 2> /dev/null") != "");
#endif
  //string loc= var_eval_system ("locate bin/locate 2> /dev/null");
  //use_locate= (search_forwards ("bin/locate", loc) > 0);

  // Set extra environment variables for Cygwin
#ifdef OS_CYGWIN
  set_env ("CYGWIN", "check_case:strict");
  set_env ("COMSPEC", "");
  set_env ("ComSpec", "");
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

void init_plugins ( )

Definition at line 387 of file init_texmacs.cpp.

                {
  install_status= 0;
  url old_settings= "$TEXMACS_HOME_PATH/system/TEX_PATHS";
  url new_settings= "$TEXMACS_HOME_PATH/system/settings.scm";
  string s;
  if (load_string (new_settings, s, false)) {
    if (load_string (old_settings, s, false)) {
      setup_texmacs ();
      install_status= 1;
    }
    else get_old_settings (s);
  }
  else texmacs_settings= block_to_scheme_tree (s);
  if (get_setting ("VERSION") != TEXMACS_VERSION) {
    init_upgrade ();
    url ch ("$TEXMACS_HOME_PATH/doc/about/changes/changes-recent.en.tm");
    install_status= exists (ch)? 2: 0;
  }
  init_tex ();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void init_tex ( )

Definition at line 155 of file tex_init.cpp.

            {
  reset_tfm_path (false);
  reset_pk_path (false);
  reset_pfb_path ();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void init_texmacs ( )

Definition at line 371 of file init_texmacs.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

static void init_user_dirs ( ) [static]

Definition at line 110 of file init_texmacs.cpp.

                  {
  make_dir ("$TEXMACS_HOME_PATH");
  make_dir ("$TEXMACS_HOME_PATH/bin");
  make_dir ("$TEXMACS_HOME_PATH/doc");
  make_dir ("$TEXMACS_HOME_PATH/doc/about");
  make_dir ("$TEXMACS_HOME_PATH/doc/about/changes");
  make_dir ("$TEXMACS_HOME_PATH/fonts");
  make_dir ("$TEXMACS_HOME_PATH/fonts/enc");
  make_dir ("$TEXMACS_HOME_PATH/fonts/error");
  make_dir ("$TEXMACS_HOME_PATH/fonts/pk");
  make_dir ("$TEXMACS_HOME_PATH/fonts/tfm");
  make_dir ("$TEXMACS_HOME_PATH/fonts/truetype");
  make_dir ("$TEXMACS_HOME_PATH/fonts/type1");
  make_dir ("$TEXMACS_HOME_PATH/fonts/virtual");
  make_dir ("$TEXMACS_HOME_PATH/langs");
  make_dir ("$TEXMACS_HOME_PATH/langs/mathematical");
  make_dir ("$TEXMACS_HOME_PATH/langs/mathematical/syntax");
  make_dir ("$TEXMACS_HOME_PATH/langs/natural");
  make_dir ("$TEXMACS_HOME_PATH/langs/natural/dic");
  make_dir ("$TEXMACS_HOME_PATH/langs/natural/hyphen");
  make_dir ("$TEXMACS_HOME_PATH/langs/programming");
  make_dir ("$TEXMACS_HOME_PATH/misc");
  make_dir ("$TEXMACS_HOME_PATH/misc/patterns");
  make_dir ("$TEXMACS_HOME_PATH/misc/pixmaps");
  make_dir ("$TEXMACS_HOME_PATH/packages");
  make_dir ("$TEXMACS_HOME_PATH/plugins");
  make_dir ("$TEXMACS_HOME_PATH/progs");
  make_dir ("$TEXMACS_HOME_PATH/styles");
  make_dir ("$TEXMACS_HOME_PATH/system");
  make_dir ("$TEXMACS_HOME_PATH/system/bib");
  make_dir ("$TEXMACS_HOME_PATH/system/cache");
  make_dir ("$TEXMACS_HOME_PATH/system/tmp");
  make_dir ("$TEXMACS_HOME_PATH/texts");
  change_mode ("$TEXMACS_HOME_PATH/system", 7 << 6);
  remove (url ("$TEXMACS_HOME_PATH/system/tmp") * url_wildcard ("*"));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void make_dir ( url  which) [static]

Definition at line 104 of file init_texmacs.cpp.

                     {
  if (!is_directory (which))
    mkdir (which);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 63 of file init_texmacs.cpp.

               {
  bool flag;
  array<string> a= read_directory ("$TEXMACS_PATH/plugins", flag);
  a << read_directory ("/etc/TeXmacs/plugins", flag);
  a << read_directory ("$TEXMACS_HOME_PATH/plugins", flag);
  a << read_directory ("/usr/share/TeXmacs/plugins", flag);
  merge_sort (a);
  int i, n= N(a);
  tree t (TUPLE);
  for (i=0; i<n; i++)
    if ((a[i] != ".") && (a[i] != "..") && ((i==0) || (a[i] != a[i-1])))
      t << a[i];
  return t;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static url plugin_path ( string  which) [static]

Definition at line 56 of file init_texmacs.cpp.

                           {
  url base= "$TEXMACS_HOME_PATH:/etc/TeXmacs:$TEXMACS_PATH:/usr/share/TeXmacs";
  url search= base * "plugins" * url_wildcard ("*") * which;
  return expand (complete (search, "r"));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void set_env_path ( string  which,
url  val 
) [static]

Definition at line 39 of file init_texmacs.cpp.

                                     {
  //cout << which << " := " << val << "\n";
  if ((!is_none (val)) && (val->t != ""))
    set_env (which, as_string (val));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void set_setting ( string  var,
string  val 
)

Definition at line 324 of file init_texmacs.cpp.

                                     {
  int i, n= N (texmacs_settings);
  for (i=0; i<n; i++)
    if (is_tuple (texmacs_settings[i], var, 1)) {
      texmacs_settings[i][1]= scm_quote (val);
      return;
    }
  texmacs_settings << tuple (var, scm_quote (val));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void setup_tex ( )

Definition at line 148 of file tex_init.cpp.

             {
  remove ("$TEXMACS_HOME_PATH/fonts/font-index.scm");
  init_helper_binaries ();
  init_heuristic_tex_paths ();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void setup_texmacs ( )

Definition at line 339 of file init_texmacs.cpp.

                 {
  url settings_file= "$TEXMACS_HOME_PATH/system/settings.scm";
  cerr << "Welcome to TeXmacs " TEXMACS_VERSION "\n";
  cerr << HRULE;

  set_setting ("VERSION", TEXMACS_VERSION);
  setup_tex ();
  
  string s= scheme_tree_to_block (texmacs_settings);
  //cout << "settings_t= " << texmacs_settings << "\n";
  //cout << "settings_s= " << s << "\n";
  if (save_string (settings_file, s) || load_string (settings_file, s, false)) {
    cerr << HRULE;
    cerr << "I could not save or reload the file\n\n";
    cerr << "\t" << settings_file << "\n\n";
    cerr << "Please give me full access control over this file and\n";
    cerr << "rerun 'TeXmacs'.\n";
    cerr << HRULE;
    FAILED ("unable to write settings");
  }
  
  cerr << HRULE;
  cerr << "Installation completed successfully !\n";
  cerr << "I will now start up the editor\n";
  cerr << HRULE;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

int install_status = 0

Definition at line 22 of file init_texmacs.cpp.

Definition at line 21 of file init_texmacs.cpp.

bool use_locate = false

Definition at line 24 of file init_texmacs.cpp.

bool use_which = false

Definition at line 23 of file init_texmacs.cpp.