Dear all,
Looking some more into this, the new environment variables for italic, bold, and underline markup are imported into commands in the ENV[] array, so that makes building those commands more generic. So far so good.
My roadblock now is that to get the format commands to act as toggles (i.e. they remove or add markup as appropriate), the "word" environment variable should let the formatting though, but it doesn't, (so '*bold*' comes in as 'bold').
Before I reinvent the wheel, does anyone have code to use the "TM_LINE_INDEX" to parse "TM_CURRENT_LINE", extracting the current word plus markers such as "TM_BOLD_MARKER" on either side if present?
My stumbling block is writing a regex to find the "TM_CURRENT_WORD" but only when it is at the "TM_LINE_INDEX" location (to avoid making mistakes when a line contains multiple copies of the current word).
tim
On 23 Sep 2008, at 7:25 AM, Hans-Jörg Bibiko wrote:
On 23.09.2008, at 00:34, Timothy Bates wrote:
I'm trying to write a snippet for wikimedia for applying bold (wrapping a string in **str**)
I've attached cmd-B to the snippet, and I'd like it to bold the CURRENT_WORD if there is no selection. Sounds like a job for:
**${TM_SELECTED_TEXT:$TM_CURRENT_WORD}**
Works fine for the selected text, but not for the current word, where it returns things like this:
he|re -->cmd-B--> he**here**re
Any pointers, or do I need to be made into a command? (in that case, what use does $TM_CURRENT_WORD have in snippets?
TM's snippet system 'only' inserts something. It only replaces something if you invoke it via 'foo' and pressing TAB. Ad hoc I do not know whether one needs $TM_CURRENT_WORD in a snippet but one never knows. In a snippet one could write **${1:${TM_SELECTED_TEXT:text}}**
Or even a command à la:
input: selection or word echo -n "**`cat`**" output: replace selection
if you don't select something in beforehand.
--Hans
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate