Remove project & _list_projects, I don't use them anymore.
1 ;;; ecmascript-mode.el --- major mode for editing ECMAScript code
3 ;; Copyright (c) 2004-2005 David Lindquist <david.lindquist@gmail.com>
5 ;; Author: David Lindquist <david.lindquist@gmail.com>
6 ;; Keywords: languages ecmascript javascript
8 ;; This is free software; you can redistribute it and/or modify it
9 ;; under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; This is distributed in the hope that it will be useful, but WITHOUT
14 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
16 ;; License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GNU Emacs; see the file COPYING. If not, write to the
20 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 ;; Boston, MA 02111-1307, USA.
25 ;; ecmascript-mode is a basic major mode for editing code conforming
26 ;; to the ECMA-262 standard (3rd edition). The most notable languages
27 ;; employing all or most of the standard are JavaScript (Netscape),
28 ;; JScript (Microsoft), and ActionScript (Macromedia).
31 ;; http://www.ecma-international.org/publications/files/ecma-st/ECMA-262.pdf
35 ;; 2005-11-24 david Fixed void function error and corrected font-lock
36 ;; problems that appeared in emacs version 21.3.50.1
37 ;; (probably due to changes in java-mode).
38 ;; 2004-??-?? david Initial release.
45 (require 'regexp-opt))
47 (defconst ecmascript-mode-version "1.1"
48 "ECMAScript Mode version number.")
50 (defgroup ecmascript nil
51 "Major mode for editing ECMAScript code."
53 :prefix "ecmascript-")
55 (defcustom ecmascript-mode-hook nil
56 "Hook for customizing `ecmascript-mode'."
60 (defvar ecmascript-mode-map (c-make-inherited-keymap)
61 "Keymap used in `ecmascript-mode' buffers.")
64 (define-derived-mode ecmascript-mode java-mode "ECMAScript"
65 "Major mode for editing ECMAScript code.
67 This mode is derived from `java-mode'; see its documentation for further
70 \\{ecmascript-mode-map}"
71 (make-local-variable 'font-lock-defaults)
72 (setq font-lock-defaults
73 '((;; comment out the lines below to adjust
74 ;; syntax highlighting gaudiness
75 ecmascript-font-lock-keywords-1
76 ecmascript-font-lock-keywords-2
77 ecmascript-font-lock-keywords-3
79 nil nil ((?_ . "w") (?$ . "w")) nil))
81 (easy-menu-define c-ecmascript-menu ecmascript-mode-map
82 "ECMAScript Mode Commands" (c-mode-menu "ECMAScript"))
85 (defvar ecmascript-font-lock-default-face 'ecmascript-font-lock-default-face)
87 (defconst ecmascript-font-lock-keywords-1
89 java-font-lock-keywords-1
92 '("\\<\\(function\\)\\>\\(?:\\s-+\\(\\sw+\\)\\)?"
93 (1 font-lock-keyword-face t)
94 (2 font-lock-function-name-face nil t))
96 ;; need to fix this to handle: var a, b;
97 '("\\<\\(var\\)\\>\\(?:\\s-+\\(\\sw+\\)\\)?"
98 (1 font-lock-keyword-face t)
99 (2 font-lock-variable-name-face nil t))
101 "Subdued level highlighting for ECMAScript mode.")
103 (defconst ecmascript-font-lock-keywords-2
105 java-font-lock-keywords-2
106 ecmascript-font-lock-keywords-1
109 '("\\<\\(debugger\\|delete\\|export\\|in\\|typeof\\|with\\)\\>"
110 (1 font-lock-keyword-face t))
114 (mapconcat 'identity java-font-lock-extra-types nil)
116 '(1 font-lock-type-face nil t))
118 ;; In Java, `void' is a type. In ECMAScript, it is an operator.
119 ;; This overrides the inherited notion of keyword `void'.
120 '("\\<\\(void\\)\\>\\(?:\\s-+\\(\\sw+\\)\\)?"
121 (1 font-lock-keyword-face t)
122 (2 ecmascript-font-lock-default-face t t))
124 ;; Value properties of the global object
125 '("\\<\\(Infinity\\|NaN\\|undefined\\)\\>" 0 font-lock-constant-face t)
127 ;; Properties of the Number constructor
131 '("MAX_VALUE" "MIN_VALUE" "NaN" "NEGATIVE_INFINITY"
132 "POSITIVE_INFINITY") t)
134 '(1 font-lock-constant-face))
136 ;; Value properties of the Math object
140 '("E" "LN10" "LN2" "LOG2E" "LOG10E" "PI" "SQRT1_2" "SQRT2") t)
142 '(1 font-lock-constant-face))
144 "Medium level highlighting for ECMAScript mode.")
146 (defconst ecmascript-font-lock-keywords-3
148 java-font-lock-keywords-3
149 ecmascript-font-lock-keywords-2
152 ;; Properties of the Date constructor
153 '("\\<Date\\.\\(parse\\|UTC\\)\\>" 1 font-lock-builtin-face)
155 ;; Function properties of the Math object
159 '("abs" "acos" "asin" "atan" "atan2" "ceil" "cos" "exp" "floor"
160 "log" "max" "min" "pow" "random" "round" "sin" "sqrt" "tan") t)
162 '(1 font-lock-builtin-face))
165 '(;; URI handling function properties
166 "decodeURI" "decodeURIComponent" "encodeURI" "encodeURIComponent"
167 ;; Function properties of the global object
168 "eval" "isFinite" "isNaN" "parseFloat" "parseInt") 'words)
169 '(0 font-lock-builtin-face))
174 '(;; Properties of the Object prototype object
175 "hasOwnProperty" "isPrototypeOf" "propertyIsEnumerable"
176 "toLocaleString" "toString" "valueOf"
177 ;; Properties of the Function prototype object
179 ;; Properties of the Array prototype object
180 "concat" "join" "pop" "push" "reverse" "shift" "slice" "sort"
182 ;; Properties of the String prototype object
183 "charAt" "charCodeAt" "fromCharCode" "indexOf" "lastIndexOf"
184 "localeCompare" "match" "replace" "search" "split" "substring"
185 "toLocaleLowerCase" "toLocaleUpperCase" "toLowerCase"
187 ;; Properties of the Number prototype object
188 "toExponential" "toFixed" "toPrecision"
189 ;; Properties of the Date prototype object
190 "getDate" "getDay" "getFullYear" "getHours" "getMilliseconds"
191 "getMinutes" "getMonth" "getSeconds" "getTime"
192 "getTimezoneOffset" "getUTCDate" "getUTCDay" "getUTCFullYear"
193 "getUTCHours" "getUTCMilliseconds" "getUTCMinutes" "getUTCMonth"
194 "getUTCSeconds" "setDate" "setFullYear" "setHours"
195 "setMilliseconds" "setMinutes" "setMonth" "setSeconds" "setTime"
196 "setUTCDate" "setUTCFullYear" "setUTCHours" "setUTCMilliseconds"
197 "setUTCMinutes" "setUTCMonth" "setUTCSeconds" "toDateString"
198 "toLocaleDateString" "toLocaleString" "toLocaleTimeString"
199 "toTimeString" "toUTCString"
200 ;; Properties of the RegExp prototype object
204 '(1 font-lock-builtin-face))
206 "Gaudy level highlighting for ECMAScript mode.")
208 (provide 'ecmascript-mode)
210 ;;; ecmascript-mode.el ends here