Hi,
This is my first post to this list. I've been a user of BBEdit for many years, and out of curiosity I've decided to check out TextMate. I'm actively involved in the MacTeX effort, mainly for testing, and I've written a set of Applescripts and shell scripts for BBEdit to play nice with LaTeX. For these scripts I made sure they play nice with the tricks TeXShop uses for multi-file projects, since TeXShop is the standard entry-level application that most will use when they start with (La)TeX on Mac OS X, and if you're compatible with the starting point, you make it a lot easier to upgrade to a serious editor.
I must say that I like what I've seen so far, but I have some suggestions:
Textmate runs either the current file or a file pointed to in some environment variable. I guess there is an easy way to set this variable, but TeXShop uses a method that is not all that hard to implement; I did so for some BBEdit AppleScripts [1]. The core is actually implemented in a (rather ugly) shell script, you may be able to reuse parts of the script.
TeXShop defines some meta comments, describing the source, and how it can be typeset. From the help-files:
%!TEX TS-program = command -- use command to typeset this file (pdflatex, latex, pdftex, texexec (context), …). If you encounter one of the classic tex formats (latex, tex), you should prepend with simpdf (simpdftex, simpdflatex) to handle some code which will not work in pdftex, like pstricks, simpdf(la)tex will take care of the final conversion to pdf and previewing.
%!TEX encoding = encoding -- this file is encoded in encoding (a string using the Apple system names, see below for a list). Since all sane encoding use the same lower 7 bits, you can start reading in US ASCII until this string is encountered, and re-open in the correct encoding.
%:Marker -- use Marker in a tags menu.
%!TEX root = Document -- Use Document as the root for typesetting the current file.
It would be useful to have a "open selection" command that opens a referenced file, and an open master command. I have some of those in my scripts in my bundle [1], for regular tex files, and graphics files (either open the original metapost source, of open the graphic in preview or so).
I have a sample project that shows most of the issues, mail me off- list if you are interested.
Regards,
Maarten Sneep
You haven't had real fun with regular expressions until you've written a vi regular expression to search for a vaguely remembered regular expression in a document which describes how they work.
References: [1] http://www.nat.vu.nl/~sneep/tex/CompileTeX-BBEdit8.dmg [2] http://mactextoolbox.sourceforge.net/articles/japanese.html
List of supported encodings in TeXShop. There is one item to take care of in editing TeX sources for Japanese users. The details for that can be found at [2].
MacOSRoman, IsoLatin, IsoLatin2, IsoLatin5, MacJapanese, DOSJapanese, SJIS_X0213, EUC_JP, JISJapanese, MacKorean, UTF-8 Unicode, Standard Unicode, Mac Cyrillic, DOS Cyrillic, DOS Russian, Windows Cyrillic, KOI8_R, Mac Chinese Traditional, Mac Chinese Simplified, DOS Chinese Traditional, DOS Chinese Simplified, GBK, GB 2312, GB 18030.
Maarten Sneep wrote:
This is my first post to this list. I've been a user of BBEdit for many years, and out of curiosity I've decided to check out TextMate. [...]
I must say that I like what I've seen so far, but I have some suggestions:
Well first, welcome. I hope you stick around!
Textmate runs either the current file or a file pointed to in some environment variable. I guess there is an easy way to set this variable, but TeXShop uses a method that is not all that hard to implement; I did so for some BBEdit AppleScripts [1]. The core is actually implemented in a (rather ugly) shell script, you may be able to reuse parts of the script.
TeXShop defines some meta comments, describing the source, and how it can be typeset. From the help-files:
%!TEX TS-program = command [...] %!TEX encoding = encoding [...] %!TEX root = Document
Interestingly, the following patch was checked into the TextMate bundles subversion repository about 7 hours ago:
[SVN] r6277 (Latex); from Kevin Ballard
[NEW] LaTeX now supports master files defined by the TeXShop convention %!TEX root = file It also observes %!TEX TS-program = progname, but at the moment it only cares if progname == xelatex Deleting aux files also observes this way of setting master files
Changed: U trunk/Bundles/Latex.tmbundle/Commands/LaTeX and view.plist U trunk/Bundles/Latex.tmbundle/Commands/Trash aux Files.plist A trunk/Bundles/Latex.tmbundle/Support/lib/options.sh
So it seems that much of what you are looking for is on the way. But as for encoding, TextMate really prefers UTF-8 for everything, so I'm not sure whether things will necessarily be made easier for other encodings.
It would be useful to have a "open selection" command that opens a referenced file, and an open master command. I have some of those in my scripts in my bundle [1], for regular tex files, and graphics files (either open the original metapost source, of open the graphic in preview or so).
How exactly does this work? There are similar commands in a few bundles (I dunno about LaTeX), and you can make TextMate commands pretty flexibly, so I imagine you'll be able to get this to work without much effort.
I imagine Haris and others can answer your questions better than I can. Again, welcome.
Cheers, Jacob Rus
On 2-dec-2006, at 16:48, Jacob Rus wrote:
Interestingly, the following patch was checked into the TextMate bundles subversion repository about 7 hours ago:
[snip]
So it seems that much of what you are looking for is on the way. But as for encoding, TextMate really prefers UTF-8 for everything, so I'm not sure whether things will necessarily be made easier for other encodings.
You lot are too fast… The encoding is mainly for reading files, but TeX (at this moment, this will change) can handle only classical 8- bit encodings. So both for storing and reading some support for US ASCII, and related 8-bit encodings is needed for TeX.
It would be useful to have a "open selection" command that opens a referenced file, and an open master command. I have some of those in my scripts in my bundle [1], for regular tex files, and graphics files (either open the original metapost source, of open the graphic in preview or so).
How exactly does this work? There are similar commands in a few bundles (I dunno about LaTeX), and you can make TextMate commands pretty flexibly, so I imagine you'll be able to get this to work without much effort.
\include{dir/file} reads in dir/file.tex (and starts a new page in the output). The location is relative to the location of the master or root file of the project. \input{dir/file} reads the contents of dir/file.tex in place (location again relative to the current location.
Tricky bits: the \include command is a plain tex command, and can handle file names with spaces \input{"dir/file with spaces"} (the same is still true of \include). However, and this is the really tricky bit: \input dir/file or \input "dir/file with spaces" are equivalent to \input{dir/file} and \input{"dir/file with spaces"}, respectively. If an extension is specified, it takes precedence, but .tex is tried in any case.
\includegraphics pretty much works the same way, but a set of extensions is tried. One additional trick: there may be a graphics search path in effect, to search a completely different tree altogether. I've never used that, but there are command-line utilities to help out here (kpsewhich, kpsewhat). It is probably too tricky to try to support this for a first release.
I imagine Haris and others can answer your questions better than I can. Again, welcome.
I can wait…
Thanks for the quick response.
Maarten
Hi Maarten,
welcome aboard! I hope you like it and stay with us!
This might overlap with what Jacob said, but since I wrote it while offline I'll just send it along as is.
On Dec 2, 2006, at 8:50 AM, Maarten Sneep wrote:
Hi,
This is my first post to this list. I've been a user of BBEdit for many years, and out of curiosity I've decided to check out TextMate. I'm actively involved in the MacTeX effort, mainly for testing, and I've written a set of Applescripts and shell scripts for BBEdit to play nice with LaTeX. For these scripts I made sure they play nice with the tricks TeXShop uses for multi-file projects, since TeXShop is the standard entry-level application that most will use when they start with (La)TeX on Mac OS X, and if you're compatible with the starting point, you make it a lot easier to upgrade to a serious editor.
TeXShop defines some meta comments, describing the source, and how it can be typeset. From the help-files:
%!TEX TS-program = command %!TEX encoding = encoding %:Marker %!TEX root = Document
By an odd coincidence, Kevin Ballard added yesterday support for %! TEX root, and some rudimentary support for %!TEX TS-program. To check that out, you will need to check out the subversion version of the bundle, which gets updated very frequently. Look at the TextMate manual [1] in the section “Getting More Bundles” for information how to set that up, and you can email the list with any problems (or even better, join us at the ##textmate IRC channel)
We actually already were doing a bit of sniffing of the file to detect which program should be used, for instance switching to latex +dvips in the presence of pstricks, or to xelatex in the presence of the xunicode or fontspec packages. But these settings will take precedence.
It would be useful to have a "open selection" command that opens a referenced file, and an open master command. I have some of those in my scripts in my bundle [1], for regular tex files, and graphics files (either open the original metapost source, of open the graphic in preview or so).
That's actually not a bad idea, and should be easy to implement. I suppose you mean something like: If the caret is over the filename in \include{filename}, then to open filename for editing, or if the caret is over the image in \includegraphics{image}, to open the image. Or would you rather the command scans the entire line for any such relevant things, and offer you a popup if there are more than one?
Addendum: I just prepared such a command, and will be committing it shortly. Probably not perfect yet.
As far as encoding goes, TextMate always presents its commands with utf-8 data, taking care of trying to figure out the encoding of the original file as best it can, and keeping this transparent from the bundle items, which just act on utf-8 data. Allan has talked extensively on his views on the whole encoding issue [2]. Let us know of any particular problems you encounter.
Finally, the %: markers have been implemented for some time now I think, you should be seeing them in the symbol list, which you can see in the bottom right of the window, or you can bring it up via ctrl-shift-T.
Perhaps here I will take the opportunity to list the various resources on the workings of the LaTeX bundle, even though they are slightly out of date (and the mailing list archives offer for the moment more up to date info).
1. The built in LaTeX bundle help, which you can find by opening the bundle menu via ctrl-esc for instance, and navigating to LaTeX -> Help. Pressing the Help button on your keyboard (if you have such a button) while in a LaTeX file should have the same effect. 2. There are a number of screencasts and post on my blog: [3]
I have a sample project that shows most of the issues, mail me off- list if you are interested.
Please do send it to me.
Haris
[1] http://www.macromates.com/textmate/manual [2] http://macromates.com/blog/archives/2005/09/18/handling-encodings- utf-8/ [3] http://skiadas.dcostanet.net/afterthought/list-of-my-textmate-pages/
Regards,
Maarten Sneep
References: [1] http://www.nat.vu.nl/~sneep/tex/CompileTeX-BBEdit8.dmg [2] http://mactextoolbox.sourceforge.net/articles/japanese.html
List of supported encodings in TeXShop. There is one item to take care of in editing TeX sources for Japanese users. The details for that can be found at [2].
MacOSRoman, IsoLatin, IsoLatin2, IsoLatin5, MacJapanese, DOSJapanese, SJIS_X0213, EUC_JP, JISJapanese, MacKorean, UTF-8 Unicode, Standard Unicode, Mac Cyrillic, DOS Cyrillic, DOS Russian, Windows Cyrillic, KOI8_R, Mac Chinese Traditional, Mac Chinese Simplified, DOS Chinese Traditional, DOS Chinese Simplified, GBK, GB 2312, GB 18030.
Hi,
On 2-dec-2006, at 20:35, Charilaos Skiadas wrote:
On Dec 2, 2006, at 8:50 AM, Maarten Sneep wrote:
TeXShop defines some meta comments, describing the source, and how it can be typeset. From the help-files:
%!TEX TS-program = command %!TEX encoding = encoding %:Marker %!TEX root = Document
By an odd coincidence, Kevin Ballard added yesterday support for %! TEX root, and some rudimentary support for %!TEX TS-program. To check that out, you will need to check out the subversion version of the bundle, which gets updated very frequently. Look at the TextMate manual [1] in the section “Getting More Bundles” for information how to set that up, and you can email the list with any problems (or even better, join us at the ##textmate IRC channel)
OK, I'll try to get the latest edition.
It would be useful to have a "open selection" command that opens a referenced file, and an open master command. I have some of those in my scripts in my bundle [1], for regular tex files, and graphics files (either open the original metapost source, of open the graphic in preview or so).
That's actually not a bad idea, and should be easy to implement. I suppose you mean something like: If the caret is over the filename in \include{filename}, then to open filename for editing, or if the caret is over the image in \includegraphics{image}, to open the image. Or would you rather the command scans the entire line for any such relevant things, and offer you a popup if there are more than one?
I scan the whole line where the insertion point is, and open the first one I find. A variation of the command opens all referenced files in the current document. For the graphics you may want to perform some additional trickery (people who use metapost may want the source of the image, rather than the pdf -- and some more name- mangling may be needed).
Addendum: I just prepared such a command, and will be committing it shortly. Probably not perfect yet.
The technical term is iteration, I believe.
As far as encoding goes, TextMate always presents its commands with utf-8 data, taking care of trying to figure out the encoding of the original file as best it can, and keeping this transparent from the bundle items, which just act on utf-8 data. Allan has talked extensively on his views on the whole encoding issue [2]. Let us know of any particular problems you encounter.
Well, tex was written in the pure 7-bit era, when computing dinosaurs inhabited the face if the internet, there may even have been a version that could run on an EBCDIC system. There are versions coming (xetex, luatex) that will handle utf-8 natively, but at this moment, tex itself is only 8-bit clean. There is an inputenc module that handles utf8, but it is far from complete. Most tex users who want to type characters beyond 7-bit ASCII will rely on one of the 8-bit sets (iso-latin-1 through 15, etc). Since this encodung is given in the source, it is not completely trivial to change this automagically.
Perhaps here I will take the opportunity to list the various resources on the workings of the LaTeX bundle, even though they are slightly out of date (and the mailing list archives offer for the moment more up to date info).
Thanks for the pointers.
I have a sample project that shows most of the issues, mail me off- list if you are interested.
Please do send it to me.
Do not expect it to compile (an update to Memoir seems to have introduced a bug somewhere). I'll send the archive in a separate message.
Maarten
On Dec 3, 2006, at 2:10 PM, Maarten Sneep wrote:
I scan the whole line where the insertion point is, and open the first one I find. A variation of the command opens all referenced files in the current document. For the graphics you may want to perform some additional trickery (people who use metapost may want the source of the image, rather than the pdf -- and some more name- mangling may be needed).
If you tell me what sort of trickery you'd like, I can try and modify the command to use it.
As far as encoding goes, TextMate always presents its commands with utf-8 data, taking care of trying to figure out the encoding of the original file as best it can, and keeping this transparent from the bundle items, which just act on utf-8 data. Allan has talked extensively on his views on the whole encoding issue [2]. Let us know of any particular problems you encounter.
Well, tex was written in the pure 7-bit era, when computing dinosaurs inhabited the face if the internet, there may even have been a version that could run on an EBCDIC system. There are versions coming (xetex, luatex) that will handle utf-8 natively, but at this moment, tex itself is only 8-bit clean. There is an inputenc module that handles utf8, but it is far from complete. Most tex users who want to type characters beyond 7-bit ASCII will rely on one of the 8-bit sets (iso-latin-1 through 15, etc). Since this encodung is given in the source, it is not completely trivial to change this automagically.
Well, TextMate likes to save things as UTF-8. I have an idea, but I don't know if it would actually work quite right. Tell me what you think:
Let TextMate save files as UTF-8. Specify a %!TEX encoding = enc- name. The Typeset command could then pass the file through iconv to convert to the desired encoding, and save it temporarily on disc as .filename.converted.tex, and then pass the -jobname switch to pdflatex to tell it to use the original filename as the name for the job.
On 3-dec-2006, at 20:32, Kevin Ballard wrote:
On Dec 3, 2006, at 2:10 PM, Maarten Sneep wrote:
I scan the whole line where the insertion point is, and open the first one I find. A variation of the command opens all referenced files in the current document. For the graphics you may want to perform some additional trickery (people who use metapost may want the source of the image, rather than the pdf -- and some more name- mangling may be needed).
If you tell me what sort of trickery you'd like, I can try and modify the command to use it.
\include: extension is never included in the tex source, extension is always .tex \input: extension may be omitted, when not present it is assumed to be .tex. Can be anything. \includegraphics: extension may be omitted. Depends on engine what the possibilities are: classic TeX: .eps, perhaps .tif. pdf TeX: .pdf, .jpg, .png, .mps. - if jpg or png are found, open them directly (no likely text-based source available). - for .mps try to open the same basename with extension .mp (metapost), as it is likely the source for the graphic. - if the pdf ends in "-1.pdf", try to open the same basename, without -1 and extension .mp (file-1.pdf -> file.mp) and sroll to beginfig(1) in that file. "1" can be replaced by any number "0" … "255". The tool mptopdf produces this output.
For eps there can be any kind of source, and guessing which one it acutally is is going to be hard. Besides, current developments in luatex point to all future things in TeX being done in pdf (dvi is going the way of the dodo).
Well, TextMate likes to save things as UTF-8. I have an idea, but I don't know if it would actually work quite right. Tell me what you think:
Let TextMate save files as UTF-8. Specify a %!TEX encoding = enc- name. The Typeset command could then pass the file through iconv to convert to the desired encoding, and save it temporarily on disc as .filename.converted.tex, and then pass the -jobname switch to pdflatex to tell it to use the original filename as the name for the job.
That might work, but as a backup, the option for \usepackage[encoding] {inputenc} should be scanned as well, since that tells TeX what to expect.
Maarten
Maarten Sneep wrote:
I scan the whole line where the insertion point is, and open the first one I find. A variation of the command opens all referenced files in the current document. For the graphics you may want to perform some additional trickery (people who use metapost may want the source of the image, rather than the pdf -- and some more name- mangling may be needed).
Well, in my opinion, it's much better to set the key equivalent to ⌅, and then only work within the scope of the "\include...". That way we don't need to use up any other keyboard shortcuts. Also, ⌅ is pretty much the norm for opening whatever thing the caret is currently on.
On Dec 3, 2006, at 4:48 PM, Jacob Rus wrote:
Well, in my opinion, it's much better to set the key equivalent to ⌅, and then only work within the scope of the "\include...". That way we don't need to use up any other keyboard shortcuts. Also, ⌅ is pretty much the norm for opening whatever thing the caret is currently on.
Unfortunately it is also the norm for adding a new \item in a list environment. So admittedly it could work if the caret is at the correct scope, but I personally would find this more useful if it gets activated from anywhere in the current line.
Haris
On 3. Dec 2006, at 22:59, Charilaos Skiadas wrote:
On Dec 3, 2006, at 4:48 PM, Jacob Rus wrote:
Well, in my opinion, it's much better to set the key equivalent to ⌅, and then only work within the scope of the "\include...". That way we don't need to use up any other keyboard shortcuts. Also, ⌅ is pretty much the norm for opening whatever thing the caret is currently on.
Unfortunately it is also the norm for adding a new \item in a list environment. So admittedly it could work if the caret is at the correct scope, but I personally would find this more useful if it gets activated from anywhere in the current line.
I think it should be ⌅ and scoped to the actual filename.
You can still manually select the command from the menu.
On Feb 11, 2007, at 7:02 AM, Allan Odgaard wrote:
On 3. Dec 2006, at 22:59, Charilaos Skiadas wrote:
On Dec 3, 2006, at 4:48 PM, Jacob Rus wrote:
Well, in my opinion, it's much better to set the key equivalent to ⌅, and then only work within the scope of the "\include...". That way we don't need to use up any other keyboard shortcuts. Also, ⌅ is pretty much the norm for opening whatever thing the caret is currently on.
Unfortunately it is also the norm for adding a new \item in a list environment. So admittedly it could work if the caret is at the correct scope, but I personally would find this more useful if it gets activated from anywhere in the current line.
I think it should be ⌅ and scoped to the actual filename.
You can still manually select the command from the menu.
Done.
Haris
On 3-dec-2006, at 22:48, Jacob Rus wrote:
Maarten Sneep wrote:
I scan the whole line where the insertion point is, and open the first one I find. A variation of the command opens all referenced files in the current document. For the graphics you may want to perform some additional trickery (people who use metapost may want the source of the image, rather than the pdf -- and some more name- mangling may be needed).
Well, in my opinion, it's much better to set the key equivalent to ⌅, and then only work within the scope of the "\include...". That way we don't need to use up any other keyboard shortcuts. Also, ⌅ is pretty much the norm for opening whatever thing the caret is currently on.
Well, when I originally wrote all this (for BBEdit) I didn't assign any keyboard shortcuts. Especially the open all in current file is a command that can easily be run from a menu, and even "open selection" (when patched to correct for the TeX idiosyncrasies) can reside in the file menu (and have a global scope from there). I don't think that open selection is so important to warrant a really short, and easily overloaded ⌅ shortcut.
Maarten
On Dec 3, 2006, at 5:07 PM, Maarten Sneep wrote:
Well, when I originally wrote all this (for BBEdit) I didn't assign any keyboard shortcuts. Especially the open all in current file is a command that can easily be run from a menu, and even "open selection" (when patched to correct for the TeX idiosyncrasies) can reside in the file menu (and have a global scope from there). I don't think that open selection is so important to warrant a really short, and easily overloaded ⌅ shortcut.
It's true, perhaps we don't need a key equivalent, especially since TextMate offers a number of ways to locate the command: 1) ctrl-esc, right arrow, "p", right arrow, down arrow, enter, or 2) ctrl-cmd-T, "openinc", enter, or 3) Clicking on the gear button at the bottom of the document
But in general there are a lot of keyboard shortcuts to go around, so we tend to associate some keyboard shortcut with each command, unless it is really a command that is going to be used very rarely.
In this case I have provisionally used ctrl-cmd-L for this, though this is likely to change once we find an better candidate. We might also want to rename the command to "Go to somethingorother" to match more what it is doing. I tend to think of it a bit like the goto commands in the rails bundle.
In a similar vein, we probably want a command that will take you from a \ref to the corresponding \label part, or at least show the couple of lines after the \label part. And conversely, from the \label part, a list of the various \ref's referring to it.
Maarten
Haris
On 3. Dec 2006, at 20:10, Maarten Sneep wrote:
As far as encoding goes, TextMate always presents its commands with utf-8 data, taking care of trying to figure out the encoding of the original file as best it can, and keeping this transparent from the bundle items, which just act on utf-8 data. Allan has talked extensively on his views on the whole encoding issue [2]. Let us know of any particular problems you encounter.
Well, tex was written in the pure 7-bit era, when computing dinosaurs inhabited the face if the internet, there may even have been a version that could run on an EBCDIC system. There are versions coming (xetex, luatex) that will handle utf-8 natively, but at this moment, tex itself is only 8-bit clean. There is an inputenc module that handles utf8, but it is far from complete. Most tex users who want to type characters beyond 7-bit ASCII will rely on one of the 8-bit sets (iso-latin-1 through 15, etc). Since this encodung is given in the source, it is not completely trivial to change this automagically.
Are you saying that the utf-8 input encoding will not support the union of latin-1 through 15? If yes, can you give an example? If no, what is the advantage of sticking to latin-x when utf-8, while still incomplete, can represent the same and more?