Back to index

texmacs  1.0.7.15
Functions | Variables
edit_process.cpp File Reference
#include "Process/edit_process.hpp"
#include "analyze.hpp"
#include "tm_buffer.hpp"
#include "merge_sort.hpp"
#include "Bibtex/bibtex.hpp"
#include "Bibtex/bibtex_functions.hpp"
#include "file.hpp"
#include "convert.hpp"
#include "scheme.hpp"

Go to the source code of this file.

Functions

url find_bib_file (url base, string fname, string suffix=".bib")
static string index_name_sub (tree t, bool all)
static string index_name (tree t)
static tree index_value (tree t)
static void insert_recursively (array< string > &a, string s, hashmap< string, tree > &h)
static void make_entry (tree &D, tree t)
static bool is_aux (tree t)

Variables

static hashmap< string, treefollowup (TUPLE)

Function Documentation

url find_bib_file ( url  base,
string  fname,
string  suffix = ".bib" 
)

Definition at line 34 of file edit_process.cpp.

                                                              {
  if (!ends (fname, suffix)) fname= fname * suffix;
  url bibf (fname);
  if (exists (bibf))
    return bibf;
  if (exists (relative (base, bibf)))
    return relative (base, bibf);
  if (exists (expand (relative (base, url_ancestor () * bibf))))
    return resolve (expand (relative (base, url_ancestor () * bibf)));
  return url_none ();
}

Here is the call graph for this function:

Here is the caller graph for this function:

static string index_name ( tree  t) [static]

Definition at line 150 of file edit_process.cpp.

                    {
  if (is_func (t, TUPLE, 2)) t= t[0];
  else if (is_func (t, TUPLE, 3)) t= t[0];
  else if (is_func (t, TUPLE, 5)) {
    if (t[0] == "") t= t[3];
    else t= t[0];
  }
  if (!is_tuple (t)) t= tuple (t);
  return locase_all (index_name_sub (t, false));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static string index_name_sub ( tree  t,
bool  all 
) [static]

Definition at line 112 of file edit_process.cpp.

                                  {
  if (is_atomic (t)) {
    string s= t->label, r;
    int i, n= N(s);
    for (i=0; i<n; i++)
      if (is_iso_alpha (s[i]) || is_digit (s[i]) || (s[i] == ' ') ||
         (all && (s[i] >= ' '))) r << s[i];
    return r;
  }
  else if (is_concat (t)) {
    string r;
    int i, n= N(t);
    for (i=0; i<n; i++)
      r << index_name_sub (t[i], all);
    return r;
  }
  else if (is_tuple (t)) {
    string r;
    int i, j, n= N(t);
    for (i=0; i<n; i++) {
      if (i!=0) r << "\t";
      string s= index_name_sub (t[i], false);
      if (s == "") s= index_name_sub (t[i], true);
      tree u= copy (followup [s]);
      for (j=0; j<N(u); j++)
       if (u[j] == t[i]) break;
      if (j == N(u)) { u << t[i]; followup (s)= u; }
      r << s;
      if (j != 0) r << "\n" << as_string (j);
    }
    return r;
  }
  else if (all && is_func (t, WITH))
    return index_name_sub (t[N(t)-1], all);
  else return "";
}

Here is the call graph for this function:

Here is the caller graph for this function:

static tree index_value ( tree  t) [static]

Definition at line 162 of file edit_process.cpp.

                     {
  if (is_func (t, TUPLE, 2)) return t;
  else if (is_func (t, TUPLE, 3)) return tuple (t[2]);
  else if (is_func (t, TUPLE, 5)) {
    tree l= t[3], r= t[4];
    if (!is_tuple (l)) l= tuple (l);
    if (t[1] == "strong") r= compound ("strong", r);
    if (t[2] != "") r= tuple ("range", t[2], r);
    return tuple (l, r);
  }
  return "";
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void insert_recursively ( array< string > &  a,
string  s,
hashmap< string, tree > &  h 
) [static]

Definition at line 176 of file edit_process.cpp.

                                                                         {
  // cout << "Insert recursively \t" << s << "\n";
  int i= search_backwards ("\t", s);
  if (i != -1) {
    string r= s (0, i);
    if (!h->contains (r)) {
      tree u= h[s][0][0];
      h (r)= tuple (tuple (copy (u (0, N(u)-1)), ""));
      insert_recursively (a, s (0, i), h);
    }
  }
  a << s;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static bool is_aux ( tree  t) [static]

Definition at line 330 of file edit_process.cpp.

                {
  return
    is_compound (t, "bibliography", 4) ||
    is_compound (t, "bibliography*", 5) ||
    is_compound (t, "table-of-contents", 2) ||
    is_compound (t, "table-of-contents*", 3) ||
    is_compound (t, "the-index", 2) ||
    is_compound (t, "the-index*", 3) ||
    is_compound (t, "the-glossary", 2) ||
    is_compound (t, "the-glossary*", 3) ||
    is_compound (t, "list-of-figures", 2) ||
    is_compound (t, "list-of-tables", 2);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void make_entry ( tree D,
tree  t 
) [static]

Definition at line 191 of file edit_process.cpp.

                             {
  // cout << "Make entry " << t << "\n";
  int i, j, n= N(t);
  for (i=0; i<n; i++)
    if (is_func (t[i], TUPLE, 1)) {
      bool flag= true;
      for (j=0; j<n; j++)
       if (is_func (t[j], TUPLE, 2) && (t[i][0] == t[j][0]))
         flag= false;
      if (flag) D << t[i][0];
    }

  for (i=0; i<n; i++)
    if (is_func (t[i], TUPLE, 2) && is_tuple (t[i][1], "range", 2)) {
      bool flag= true;
      for (j=i+1; j<n; j++)
       if (is_func (t[j], TUPLE, 2) && is_tuple (t[j][1], "range", 2))
         if ((t[i][0] == t[j][0]) && (t[i][1][1] == t[j][1][1])) {
           t[i][1]= tree (CONCAT, t[i][1][2], "--", t[j][1][2]);
           t[j]= "";
           flag= false;
           break;
         }
      if (flag) t[i][1]= tree (CONCAT, t[i][1][2], "--?");
    }

  hashmap<tree,tree> h ("");
  for (i=0; i<n; i++)
    if (is_func (t[i], TUPLE, 2)) {
      tree l= t[i][0], r= t[i][1];
      if (!h->contains (l)) h (l)= r;
      else {
       tree rr= h[l];
       if (rr == "") rr= r;
       else if (r != "") {
         if (!is_concat (rr)) rr= tree (CONCAT, rr);
         rr << ", " << r;
       }
       h (l)= rr;
      }
    }

  for (i=0; i<n; i++)
    if (is_func (t[i], TUPLE, 2)) {
      tree l= t[i][0];
      if (h->contains (l)) {
       int k= N(l);
       tree e= compound ("index-" * as_string (k), copy (l[k-1]), h[l]);
       if (h[l] == "")
         e= compound ("index-" * as_string (k) * "*", copy (l[k-1]));
       D << e;
       h->reset (l);
      }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation