tamzinblake / js3-mode

A chimeric fork of js2-mode and js-mode
GNU General Public License v3.0
180 stars 13 forks source link

js3-indent-tabs-mode doesn't seem to be respected in .dir-locals.el #105

Open mattdeboard opened 10 years ago

mattdeboard commented 10 years ago

So I'm working on a project that uses tabs instead of spaces. Normally I can set up my .dir-locals.el like so:

((nil . (indent-tabs-mode . t)
        (whitespace-action . nil)))

and tabs will be used instead of spaces. However it seems as though this is not the case with js3-mode. I'm doing the following:

((nil . (js3-indent-tabs-mode . t)
        (whitespace-action . nil)))

but pressing <TAB> still inserts spaces. Also, when I do this, then check the value of the variable with C-h v js3-indent-tabs-mode, it still reports as nil. So I threw that out and just added the following to the top of the file:

// -*- js3-indent-tabs-mode: t -*-

Now C-h v js3-indent-tabs-mode reports its buffer-local value is t. But when I hit <TAB>, it's still inserting spaces. So just on a lark, I updated the file header to:

// -*- js3-indent-tabs-mode: t js3-manual-indentation: t -*-

Now <TAB> inserts TAB characters, but it of course only inserts one. So that's half a solution. Ideally though I could still have auto-indentation AND insert TAB characters instead of spaces.

I'm on v1.1.0, Emacs 24.4.50

mattdeboard commented 10 years ago

Also, hi @plumlee, I saw you commenting on #100

tamzinblake commented 10 years ago

I'm not sure how auto-indentation would even work with tabs in js3-mode. Currently it's designed to do a lot of "lining things up" for the most part. You might want to look at js2-mode, which will soon use the indentation from js-mode by default.

plumlee commented 10 years ago

Heya @mattdeboard. You could also use spaces, but tabify on a save? But that's a pretty ugly hack.

mattdeboard commented 10 years ago

Yeah I just switched to js2-mode. Seems fine for now, but js3-mode is so much faster parsing large files.

tamzinblake commented 10 years ago

@mattdeboard I also saw that here https://github.com/mooz/js2-mode/issues/163

I don't understand how js2-mode is slower than js3-mode at parsing. I've made some changes to the parser but it's still basically the same, and I haven't seen much change on their end either. It would be interesting if this is because I yanked out the XML stuff or something.

If this is because of something we're doing well here rather than a bug I haven't fixed or something, we should see if we can fix js2-mode to not be slow.

mattdeboard commented 10 years ago

Unfortunately I can't really give you the example I'm going from since it's proprietary code, but the upshot is it's the result of compiling a whole bunch of coffeescript files into a single JS file (via requirejs). The resulting file is about 61k lines of JS, not uglified or minified. Takes 10-15s for js2-mode to load it up, apply syntax highlighting and free up the process to the user. js3-mode takes ~5s if that.

And it's extremely sluggish moving through the file even after it's fully loaded. It smells like a whole lot of parsing of the whole file over and over.