Hi,
Some weeks ago I wrote this ruby script that works inside a TextMate command to build a list of references declared in Latex files and let the user select the reference he wants to insert in the text:
----------------------- #!/usr/bin/env ruby -wKU
SUPPORT = ENV['TM_SUPPORT_PATH'] DIALOG = SUPPORT + '/bin/tm_dialog'
require SUPPORT + '/lib/escape' require SUPPORT + '/lib/plist' require 'pathname' require 'find'
refs = []
Find.find(ENV['TM_PROJECT_DIRECTORY']) do |f| file_name = File.basename(f) if /.(tex)$/ =~ file_name File.open(file_name,"r") do |infile| infile.each_line do |line| if line =~ /.*\label{.*/ line = line.gsub(/.*\label{(.*)}.*/, '\1').chomp refs << { 'title' => line, 'code' => "\ref{#{line}}" } end end end end end abort if refs.empty?
plist = { "menuItems" => refs }.to_plist res = PropertyList::load(`#{e_sh DIALOG} -up #{e_sh plist}`) abort unless res.has_key? "selectedMenuItem"
print %(#{res["selectedMenuItem"]['code']}) -----------------------
Since the last updates (both of TextMate and its bundles), the script does not work anymore.
When I invoke it, it gives me back the following error.
----------------------- tm_dialog: you have updated the tm_dialog tool to v7 but the Dialog plug-in running is still at v4. tm_dialog: either checkout the PlugIns folder from the repository or remove your checkout of the Support folder. tm_dialog: if you did checkout the PlugIns folder, you need to relaunch TextMate to load the new plug-in. /tmp/temp_textmate.ZcyesN:32:in `load': Cannot parse a NULL or zero- length data (PropertyListError) from /tmp/temp_textmate.ZcyesN:32 -----------------------
I'm a TextMate newbe, thus I'm not sure, but from the error message it seems like I need to update the Dialog.tmplugin file. How can I fix this ?
Cheers, Leonardo
Leonardo Querzoni wrote:
tm_dialog: you have updated the tm_dialog tool to v7 but the Dialog plug-in running is still at v4. tm_dialog: either checkout the PlugIns folder from the repository or remove your checkout of the Support folder. tm_dialog: if you did checkout the PlugIns folder, you need to relaunch TextMate to load the new plug-in. /tmp/temp_textmate.ZcyesN:32:in `load': Cannot parse a NULL or zero- length data (PropertyListError) from /tmp/temp_textmate.ZcyesN:32
I'm a TextMate newbe, thus I'm not sure, but from the error message it seems like I need to update the Dialog.tmplugin file. How can I fix this ?
When you do an svn update of the /plugins folder, then you need to make sure to restart textmate, so that the new plugin will be loaded.
On Dec 14, 2006, at 6:32 AM, Leonardo Querzoni wrote:
Some weeks ago I wrote this ruby script that works inside a TextMate command to build a list of references declared in Latex files and let the user select the reference he wants to insert in the text:
Out of curiosity, any reason you are not simply using the "Insert -> Label From Document" command in the LaTeX bundle? I suppose it doesn't insert the \ref part. I think we can modify the command to do just that. Are there other reasons?
Haris
Haris, the Insert Label command is nice but difficult to use. Let me explain.
First of all I must write by hand \ref{} or \eqref{} and this could be improved as you say.
But the worse is that usually the number of labels is quite high (50+ is common). When I invoke the command, a very long list appears, and it is in alphabetical order. I must scroll up and down to locate the label I want; of course I do not remember which one it is exactly, so it takes a long time to find the right one.
You will say: I must write the initial letters of the label so the list that appears is much shorter. This is not a solution because:
1) this forces me to remember the beginning of the right label: it takes even longer to remember it, and it takes longer to write \eqref{firstletters...} than to write the full label by hand
2) all of my labels start with eq: (I'm not alone I think) Apparently, if I write eq: followed by some letters the script does not work; maybe you check for letters and digits only in the name?
Exactly to overcome these problems I proposed some weeks ago a different mechanism based on a semi-permanent html window. Would you like to give a look to it? It's rudimentary but I used it a little and it seems to be handier that the present Insert Label command. Please tell me if you have the time to check it, I think there is something useful in it
Piero
On Dec 14, 2006, at 10:33 PM, Piero D'Ancona wrote:
Haris, the Insert Label command is nice but difficult to use. Let me explain.
First of all I must write by hand \ref{} or \eqref{} and this could be improved as you say.
Will fix that in my next commit, I've already made the changes locally. It does require that you type the first couple of letters of the citation though, like "fig" for instance for figures, or "eq" for equations.
But the worse is that usually the number of labels is quite high (50+ is common). When I invoke the command, a very long list appears, and it is in alphabetical order. I must scroll up and down to locate the label I want; of course I do not remember which one it is exactly, so it takes a long time to find the right one.
You don't have to scroll up and down, you can just start typing letters starting with the first letter and it moves you to the appropriate place in the list. And the long list will be there no matter what format the thing is in, no matter what, if that's how many citations you have.
You will say: I must write the initial letters of the label so the list that appears is much shorter. This is not a solution because:
- this forces me to remember the beginning of
the right label: it takes even longer to remember it, and it takes longer to write \eqref{firstletters...} than to write the full label by hand
If you name them consistently, with eq for equations, thm for theorems, def for definitions and so one, it would certainly be easy to type the first three letters, presumably you know what kind of text you want to link to, i.e. whether it refers to an equation or whatnot. I always follow the "three letters plus a :" convention, and it certainly makes my life easier. I also opt for very long descriptive names, like fig:changeNearCritPoint and thm:descentPathBasis. So often the name gives me quite a clue as to what the label refers to. If we even had Allan's nice "Go to..." window, it would make filtering even easier. *That* would be the better solution IMO.
- all of my labels start with eq: (I'm not alone I think)
Apparently, if I write eq: followed by some letters the script does not work; maybe you check for letters and digits only in the name?
The problem here is that you have not set ":" to be in your list of word characters (Preferences -> Text Editing). If you stop at eq, or if you add : to this list, it should work just fine. The command accepts as input the current word or selection, so if ":" is not a word character, then the caret doesn't find a word to work with, since it is between the ":" and the "}" atm.
Exactly to overcome these problems I proposed some weeks ago a different mechanism based on a semi-permanent html window. Would you like to give a look to it? It's rudimentary but I used it a little and it seems to be handier that the present Insert Label command. Please tell me if you have the time to check it, I think there is something useful in it
I have actually looked at it, and it is pretty nice overall. It is definitely nice that you can leave it open at the side, though I think for that a plugin would be better, or at least a HTML window that using javascript to reparse the file every now and then and update its information. My main problem with it is though, that it requires you to use the mouse, and that is really not acceptable. It has the great advantage of showing you the context of each label, and this is something we could relatively easily incorporate into the existing command, at least showing the line that the label is at on the side (well, should probably cut the line to 40 characters or so, since LaTeX lines tend to be long).
The thing we are missing, which would be very nice, would be a command that would show you as a popup the context around the corresponding \label entry, when you are over a \ref entry. Shouldn't be too hard to implement.
Piero
Haris
Leonardo Querzoni <querzoni@...> writes:
I'm a TextMate newbe, thus I'm not sure, but from the error message it seems like I need to update the Dialog.tmplugin file. How can I fix this ?
Leo: the following works for me (but I must say that this aspect of TextMate should be really ironed out)
In a terminal window, cd /Library/Application\ Support/TextMate and then svn co http://macromates.com/svn/Bundles/trunk/PlugIns (if asked for name/pass: anon/anon)
I see this has come up several times, with the common (and rather obvious, seeing as it's stated fairly explicitly in the error message) answer being to update the entire Support directory from SVN and restart TextMate.
I bring this back up, however, because I thought the GetBundle bundle's autoupdater was generally supposed to keep everything up-to-date with the repository. I've been using this in place of a personal (manual) SVN checkout since my last OS reinstall a month or two ago, but I've just found that *it* seems to have updated the bundles independently of the plugins, if it updated plugins at all. Forcing a manual update-all through the bundle's commands and restarting TextMate multiple times has yielded no change.
I thought the bundle updater was the preferred way of staying up-to-date these days. Is that no longer the case? How are we supposed to keep the plugins and bundles in sync using the auto-updater? I'm more than capable of checking out the bundles by hand (indeed, it was the SVN bundle where I first ran into this), I'd just like to stay on the smoothest/most-approved path where possible.
Thanks. -jrk
On 12/14/06, Leonardo Querzoni querzoni@gmail.com wrote:
Hi,
Some weeks ago I wrote this ruby script that works inside a TextMate command to build a list of references declared in Latex files and let the user select the reference he wants to insert in the text:
#!/usr/bin/env ruby -wKU
SUPPORT = ENV['TM_SUPPORT_PATH'] DIALOG = SUPPORT + '/bin/tm_dialog'
require SUPPORT + '/lib/escape' require SUPPORT + '/lib/plist' require 'pathname' require 'find'
refs = []
Find.find(ENV['TM_PROJECT_DIRECTORY']) do |f| file_name = File.basename(f) if /.(tex)$/ =~ file_name File.open(file_name,"r") do |infile| infile.each_line do |line| if line =~ /.*\label{.*/ line = line.gsub(/.*\label{(.*)}.*/, '\1').chomp refs << { 'title' => line, 'code' => "\ref{#{line}}" } end end end end end abort if refs.empty?
plist = { "menuItems" => refs }.to_plist res = PropertyList::load(`#{e_sh DIALOG} -up #{e_sh plist}`) abort unless res.has_key? "selectedMenuItem"
print %(#{res["selectedMenuItem"]['code']})
Since the last updates (both of TextMate and its bundles), the script does not work anymore.
When I invoke it, it gives me back the following error.
tm_dialog: you have updated the tm_dialog tool to v7 but the Dialog plug-in running is still at v4. tm_dialog: either checkout the PlugIns folder from the repository or remove your checkout of the Support folder. tm_dialog: if you did checkout the PlugIns folder, you need to relaunch TextMate to load the new plug-in. /tmp/temp_textmate.ZcyesN:32:in `load': Cannot parse a NULL or zero- length data (PropertyListError) from /tmp/temp_textmate.ZcyesN:32
I'm a TextMate newbe, thus I'm not sure, but from the error message it seems like I need to update the Dialog.tmplugin file. How can I fix this ?
Cheers, Leonardo
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate