Back to index

texmacs  1.0.7.15
generic.cpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : generic.cpp
00004 * DESCRIPTION: routines for generic formats
00005 * COPYRIGHT  : (C) 2000  Joris van der Hoeven
00006 *******************************************************************************
00007 * This software falls under the GNU general public license version 3 or later.
00008 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00009 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00010 ******************************************************************************/
00011 
00012 #include "convert.hpp"
00013 #include "file.hpp"
00014 #include "scheme.hpp"
00015 
00016 static url current_file_focus= url_none ();
00017 
00018 bool
00019 is_snippet (tree doc) {
00020   if (!is_document (doc)) return true;
00021   int i, n= N(doc);
00022   for (i=0; i<n; i++)
00023     if (is_compound (doc[i], "TeXmacs", 1))
00024       return false;
00025   return true;
00026 }
00027 
00028 string
00029 get_texmacs_path () {
00030   string tmpath= get_env ("TEXMACS_PATH");
00031   while ((N(tmpath)>0) && (tmpath [N(tmpath) - 1] == '/'))
00032     tmpath= tmpath (0, N(tmpath)-1);
00033   return tmpath;
00034 }
00035 
00036 url
00037 get_file_focus () {
00038   return current_file_focus;
00039 }
00040 
00041 void
00042 set_file_focus (url u) {
00043   current_file_focus= u;
00044 }
00045 
00046 string
00047 suffix_to_format (string suffix) {
00048   return as_string (call ("format-from-suffix", suffix));
00049 }
00050 
00051 string
00052 format_to_suffix (string fm) {
00053   return as_string (call ("format-default-suffix", fm));
00054 }
00055 
00056 string
00057 get_format (string s, string suffix) {
00058   return as_string (call ("format-determine", s, suffix));
00059 }
00060 
00061 tree
00062 generic_to_tree (string s, string fm) {
00063   return as_tree (call ("generic->texmacs", s, fm));
00064 }
00065 
00066 string
00067 tree_to_generic (tree doc, string fm) {
00068   return as_string (call ("texmacs->generic", doc, fm));
00069 }