1. I think the program rocks.
2. I was writing some HTML and I had the need to have a command that jumped to the *inside* of the next tag. I couldn't figure out how to do this in TM (or any other editor), playing with snippets and Perl shell command ideas until I realized I could record a macro that did:
find <(.*?)> as regular expression hit left arrow (to go to start of found selection), hit right arrow (to skip over the <) find [^>]* to select all characters up to the >.
It works just great.
3. In some corner of my head I feel like snippets, macros and commands should really all be one type of automation entity. I'm not sure how to do that, but it's a little confusing to have so much power distributed across three different kinds of triggers...
4. Actual interface bug (in my opinion). If you start a selection, say in the middle of the screen, and drag up past the window top, TM should select everything up through the first character of the document. Instead, it only selects up to the first line stopping at the original column.
- Eric
On 24. Oct 2004, at 8:42, Eric Hsu wrote:
- In some corner of my head I feel like snippets, macros and commands
should really all be one type of automation entity. I'm not sure how to do that, but it's a little confusing to have so much power distributed across three different kinds of triggers...
I've been thinking about this myself. I also want templates, drag commands, and upcoming "project drawer commands" to be rolled into this unification.
In a way, a snippet could be viewed as a normal command, but with 'cat' as the interpreter instead of 'bash' (with output set to 'insert as snippet').
In a similar way, a macro could also just have another interpreter (e.g. 'AppleScript' in the future).
Templates (and drag commands) already are basically just commands, and moving them into this unification allows the former to also utilize the snippet features (i.e. to have placeholders in the templates).
With regard to the actual trigger, the snippet trigger is basically just a multi-stroke hotkey -- I'd like to change this to be a regular expression instead (but with slightly changed semantics, in that it'll always do non-greedy matching) and introduce some special codes for the various modifier keys, then this would be a superset of both hotkeys and snippet triggers, but allow so much more customizability, e.g. a trigger could be: "\n}" and the command could do a shift-left (i.e. the requested de-indent pattern).
There should be an option whether to leave the trigger in the text or not (before executing the command).
The downside is that there may be a little more work required, i.e. currently the '\t' after the snippet trigger is implicit, and the 'cat' interpreter is also implicit.
I'd be interested in hearing peoples thoughts on the issue!
Kind regards Allan
I love the idea of Daniel Von Fanges TextMate Log Script[1], but my unfamiliarity with both ruby and textmate is giving me a headache. I hope I can use you guys as a sounding board and this doesn't bug you too much.
[1]: http://www.braino.org/blog/archives/001440.php
I can't make the date function work within the command - If I execute my script outside of textmate it works beautifully, but from within textmate I get:
<code> date: illegal time format usage: date [-nu] [-r seconds] [+format] date [[[[[cc]yy]mm]dd]hh]mm[.ss] </code>
When I run the same script with the textmate variables replaced by normal strings I get:
<code>* [23:19:54 ] @test -> just a test action</code>
Do the ticks ` in the date function mean that I'm using bash's date program? The error thrown in the command matches the error from the command line, but why doesn't it happen when the script is executed by ruby?
Why won't this work? All the help I can get would be very much apreciated. I'm using v1.02b1, and here's what the command looks like in it's entirety:
<code> /usr/bin/env ruby <<END task_text = "$TM_CURRENT_LINE" task_text.gsub!("* ","* [#{`date "+%H:%M:%S"`}] ") task_text.gsub!("\n","")
from = "$TM_CURRENT_FILE"
File.open("/Users/kjell/Documents/planner/complete",'a'){|archive_file| archive_file.puts task_text #archive_file.puts " in #{from} #{`date "+%H:%M %Y%m%d %a"`}" archive_file.puts } END </code>
With Daniel's help, I'm using the script like:
in the command window:
/usr/local/bin/ruby ~/Library/Application\ Support/Textmate/completedTask.rb $TM_FILEPATH
the ruby script:
#!/usr/local/bin/ruby
task_text = $stdin.read task_text.gsub!("\[ \] ","[X] ")
from = File.basename(ARGV[0],".txt")
File.open("/Users/tim/Documents/projects/GTD/Inbox/ done.txt",'a'){|archive_file| archive_file.puts archive_file.puts task_text archive_file.puts " in #{from} #{`date "+%H:%M %Y%m%d %a"`}" }
I mapped it to a key and it moves the selected text/line to "done.txt" Except the task_text.gsub!("\[ \] ","[X] ") stuff doesn't seem to be working.
Any ruby mentors out there? We really want to learn :)
-t
On Oct 25, 2004, at 6:55 PM, Kjell Olsen wrote:
I love the idea of Daniel Von Fanges TextMate Log Script[1], but my unfamiliarity with both ruby and textmate is giving me a headache. I hope I can use you guys as a sounding board and this doesn't bug you too much.
I can't make the date function work within the command - If I execute my script outside of textmate it works beautifully, but from within textmate I get:
<code> date: illegal time format usage: date [-nu] [-r seconds] [+format] date [[[[[cc]yy]mm]dd]hh]mm[.ss] </code>
When I run the same script with the textmate variables replaced by normal strings I get:
<code>* [23:19:54 ] @test -> just a test action</code>
Do the ticks ` in the date function mean that I'm using bash's date program? The error thrown in the command matches the error from the command line, but why doesn't it happen when the script is executed by ruby?
Why won't this work? All the help I can get would be very much apreciated. I'm using v1.02b1, and here's what the command looks like in it's entirety:
<code> /usr/bin/env ruby <<END task_text = "$TM_CURRENT_LINE" task_text.gsub!("* ","* [#{`date \"+%H:%M:%S\"`}] ") task_text.gsub!("\n","")
from = "$TM_CURRENT_FILE"
File.open("/Users/kjell/Documents/planner/complete",'a'){|archive_file| archive_file.puts task_text #archive_file.puts " in #{from} #{`date "+%H:%M %Y%m%d %a"`}" archive_file.puts } END
</code>
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/mailman/listinfo/textmate
Am 26.10.2004 um 11:28 schrieb Timothy Martens:
I mapped it to a key and it moves the selected text/line to "done.txt" Except the task_text.gsub!("\[ \] ","[X] ") stuff doesn't seem to be working.
In Ruby 1.8 this should be
task_text.gsub(/[\s*?]/, '[X]')
The left argument is a RegEx object, not a string.
On Oct 26, 2004, at 1:10 AM, Nils Kassube wrote:
In Ruby 1.8 this should be
task_text.gsub(/[\s*?]/, '[X]')
So this would replace "space[space]space" with "space[X]space"
It's still not working. I simply get the same (empty brackets) i the archive file?
-t
Am 27.10.2004 um 01:10 schrieb Timothy Martens:
So this would replace "space[space]space" with "space[X]space" It's still not working. I simply get the same (empty brackets) i the archive file?
irb(main):001:0> task_text = ' [ ] do it' => " [ ] do it" irb(main):002:0> task_text.gsub(/[\s*?]/, '[X]') => " [X] do it"
Nils-Kassubes-Computer% ruby -v ruby 1.8.2 (2004-07-29) [powerpc-darwin7.5.0]
What's the output of "ruby -v" on your Mac?
Ok, thanks everyone who helped - I got it working. I touched up the ruby script, now it adds in the date and the from file on the same line. Here it is:
ruby <<END from = File.basename("$TM_FILEPATH","") time_now = Time.now time = time_now.strftime("%H:%M:%S")
task = "$TM_CURRENT_LINE" task.gsub!("^. ","* [#{time}] ") task += " {#{ from}}"
File.open("$TM_PROJECT_DIRECTORY/complete",'a'){|file| file.puts task file.puts } END
I have standard input set to none, because I instead use $TM_CURRENT_LINE to get the line that I want. But because this doesn't delete the line that has been completed, I recorded a macro which executes this command and then completely deletes the line that the cursor is on (control-shift-left arrow, shift-left arrow) and this works great.
I still have some work to do on it though: I want to have the completed files separated by day and month automatically and eventually want to ruby out reports of time spent on certain actions. Also I'm going to try and figure out how to have the list reverse chronologically, with the most recent completed items at the top. Should be a fun ruby exercise! Thanks for all your help - and if you know how to do either of my two things, feel free to give me some more.