4

A lot of JS code I work with contains files that are defined with the following indentation:

define("my_module", function() {

// top-level code is not indented because the whole file
// is wrapped in a giant closure

});

Is there a way to force Emacs (js2-mode) to ignore the outer function for the purposes of indentation (such that it indents the same as if it was not wrapped in a giant function)?

  • This is not an answer, but here's what I do: since I'll minify the code anyway, I just have the same script that minifies it also wrap it into whatever module/wrapper function I need. This also has the effect of having working outlines for functions. –  Aug 26 '13 at 23:07
  • Same question but more generally: not indenting top-level items wrapped in an IIFE. – Amory Apr 12 '21 at 18:30

0 Answers0