I have been recently editing javascript files to reduce warnings but found an issue of adopted styls in comm-central thunderbird codes.
I checked for the preferred style: [1] I found one reference here: http://autonome.wordpress.com/2006/03/24/javascript-style-guide-for-mozilla-projects/ [2] I found another which looks official. https://developer.mozilla.org/en-US/docs/Developer_Guide/Coding_Style It is not entirely clear which indentation levels are preferred. - two spaces in [1], or - four spaces (Java style section of the official-looking page in [2] states that it intentionally deviates from Java Style guide. It seems that existing javascript files were created with different style ideas. We need to remedy this when a file is re-visited for modification. But trying to stick to some ideal style without any guideline, and tool support is difficult. Concrete tool requirement example: I am using Emacs for editing. Does anyone have a good Emacs mode line that I can embed in the JavaScript source code at the beginning to guide to help the coders who write new code or modify existing code to stick to the suggested style guideline? These days, Emacs defaults to use so called JavaScript mode for javascript editing, and it is now rather difficult with its default setting to uniformly apply 2 space indentation through out. I recall there was a mode line in ... /mozilla/toolkit/mozapps/downloads/nsHelperAppDlg.js quoted below: /* -*- Mode: javascript; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=2 et sw=2 tw=80: */ I found out I can set the 2 space indentation for sentence that follows "{" with the addition of "js-curly-indent-offset : - 2". However, if a previous line does not end with "{", I get four space indentation. function f () { if (a) { sss } if (b) xxx; } I can ask gnu-emacs-help mailing list for help, but without the exact preferred style specification, I will not be able to obtain satisfactory answer. So my question boils down to - what is the preferred style for JavaScript now for mozilla source code? - Has anyone have mode-line (or .emacs) setting to make the indentation in Emacs to follow the prefered style? TIA _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform