Syntax highlighted output
Hello All, I am writing a project report for a PHP project I have completed and I need to include the code I have written. I would like to have code that is highlighted similar to the editor I use (it's Notepad2 but I'm sure most of you know what I mean), has line numbers and is in a monospaced font. Now I know that ConTeXt itself doesn't have support for PHP highlighting but I have found something in the third party modules that is able to use ViM to do what I want. Unfortuantely, I can't get it to work, hence why I am here! I'm on Windows XP and I am using the standalone ConTeXt distribution from the 22nd March 2007. When I came to install the module, I found that it was already included in the distribution. I have installed the distribution under C:\ConTeXt\ along with Perl (C:\perl\) and Ruby (C:\ruby\). What is non-standard in my setup is my own custom built batch file: set file=c_Implementation call C:\ConTeXt\usr\local\context\tex\setuptex.bat C:\ConTeXt\usr\local\context\tex call texmfstart texexec --pdf %file% rem Clears up the log files and puts them in separete directory. if exist %file%.log move %file%.log Log\%file%.log if exist %file%-mpgraph.mp move %file%-mpgraph.mp Log\%file%-mpgraph.mp if exist %file%.tmp move %file%.tmp Log\%file%.tmp if exist %file%.tui move %file%.tui Log\%file%.tui if exist %file%.tuo move %file%.tuo Log\%file%.tuo if exist mpgraph.mp move mpgraph.mp Log\mpgraph.mp if exist %file%-mpgraph-temp-mpgraph.mp move %file%-mpgraph-temp-mpgraph.mp Log\%file%-mpgraph-temp-mpgraph.mp if exist %file%-mpgraph-temp.dvi move %file%-mpgraph-temp.dvi Log\%file%-mpgraph-temp.dvi if exist %file%-mpgraph.log move %file%-mpgraph.log Log\%file%-mpgraph.log if exist %file%-mpgraph.mp.keep move %file%-mpgraph.mp.keep Log\%file%-mpgraph.mp.keep if exist %file%-mpgraph.1 move %file%-mpgraph.1 Log\%file%-mpgraph.1 if exist %file%-mpgraph.mpb move %file%-mpgraph.mpb Log\%file%-mpgraph.mpb if exist %file%-mpgraph.mpo move %file%-mpgraph.mpo Log\%file%-mpgraph.mpo if exist %file%-mpgraph.mpx move %file%-mpgraph.mpx Log\%file%-mpgraph.mpx rem Runs whatever is associated with PDF files if exist %file%.pdf start %file%.pdf I'll put that in the directory of the .tex file I want to run it on. In this case it is "c_Implementation.tex". My implementation file looks like this: \startcomponent c_Implementation \product ../prd_TennisClubBookingSystem \project ../../prj_School %%%%%%%%%%%%%%%%% % Setup Figures % %%%%%%%%%%%%%%%%% \setupexternalfigures[directory={Implementation/Figures,Figures}] %%%%%%%%%%% % Content % %%%%%%%%%%% \chapter[cha:Implementation]{Implementation} \setupcolors[state=start] \definevimtyping [RUBY] [syntax=ruby] \startRUBY #! /usr/bin/ruby # This is my first ruby program puts "Hello World" \stopRUBY And when I run my batch file on it, TeXexec returns the error: ! Undefined control sequence. l.36 \definevimtyping [RUBY] [syntax=ruby] I think where I am falling down is that ViM doesn't seem integrated to me. I have it placed under C:\Programs\ViM\ and I used the installer which has all the different types GUI and command line version as well. Do I need the set something up in the module to make it know where ViM is or do I need to somehow directly use ViM itself? Thank you for reading and thank you in advance for any help! Chris
On 4/28/07, Chris Rawnsley
Hello All, I am writing a project report for a PHP project I have completed and I need to include the code I have written. I would like to have code that is highlighted similar to the editor I use (it's Notepad2 but I'm sure most of you know what I mean), has line numbers and is in a monospaced font. you can also consider my 2 cents http://www.logosrl.it/context/modules/2007-04-17/verb-modu_ebook.pdf -- luigi
If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net
you can also consider my 2 cents http://www.logosrl.it/context/modules/2007-04-17/verb-modu_ebook.pdf -- luigi Thanks for your reply. From what I understand, there isn't currently a verb file for PHP and I gather they are quite lengthy to write. Unfortuantely, I don't have the time to write one myself else I might look further into it.
-- Chris
On Sat, 28 Apr 2007, Chris Rawnsley wrote:
Hello All, I am writing a project report for a PHP project I have completed and I need to include the code I have written. I would like to have code that is highlighted similar to the editor I use (it's Notepad2 but I'm sure most of you know what I mean), has line numbers and is in a monospaced font.
Now I know that ConTeXt itself doesn't have support for PHP highlighting but I have found something in the third party modules that is able to use ViM to do what I want. Unfortuantely, I can't get it to work, hence why I am here!
I'm on Windows XP and I am using the standalone ConTeXt distribution from the 22nd March 2007. When I came to install the module, I found that it was already included in the distribution. I have installed the distribution under C:\ConTeXt\ along with Perl (C:\perl\) and Ruby (C:\ruby\). What is non-standard in my setup is my own custom built batch file:
I'll put that in the directory of the .tex file I want to run it on. In this case it is "c_Implementation.tex". My implementation file looks like this:
\startcomponent c_Implementation \product ../prd_TennisClubBookingSystem \project ../../prj_School
You do not need to mention ../ and ../../. ConTeXt automatically searches for product and project files in one higher directory.
%%%%%%%%%%%%%%%%% % Setup Figures % %%%%%%%%%%%%%%%%% \setupexternalfigures[directory={Implementation/Figures,Figures}]
%%%%%%%%%%% % Content % %%%%%%%%%%% \chapter[cha:Implementation]{Implementation}
\setupcolors[state=start]
\definevimtyping [RUBY] [syntax=ruby] \startRUBY #! /usr/bin/ruby # This is my first ruby program puts "Hello World" \stopRUBY
And when I run my batch file on it, TeXexec returns the error: ! Undefined control sequence. l.36 \definevimtyping [RUBY] [syntax=ruby]
Do you have \usemodule[vim] somewhere in the setup? Does the log file say something like "module: ViM Syntax Highliting" What does texmfstart --locate 't-vim.tex' give?
I think where I am falling down is that ViM doesn't seem integrated to me. I have it placed under C:\Programs\ViM\ and I used the installer which has all the different types GUI and command line version as well. Do I need the set something up in the module to make it know where ViM is or do I need to somehow directly use ViM itself?
You need vim.exe to be in your PATH. Does texmfstart bin:vim start vim? Aditya
On Sat, 28 Apr 2007, Aditya Mahajan wrote:
Do you have \usemodule[vim] somewhere in the setup? Does the log file say something like "module: ViM Syntax Highliting"
I realized that the documentation does not say that you need to add \usemodule[vim] in your file. I will include it in the documentation. Aditya
Thank you for your reply. It got closer this time but through a different error: ! I can't find file `c_Implementation-vimsyntax.tmp-vimsyntax.tmp'. <to be read again> \relax \dodotypevimfile ...\input #2-vimsyntax.tmp\relax \egroup \@@vsafter l.41 \stopRUBY Please type another input file name: That file isn't created in the directory I am working in and I searched the computer and couldn't find it anywhere else either. Any other ideas? -- Chris
On Sat, 28 Apr 2007, Chris Rawnsley wrote:
Thank you for your reply. It got closer this time but through a different error:
! I can't find file `c_Implementation-vimsyntax.tmp-vimsyntax.tmp'. <to be read again> \relax \dodotypevimfile ...\input #2-vimsyntax.tmp\relax \egroup \@@vsafter l.41 \stopRUBY
Please type another input file name:
That file isn't created in the directory I am working in and I searched the computer and couldn't find it anywhere else either. Any other ideas?
Do you have write18 enabled? Check the log file, it should say something like \wirte18 enabled. and system(texmfstrart bin:vim -c ...long list of arguments...) executed To enable write18 search the wiki for write18. Aditya
On 28/04/07, Aditya Mahajan
Do you have write18 enabled? Check the log file, it should say something like
\wirte18 enabled. Yep the log file mentions that line.
system(texmfstrart bin:vim -c ...long list of arguments...) executed Well, firstly, the log says this:
system : module vim loaded (c:/ConTeXt/usr/local/context/tex/texmf-local/tex/context/third/vim/t-vim.tex loading : Context Module for ViM Sytax Highlighting color : system hex is loaded It then goes on to say what you listed. Here is the full output (I have also shown the tail end of the last error I mentioned in a previous email): system(texmfstart bin:vim "-u NONE -e -c \"set noswapfile\" -c \"set tabstop=8\ " -c \"set cp\" -c \"syntax on\" -c \"set syntax=ruby\" -c \"let contextstartli ne=1\" -c \"let contextstopline=0\" -c \"source kpse:2context.vim\" -c \"wqa\" " c_Implementation-vimsyntax.tmp)...executed. ! I can't find file `c_Implementation-vimsyntax.tmp-vimsyntax.tmp'. <to be read again>
On 28/04/07, Aditya Mahajan
You do not need to mention ../ and ../../. ConTeXt automatically searches for product and project files in one higher directory. Ah thanks for the tip. I can certainly see that becoming useful in the future.
What does texmfstart --locate 't-vim.tex' give?
C:/ConTeXt/usr/local/context/tex/texmf-local/tex/context/third/vim/t-vim.tex
You need vim.exe to be in your PATH.
Does texmfstart bin:vim start vim? No it didn't. I had it in my path previously but I moved ViM from Program Files to Programs and I didn't update PATH. I need to reset, so back in a tick!
Thanks alot for your help! -- Chris
You need vim.exe to be in your PATH.
Does texmfstart bin:vim start vim? Right, this now starts ViM.
When I went to compile it threw a different error: VIM - Vi IMproved 7.0 (2006 May 7, compiled May 7 2006 16:18:30) Garbage after option argument: "-u NONE -e -c set" More info with: "vim -h" ! I can't find file `c_Implementation-vimsyntax.tmp-vimsyntax.tmp'. <to be read again> \relax \dodotypevimfile ...\input #2-vimsyntax.tmp\relax \egroup \@@vsafter l.20 \stopRUBY Please type another input file name: -- Chris
On Sat, 28 Apr 2007, Chris Rawnsley wrote:
You need vim.exe to be in your PATH.
Does texmfstart bin:vim start vim? Right, this now starts ViM.
When I went to compile it threw a different error:
VIM - Vi IMproved 7.0 (2006 May 7, compiled May 7 2006 16:18:30) Garbage after option argument: "-u NONE -e -c set" More info with: "vim -h"
This is strange....Are you using command.exe or some other shell? It appears that there is a problem with quoting of quotes. what happens when you run the following command (all in one line) texmfstart bin:vim "-u NONE -e -c \"set noswapfile\" -c \"set tabstop=8\" -c \"set cp\" -c \"syntax on\" -c \"set syntax=ruby\" -c \"let contextstartline=1\" -c \"let contextstopline=0\" -c \"source kpse:2context.vim\" -c \"wqa\" c_Implementation-vimsyntax.tmp Aditya
Ah ha! It is a very simple thing that is stopping it. In t-vim.tex on line 312 the preceeding double quote needed to be removed and on line 324 the double quote before %1 needed to be removed. Line 312 before: " -u NONE % No need to read unnessary configurations Line 312 after: -u NONE % No need to read unnessary configurations Line 324 before: " #1}} Line 324 after: #1}} I'll move passed just using the examples now and see if this still works. This is going to save me alot of time. Thanks for your help and thank you for creating it in the first place :-) -- Chris
On Sat, 28 Apr 2007, Chris Rawnsley wrote:
Ah ha! It is a very simple thing that is stopping it.
In t-vim.tex on line 312 the preceeding double quote needed to be removed and on line 324 the double quote before %1 needed to be removed.
Line 312 before: " -u NONE % No need to read unnessary configurations Line 312 after: -u NONE % No need to read unnessary configurations
Line 324 before: " #1}} Line 324 after: #1}}
I never really understood how quoting behaves in the tex->ruby->vim chain. Something is still fishy there as the module used to work fine in my and Mojca's machine (both Windoes). I will try to dig deeper into it.
I'll move passed just using the examples now and see if this still works. This is going to save me alot of time. Thanks for your help and thank you for creating it in the first place :-)
Some caveats - The module is slow. - It reconvers the snippets each time you compile your document. - If you want to typeset a big chunk of code, it is possible to convert the code using 2context and then just import this code. There is no user interface for it. In case you need it, I can provide that. Hopefully, with luatex, writing syntax highlighting will become much easier. Aditya
LuaTeX does certainly look very promising indeed.
- If you want to typeset a big chunk of code, it is possible to convert the code using 2context and then just import this code. There is no user interface for it. In case you need it, I can provide that.
I think that solution would be best for me. I have quite a large chunk of code so compiling will take a while. If you mean a user interface as in GUI, I'm fine with working on the command line. If you weren't talking about a GUI then if you could spare the time it'd be greatfully appreciated. Just as a side note, is there a way to fix it so that line numberings are always on the left? Oh and how can I change to a fixed width font for code listings? -- Chris
On Sat, 28 Apr 2007, Chris Rawnsley wrote:
LuaTeX does certainly look very promising indeed.
- If you want to typeset a big chunk of code, it is possible to convert the code using 2context and then just import this code. There is no user interface for it. In case you need it, I can provide that.
I think that solution would be best for me. I have quite a large chunk of code so compiling will take a while. If you mean a user interface as in GUI, I'm fine with working on the command line. If you weren't talking about a GUI then if you could spare the time it'd be greatfully appreciated.
Suppose you have a file called program.php. You create a batch file that runs the texmfstart bin:vim ... line to create program-vimsyntax.tmp file. Then in your ConTeXt code, you can say, \typevimfile[convert=no][program.php] So, compiling will not be slowed by running vim each time. But you will manually have to make sure that you convert all files. I will try to provide a user interface for something like this.
Just as a side note, is there a way to fix it so that line numberings are always on the left?
\sesupvimtyping[numbering=on]
Oh and how can I change to a fixed width font for code listings?
By default, \tftt and \tt fonts are used for code listing. The easiest way to change to a different font is to use it as your default teletype font. If that is not possible, then you will need to define a new colorscheme, along the lines of the default colorscheme, but changing \v!mono with whatever font you want. Aditya
On 28/04/07, Aditya Mahajan
Suppose you have a file called program.php. You create a batch file that runs the texmfstart bin:vim ... line to create program-vimsyntax.tmp file. Then in your ConTeXt code, you can say,
\typevimfile[convert=no][program.php]
Ah that's going to save me a bunch of time. Thank you.
Just as a side note, is there a way to fix it so that line numberings are always on the left?
\sesupvimtyping[numbering=on]
I've done that. I should've been more clear sorry. I've setup my pages with the "alternative=doublesided" option. So for even numbered pages I have numbering in the left margin like I want, however, for odd pages it switches to the right side.
By default, \tftt and \tt fonts are used for code listing. The easiest way to change to a different font is to use it as your default teletype font. If that is not possible, then you will need to define a new colorscheme, along the lines of the default colorscheme, but changing \v!mono with whatever font you want.
Umm what's a teletype font for starters? -- Chris
On Sat, 28 Apr 2007, Chris Rawnsley wrote:
On 28/04/07, Aditya Mahajan
wrote: Suppose you have a file called program.php. You create a batch file that runs the texmfstart bin:vim ... line to create program-vimsyntax.tmp file. Then in your ConTeXt code, you can say,
\typevimfile[convert=no][program.php]
Ah that's going to save me a bunch of time. Thank you.
I will need two three days to work on this.
Just as a side note, is there a way to fix it so that line numberings are always on the left?
\sesupvimtyping[numbering=on]
I've done that. I should've been more clear sorry. I've setup my pages with the "alternative=doublesided" option. So for even numbered pages I have numbering in the left margin like I want, however, for odd pages it switches to the right side.
Right now, this is not possible. Let me see if I can add this feature.
By default, \tftt and \tt fonts are used for code listing. The easiest way to change to a different font is to use it as your default teletype font. If that is not possible, then you will need to define a new colorscheme, along the lines of the default colorscheme, but changing \v!mono with whatever font you want.
Umm what's a teletype font for starters?
A fixed width font is also called a teletype font. By default, the code listing should be in a fixed width font, so I thought that you were talking about how to use a different fixed width font. Aditya
On 29/04/07, Aditya Mahajan
I will need two three days to work on this.
Sorry I misunderstood you. I thought that function was already implemented. Don't feel you have to rush to get this implemented :) I can bear with the slow ness.
Right now, this is not possible. Let me see if I can add this feature.
That would be very useful. Thank you.
A fixed width font is also called a teletype font. By default, the code listing should be in a fixed width font, so I thought that you were talking about how to use a different fixed width font.
Ah I set up my body font like so: \definetypeface [palatino] [rm] [serif] [palatino] [default] [encoding=ec] \switchtotypeface [palatino] [12pt,rm] Though when it comes to listing code it doesn't automatically switch to a teletype font and it sticks with the body font, however, when I comment out of those two lines it does use a fixed width font. I'm guessing here but does that mean there is no teletype font in Palatino? I not trying to put on demands on you here but the changes you say will only be useful to me if I get them before tonight. I need to hand in the project tomorrow. So I don't want you to spend time on implementing features that won't be appreciated by me (but I'm sure others will find it useful! I will as well in the future too). Basically, all I'm saying here is that you don't have to rush these features on my behalf. I hope that didn't come off as being rude because it certainly wasn't meant to be. I'll gladly test anything in the future too. If you need any help I'd gladly return the favour :) -- Chris
On Sun, 29 Apr 2007 12:38:16 +0100
"Chris Rawnsley"
On 29/04/07, Aditya Mahajan
wrote: I will need two three days to work on this.
Sorry I misunderstood you. I thought that function was already implemented. Don't feel you have to rush to get this implemented :) I can bear with the slow ness.
Right now, this is not possible. Let me see if I can add this feature.
That would be very useful. Thank you.
A fixed width font is also called a teletype font. By default, the code listing should be in a fixed width font, so I thought that you were talking about how to use a different fixed width font.
Ah I set up my body font like so:
\definetypeface [palatino] [rm] [serif] [palatino] [default] [encoding=ec] \switchtotypeface [palatino] [12pt,rm]
Hi Chris, replace this two lines with \usetypescript[palatino][texnansi] % use better texnansi than ec \setupbodyfont[palatino] % rm and 12pt are default values Wolfgang
Though when it comes to listing code it doesn't automatically switch to a teletype font and it sticks with the body font, however, when I comment out of those two lines it does use a fixed width font. I'm guessing here but does that mean there is no teletype font in Palatino?
I not trying to put on demands on you here but the changes you say will only be useful to me if I get them before tonight. I need to hand in the project tomorrow. So I don't want you to spend time on implementing features that won't be appreciated by me (but I'm sure others will find it useful! I will as well in the future too). Basically, all I'm saying here is that you don't have to rush these features on my behalf.
I hope that didn't come off as being rude because it certainly wasn't meant to be.
I'll gladly test anything in the future too. If you need any help I'd gladly return the favour :)
-- Chris ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
On Sun, 29 Apr 2007, Chris Rawnsley wrote:
On 29/04/07, Aditya Mahajan
wrote: I will need two three days to work on this.
Sorry I misunderstood you. I thought that function was already implemented. Don't feel you have to rush to get this implemented :) I can bear with the slow ness.
The nuts and pieces are there, but right now there is no such function. Here is what you can do. Write a batch script which calls 2context (see the complete command in \runvimsyntax in t-vim). Run it on the file that you want. After loading t-vim, add the following line \let\runvimsyntax\gobbleoneargument For making the line numbers always appear on the left, add this code after loading t-vim. \unprotect \def\showvimlinenumber {\inleft%was \inmargin%TODO: make configurable {\dostartattributes\??vs\c!numberstyle\c!numbercolor\empty \countervalue{vimlinenumber} \dostopattributes}} \protect
Right now, this is not possible. Let me see if I can add this feature.
That would be very useful. Thank you.
A fixed width font is also called a teletype font. By default, the code listing should be in a fixed width font, so I thought that you were talking about how to use a different fixed width font.
Ah I set up my body font like so:
\definetypeface [palatino] [rm] [serif] [palatino] [default] [encoding=ec] \switchtotypeface [palatino] [12pt,rm]
Though when it comes to listing code it doesn't automatically switch to a teletype font and it sticks with the body font, however, when I comment out of those two lines it does use a fixed width font. I'm guessing here but does that mean there is no teletype font in Palatino?
Strange, I thought that with your font setup ConTeXt should fall back to latin modern mono. Anyway, Wolfgang's suggestion should work and will give you latin modern mono scaled properly to match Palatino's height.
I not trying to put on demands on you here but the changes you say will only be useful to me if I get them before tonight. I need to hand in the project tomorrow. So I don't want you to spend time on implementing features that won't be appreciated by me (but I'm sure others will find it useful! I will as well in the future too). Basically, all I'm saying here is that you don't have to rush these features on my behalf.
I hope that didn't come off as being rude because it certainly wasn't meant to be.
Don't worry. I made this module to just have the features that I needed. As a result, there are lot of things that are missing from the module. Your effort to make the module work has been a good feedback to me. Aditya
On 29/04/07, Aditya Mahajan
The nuts and pieces are there, but right now there is no such function. Here is what you can do. Write a batch script which calls 2context (see the complete command in \runvimsyntax in t-vim). Run it on the file that you want. After loading t-vim, add the following line
\let\runvimsyntax\gobbleoneargument
I can't get it to work. I've added that line and then I've used the syntax you posted previously: \typevimfile[convert=no][copy.tmp] Returns the error: File does not exist. (Or more precisely: [file [ does not exist] Copy.tmp] )
For making the line numbers always appear on the left, add this code after loading t-vim.
\unprotect
\def\showvimlinenumber {\inleft%was \inmargin%TODO: make configurable {\dostartattributes\??vs\c!numberstyle\c!numbercolor\empty \countervalue{vimlinenumber} \dostopattributes}}
\protect
That works a charm. Thanks you for doing this so quick!
Strange, I thought that with your font setup ConTeXt should fall back to latin modern mono. Anyway, Wolfgang's suggestion should work and will give you latin modern mono scaled properly to match Palatino's height.
Yep. It's sorted itself out now.
Don't worry. I made this module to just have the features that I needed. As a result, there are lot of things that are missing from the module. Your effort to make the module work has been a good feedback to me.
Ah that's good. Well I'll try and give as much as you can bear! :) -- Chris
On Sun, 29 Apr 2007, Chris Rawnsley wrote:
On 29/04/07, Aditya Mahajan
wrote: The nuts and pieces are there, but right now there is no such function. Here is what you can do. Write a batch script which calls 2context (see the complete command in \runvimsyntax in t-vim). Run it on the file that you want. After loading t-vim, add the following line
\let\runvimsyntax\gobbleoneargument
I can't get it to work. I've added that line and then I've used the syntax you posted previously:
\typevimfile[convert=no][copy.tmp]
Sorry, that syntax was incorrect and was for a future feature that I was thinking of. If is not implemented yet. The following should work right now. Suppose your file is called copy.php, run it through the batchfile (that you will need to create). You should get a file called copy.php-vimsyntax.tmp Now after loading vim, add \definevimtyping [typePHP] [syntax=php, before={\bgroup \let\runvimsyntax\gobbleoneargument}, after={\egroup}] and then use \typePHP{copy.php} Aditya
On 29/04/07, Aditya Mahajan
Now after loading vim, add \definevimtyping [typePHP] [syntax=php, before={\bgroup \let\runvimsyntax\gobbleoneargument}, after={\egroup}]
and then use
\typePHP{copy.php}
I can't get it to work. Firstly, when I use \definevimtyping and then \typePHP the system cannot find the definition for \typePHP. If I use \definetypevimfile instead of \definevimtyping it works. Unfortuantely this doesn't actually save time as it loads ViM for whatever is required. Now for some general feedback. At the moment, if a line wraps, the line number doesn't feature in the margin. I think the placement should be different, however. It currently looks something like: 11 require_once(BASE_DIR.'inc/html.php'); // HTML output 12 require_once(BASE_DIR.'inc/auth.php'); // Authorise user require_once(BASE_DIR.'inc/action.php'); // List of possi- 13 ble actions 14 require_once(BASE_DIR.'inc/calendar.php'); As you can see line 13 has wrapped but I would prefer it if the line number was on the line above. So like this: 11 require_once(BASE_DIR.'inc/html.php'); // HTML output 12 require_once(BASE_DIR.'inc/auth.php'); // Authorise user 13 require_once(BASE_DIR.'inc/action.php'); // List of possi- ble actions 14 require_once(BASE_DIR.'inc/calendar.php'); Also not all my lines are wrapping properly. For instance, a line like: if(!defined('BASE_DIR')) define('BASE_DIR',realpath(dirname(__FILE__).'/../').'/'); Other than that, I'm loving the output. -- Chris
On Sun, 29 Apr 2007, Chris Rawnsley wrote:
On 29/04/07, Aditya Mahajan
wrote: Now after loading vim, add \definevimtyping [typePHP] [syntax=php, before={\bgroup \let\runvimsyntax\gobbleoneargument}, after={\egroup}]
and then use
\typePHP{copy.php}
I can't get it to work. Firstly, when I use \definevimtyping and then \typePHP the system cannot find the definition for \typePHP. If I use \definetypevimfile instead of \definevimtyping it works. Unfortuantely this doesn't actually save time as it loads ViM for whatever is required.
Well, then I need to make some more changes in the module. Since, you are up against a deadline right now, and are willing to suffer the delay caused by this module, I will trying hacks to make this work. Hopefully, the next release of vim module will have a robust solution.
Now for some general feedback.
At the moment, if a line wraps, the line number doesn't feature in the margin. I think the placement should be different, however. It currently looks something like:
11 require_once(BASE_DIR.'inc/html.php'); // HTML output 12 require_once(BASE_DIR.'inc/auth.php'); // Authorise user require_once(BASE_DIR.'inc/action.php'); // List of possi- 13 ble actions 14 require_once(BASE_DIR.'inc/calendar.php');
As you can see line 13 has wrapped but I would prefer it if the line number was on the line above. So like this:
11 require_once(BASE_DIR.'inc/html.php'); // HTML output 12 require_once(BASE_DIR.'inc/auth.php'); // Authorise user 13 require_once(BASE_DIR.'inc/action.php'); // List of possi- ble actions 14 require_once(BASE_DIR.'inc/calendar.php');
I know this, but I do not know how to correct it. For my input, I just indented the source file so that every line was 75 characters long. It is easier to do that on the source file, then to write code in TeX to to do that sensibly.
Also not all my lines are wrapping properly. For instance, a line like:
if(!defined('BASE_DIR')) define('BASE_DIR',realpath(dirname(__FILE__).'/../').'/');
Basically, TeX does not know where to break the line. As I said above, the easier way is to do the line breaking in your source by hand.
Other than that, I'm loving the output.
Great! Aditya
On Sun, 29 Apr 2007, Aditya Mahajan wrote:
On Sun, 29 Apr 2007, Chris Rawnsley wrote:
On 29/04/07, Aditya Mahajan
wrote: Now after loading vim, add \definevimtyping [typePHP] [syntax=php, before={\bgroup \let\runvimsyntax\gobbleoneargument}, after={\egroup}]
and then use
\typePHP{copy.php}
I can't get it to work. Firstly, when I use \definevimtyping and then \typePHP the system cannot find the definition for \typePHP. If I use \definetypevimfile instead of \definevimtyping it works. Unfortuantely this doesn't actually save time as it loads ViM for whatever is required.
Well, then I need to make some more changes in the module. Since, you are up against a deadline right now, and are willing to suffer the delay caused by this module, I will trying hacks to make this work.
Eh.. I meant, "I will _stop_ trying hacks to make this work."
On 29/04/07, Aditya Mahajan
On Sun, 29 Apr 2007, Aditya Mahajan wrote:
Well, then I need to make some more changes in the module. Since, you are up against a deadline right now, and are willing to suffer the delay caused by this module, I will trying hacks to make this work.
Eh.. I meant, "I will _stop_ trying hacks to make this work."
That's cool. I think it works *more* than adaquetly as it stands now.
Hopefully, the next release of vim module will have a robust solution.
Maybe if you ripped out the syntax highlighting part of ViM you could make a program with faster start up and execution. Alternatively, you could use something like Scintilla ( http://scintilla.sourceforge.net/ ). If you could add some mechinisms for recognising cached files. There are always *-vimsyntax.tmp these files created. Maybe on first runs of TeXexec these should always be created and overwrite ones left over. Then when TeXexec repeats itself however many times it does, it just reads from those *-vimsyntax.tmp files. I'm sure you already have some ideas of your own though ;) It's been fun! A *huge* thanks to you! -- Chris
On Sun, 29 Apr 2007, Chris Rawnsley wrote:
On 29/04/07, Aditya Mahajan
wrote: On Sun, 29 Apr 2007, Aditya Mahajan wrote:
Well, then I need to make some more changes in the module. Since, you are up against a deadline right now, and are willing to suffer the delay caused by this module, I will trying hacks to make this work.
Eh.. I meant, "I will _stop_ trying hacks to make this work."
That's cool. I think it works *more* than adaquetly as it stands now.
Hopefully, the next release of vim module will have a robust solution.
Maybe if you ripped out the syntax highlighting part of ViM you could make a program with faster start up and execution.
This is way beyond my technical skills.
Alternatively, you could use something like Scintilla ( http://scintilla.sourceforge.net/ ).
I used vim since that is the only editor that I use and know well. In principle, any editor component can be used. If you know how to get Scintilla to generated a parsed output of its syntax highlighting, it is easy to use scintilla instead of vim. The trouble is, I do not know much about scintilla.
If you could add some mechinisms for recognising cached files. There are always *-vimsyntax.tmp these files created. Maybe on first runs of TeXexec these should always be created and overwrite ones left over. Then when TeXexec repeats itself however many times it does, it just reads from those *-vimsyntax.tmp files. I'm sure you already have some ideas of your own though ;)
There was a bad design decision in the module, which kind of makes this difficult. When I look at the whole thing again, I will try to do it in a way so that the files are not parsed on every run. There is also the option of using texmfstart --ifchanged, so that vim is called only if the file has changed. The main delay is in starting up and stopping vim. So, another option will be to convert all the files in a single shot at the end of a run, and then include them later. Last time I could not get these to work. But now that someone else is also using the module, I will give it a shot again. Aditya
I can also see a need for relative paths for inputted files. In my setup, I like to compile individual components of my document. When I need to look at whole document I'll do that at the end. For instance, for inputting images, I put this line at the top of the component: \setupexternalfigures[directory={Analysis/Figures,Figures}] Then if I compile it from within the Analysis directory it can't find the first path in the argument (Analysis/Figures) so it uses the second (Figures). I'm sure you understand how the command works. Is there a way to accomplish this in your module?
participants (4)
-
Aditya Mahajan
-
Chris Rawnsley
-
luigi scarso
-
Wolfgang Schuster