[TxMt] Re: snippet that replaces the current word

Luke Daley ld at ldaley.com
Tue Sep 23 13:39:42 UTC 2008


On 23/09/2008, at 10:40 PM, Timothy Bates wrote:

> 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).

Hi Timothy,

The goal of unified formatting commands is pretty much only that at  
the moment, a goal.

As you have worked out, this is a tricky problem to crack. I have had  
several rounds of discussions with Allan and Michael about this which  
pretty much resulted in us spinning on the problems. The reason for  
creating the branch was to work through these issues. The point is,  
the current code is not a solution, only a start.

What is making things harder for you is that I didn't commit  
everything when I branched, apologies for that.

I just added the Un* commands. These should solve the problem you are  
seeing. However, you need to make sure your grammar scopes  
`markup.bold.*` correctly. This scope should be the bolded content as  
well as the bold markers.

Give that a try and see if that works for you. =

--

LD.




More information about the textmate mailing list