[TxMt] How to open files with no extension in Quicklook/Textmate (Ciaran's plugin) & Thank You Allan!

Brandon M Fryslie bmf at email.arizona.edu
Mon Dec 20 15:25:10 UTC 2010


This is my first post to this list so I just want to say thank you Allan,
for your fantastic ideas, for that is what truly makes TextMate not only the
greatest, but orders of magnitude greater than the closest contender.  I'm
positive the code is delightful as well, but it was your fantastic vision
that saw what could be achieved if you made it easy and accessible to not
just write a script, not only write a script that can manipulate one's text
to finest granularity, you didn't only give us the tools to define and parse
our languages as we see fit, but you fought to package all of it up and
spread it around in a transparent, open source, community driven way, so we
can each build off each other and do more than any of us could have alone.
 Not only that, but you honestly make sitting around configuring shortcuts
something I look forward to.  Currently I'm plugging an RTF -> HTML
converter into a shell script that will render to web preview so I won't
have to leave TM for anything but AppleScripts.  No other program is nearly
flexible enough that I would even know where to begin.  And for that, Kudos.

OK, onto the second part.  I'm guessing usually people ask questions, and I
actually do have one I'll ask at the end.  But here is the answer to
something I looked for, for quite a few hours and could find almost nothing.
 Definitely not anything close to the solution (people were brute forcing it
with bash scripts, barf).  I'm sure it's common knowledge for you haxxors
out there at this point, but the reason I'm posting this is so hopefully it
will get put up somewhere or indexed and save some people some time.

So at first, I wanted all plain-text file with any extension to open with
TextMate.  No problem.  Then I wanted all files with NO extension to open in
TextMate.  That took a few minutes but I was about to find some instructions
that sorta worked and get it fixed from there.  However I also want all
files without an extension to open in Ciaran's TM in QL plugin.  It's super
easy, and now I'm like "Duh!"  Here are the steps:

0.  Get plugin and install it if you haven't already*.  Or use a different
generator.  Other generators will work, but they aren't nearly as cool.
1.  [Optional] If you have a file you specifically want to know is gonna
open, go to terminal and type mdls <path/filename>.  Read the value for this
key: kMDItemContentType.  That is the UTI type.  Remember it.
2.  Type in 'mate
/Library/QuickLook/TMQuicklook.qlgenerator/Contents/Info.plist' to a
terminal.
3.  Find the key "LSItemContentTypes" and start duplicating lines to add
more UTI types.  I added public.source-code, p.xml, p.plain-text, p.data,
and com.apple.property-list, and I'll just continue adding more when I find
types that don't open.  But p.plain-text and p.data take care of
unextension'd files.
4.  Run "qlmanage -r" and "qlmanage -r cache" to both reload the generators
and clear the thumbnail cache.

* http://ciaranwal.sh/2007/11/15/quicklook-and-textmate

That's it!  You can use that process to make each filetype/UTI open in
SOMETHING (run qlmanage -d 4 -p <file> and it prints the paths of all its
generators!) so you aren't starting at a gigantic icon, sitting there,
mocking you with his complete lack of utility.

OK, I do have a couple questions though (*questions in bold*): *what is the
status on true multikey bindings?*  I've been poking around for a while, and
I know how to make them for the built in NSResponder action methods (delete
a line, move around, etc) with the DefaultKeyBinding.dict.  I want to be
able to map an arbitrary TextMate (or other program) action to these things
however.  I tried poking around in some nibs and got some method names from
menu items, but couldn't get it working with KeyBindingsEditor.  Ideally I'd
be able to map it to any script, application, or action.

This is similar to what ThisService does, actually (maps any script: ruby,
osa, etc to OS X Services menu which can bind to a hotkey.  Takes input,
spits out text).  Another goal is to use this 'services' ability to write a
little 'Edit in TextMate' script that can take your text and a keycombo, run
a TextMate command on it and spit it back into the textbox all in the
background.  My impression is that they nerfed Input Managers with Snow
Leopard, so I'm tentatively planning on using AppleScript to move the text
around, and if that is too slow I'll figure out how to write a SIMBL plugin.
 *What's the opinion on AppleScript for that?  Can it be done reasonably
fast in the background?  *
*
*
2 last questions:  first off, *what tools should I be using to write a regex
for use in the language definition?*  While awesome and useful, I find
(especially large) regex's incredibly ugly and unintuitive.    I would like
to have a better syntax (my tentative idea is to use a ' ' (space) for
escaping to reduce clutter), a 'metalanguage' where I can glance at a
regex-equivalent and grasp its operations and matches quickly, and a
visualizer to help even more.  I am getting started on all of this, but I'd
like to know if maybe I'm reinventing the wheel and just didn't find the
right tool yet.  The problem isn't that I can't write regexes, but that they
are so complicated it is a barrier to new TextMate features.  If we had
something everyone could put together like legos, I think it would really
help jump start development.  As it is, I can barely adjust the line endings
for the languages I have.

My final question is:  There is bundle/command menu at ctrl+cmd+t, in which
a user can search their current scope by typing a command name, or search
all scopes by typing in uppercase.  One can also search by keyboard shortcut
in the current scope.  However* I'm unable to find a method by which to show
all commands of a certain binding in every scope.  Is there such a command?
* I plan to write an application to keep track of system wide keyboard
shortcuts and this would be very useful.

Thanks again, you made coding not just fun but exciting.  And always
remember, the closer you get to perfection, the easier it is for others to
complain.  I'm sure you've been there.  If I'm on windows, I don't mind just
clicking the buttons and doing my thing (for a few minutes).  The experience
is so crappy you'd have to start over to make it good.  It's only when it is
sooo sooo close to perfect, like TextMate, that I can sit and ponder and
think and pore over what exactly isn't quite perfect and could be fixed.

And luckily I can at least fix some of them when I'm using TextMate.

Cheers, mate!

Brandon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20101220/37217eca/attachment.html>


More information about the textmate mailing list