Search: Language:
== JS mode (formerly Espresso) == For more general information on working with JavaScript in Emacs, see the JavaScript page. For a long while there was debate and back-and-forth about JavaScript support in Emacs. There were a number of different options, in various stages of maturity and completion. As of Emacs 23.2, there is a standard major mode for editing javascript: js-mode. It is derived and updated from Espresso-mode. Espresso-mode itself is a fork of Karl Landstrom's JavaScript mode (described below), but with additional features and robustness improvements. For the legacy page, see http://www.nongnu.org/espresso. For the current js-mode, just get a current Emacs (23.2 or later). If you have a back-rev of Emacs, see EmacsDevelopmentSources for how to get js-mode. js-mode includes: * Support for cc-mode's comment wrapping. * C preprocessor support -- yes, people use this with JavaScript. * Full suite of movement commands, including ##beginning-of-defun##, ##end-of-defun##, and so on. * Configurable recognition of class definitions. JavaScript, being a prototype-based language, has no "classes" per se, but there are constructions used to mean the same thing. * Hierarchical ##imenu## support using the aforementioned class definition recognition. In addition to recognizing top-level functions, ##imenu## will recognize methods. * Improved fontification of regular expression literals == JavaScript mode == Anything with the name "javascript-mode" or "javascript" is likely deprecated -- and decrepit. The following links are kept around for information, but if you are using JavaScript, you want js-mode or [[Js2Mode]]. Usually this name refers to Karl Landstrom's implementation: https://web.archive.org/web/20130313070358/http://www.karllandstrom.se/downloads/emacs/javascript.el Another obsolete implementation by Peter Kruse: https://web.archive.org/web/20190406114129/http://wal.sh/code/elisp/trunk/javascript-kruse.el The Mewde Project contain XEmacs' javascript mode while adding Mozilla Spider Monkey Project Javascript-Shell support. It works inside Emacs, but only primitively. == Fix for Greasemonkey scripts == The following fix from [[EmacsInitFileOfSylecn|Sylecn]] addresses a bug where the metadata block in Greasemonkey scripts confuses the syntax highlighter: (eval-after-load 'js '(progn (setq js--regexp-literal-fix "[^=][=(,:]\\(?:\\s-\\|\n\\)*\\(/\\)\\(?:\\\\.\\|[^/*\\]\\)\\(?:\\\\.\\|[^/\\]\\)*\\(/\\)") (setq js-font-lock-syntactic-keywords-fix ;; "|" means generic string fence `((,js--regexp-literal-fix (1 "|") (2 "|")))) (setq js-font-lock-syntactic-keywords js-font-lock-syntactic-keywords-fix))) ---- ProgrammingModes CategoryJavaScript
Summary:
This change is a minor edit.
Please make sure you contribute only your own work. IP numbers are made available via the page history. If you want to keep it a secret, you need to use Tor. See TextFormattingRules for how to format text. See StyleGuide for the suggested writing style on this wiki.
To save this page you must answer this question:
What is the greatest editor out there?
Username:
Replace this text with a file