# [TxMt] a better label completion techique

Piero D\\\\\\\'Ancona pierodancona at gmail.com
Sun Sep 24 13:56:05 UTC 2006

Hi,
this is a followup to the thread with a similar name,
but I thought it deserved a new thread since I'm posting
a complete solution (hehe - I'm trapped in a hotel room
in Paris, it's raining here...)

So:

1) create a new command "Lable Table" with
input= entire document
output=Show as HTML

2) the command is the following. (I know, I should
post a .tmCommand file, but I do not know how
so bear with me). GMane requested me to split
the commands, but we have here 6 commands
(5 sed and 1 tr) which should be on one line each.
When joining back the last sed command do not
introduce spaces.

sed -n -e "/\\label/{=;N;N;G;p;}" |
sed '/^$/d' | sed 's/^$$[0-9]*$$$/\<p\>\<\/p\>\1/' |
sed 's/$$.$$\$/\1\<br\>/' |
sed 's/\\label{$$.*$$}/\<a href=\"javascript:TextMate.system
(\"\/usr\/bin\/osascript \&\>\/dev\/null -e %tell app \\\
"TextMate\\\" to insert \\\"\1\\\"% \&
amp;\&quot, null);\"\>\\label{\1}\<\/a>/' |
tr "%" "'"

3) open a .tex file and experiment. When you click on a label
the argument is inserted. The command and the text
insertion is very fast, and as to usability it's already
better than the standard Label completion (my taste).

Please, some real coder take this stuff and make it into
some serious code, I think the result is pretty amazing
compared with the simplicity. I am not able to extend
the script for multiple files (i.e. one master file and the
\includes), any help?

Ciao,
Piero