Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1
Send Topic Print
Edit in Textmate (Read 13062 times)
Stéphane R
Full Member
*
Offline



Posts: 71

Edit in Textmate
Feb 27th, 2010, 4:10pm
 
Hi,

I'm posting this to share another quick trick which I've found very useful - apologies if this is too basic to be posted here.

As I'm a bit frustrated with the in-built editor for TB notes - and lately even copy/paste is sometimes not working - and absolutely love Textmate's extensive arsenal to manipulate text, I've devised a little workflow to automatise external editing.

It requires creating two stamps to interact with the clipboard
1) Stamp "Copy Text" with the following rule:   runCommand("echo $Text | pbcopy")
2) Stamp "Paste Text" with rule:   $Text=`pbpaste

Then write two small macros in Keyboard Maestro:

1) "Edit in Textmate"
Triggered by "The Hot Key ⌥T" (only in Tinderbox)
Executes the following actions:
  Select ‘Copy Text’ in the menu ‘Stamps’ in the front application
  Activate TextMate
  Select ‘New’ in the menu ‘File’
  Type the ⌘V Keystroke

2) "Paste into Tinderbox"
Triggered by "The Hot Key ⌘T" (only in Textmate)
Executes the following actions:
  Type the ⌘A Keystroke
  Type the ⌘C Keystroke
  Type the ⌘W Keystroke
  Type the Space Keystroke
  Activate Tinderbox
  Select ‘Paste Text’ in the menu ‘Stamps’


That's it


PS: Of course, this would mess with styling, so it's only useful with plain text
Back to top
 
« Last Edit: Feb 27th, 2010, 5:22pm by Stéphane R »  
  IP Logged
Matt Cawood
Full Member
*
Offline



Posts: 109
New England, Australia
Re: Edit in Textmate
Reply #1 - Feb 28th, 2010, 5:41am
 
Those considering this trick might also consider the very capable editor Jedit X and associated preference pane, JEdit Anywhere. This combination allows you to highlight text in Tinderbox, double-click the option key to automatically transfer the text to JEdit X, use JEdit's useful tools, and then push the edit back to the original Tinderbox note. See www.artman21.com

I'm pretty enamoured of JEdit X. It's cleanly and thoughtfully designed, and happens to do all the things I want it to do. I tried Tinderbox as my one-stop-shop for writing articles, and while it was close--and I loved the footnoting capability for notes-to-self--it misses some capability. Find-and-replace, for instance. I could write an agent to do the job, but that seems a long way around.

I was going to continue using Tinderbox and just use JEdit Anywhere to help me out when I hit up against Tinderbox's limitations, but realised that because all my Tinderbox work notes end up being archived in Devonthink anyway, I may as well make a JEdit writing template in Devonthink and work from that. And I do.
Back to top
 
 
  IP Logged
Paul Walters
Full Member
*
Offline



Posts: 267

Re: Edit in Textmate
Reply #2 - Feb 28th, 2010, 9:10am
 
Excellent tips, Matt.  Here's another approach that doesn't require a TextMate license.  If you have Bean (free and very good RTF editor) it has a service: "New Document Containing Selection".  If that service is activated in the "text" section of Snow Leopard services -- assigning a hot key is optional -- then any portion of a Tinderbox note's text can be zapped into Bean using the Tinderbox > Services menu or the hot key.  After Bean editing, select all/copy and back to Tinderbox to paste the change right on top of the selected text.  This approach yields styled text.  It would also fit into your Keyboard Maestro recipe.
Back to top
 
« Last Edit: Feb 28th, 2010, 9:10am by Paul Walters »  
  IP Logged
Matt Cawood
Full Member
*
Offline



Posts: 109
New England, Australia
Re: Edit in Textmate
Reply #3 - Mar 8th, 2010, 12:41am
 
A quick appendix on JEdit Anywhere: I've also found it to be a great tool to help writing long agent queries.

The limited single line query view available in Tinderbox means that queries often run off the page, leaving you to scroll clumsily back and forth as you work out what you've said, where. JEdit Anywhere pops the query into a full editing window, where you can see it in all its glory, edit it, and then automatically save it back into the query window. Neat.

The usual disclaimers about my lack of association with JEdit's developer applies ...
Back to top
 
 
  IP Logged
Jean Goodwin
Full Member
*
Offline



Posts: 136
North Carolina
Re: Edit in Textmate
Reply #4 - Mar 8th, 2010, 8:00am
 
Personally, I use Tinderbox itself to edit complex $Rules, $OnAdds, $AgentQuerys and $AgentActions.  I make the $Rule (etc.) a KeyAttribute, and edit the expression by opening the note/agent and cutting & pasting it from the note's Text.  That way, I get to save all the failed attempts so I don't repeat them.
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Edit in Textmate
Reply #5 - Mar 8th, 2010, 8:21am
 
You can also use another note to hold code. I do this often, setting the font to a monospace - coding style font so I can see and control where white space. Indeed, v5.0.2's built-in prototype 'Code' is set up for just such usage. You can even use the code in situ. Instead of pasting the code into the first note's rule, open the code note's Rule and type $Rule(Some note) = $Text; with 'Some note' being the name of the note on whose Rule we are working.

No need for other apps - unless you prefer that - and a much easier way to handle long action code sequences.
Back to top
 
« Last Edit: Mar 8th, 2010, 3:50pm by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Sumner Gerard
Full Member
*
Offline



Posts: 359

Re: Edit in Textmate
Reply #6 - Mar 8th, 2010, 12:25pm
 
Noticed the built-in prototypes but didn't know how one could use prototype 'Code' -- i.e. that it could reduce the need for an external text editor. (In 5.0.2. I've found editing stamp actions particularly challenging; changes made to existing code in the Stamps/Edit Stamp 'Action' box 'disappear' before I have a chance to save them, as if the original code is being 'refreshed' at short intervals, wiping out any unsaved changes.)

Here do you mean you can construct code in the text window of the note with prototype 'Code' and then choose 'Rename' and in the Rule box enter:

      $Rule(Some note) = $Text
   
Or is there a way of doing it involving just $Rule ?
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Edit in Textmate
Reply #7 - Mar 8th, 2010, 12:48pm
 
I think that interpretation re ''Code' is over literal. The 'Code' prototype is simply a prototype where various text window settings have been tweaked to aid coding, i.e. sidebar off, monospace font, no paragraph spacing. It doesn't affect how action code runs - the same code will run equally well from a default note as it does from one using the 'Code' prototype. I just find the display in the latter easier to use for code, you may prefer to use default settings.

To view/edit/set the Rule code of note 'A' in note A (i.e. in the same note), simply open Note A's text window. Type in your rule code but note this means you can't have any other text there, just the code. Now open Rename and in the 'Rule' box type "$Rule=$Text". Click OK. Assuming no code errors, if you re-open the rename dialog, the rule is now what was in $Text. If you edit $Text, you'll have to re-apply the $Rule=$Text to make the note re-import the text.

That is why my earlier example is better, we store A's  rule code in Note B and use B's rule to set A's rule to the $Text of B. 2 advantages: A can now have normal (body text $Text) plus changes to the text of B update A's rule.  If you don't understand - just try it as the results are self-evident.
Back to top
 
« Last Edit: Mar 8th, 2010, 3:50pm by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Edit in Textmate
Reply #8 - Mar 8th, 2010, 1:07pm
 
Toavoid the unwanted refresh in 5.0.2, turn off automatic agent updates. (This will be fixed in the next release)
Back to top
 
 
WWW   IP Logged
Sumner Gerard
Full Member
*
Offline



Posts: 359

Re: Edit in Textmate
Reply #9 - Mar 8th, 2010, 1:47pm
 
Mark B: Turning off automatic updates does the trick. Seems you have to give it a little time to "take hold."  Thanks.

Mark A:  Sorry for being so literal!  Learning by example here.

Quote:
use B's rule to set A's rule to the $Text of B

This is what I was thinking needed to be done, so, substituting A for the original Some note, I got a little confused by your $Rule(Some note) = $Rule , thinking it instead must be something like $Rule(Some note)=$Text .

The latter does work for me, but wanted to make sure I wasn't missing something even better.  Got the idea now. Thanks for the very helpful pointer, and your patience in explaining it!
Back to top
 
 
  IP Logged
Matt Cawood
Full Member
*
Offline



Posts: 109
New England, Australia
Re: Edit in Textmate
Reply #10 - Mar 8th, 2010, 3:39pm
 
Didn't realise this was possible. Thanks! Actually, I think there's a role for both methods.
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Edit in Textmate
Reply #11 - Mar 8th, 2010, 3:56pm
 
Sumner, you're right - I've edited the original reference. You can set $Rule(Some other note) to the $Rule of the current note - but not via the current note's Rule, unless you first set the Rule, e.g $Color="bright blue";$Rule(some note)=$Rule;. However, $Rule(some note)=$Text; is really what I was thinking of originally.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Pages: 1
Send Topic Print