jed-users mailing list

[2003 Date Index] [2003 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

l4j: new latex_view() with xdvi -sourceposition


Hi,

I've took a look at latex_view() and I couldn't understand why it is so
bloated. So I rewrote it.

And...
* I don't found a reason to open a buffer for the viewing command. All
  output is send to /dev/null, so what should be occure in this buffer?

* I don't find where run_shell_cmd is coming from. In shell.sl are only a
  version for DOS and VMS. And I don't know what it does more then
  system(), so I replaced the call with system().
  Is there a & in the DOS-call needed or how create a background process
  in DOS?
  
* I added the option -sourceposition to xdvi. So if you view a dvi file,
  xdvi highlights the position where your cursor stands in the .latex
  file.
  Therefore latex must be called with --src. I coded this hard. So this
  must be removed in the future.

#v+
--- /home/joerg/.jed/latex.sl.orig	2003-05-22 00:00:41.000000000 +0200
+++ /home/joerg/.jed/latex.sl	2003-06-01 18:06:35.000000000 +0200
@@ -463,71 +512,50 @@
 
 public define latex_view ()
 {
-  variable dvi, ps, pdf;
-  !if (USE_MASTER)
-    (latex_file, latex_file_dir,,) = getbuf_info ();
-  dvi = path_sans_extname (dircat (latex_file_dir, latex_file)) + ".dvi";
-  ps  = path_sans_extname (dircat (latex_file_dir, latex_file)) + ".ps";
-  pdf = path_sans_extname (dircat (latex_file_dir, latex_file)) + ".pdf";
-  
-  switch (LaTeX_Default_Output)
-    
-   { case "dvi":
-     if (1 != file_status (dvi)) {
+   !if (USE_MASTER)
+     (latex_file, latex_file_dir,,) = getbuf_info ();
+
+%   variable old_buf = whatbuf();
+   
+   variable file, cmd;%, buf_name;
+   file = path_sans_extname( dircat(latex_file_dir, latex_file) );
+   
+   switch (LaTeX_Default_Output)
+     { case "dvi":
+	file = file+".dvi";
+	cmd = "cd " + latex_file_dir + " && " + LaTeX_View_Dvi_Cmd +
+	  " -sourceposition " + sprintf("%d", what_line()) + latex_file;
+%	buf_name = LaTeX_Xdvi_Buffer
+     }
+     { case "ps":
+	file = file+".ps";
+	cmd = LaTeX_View_Ps_Cmd;
+%	buf_name = LaTeX_Gv_Buffer;
+     }
+     { case "dvipdf" or case "pdf":
+	file = file+".pdf";
+	cmd = LaTeX_View_Pdf_Cmd;
+%	buf_name = LaTeX_Xpdf_Buffer;
+     }
+   
+   if (1 != file_status (file)) {
        beep ();
-       flush ("No file " + dvi + "! Building it...");
+       flush ("No file " + file + "! Building it...");
        usleep (2000);
-       LaTeX_Default_Output = "dvi";
        latex_compose ();
      }
-     flush ("Running: " + LaTeX_View_Dvi_Cmd +
-            " " + dvi + " (building fonts...)");
-     sw2buf (LaTeX_Xdvi_Buffer);
-     set_readonly (0);
-     erase_buffer ();
+   flush("Running: " + cmd + " " + file);
+%   sw2buf(buf_name);
+%   set_readonly(0);
+%   erase_buffer();
 #ifdef UNIX
-     if (0 != run_shell_cmd ("cd " + latex_file_dir + "; " + 
-                         LaTeX_View_Dvi_Cmd + " " + dvi + devnull))
+   if (0 != system(cmd + " " + file + ">/dev/null 2>&1 &") )
 #elifdef WIN32
-     if (0 != run_shell_cmd (LaTeX_View_Dvi_Cmd + " " + dvi))
+   if (0 != system(cmd + " " + file + ">NUL") )
 #endif
-       error ("Could not run " + LaTeX_View_Dvi_Cmd + " " + dvi);
-     sw2buf (LaTeX_Buffer);
-   }
-     
-   { case "ps":
-     if (1 != file_status (dvi)) {
-       beep ();
-       flush ("No file " + dvi + "! Building it...");
-       usleep (2000);
-       LaTeX_Default_Output = "dvi";
-       latex_compose ();
-     }
-     flush ("Running: " + LaTeX_View_Ps_Cmd + " " + ps);
-     sw2buf (LaTeX_Gv_Buffer);
-     set_readonly (0);
-     erase_buffer ();
-     if (0 != run_shell_cmd (LaTeX_View_Ps_Cmd + " " + ps + devnull))
-       error ("Could not run " + LaTeX_View_Ps_Cmd + " " + ps);
-     sw2buf (LaTeX_Buffer);
-   }
-
-   { case "dvipdf" or case "pdf":
-     if (1 != file_status (pdf)) {
-       beep ();
-       flush ("No file " + pdf + "! Building it...");
-       usleep (2000);
-       LaTeX_Default_Output = "pdf";
-       latex_compose ();
-     }
-     flush ("Running: " + LaTeX_View_Pdf_Cmd +  " " + pdf);
-     sw2buf (LaTeX_Xpdf_Buffer);
-     set_readonly (0);
-     erase_buffer ();
-     if (0 != run_shell_cmd (LaTeX_View_Pdf_Cmd +  " " + pdf + devnull))
-       error ("Could not run " + LaTeX_View_Pdf_Cmd + " " + pdf);
-     sw2buf (LaTeX_Buffer);
-   }
+       error ("Could not run " + cmd + " " + file);
+   
+%   sw2buf (old_buf);
 }
 
 % -----
#v-

Jörg.

--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.


[2003 date index] [2003 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]