Hi folks. I'm starting to get into javascript, and am having problems with the Reformat Document (Beautify) command.
I want soft tabs of 2 spaces. I read in a .js file, with the 2 space indentation, and call the Reformat Document. It alas, does not use the current 2 space soft tabs, but defaults to 4.
Yet if I edit the file, the auto indent correctly uses the 2 space indent.
So clearly the tab setting I use (bottom of textmate, tabs menu) is used by the auto-indent, but apparently not for Reformat Document.
What am I doing wrong?! Is there a textmate/javascript variable or preference that needs to be set? Should the tabs menu control both the auto-indent and Reformat?
-- Owen
On Jun 21, 2009, at 3:09 PM, Owen Densmore wrote:
Hi folks. I'm starting to get into javascript, and am having problems with the Reformat Document (Beautify) command.
Unfortunately this script is a third party script we adapted, they've since switched to writing it in javascript. We don't have any way of running javascript in TextMate so we've been cut off from updates.
Michael Sheets <mummer@...> writes:
Unfortunately this script is a third party script we adapted, they've since switched to writing it in javascript. We don't have any way of running javascript in TextMate so we've been cut off from updates.
Thanks Michael. This is fascinating: our group (redfish.com) has been REALLY impressed how effective javascript has become. With the 1.7 "pythonic" extensions, along with its prototype inheritance and server-side use, javascript is becoming a serious player.
As an example, when doing "web apps" in Google App Engine, its irritating to have one language on the server (Python), another on the client (JS), and a third as the communication layer (XML). Moving to JS completely fixes that: JS on both sides (possibly using Rhino on the server for easy access to Java classes) and JSON in between. So rather than parsing XML, you just "exec" the XMLHttpRequest's JSON data and instantly have a native JS data structure.
I'm surprised TM doesn't consider using JS as an extension language. It is fairly light weigh and has several engines to choose from. Getting Rhino on the Mac is trivial and may start to be standard due to it being included in the Java SDK.
So I'd really not try to avoid JS extensions if need be.
Thanks for the clear response,
-- Owen
It's not so much that JS isn't an official scripting language in TM as it is that the Mac doesn't ship with a js script runner.
Personally I'd be in favor of simply using rhino as the js script runner. Just need to include it in your bundle of the shared TM support folder.
On Jun 21, 2009, at 7:52 PM, Owen Densmore wrote:
TM doesn't consider using JS as an extension language
—Thomas Aylott / subtleGradient