A few small patches

View: New views
13 Messages — Rating Filter:   Alert me  

A few small patches

by Norbert Nemec :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi there,

I have here four small patches fixing some minor problems.

Greetings,
Norbert

From e37863bec96b8b6b8e327b2a6971b949989e85e7 Mon Sep 17 00:00:00 2001
From: Norbert Nemec <Norbert@...>
Date: Wed, 7 Oct 2009 12:16:56 +0100
Subject: [PATCH 01/11] Do selection_get_cut operations on the "tmp" buffer by default. The "primary" buffer should only be used by explicit cut&paste operations by the user.

---
 src/src/Edit/Replace/edit_select.cpp |   42 +++++++++++++++++-----------------
 1 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/src/src/Edit/Replace/edit_select.cpp b/src/src/Edit/Replace/edit_select.cpp
index 571609a..82f7711 100644
--- a/src/src/Edit/Replace/edit_select.cpp
+++ b/src/src/Edit/Replace/edit_select.cpp
@@ -801,27 +801,27 @@ edit_select_rep::raw_cut (path p1, path p2) {
 void
 edit_select_rep::selection_cut (string key) {
   if (inside_active_graphics ()) {
-    tree t= as_tree (eval ("(graphics-cut)"));
-    selection_set (key, t);
-    return;
-  }
-  if (!selection_active_any ()) return;
-  if (selection_active_table ()) {
-    path p1= start_p, p2= end_p;
-    tree sel= selection_get ();
-    selection_set (key, sel);
-    cut (p1, p2);
-  }
-  else {
+    if(key != "none") {
+      tree t= as_tree (eval ("(graphics-cut)"));
+      selection_set (key, t);
+    }
+  } else if (selection_active_any ()) {
     path p1, p2;
-    selection_get (p1, p2);
-    go_to (p2);
-    if (p2 == p1) return;
-
-    tree sel= compute_selection (et, p1, p2);
-    // cout << "Selection " << sel << "\n";
-    selection_set (key, simplify_correct (sel));
-    // cout << "Selected  " << sel << "\n";
+    if (selection_active_table ()) {
+      p1= start_p; p2= end_p;
+      if(key != "none") {
+        tree sel= selection_get ();
+        selection_set (key, sel);
+      }
+    } else {
+      selection_get (p1, p2);
+      go_to (p2);
+      if (p2 == p1) return;
+      if(key != "none") {
+        tree sel= compute_selection (et, p1, p2);
+        selection_set (key, simplify_correct (sel));
+      }
+    }
     cut (p1, p2);
   }
 }
@@ -829,7 +829,7 @@ edit_select_rep::selection_cut (string key) {
 tree
 edit_select_rep::selection_get_cut () {
   tree t= selection_get ();
-  selection_cut ();
+  selection_cut ("none");
   return t;
 }
 
--
1.6.3.3


From 5615cdc68f4838f1505f308be44be449b20da78e Mon Sep 17 00:00:00 2001
From: Norbert Nemec <Norbert@...>
Date: Wed, 7 Oct 2009 12:16:56 +0100
Subject: [PATCH 02/11] Fix two minor memory leaks

---
 src/src/Plugins/X11/x_window.cpp  |   10 ++++++++--
 src/src/System/Misc/sys_utils.cpp |    5 ++++-
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/src/Plugins/X11/x_window.cpp b/src/src/Plugins/X11/x_window.cpp
index ae42811..2ee5aec 100644
--- a/src/src/Plugins/X11/x_window.cpp
+++ b/src/src/Plugins/X11/x_window.cpp
@@ -66,6 +66,12 @@ x_window_rep::set_hints (SI min_w, SI min_h, SI max_w, SI max_h) {
     wm_hints,
     class_hints
   );
+
+  XFree(size_hints);
+  XFree(wm_hints);
+  XFree(class_hints);
+  XFree(Window_Name.value);
+  XFree(Icon_Name.value);
   // cout << "Setting hints required " << (texmacs_time ()-start_2) << " ms\n";
 }
 
@@ -78,7 +84,7 @@ x_window_rep::initialize () {
   dpy= gui->dpy;
   gc = gui->gc;
   full_screen_flag= false;
-  
+
   // int start_1= texmacs_time ();
   ren->set_origin (0, 0);
   ren->decode (def_w, def_h); def_h= -def_h;
@@ -284,7 +290,7 @@ x_window_rep::get_name () {
 void
 x_window_rep::set_visibility (bool flag) {
   if (flag) XMapRaised (dpy, win);
-  else XUnmapWindow (dpy, win);  
+  else XUnmapWindow (dpy, win);
 }
 
 void
diff --git a/src/src/System/Misc/sys_utils.cpp b/src/src/System/Misc/sys_utils.cpp
index 7dc9c09..7782aff 100644
--- a/src/src/System/Misc/sys_utils.cpp
+++ b/src/src/System/Misc/sys_utils.cpp
@@ -86,9 +86,12 @@ set_env (string var, string with) {
   char* _var = as_charp (var);
   char* _with= as_charp (with);
   setenv (_var, _with, 1);
+  tm_delete_array(_var);
+  tm_delete_array(_with);
 #else
   char* _varw= as_charp (var * "=" * with);
   (void) putenv (_varw);
+  // do not delete _varw !!!
+  // -> known memory leak, but solution more complex than it is worth
 #endif
-  // do not delete _var and _with !!!
 }
--
1.6.3.3


From b22de9ca9044aaaff821ce726b43144272817629 Mon Sep 17 00:00:00 2001
From: Norbert Nemec <Norbert@...>
Date: Wed, 7 Oct 2009 12:16:56 +0100
Subject: [PATCH 03/11] Fix some issues in the cork-to-latex converter. Also remove non-ascii characters from the sources.
 (These are nasty in some editors)

ToDo: output \usepackage[T1]{fontenc} only when really needed
---
 .../progs/convert/latex/latex-texmacs-drd.scm      |  228 ++++++++++++++------
 src/TeXmacs/progs/convert/latex/latex-tools.scm    |    5 +-
 src/TeXmacs/progs/convert/latex/tmtex.scm          |    3 -
 3 files changed, 164 insertions(+), 72 deletions(-)

diff --git a/src/TeXmacs/progs/convert/latex/latex-texmacs-drd.scm b/src/TeXmacs/progs/convert/latex/latex-texmacs-drd.scm
index 55473c4..587efe4 100644
--- a/src/TeXmacs/progs/convert/latex/latex-texmacs-drd.scm
+++ b/src/TeXmacs/progs/convert/latex/latex-texmacs-drd.scm
@@ -470,73 +470,167 @@
 ;; Catcode tables
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-(drd-table iso-latin-catcodes%
-  ("à" "\\`a")
-  ("À" "\\`A")
-  ("á" "\\'a")
-  ("Á" "\\'A")
-  ("ä" "\\\"a")
-  ("Ä" "\\\"A")
-  ("â" "\\^a")
-  ("Â" "\\^A")
-  ("å" "{\\aa}")
-  ("Å" "{\\AA}")
-  ("Ã" "\\~A")
-  ("ã" "\\~a")
-  ("Æ" "{\\AE}")
-  ("æ" "{\\ae}")
-  ("ç" "\\c{c}")
-  ("Ç" "\\c{C}")
-  ("ð" "{\\dh}")
-  ("Ð" "{\\DH}")
-  ("è" "\\`e")
-  ("È" "\\`E")
-  ("é" "\\'e")
-  ("É" "\\'E")
-  ("ë" "\\\"e")
-  ("Ë" "\\\"E")
-  ("ê" "\\^e")
-  ("Ê" "\\^E")
-  ("ì" "\\`{\\i}")
-  ("Ì" "\\`I")
-  ("í" "\\'{\\i}")
-  ("Í" "\\'I")
-  ("ï" "\\\"{\\i}")
-  ("Ï" "\\\"I")
-  ("î" "\\^{\\i}")
-  ("Î" "\\^I")
-  ("Ñ" "\\~N")
-  ("ñ" "\\~n")
-  ("ò" "\\`o")
-  ("Ò" "\\`O")
-  ("ó" "\\'o")
-  ("Ó" "\\'O")
-  ("ö" "\\\"o")
-  ("Ö" "\\\"O")
-  ("ô" "\\^o")
-  ("Ô" "\\^O")
-  ("Õ" "\\~O")
-  ("õ" "\\~o")
-  ("Ø" "{\\O}")
-  ("ø" "{\\o}")
-  ("ß" "{\\ss}")
-  ("þ" "{\\th}")
-  ("Þ" "{\\TH}")
-  ("ù" "\\`u")
-  ("Ù" "\\`U")
-  ("ú" "\\'u")
-  ("Ú" "\\'U")
-  ("ü" "\\\"u")
-  ("Ü" "\\\"U")
-  ("û" "\\^u")
-  ("Û" "\\^U")
-  ("ý" "\\'y")
-  ("Ý" "\\'Y")
-  ("ÿ" "\\\"y")
-  ("¾" "\\\"Y")
-  ("¡" "!`")
-  ("" "?`")
-  ("¿" "?`"))
+(drd-table corkT1-to-latex-catcodes%
+  ("\x00" "\\`{ }")
+  ("\x01" "\\'{ }")
+  ("\x02" "\\^{ }")
+  ("\x03" "\\~{ }")
+  ("\x04" "\\\"{ }")
+  ("\x05" "\\H{ }")
+  ("\x06" "\\r{ }")
+  ("\x07" "\\v{ }")
+  ("\x08" "\\u{ }")
+  ("\x09" "\\b{ }")
+;  ("\x0A" "\\.{ }") ; newline may still be present in strings!!!
+  ("\x0B" "\\c{ }")
+  ("\x0C" "\\k{ }")
+  ("\x0D" ",")
+  ("\x0E" "{\\guilsinglleft}")
+  ("\x0F" "{\\guilsinglright}")
+  ("\x10" "``")
+  ("\x11" "''")
+  ("\x12" ",,")
+  ("\x13" "<<")
+  ("\x14" ">>")
+  ("\x15" "--")
+  ("\x16" "---")
+  ("\x17" "{}")
+  ("\x18" "{}")
+  ("\x19" "\\i")
+  ("\x1A" "\\j")
+  ("\x1B" "ff")
+  ("\x1C" "fi")
+  ("\x1D" "fl")
+  ("\x1E" "ffi")
+  ("\x1F" "ffl")
+  ("\x80" "\\u{A}")
+  ("\x81" "\\k{A}")
+  ("\x82" "\\'C")
+  ("\x83" "\\v{C}")
+  ("\x84" "\\v{D}")
+  ("\x85" "\\v{E}")
+  ("\x86" "\\k{E}")
+  ("\x87" "\\u{G}")
+  ("\x88" "\\'L")
+  ("\x89" "\\v{L}")
+  ("\x8A" "\\L")
+  ("\x8B" "\\'N")
+  ("\x8C" "\\v{N}")
+  ("\x8D" "{\\NG}")
+  ("\x8E" "\\H{O}")
+  ("\x8F" "\\'R")
+  ("\x90" "\\v{R}")
+  ("\x91" "\\'S")
+  ("\x92" "\\v{S}")
+  ("\x93" "\\c{S}")
+  ("\x94" "\\v{T}")
+  ("\x95" "\\c{T}")
+  ("\x96" "\\H{U}")
+  ("\x97" "\\r{U}")
+  ("\x98" "\\\"Y")
+  ("\x99" "\\'Z")
+  ("\x9A" "\\v{Z}")
+  ("\x9B" "\\.Z")
+  ("\x9C" "IJ")
+  ("\x9D" "\\.I")
+  ("\x9E" "{\\dj}")
+  ("\x9F" "{\\S}")
+  ("\xA0" "\\u{a}")
+  ("\xA1" "\\k{a}")
+  ("\xA2" "\\'c")
+  ("\xA3" "\\v{c}")
+  ("\xA4" "\\v{d}")
+  ("\xA5" "\\v{e}")
+  ("\xA6" "\\k{e}")
+  ("\xA7" "\\u{g}")
+  ("\xA8" "\\'l")
+  ("\xA9" "\\v{l}")
+  ("\xAA" "{\\l}")
+  ("\xAB" "\\'n")
+  ("\xAC" "\\v{n}")
+  ("\xAD" "{\\ng}")
+  ("\xAE" "\\H{o}")
+  ("\xAF" "\\'r")
+  ("\xB0" "\\v{r}")
+  ("\xB1" "\\'s")
+  ("\xB2" "\\v{s}")
+  ("\xB3" "\\c{s}")
+  ("\xB4" "\\v{t}")
+  ("\xB5" "\\c{t}")
+  ("\xB6" "\\H{u}")
+  ("\xB7" "\\r{u}")
+  ("\xB8" "\\\"y")
+  ("\xB9" "\\'z")
+  ("\xBA" "\\v{z}")
+  ("\xBB" "\\.z")
+  ("\xBC" "ij")
+  ("\xBD" "!`")
+  ("\xBE" "?`")
+  ("\xBF" "{\\pounds}")
+  ("\xC0" "\\`A")
+  ("\xC1" "\\'A")
+  ("\xC2" "\\^A")
+  ("\xC3" "\\~A")
+  ("\xC4" "\\\"A")
+  ("\xC5" "{\\AA}")
+  ("\xC6" "{\\AE}")
+  ("\xC7" "\\c{C}")
+  ("\xC8" "\\`E")
+  ("\xC9" "\\'E")
+  ("\xCA" "\\^E")
+  ("\xCB" "\\\"E")
+  ("\xCC" "\\`I")
+  ("\xCD" "\\'I")
+  ("\xCE" "\\^I")
+  ("\xCF" "\\\"I")
+  ("\xD0" "{\\DH}")
+  ("\xD1" "\\~N")
+  ("\xD2" "\\`O")
+  ("\xD3" "\\'O")
+  ("\xD4" "\\^O")
+  ("\xD5" "\\~O")
+  ("\xD6" "\\\"O")
+  ("\xD7" "{\\OE}")
+  ("\xD8" "{\\O}")
+  ("\xD9" "\\`U")
+  ("\xDA" "\\'U")
+  ("\xDB" "\\^U")
+  ("\xDC" "\\\"U")
+  ("\xDD" "\\'Y")
+  ("\xDE" "{\\TH}")
+  ("\xDF" "{\\SS}")
+  ("\xE0" "\\`a")
+  ("\xE1" "\\'a")
+  ("\xE2" "\\^a")
+  ("\xE3" "\\~a")
+  ("\xE4" "\\\"a")
+  ("\xE5" "{\\aa}")
+  ("\xE6" "{\\ae}")
+  ("\xE7" "\\c{c}")
+  ("\xE8" "\\`e")
+  ("\xE9" "\\'e")
+  ("\xEA" "\\^e")
+  ("\xEB" "\\\"e")
+  ("\xEC" "\\`{\\i}")
+  ("\xED" "\\'{\\i}")
+  ("\xEE" "\\^{\\i}")
+  ("\xEF" "\\\"{\\i}")
+  ("\xF0" "{\\dh}")
+  ("\xF1" "\\~n")
+  ("\xF2" "\\`o")
+  ("\xF3" "\\'o")
+  ("\xF4" "\\^o")
+  ("\xF5" "\\~o")
+  ("\xF6" "\\\"o")
+  ("\xF7" "{\\oe}")
+  ("\xF8" "{\\o}")
+  ("\xF9" "\\`u")
+  ("\xFA" "\\'u")
+  ("\xFB" "\\^u")
+  ("\xFC" "\\\"u")
+  ("\xFD" "\\'y")
+  ("\xFE" "{\\th}")
+  ("\xFF" "{\\ss}"))
 
 (drd-table cyrillic-catcodes%
   ("À" "\\CYRA")
diff --git a/src/TeXmacs/progs/convert/latex/latex-tools.scm b/src/TeXmacs/progs/convert/latex/latex-tools.scm
index 12f3bf8..7b4e610 100644
--- a/src/TeXmacs/progs/convert/latex/latex-tools.scm
+++ b/src/TeXmacs/progs/convert/latex/latex-tools.scm
@@ -54,7 +54,7 @@
 (define (latex-replace-catcode s)
   (or (if latex-cyrillic-catcode?
   (drd-ref cyrillic-catcodes% s)
-  (drd-ref iso-latin-catcodes% s))
+  (drd-ref corkT1-to-latex-catcodes% s))
       s))
 
 (tm-define (latex-expand-catcodes t)
@@ -285,8 +285,9 @@
  (pre-page     (latex-serialize-preamble Page))
  (pre-macro    (latex-serialize-preamble Macro))
  (pre-catcode  (latex-catcode-defs Text))
+ (pre-fontenc  "\\usepackage[T1]{fontenc}\n")
  (pre-uses     (latex-use-package-command Text)))
     (values
-      (string-append pre-uses)
+      (string-append pre-uses pre-fontenc)
       (string-append pre-page)
       (string-append pre-language pre-catcode pre-macro))))
diff --git a/src/TeXmacs/progs/convert/latex/tmtex.scm b/src/TeXmacs/progs/convert/latex/tmtex.scm
index 1cd8127..0e622ac 100644
--- a/src/TeXmacs/progs/convert/latex/tmtex.scm
+++ b/src/TeXmacs/progs/convert/latex/tmtex.scm
@@ -316,9 +316,6 @@
       ((== c #\22) (tmtex-text-sub ",," l))
       ((== c #\25) (tmtex-text-sub "--" l))
       ((== c #\26) (tmtex-text-sub "---" l))
-      ((== c #\237) (tmtex-text-sub "\\S" l))
-      ((== c #\337) (tmtex-text-sub "SS" l))
-      ((== c #\377) (tmtex-text-sub "ß" l))
       (else (cons c (tmtex-text-list (cdr l))))))))
 
 (define (tmtex-math-operator l)
--
1.6.3.3


From 03bf57f87573c4d845946738023f0ba97f16def5 Mon Sep 17 00:00:00 2001
From: Norbert Nemec <Norbert@...>
Date: Wed, 7 Oct 2009 12:16:56 +0100
Subject: [PATCH 04/11] Fix occasional crash when ci->nr is zero. (Probably should never happen, but Qt seems to handle counter incorrectly.)

---
 src/src/Graphics/Renderer/basic_renderer.cpp |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/src/Graphics/Renderer/basic_renderer.cpp b/src/src/Graphics/Renderer/basic_renderer.cpp
index de681bd..71ad4f2 100755
--- a/src/src/Graphics/Renderer/basic_renderer.cpp
+++ b/src/src/Graphics/Renderer/basic_renderer.cpp
@@ -379,7 +379,7 @@ void basic_renderer_rep::image_auto_gc () {
     fact= fact * fact * fact;
     if ((ci->w * ci->h) < 400) fact= fact * 5;
     if ((ci->w * ci->h)  < 6400) fact= fact * 5;
-    if (diff/fact > 60000) {
+    if (diff > 60000*fact) {
       cache_image->reset (lookup);
       ps_bbox->reset (lookup[0]);
     }
--
1.6.3.3


_______________________________________________
Texmacs-dev mailing list
Texmacs-dev@...
http://lists.gnu.org/mailman/listinfo/texmacs-dev

Re: A few small patches

by Joris van der Hoeven :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear Norber,

On Wed, Oct 07, 2009 at 06:44:04PM +0100, Norbert Nemec wrote:
> I have here four small patches fixing some minor problems.

Thanks for the patches; I applied numbers 1, 2 and 4.
Please include a check whether \usepackage[T1]{fontenc}
is really needed and I will apply patch 3 (I am trying to be
quite strict on only including the strictly necessary packages)
Are you sure that the tm_delete_array at the end of patch 2
is safe now? In the past I have had some very nasty segfaults
on some platforms.

Thanks again, --Joris


_______________________________________________
Texmacs-dev mailing list
Texmacs-dev@...
http://lists.gnu.org/mailman/listinfo/texmacs-dev

Re: A few small patches

by Norbert Nemec :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear Joris,

if I recall correctly, I put the fontenc in only for its side-effect:
Without fontenc, non-ascii characters in the source are simply dropped.
With fontenc and without inputenc, they are simply passed through
without reencoding. This is a rather fragile approach, but it is the
only way to get correct results.

[The real core issue here is that TeXmacs does not really have an
internal encoding. It simply handles byte strings and leaves it to the
font to translate them into a graphical representation without ever
knowing what the characters mean. This makes correct export virtually
impossible.]

One could make the \usepackage[T1]{fontenc} dependent on whether there
are non-ascii characters in the written latex. This, however, would need
to be checked explicitely at some point. Currently, there is no way to
determine it easily.

As for the tm_delete_array - Indeed, I am sure that it is safe. There is
a subtle difference between putenv and setenv (see
http://www.greenend.org.uk/rjk/2008/putenv.html) which means that one
should delete in one case and one should not do so in the other case. As
it turns out, either case produces a memory leak, but it is small enough
not to worry about it.

Greetings,
Norbert




Joris van der Hoeven wrote:

> Dear Norber,
>
> On Wed, Oct 07, 2009 at 06:44:04PM +0100, Norbert Nemec wrote:
>  
>> I have here four small patches fixing some minor problems.
>>    
>
> Thanks for the patches; I applied numbers 1, 2 and 4.
> Please include a check whether \usepackage[T1]{fontenc}
> is really needed and I will apply patch 3 (I am trying to be
> quite strict on only including the strictly necessary packages)
> Are you sure that the tm_delete_array at the end of patch 2
> is safe now? In the past I have had some very nasty segfaults
> on some platforms.
>
> Thanks again, --Joris
>
>
> _______________________________________________
> Texmacs-dev mailing list
> Texmacs-dev@...
> http://lists.gnu.org/mailman/listinfo/texmacs-dev
>
>  



_______________________________________________
Texmacs-dev mailing list
Texmacs-dev@...
http://lists.gnu.org/mailman/listinfo/texmacs-dev

Re: A few small patches

by Joris van der Hoeven :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear Norbert,

On Fri, Oct 09, 2009 at 09:25:24PM +0100, Norbert Nemec wrote:

> if I recall correctly, I put the fontenc in only for its side-effect:
> Without fontenc, non-ascii characters in the source are simply dropped.
> With fontenc and without inputenc, they are simply passed through
> without reencoding. This is a rather fragile approach, but it is the
> only way to get correct results.
>
> [The real core issue here is that TeXmacs does not really have an
> internal encoding. It simply handles byte strings and leaves it to the
> font to translate them into a graphical representation without ever
> knowing what the characters mean. This makes correct export virtually
> impossible.]
>
> One could make the \usepackage[T1]{fontenc} dependent on whether there
> are non-ascii characters in the written latex. This, however, would need
> to be checked explicitely at some point. Currently, there is no way to
> determine it easily.

Do we really need non-ascii characters? The generated LaTeX files will
be more portable if we avoid non-ascii characters alltogether.
Only if the user allows the converter to put catcodes in the preamble,
we should allow for non-ascii characters, and add the necessary catcodes.
 
Best wishes, --Joris


_______________________________________________
Texmacs-dev mailing list
Texmacs-dev@...
http://lists.gnu.org/mailman/listinfo/texmacs-dev

Re: A few small patches

by Joris van der Hoeven :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Oct 12, 2009 at 10:46:24PM +0200, Joris van der Hoeven wrote:
> Only if the user allows the converter to put catcodes in the preamble,

This can be specified in the preferences.


_______________________________________________
Texmacs-dev mailing list
Texmacs-dev@...
http://lists.gnu.org/mailman/listinfo/texmacs-dev

Re: A few small patches

by Norbert Nemec :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> Do we really need non-ascii characters? The generated LaTeX files will
> be more portable if we avoid non-ascii characters alltogether.
> Only if the user allows the converter to put catcodes in the preamble,
> we should allow for non-ascii characters, and add the necessary catcodes
I agree that this would be the ideal solution. However, this would mean
that the converter would need to take into accound the encoding of each
individual font. Unfortunately, the binary character sequences within
TeXmacs have their encoding defined only by the currently active font.
Currently, only the CorkT1 encoding is properly transcoded to catcodes.
(at least after my patch, that is...) If people use different fonts with
different encodings somewhere in their TeXmacs document, these will not
be translated correctly to LaTeX or anything else.


_______________________________________________
Texmacs-dev mailing list
Texmacs-dev@...
http://lists.gnu.org/mailman/listinfo/texmacs-dev

Re: A few small patches

by Joris van der Hoeven :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Oct 13, 2009 at 08:41:01AM +0100, Norbert Nemec wrote:

>
> >Do we really need non-ascii characters? The generated LaTeX files will
> >be more portable if we avoid non-ascii characters alltogether.
> >Only if the user allows the converter to put catcodes in the preamble,
> >we should allow for non-ascii characters, and add the necessary catcodes
>
> I agree that this would be the ideal solution. However, this would mean
> that the converter would need to take into accound the encoding of each
> individual font. Unfortunately, the binary character sequences within
> TeXmacs have their encoding defined only by the currently active font.

Well, we basically have Cork and Cyrillic. This should be replaced by unicode.

> Currently, only the CorkT1 encoding is properly transcoded to catcodes.
> (at least after my patch, that is...) If people use different fonts with
> different encodings somewhere in their TeXmacs document, these will not
> be translated correctly to LaTeX or anything else.

OK, but then why is it necessary to always include the additional packages?
In principle, the catcodes are only included for those symbols which
are really needed. By hacking the catcode generation mechanism a bit,
it should therefore be easy to adapt you patch in such a wat that
fontenc, etc. are only included if really needed.

Best wishes, --Joris

--------------------------------------------------
\documentclass{letter}

%%%%%%%%%% Start TeXmacs macros
\catcode`\?=\active \def?{\'e}
%%%%%%%%%% End TeXmacs macros

\begin{document}

Accentu?.

\end{document}


_______________________________________________
Texmacs-dev mailing list
Texmacs-dev@...
http://lists.gnu.org/mailman/listinfo/texmacs-dev

Re: A few small patches

by Norbert Nemec :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Joris van der Hoeven wrote:
> Well, we basically have Cork and Cyrillic. This should be replaced by
> unicode.
True. Ideally...
>
> OK, but then why is it necessary to always include the additional packages?
> In principle, the catcodes are only included for those symbols which
> are really needed. By hacking the catcode generation mechanism a bit,
> it should therefore be easy to adapt you patch in such a wat that
> fontenc, etc. are only included if really needed.
>  
Basically, I did not think it was worth the hassle to program that decision.

But then, I guess the issue is not really worth the discussion. I doubt
that anybody would actually miss fontenc. Most people use CorkT1 or
Cyrillic anyway...

Feel free to drop the line about fontenc from the patch. The remains of
the patch should still be valuable enough to include.

Greetings,
Norbert



_______________________________________________
Texmacs-dev mailing list
Texmacs-dev@...
http://lists.gnu.org/mailman/listinfo/texmacs-dev

Re: A few small patches

by Joris van der Hoeven :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear Norbert,

On Tue, Oct 13, 2009 at 05:14:38PM +0100, Norbert Nemec wrote:

> >OK, but then why is it necessary to always include the additional packages?
> >In principle, the catcodes are only included for those symbols which
> >are really needed. By hacking the catcode generation mechanism a bit,
> >it should therefore be easy to adapt you patch in such a wat that
> >fontenc, etc. are only included if really needed.
> >  
> Basically, I did not think it was worth the hassle to program that decision.
>
> But then, I guess the issue is not really worth the discussion. I doubt
> that anybody would actually miss fontenc. Most people use CorkT1 or
> Cyrillic anyway...
>
> Feel free to drop the line about fontenc from the patch. The remains of
> the patch should still be valuable enough to include.

I am sorry to complexify the discussion for such a seemingly silly thing.
The point is that I took great pains to be strict on dependencies for
every single macro or catcode in the LaTeX converter. This is important
because it reduces the risk of strange errors due to conflicting
LaTeX packages (such errors really occur, believe me). It also keeps
the LaTeX conversion very clean.

Therefore, I just want to understand the issue and see if there is
an easy solution to the problem. What exactly does fontenc do for you?
If it just allows you to use some non-ASCII characters,
then maybe we could just use the catcode generation mechanism instead.
For which characters is fontenc really needed? If I can simply
drop the line about fontenc, what do we loose?

Best wishes, --Joris


_______________________________________________
Texmacs-dev mailing list
Texmacs-dev@...
http://lists.gnu.org/mailman/listinfo/texmacs-dev

Re: A few small patches

by Norbert Nemec :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Joris van der Hoeven wrote:

> Dear Norbert,
>  
> I am sorry to complexify the discussion for such a seemingly silly thing.
> The point is that I took great pains to be strict on dependencies for
> every single macro or catcode in the LaTeX converter. This is important
> because it reduces the risk of strange errors due to conflicting
> LaTeX packages (such errors really occur, believe me). It also keeps
> the LaTeX conversion very clean.
>
> Therefore, I just want to understand the issue and see if there is
> an easy solution to the problem. What exactly does fontenc do for you?
> If it just allows you to use some non-ASCII characters,
> then maybe we could just use the catcode generation mechanism instead.
> For which characters is fontenc really needed? If I can simply
> drop the line about fontenc, what do we loose?
>  
Actually, I have to reconstruct this myself from the pieces that I
remember. It has been some time since I created this patch. It was in my
private repository ever since.

As I see it now, fontenc should actually not be needed at all any more.
I first put it in to correct the problem which I later solved cleanly by
completing the translation table for CorkT1.

As it is, the latex converter simply assumes that everything is either
CorkT1 or cyrillic. The former is now completely converted to catcodes.
I have no idea about the latter.

This means that exported latex files should never contain any non-ascii
characters (except in the case that they are defined in the header).
fontenc should therefore never have any effect at all (except for
correcting the.. hyphenation within latex).

This is all theory based on vague memories, but it seems to fit together
now...


_______________________________________________
Texmacs-dev mailing list
Texmacs-dev@...
http://lists.gnu.org/mailman/listinfo/texmacs-dev

Re: A few small patches

by Joris van der Hoeven :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Oct 15, 2009 at 06:31:54PM +0100, Norbert Nemec wrote:

> Actually, I have to reconstruct this myself from the pieces that I
> remember. It has been some time since I created this patch. It was in my
> private repository ever since.
>
> As I see it now, fontenc should actually not be needed at all any more.
> I first put it in to correct the problem which I later solved cleanly by
> completing the translation table for CorkT1.
>
> As it is, the latex converter simply assumes that everything is either
> CorkT1 or cyrillic. The former is now completely converted to catcodes.
> I have no idea about the latter.
>
> This means that exported latex files should never contain any non-ascii
> characters (except in the case that they are defined in the header).
> fontenc should therefore never have any effect at all (except for
> correcting the.. hyphenation within latex).
>
> This is all theory based on vague memories, but it seems to fit together
> now...

OK, so this means that I can go on and apply your patch
without the line concerning fontenc. In principle, LaTeX files
should never contain non-ascii characters indeed, except if
the user enabled catcodes in headers in the conversion preferences.
In this latter case, your patch still works fine? Please confirm
by trying on a relevant example which you probably have somewhere around.

Many thanks, --Joris


_______________________________________________
Texmacs-dev mailing list
Texmacs-dev@...
http://lists.gnu.org/mailman/listinfo/texmacs-dev

Re: A few small patches

by Norbert Nemec :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Joris van der Hoeven wrote:

> On Thu, Oct 15, 2009 at 06:31:54PM +0100, Norbert Nemec wrote:
>  
>> Actually, I have to reconstruct this myself from the pieces that I
>> remember. It has been some time since I created this patch. It was in my
>> private repository ever since.
>>
>> As I see it now, fontenc should actually not be needed at all any more.
>> I first put it in to correct the problem which I later solved cleanly by
>> completing the translation table for CorkT1.
>>
>> As it is, the latex converter simply assumes that everything is either
>> CorkT1 or cyrillic. The former is now completely converted to catcodes.
>> I have no idea about the latter.
>>
>> This means that exported latex files should never contain any non-ascii
>> characters (except in the case that they are defined in the header).
>> fontenc should therefore never have any effect at all (except for
>> correcting the.. hyphenation within latex).
>>
>> This is all theory based on vague memories, but it seems to fit together
>> now...
>>    
>
> OK, so this means that I can go on and apply your patch
> without the line concerning fontenc. In principle, LaTeX files
> should never contain non-ascii characters indeed, except if
> the user enabled catcodes in headers in the conversion preferences.
> In this latter case, your patch still works fine? Please confirm
> by trying on a relevant example which you probably have somewhere around.
>  
Indeed, I checked this yesterday. Works fine for me.



_______________________________________________
Texmacs-dev mailing list
Texmacs-dev@...
http://lists.gnu.org/mailman/listinfo/texmacs-dev

Re: A few small patches

by Joris van der Hoeven :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for all, I applied the patch without the fontenc stuff. --Joris

On Fri, Oct 16, 2009 at 05:42:48PM +0100, Norbert Nemec wrote:

> Joris van der Hoeven wrote:
> >On Thu, Oct 15, 2009 at 06:31:54PM +0100, Norbert Nemec wrote:
> >  
> >>Actually, I have to reconstruct this myself from the pieces that I
> >>remember. It has been some time since I created this patch. It was in my
> >>private repository ever since.
> >>
> >>As I see it now, fontenc should actually not be needed at all any more.
> >>I first put it in to correct the problem which I later solved cleanly by
> >>completing the translation table for CorkT1.
> >>
> >>As it is, the latex converter simply assumes that everything is either
> >>CorkT1 or cyrillic. The former is now completely converted to catcodes.
> >>I have no idea about the latter.
> >>
> >>This means that exported latex files should never contain any non-ascii
> >>characters (except in the case that they are defined in the header).
> >>fontenc should therefore never have any effect at all (except for
> >>correcting the.. hyphenation within latex).
> >>
> >>This is all theory based on vague memories, but it seems to fit together
> >>now...
> >>    
> >
> >OK, so this means that I can go on and apply your patch
> >without the line concerning fontenc. In principle, LaTeX files
> >should never contain non-ascii characters indeed, except if
> >the user enabled catcodes in headers in the conversion preferences.
> >In this latter case, your patch still works fine? Please confirm
> >by trying on a relevant example which you probably have somewhere around.
> >  
> Indeed, I checked this yesterday. Works fine for me.
>
>
>
> _______________________________________________
> Texmacs-dev mailing list
> Texmacs-dev@...
> http://lists.gnu.org/mailman/listinfo/texmacs-dev


_______________________________________________
Texmacs-dev mailing list
Texmacs-dev@...
http://lists.gnu.org/mailman/listinfo/texmacs-dev