Mercurial > emacs
annotate lisp/progmodes/js.el @ 111473:1e95f3ea022d
Add const to array elements of font filter properties.
* font.c (font_filter_properties): Add const to array elements of properties args.
* font.h (font_filter_properties): Likewise.
* ftfont.c (ftfont_booleans, ftfont_non_booleans): Add const to array elements.
* w32font.c (w32font_booleans, w32font_non_booleans): Likewise.
author | YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> |
---|---|
date | Wed, 10 Nov 2010 18:02:54 +0900 |
parents | 05dc9dca8729 |
children | b47e85affa59 |
rev | line source |
---|---|
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1 ;;; js.el --- Major mode for editing JavaScript |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2 |
106815 | 3 ;; Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
4 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
5 ;; Author: Karl Landstrom <karl.landstrom@brgeight.se> |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
6 ;; Daniel Colascione <dan.colascione@gmail.com> |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
7 ;; Maintainer: Daniel Colascione <dan.colascione@gmail.com> |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
8 ;; Version: 9 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
9 ;; Date: 2009-07-25 |
110015
280c8ae2476d
Add "Package:" file headers to denote built-in packages.
Chong Yidong <cyd@stupidchicken.com>
parents:
109997
diff
changeset
|
10 ;; Keywords: languages, javascript |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
11 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
12 ;; This file is part of GNU Emacs. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
13 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
14 ;; GNU Emacs is free software: you can redistribute it and/or modify |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
15 ;; it under the terms of the GNU General Public License as published by |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
16 ;; the Free Software Foundation, either version 3 of the License, or |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
17 ;; (at your option) any later version. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
18 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
19 ;; GNU Emacs is distributed in the hope that it will be useful, |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
22 ;; GNU General Public License for more details. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
23 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
24 ;; You should have received a copy of the GNU General Public License |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
25 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
26 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
27 ;;; Commentary |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
28 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
29 ;; This is based on Karl Landstrom's barebones javascript-mode. This |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
30 ;; is much more robust and works with cc-mode's comment filling |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
31 ;; (mostly). |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
32 ;; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
33 ;; The main features of this JavaScript mode are syntactic |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
34 ;; highlighting (enabled with `font-lock-mode' or |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
35 ;; `global-font-lock-mode'), automatic indentation and filling of |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
36 ;; comments, C preprocessor fontification, and MozRepl integration. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
37 ;; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
38 ;; General Remarks: |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
39 ;; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
40 ;; XXX: This mode assumes that block comments are not nested inside block |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
41 ;; XXX: comments |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
42 ;; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
43 ;; Exported names start with "js-"; private names start with |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
44 ;; "js--". |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
45 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
46 ;;; Code: |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
47 |
110270
c7809974cd64
Misc cleanups and simplifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110015
diff
changeset
|
48 |
c7809974cd64
Misc cleanups and simplifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110015
diff
changeset
|
49 (require 'cc-mode) |
c7809974cd64
Misc cleanups and simplifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110015
diff
changeset
|
50 (require 'font-lock) |
c7809974cd64
Misc cleanups and simplifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110015
diff
changeset
|
51 (require 'newcomment) |
c7809974cd64
Misc cleanups and simplifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110015
diff
changeset
|
52 (require 'imenu) |
c7809974cd64
Misc cleanups and simplifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110015
diff
changeset
|
53 (require 'etags) |
c7809974cd64
Misc cleanups and simplifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110015
diff
changeset
|
54 (require 'thingatpt) |
c7809974cd64
Misc cleanups and simplifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110015
diff
changeset
|
55 (require 'easymenu) |
c7809974cd64
Misc cleanups and simplifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110015
diff
changeset
|
56 (require 'moz nil t) |
c7809974cd64
Misc cleanups and simplifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110015
diff
changeset
|
57 (require 'json nil t) |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
58 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
59 (eval-when-compile |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
60 (require 'cl) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
61 (require 'comint) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
62 (require 'ido)) |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
63 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
64 (defvar inferior-moz-buffer) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
65 (defvar moz-repl-name) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
66 (defvar ido-cur-list) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
67 (declare-function ido-mode "ido") |
104391
0642b524d60c
(inferior-moz-process): Fix declaration.
Glenn Morris <rgm@gnu.org>
parents:
104276
diff
changeset
|
68 (declare-function inferior-moz-process "ext:mozrepl" ()) |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
69 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
70 ;;; Constants |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
71 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
72 (defconst js--name-start-re "[a-zA-Z_$]" |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
73 "Regexp matching the start of a JavaScript identifier, without grouping.") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
74 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
75 (defconst js--stmt-delim-chars "^;{}?:") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
76 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
77 (defconst js--name-re (concat js--name-start-re |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
78 "\\(?:\\s_\\|\\sw\\)*") |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
79 "Regexp matching a JavaScript identifier, without grouping.") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
80 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
81 (defconst js--objfield-re (concat js--name-re ":") |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
82 "Regexp matching the start of a JavaScript object field.") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
83 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
84 (defconst js--dotted-name-re |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
85 (concat js--name-re "\\(?:\\." js--name-re "\\)*") |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
86 "Regexp matching a dot-separated sequence of JavaScript names.") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
87 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
88 (defconst js--cpp-name-re js--name-re |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
89 "Regexp matching a C preprocessor name.") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
90 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
91 (defconst js--opt-cpp-start "^\\s-*#\\s-*\\([[:alnum:]]+\\)" |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
92 "Regexp matching the prefix of a cpp directive. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
93 This includes the directive name, or nil in languages without |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
94 preprocessor support. The first submatch surrounds the directive |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
95 name.") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
96 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
97 (defconst js--plain-method-re |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
98 (concat "^\\s-*?\\(" js--dotted-name-re "\\)\\.prototype" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
99 "\\.\\(" js--name-re "\\)\\s-*?=\\s-*?\\(function\\)\\_>") |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
100 "Regexp matching an explicit JavaScript prototype \"method\" declaration. |
104683
2b8eeeaa8c1d
* international/ucs-normalize.el (ucs-normalize-sort, quick-check-list):
Juanma Barranquero <lekktu@gmail.com>
parents:
104391
diff
changeset
|
101 Group 1 is a (possibly-dotted) class name, group 2 is a method name, |
2b8eeeaa8c1d
* international/ucs-normalize.el (ucs-normalize-sort, quick-check-list):
Juanma Barranquero <lekktu@gmail.com>
parents:
104391
diff
changeset
|
102 and group 3 is the 'function' keyword.") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
103 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
104 (defconst js--plain-class-re |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
105 (concat "^\\s-*\\(" js--dotted-name-re "\\)\\.prototype" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
106 "\\s-*=\\s-*{") |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
107 "Regexp matching a JavaScript explicit prototype \"class\" declaration. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
108 An example of this is \"Class.prototype = { method1: ...}\".") |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
109 |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
110 ;; var NewClass = BaseClass.extend( |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
111 (defconst js--mp-class-decl-re |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
112 (concat "^\\s-*var\\s-+" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
113 "\\(" js--name-re "\\)" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
114 "\\s-*=\\s-*" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
115 "\\(" js--dotted-name-re |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
116 "\\)\\.extend\\(?:Final\\)?\\s-*(\\s-*{?\\s-*$")) |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
117 |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
118 ;; var NewClass = Class.create() |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
119 (defconst js--prototype-obsolete-class-decl-re |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
120 (concat "^\\s-*\\(?:var\\s-+\\)?" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
121 "\\(" js--dotted-name-re "\\)" |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
122 "\\s-*=\\s-*Class\\.create()")) |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
123 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
124 (defconst js--prototype-objextend-class-decl-re-1 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
125 (concat "^\\s-*Object\\.extend\\s-*(" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
126 "\\(" js--dotted-name-re "\\)" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
127 "\\s-*,\\s-*{")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
128 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
129 (defconst js--prototype-objextend-class-decl-re-2 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
130 (concat "^\\s-*\\(?:var\\s-+\\)?" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
131 "\\(" js--dotted-name-re "\\)" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
132 "\\s-*=\\s-*Object\\.extend\\s-*\(")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
133 |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
134 ;; var NewClass = Class.create({ |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
135 (defconst js--prototype-class-decl-re |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
136 (concat "^\\s-*\\(?:var\\s-+\\)?" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
137 "\\(" js--name-re "\\)" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
138 "\\s-*=\\s-*Class\\.create\\s-*(\\s-*" |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
139 "\\(?:\\(" js--dotted-name-re "\\)\\s-*,\\s-*\\)?{?")) |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
140 |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
141 ;; Parent class name(s) (yes, multiple inheritance in JavaScript) are |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
142 ;; matched with dedicated font-lock matchers |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
143 (defconst js--dojo-class-decl-re |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
144 (concat "^\\s-*dojo\\.declare\\s-*(\"\\(" js--dotted-name-re "\\)")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
145 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
146 (defconst js--extjs-class-decl-re-1 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
147 (concat "^\\s-*Ext\\.extend\\s-*(" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
148 "\\s-*\\(" js--dotted-name-re "\\)" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
149 "\\s-*,\\s-*\\(" js--dotted-name-re "\\)") |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
150 "Regexp matching an ExtJS class declaration (style 1).") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
151 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
152 (defconst js--extjs-class-decl-re-2 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
153 (concat "^\\s-*\\(?:var\\s-+\\)?" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
154 "\\(" js--name-re "\\)" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
155 "\\s-*=\\s-*Ext\\.extend\\s-*(\\s-*" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
156 "\\(" js--dotted-name-re "\\)") |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
157 "Regexp matching an ExtJS class declaration (style 2).") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
158 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
159 (defconst js--mochikit-class-re |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
160 (concat "^\\s-*MochiKit\\.Base\\.update\\s-*(\\s-*" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
161 "\\(" js--dotted-name-re "\\)") |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
162 "Regexp matching a MochiKit class declaration.") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
163 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
164 (defconst js--dummy-class-style |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
165 '(:name "[Automatically Generated Class]")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
166 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
167 (defconst js--class-styles |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
168 `((:name "Plain" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
169 :class-decl ,js--plain-class-re |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
170 :prototype t |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
171 :contexts (toplevel) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
172 :framework javascript) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
173 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
174 (:name "MochiKit" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
175 :class-decl ,js--mochikit-class-re |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
176 :prototype t |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
177 :contexts (toplevel) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
178 :framework mochikit) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
179 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
180 (:name "Prototype (Obsolete)" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
181 :class-decl ,js--prototype-obsolete-class-decl-re |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
182 :contexts (toplevel) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
183 :framework prototype) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
184 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
185 (:name "Prototype (Modern)" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
186 :class-decl ,js--prototype-class-decl-re |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
187 :contexts (toplevel) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
188 :framework prototype) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
189 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
190 (:name "Prototype (Object.extend)" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
191 :class-decl ,js--prototype-objextend-class-decl-re-1 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
192 :prototype t |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
193 :contexts (toplevel) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
194 :framework prototype) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
195 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
196 (:name "Prototype (Object.extend) 2" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
197 :class-decl ,js--prototype-objextend-class-decl-re-2 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
198 :prototype t |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
199 :contexts (toplevel) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
200 :framework prototype) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
201 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
202 (:name "Dojo" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
203 :class-decl ,js--dojo-class-decl-re |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
204 :contexts (toplevel) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
205 :framework dojo) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
206 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
207 (:name "ExtJS (style 1)" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
208 :class-decl ,js--extjs-class-decl-re-1 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
209 :prototype t |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
210 :contexts (toplevel) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
211 :framework extjs) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
212 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
213 (:name "ExtJS (style 2)" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
214 :class-decl ,js--extjs-class-decl-re-2 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
215 :contexts (toplevel) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
216 :framework extjs) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
217 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
218 (:name "Merrill Press" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
219 :class-decl ,js--mp-class-decl-re |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
220 :contexts (toplevel) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
221 :framework merrillpress)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
222 |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
223 "List of JavaScript class definition styles. |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
224 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
225 A class definition style is a plist with the following keys: |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
226 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
227 :name is a human-readable name of the class type |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
228 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
229 :class-decl is a regular expression giving the start of the |
104683
2b8eeeaa8c1d
* international/ucs-normalize.el (ucs-normalize-sort, quick-check-list):
Juanma Barranquero <lekktu@gmail.com>
parents:
104391
diff
changeset
|
230 class. Its first group must match the name of its class. If there |
2b8eeeaa8c1d
* international/ucs-normalize.el (ucs-normalize-sort, quick-check-list):
Juanma Barranquero <lekktu@gmail.com>
parents:
104391
diff
changeset
|
231 is a parent class, the second group should match, and it should be |
2b8eeeaa8c1d
* international/ucs-normalize.el (ucs-normalize-sort, quick-check-list):
Juanma Barranquero <lekktu@gmail.com>
parents:
104391
diff
changeset
|
232 the name of the class. |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
233 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
234 If :prototype is present and non-nil, the parser will merge |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
235 declarations for this constructs with others at the same lexical |
104683
2b8eeeaa8c1d
* international/ucs-normalize.el (ucs-normalize-sort, quick-check-list):
Juanma Barranquero <lekktu@gmail.com>
parents:
104391
diff
changeset
|
236 level that have the same name. Otherwise, multiple definitions |
2b8eeeaa8c1d
* international/ucs-normalize.el (ucs-normalize-sort, quick-check-list):
Juanma Barranquero <lekktu@gmail.com>
parents:
104391
diff
changeset
|
237 will create multiple top-level entries. Don't use :prototype |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
238 unnecessarily: it has an associated cost in performance. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
239 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
240 If :strip-prototype is present and non-nil, then if the class |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
241 name as matched contains |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
242 ") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
243 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
244 (defconst js--available-frameworks |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
245 (loop with available-frameworks |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
246 for style in js--class-styles |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
247 for framework = (plist-get style :framework) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
248 unless (memq framework available-frameworks) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
249 collect framework into available-frameworks |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
250 finally return available-frameworks) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
251 "List of available JavaScript frameworks symbols.") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
252 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
253 (defconst js--function-heading-1-re |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
254 (concat |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
255 "^\\s-*function\\s-+\\(" js--name-re "\\)") |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
256 "Regexp matching the start of a JavaScript function header. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
257 Match group 1 is the name of the function.") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
258 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
259 (defconst js--function-heading-2-re |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
260 (concat |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
261 "^\\s-*\\(" js--name-re "\\)\\s-*:\\s-*function\\_>") |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
262 "Regexp matching the start of a function entry in an associative array. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
263 Match group 1 is the name of the function.") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
264 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
265 (defconst js--function-heading-3-re |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
266 (concat |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
267 "^\\s-*\\(?:var\\s-+\\)?\\(" js--dotted-name-re "\\)" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
268 "\\s-*=\\s-*function\\_>") |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
269 "Regexp matching a line in the JavaScript form \"var MUMBLE = function\". |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
270 Match group 1 is MUMBLE.") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
271 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
272 (defconst js--macro-decl-re |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
273 (concat "^\\s-*#\\s-*define\\s-+\\(" js--cpp-name-re "\\)\\s-*(") |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
274 "Regexp matching a CPP macro definition, up to the opening parenthesis. |
104683
2b8eeeaa8c1d
* international/ucs-normalize.el (ucs-normalize-sort, quick-check-list):
Juanma Barranquero <lekktu@gmail.com>
parents:
104391
diff
changeset
|
275 Match group 1 is the name of the macro.") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
276 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
277 (defun js--regexp-opt-symbol (list) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
278 "Like `regexp-opt', but surround the result with `\\\\_<' and `\\\\_>'." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
279 (concat "\\_<" (regexp-opt list t) "\\_>")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
280 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
281 (defconst js--keyword-re |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
282 (js--regexp-opt-symbol |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
283 '("abstract" "break" "case" "catch" "class" "const" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
284 "continue" "debugger" "default" "delete" "do" "else" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
285 "enum" "export" "extends" "final" "finally" "for" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
286 "function" "goto" "if" "implements" "import" "in" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
287 "instanceof" "interface" "native" "new" "package" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
288 "private" "protected" "public" "return" "static" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
289 "super" "switch" "synchronized" "throw" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
290 "throws" "transient" "try" "typeof" "var" "void" "let" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
291 "yield" "volatile" "while" "with")) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
292 "Regexp matching any JavaScript keyword.") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
293 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
294 (defconst js--basic-type-re |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
295 (js--regexp-opt-symbol |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
296 '("boolean" "byte" "char" "double" "float" "int" "long" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
297 "short" "void")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
298 "Regular expression matching any predefined type in JavaScript.") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
299 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
300 (defconst js--constant-re |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
301 (js--regexp-opt-symbol '("false" "null" "undefined" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
302 "Infinity" "NaN" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
303 "true" "arguments" "this")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
304 "Regular expression matching any future reserved words in JavaScript.") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
305 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
306 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
307 (defconst js--font-lock-keywords-1 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
308 (list |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
309 "\\_<import\\_>" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
310 (list js--function-heading-1-re 1 font-lock-function-name-face) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
311 (list js--function-heading-2-re 1 font-lock-function-name-face)) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
312 "Level one font lock keywords for `js-mode'.") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
313 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
314 (defconst js--font-lock-keywords-2 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
315 (append js--font-lock-keywords-1 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
316 (list (list js--keyword-re 1 font-lock-keyword-face) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
317 (list "\\_<for\\_>" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
318 "\\s-+\\(each\\)\\_>" nil nil |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
319 (list 1 'font-lock-keyword-face)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
320 (cons js--basic-type-re font-lock-type-face) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
321 (cons js--constant-re font-lock-constant-face))) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
322 "Level two font lock keywords for `js-mode'.") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
323 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
324 ;; js--pitem is the basic building block of the lexical |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
325 ;; database. When one refers to a real part of the buffer, the region |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
326 ;; of text to which it refers is split into a conceptual header and |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
327 ;; body. Consider the (very short) block described by a hypothetical |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
328 ;; js--pitem: |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
329 ;; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
330 ;; function foo(a,b,c) { return 42; } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
331 ;; ^ ^ ^ |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
332 ;; | | | |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
333 ;; +- h-begin +- h-end +- b-end |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
334 ;; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
335 ;; (Remember that these are buffer positions, and therefore point |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
336 ;; between characters, not at them. An arrow drawn to a character |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
337 ;; indicates the corresponding position is between that character and |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
338 ;; the one immediately preceding it.) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
339 ;; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
340 ;; The header is the region of text [h-begin, h-end], and is |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
341 ;; the text needed to unambiguously recognize the start of the |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
342 ;; construct. If the entire header is not present, the construct is |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
343 ;; not recognized at all. No other pitems may be nested inside the |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
344 ;; header. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
345 ;; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
346 ;; The body is the region [h-end, b-end]. It may contain nested |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
347 ;; js--pitem instances. The body of a pitem may be empty: in |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
348 ;; that case, b-end is equal to header-end. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
349 ;; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
350 ;; The three points obey the following relationship: |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
351 ;; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
352 ;; h-begin < h-end <= b-end |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
353 ;; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
354 ;; We put a text property in the buffer on the character *before* |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
355 ;; h-end, and if we see it, on the character *before* b-end. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
356 ;; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
357 ;; The text property for h-end, js--pstate, is actually a list |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
358 ;; of all js--pitem instances open after the marked character. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
359 ;; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
360 ;; The text property for b-end, js--pend, is simply the |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
361 ;; js--pitem that ends after the marked character. (Because |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
362 ;; pitems always end when the paren-depth drops below a critical |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
363 ;; value, and because we can only drop one level per character, only |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
364 ;; one pitem may end at a given character.) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
365 ;; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
366 ;; In the structure below, we only store h-begin and (sometimes) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
367 ;; b-end. We can trivially and quickly find h-end by going to h-begin |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
368 ;; and searching for an js--pstate text property. Since no other |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
369 ;; js--pitem instances can be nested inside the header of a |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
370 ;; pitem, the location after the character with this text property |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
371 ;; must be h-end. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
372 ;; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
373 ;; js--pitem instances are never modified (with the exception |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
374 ;; of the b-end field). Instead, modified copies are added at subseqnce parse points. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
375 ;; (The exception for b-end and its caveats is described below.) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
376 ;; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
377 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
378 (defstruct (js--pitem (:type list)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
379 ;; IMPORTANT: Do not alter the position of fields within the list. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
380 ;; Various bits of code depend on their positions, particularly |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
381 ;; anything that manipulates the list of children. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
382 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
383 ;; List of children inside this pitem's body |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
384 (children nil :read-only t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
385 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
386 ;; When we reach this paren depth after h-end, the pitem ends |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
387 (paren-depth nil :read-only t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
388 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
389 ;; Symbol or class-style plist if this is a class |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
390 (type nil :read-only t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
391 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
392 ;; See above |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
393 (h-begin nil :read-only t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
394 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
395 ;; List of strings giving the parts of the name of this pitem (e.g., |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
396 ;; '("MyClass" "myMethod"), or t if this pitem is anonymous |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
397 (name nil :read-only t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
398 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
399 ;; THIS FIELD IS MUTATED, and its value is shared by all copies of |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
400 ;; this pitem: when we copy-and-modify pitem instances, we share |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
401 ;; their tail structures, so all the copies actually have the same |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
402 ;; terminating cons cell. We modify that shared cons cell directly. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
403 ;; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
404 ;; The field value is either a number (buffer location) or nil if |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
405 ;; unknown. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
406 ;; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
407 ;; If the field's value is greater than `js--cache-end', the |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
408 ;; value is stale and must be treated as if it were nil. Conversely, |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
409 ;; if this field is nil, it is guaranteed that this pitem is open up |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
410 ;; to at least `js--cache-end'. (This property is handy when |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
411 ;; computing whether we're inside a given pitem.) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
412 ;; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
413 (b-end nil)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
414 |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
415 ;; The pitem we start parsing with. |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
416 (defconst js--initial-pitem |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
417 (make-js--pitem |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
418 :paren-depth most-negative-fixnum |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
419 :type 'toplevel)) |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
420 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
421 ;;; User Customization |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
422 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
423 (defgroup js nil |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
424 "Customization variables for JavaScript mode." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
425 :tag "JavaScript" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
426 :group 'languages) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
427 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
428 (defcustom js-indent-level 4 |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
429 "Number of spaces for each indentation step in `js-mode'." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
430 :type 'integer |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
431 :group 'js) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
432 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
433 (defcustom js-expr-indent-offset 0 |
109997
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
434 "Number of additional spaces for indenting continued expressions. |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
435 The value must be no less than minus `js-indent-level'." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
436 :type 'integer |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
437 :group 'js) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
438 |
109997
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
439 (defcustom js-paren-indent-offset 0 |
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
440 "Number of additional spaces for indenting expressions in parentheses. |
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
441 The value must be no less than minus `js-indent-level'." |
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
442 :type 'integer |
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
443 :group 'js |
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
444 :version "24.1") |
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
445 |
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
446 (defcustom js-square-indent-offset 0 |
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
447 "Number of additional spaces for indenting expressions in square braces. |
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
448 The value must be no less than minus `js-indent-level'." |
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
449 :type 'integer |
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
450 :group 'js |
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
451 :version "24.1") |
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
452 |
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
453 (defcustom js-curly-indent-offset 0 |
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
454 "Number of additional spaces for indenting expressions in curly braces. |
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
455 The value must be no less than minus `js-indent-level'." |
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
456 :type 'integer |
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
457 :group 'js |
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
458 :version "24.1") |
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
459 |
107692
831fbe6bd8c0
Revert 2009-08-15 change, restoring electric punctuation (Bug#5586)
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
460 (defcustom js-auto-indent-flag t |
831fbe6bd8c0
Revert 2009-08-15 change, restoring electric punctuation (Bug#5586)
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
461 "Whether to automatically indent when typing punctuation characters. |
831fbe6bd8c0
Revert 2009-08-15 change, restoring electric punctuation (Bug#5586)
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
462 If non-nil, the characters {}();,: also indent the current line |
831fbe6bd8c0
Revert 2009-08-15 change, restoring electric punctuation (Bug#5586)
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
463 in Javascript mode." |
831fbe6bd8c0
Revert 2009-08-15 change, restoring electric punctuation (Bug#5586)
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
464 :type 'boolean |
831fbe6bd8c0
Revert 2009-08-15 change, restoring electric punctuation (Bug#5586)
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
465 :group 'js) |
831fbe6bd8c0
Revert 2009-08-15 change, restoring electric punctuation (Bug#5586)
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
466 |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
467 (defcustom js-flat-functions nil |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
468 "Treat nested functions as top-level functions in `js-mode'. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
469 This applies to function movement, marking, and so on." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
470 :type 'boolean |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
471 :group 'js) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
472 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
473 (defcustom js-comment-lineup-func #'c-lineup-C-comments |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
474 "Lineup function for `cc-mode-style', for C comments in `js-mode'." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
475 :type 'function |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
476 :group 'js) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
477 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
478 (defcustom js-enabled-frameworks js--available-frameworks |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
479 "Frameworks recognized by `js-mode'. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
480 To improve performance, you may turn off some frameworks you |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
481 seldom use, either globally or on a per-buffer basis." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
482 :type (cons 'set (mapcar (lambda (x) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
483 (list 'const x)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
484 js--available-frameworks)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
485 :group 'js) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
486 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
487 (defcustom js-js-switch-tabs |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
488 (and (memq system-type '(darwin)) t) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
489 "Whether `js-mode' should display tabs while selecting them. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
490 This is useful only if the windowing system has a good mechanism |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
491 for preventing Firefox from stealing the keyboard focus." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
492 :type 'boolean |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
493 :group 'js) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
494 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
495 (defcustom js-js-tmpdir |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
496 "~/.emacs.d/js/js" |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
497 "Temporary directory used by `js-mode' to communicate with Mozilla. |
109258 | 498 This directory must be readable and writable by both Mozilla and Emacs." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
499 :type 'directory |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
500 :group 'js) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
501 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
502 (defcustom js-js-timeout 5 |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
503 "Reply timeout for executing commands in Mozilla via `js-mode'. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
504 The value is given in seconds. Increase this value if you are |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
505 getting timeout messages." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
506 :type 'integer |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
507 :group 'js) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
508 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
509 ;;; KeyMap |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
510 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
511 (defvar js-mode-map |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
512 (let ((keymap (make-sparse-keymap))) |
107692
831fbe6bd8c0
Revert 2009-08-15 change, restoring electric punctuation (Bug#5586)
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
513 (mapc (lambda (key) |
831fbe6bd8c0
Revert 2009-08-15 change, restoring electric punctuation (Bug#5586)
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
514 (define-key keymap key #'js-insert-and-indent)) |
831fbe6bd8c0
Revert 2009-08-15 change, restoring electric punctuation (Bug#5586)
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
515 '("{" "}" "(" ")" ":" ";" ",")) |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
516 (define-key keymap [(control ?c) (meta ?:)] #'js-eval) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
517 (define-key keymap [(control ?c) (control ?j)] #'js-set-js-context) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
518 (define-key keymap [(control meta ?x)] #'js-eval-defun) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
519 (define-key keymap [(meta ?.)] #'js-find-symbol) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
520 (easy-menu-define nil keymap "Javascript Menu" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
521 '("Javascript" |
109258 | 522 ["Select New Mozilla Context..." js-set-js-context |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
523 (fboundp #'inferior-moz-process)] |
109258 | 524 ["Evaluate Expression in Mozilla Context..." js-eval |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
525 (fboundp #'inferior-moz-process)] |
109258 | 526 ["Send Current Function to Mozilla..." js-eval-defun |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
527 (fboundp #'inferior-moz-process)])) |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
528 keymap) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
529 "Keymap for `js-mode'.") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
530 |
107692
831fbe6bd8c0
Revert 2009-08-15 change, restoring electric punctuation (Bug#5586)
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
531 (defun js-insert-and-indent (key) |
831fbe6bd8c0
Revert 2009-08-15 change, restoring electric punctuation (Bug#5586)
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
532 "Run the command bound to KEY, and indent if necessary. |
831fbe6bd8c0
Revert 2009-08-15 change, restoring electric punctuation (Bug#5586)
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
533 Indentation does not take place if point is in a string or |
831fbe6bd8c0
Revert 2009-08-15 change, restoring electric punctuation (Bug#5586)
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
534 comment." |
831fbe6bd8c0
Revert 2009-08-15 change, restoring electric punctuation (Bug#5586)
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
535 (interactive (list (this-command-keys))) |
831fbe6bd8c0
Revert 2009-08-15 change, restoring electric punctuation (Bug#5586)
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
536 (call-interactively (lookup-key (current-global-map) key)) |
831fbe6bd8c0
Revert 2009-08-15 change, restoring electric punctuation (Bug#5586)
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
537 (let ((syntax (save-restriction (widen) (syntax-ppss)))) |
831fbe6bd8c0
Revert 2009-08-15 change, restoring electric punctuation (Bug#5586)
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
538 (when (or (and (not (nth 8 syntax)) |
831fbe6bd8c0
Revert 2009-08-15 change, restoring electric punctuation (Bug#5586)
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
539 js-auto-indent-flag) |
831fbe6bd8c0
Revert 2009-08-15 change, restoring electric punctuation (Bug#5586)
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
540 (and (nth 4 syntax) |
831fbe6bd8c0
Revert 2009-08-15 change, restoring electric punctuation (Bug#5586)
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
541 (eq (current-column) |
831fbe6bd8c0
Revert 2009-08-15 change, restoring electric punctuation (Bug#5586)
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
542 (1+ (current-indentation))))) |
831fbe6bd8c0
Revert 2009-08-15 change, restoring electric punctuation (Bug#5586)
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
543 (indent-according-to-mode)))) |
831fbe6bd8c0
Revert 2009-08-15 change, restoring electric punctuation (Bug#5586)
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
544 |
831fbe6bd8c0
Revert 2009-08-15 change, restoring electric punctuation (Bug#5586)
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
545 |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
546 ;;; Syntax table and parsing |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
547 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
548 (defvar js-mode-syntax-table |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
549 (let ((table (make-syntax-table))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
550 (c-populate-syntax-table table) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
551 (modify-syntax-entry ?$ "_" table) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
552 table) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
553 "Syntax table for `js-mode'.") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
554 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
555 (defvar js--quick-match-re nil |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
556 "Autogenerated regexp used by `js-mode' to match buffer constructs.") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
557 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
558 (defvar js--quick-match-re-func nil |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
559 "Autogenerated regexp used by `js-mode' to match constructs and functions.") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
560 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
561 (make-variable-buffer-local 'js--quick-match-re) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
562 (make-variable-buffer-local 'js--quick-match-re-func) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
563 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
564 (defvar js--cache-end 1 |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
565 "Last valid buffer position for the `js-mode' function cache.") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
566 (make-variable-buffer-local 'js--cache-end) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
567 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
568 (defvar js--last-parse-pos nil |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
569 "Latest parse position reached by `js--ensure-cache'.") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
570 (make-variable-buffer-local 'js--last-parse-pos) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
571 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
572 (defvar js--state-at-last-parse-pos nil |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
573 "Parse state at `js--last-parse-pos'.") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
574 (make-variable-buffer-local 'js--state-at-last-parse-pos) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
575 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
576 (defun js--flatten-list (list) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
577 (loop for item in list |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
578 nconc (cond ((consp item) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
579 (js--flatten-list item)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
580 (item (list item))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
581 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
582 (defun js--maybe-join (prefix separator suffix &rest list) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
583 "Helper function for `js--update-quick-match-re'. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
584 If LIST contains any element that is not nil, return its non-nil |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
585 elements, separated by SEPARATOR, prefixed by PREFIX, and ended |
104683
2b8eeeaa8c1d
* international/ucs-normalize.el (ucs-normalize-sort, quick-check-list):
Juanma Barranquero <lekktu@gmail.com>
parents:
104391
diff
changeset
|
586 with SUFFIX as with `concat'. Otherwise, if LIST is empty, return |
2b8eeeaa8c1d
* international/ucs-normalize.el (ucs-normalize-sort, quick-check-list):
Juanma Barranquero <lekktu@gmail.com>
parents:
104391
diff
changeset
|
587 nil. If any element in LIST is itself a list, flatten that |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
588 element." |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
589 (setq list (js--flatten-list list)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
590 (when list |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
591 (concat prefix (mapconcat #'identity list separator) suffix))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
592 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
593 (defun js--update-quick-match-re () |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
594 "Internal function used by `js-mode' for caching buffer constructs. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
595 This updates `js--quick-match-re', based on the current set of |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
596 enabled frameworks." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
597 (setq js--quick-match-re |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
598 (js--maybe-join |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
599 "^[ \t]*\\(?:" "\\|" "\\)" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
600 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
601 ;; #define mumble |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
602 "#define[ \t]+[a-zA-Z_]" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
603 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
604 (when (memq 'extjs js-enabled-frameworks) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
605 "Ext\\.extend") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
606 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
607 (when (memq 'prototype js-enabled-frameworks) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
608 "Object\\.extend") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
609 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
610 ;; var mumble = THING ( |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
611 (js--maybe-join |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
612 "\\(?:var[ \t]+\\)?[a-zA-Z_$0-9.]+[ \t]*=[ \t]*\\(?:" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
613 "\\|" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
614 "\\)[ \t]*\(" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
615 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
616 (when (memq 'prototype js-enabled-frameworks) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
617 "Class\\.create") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
618 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
619 (when (memq 'extjs js-enabled-frameworks) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
620 "Ext\\.extend") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
621 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
622 (when (memq 'merrillpress js-enabled-frameworks) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
623 "[a-zA-Z_$0-9]+\\.extend\\(?:Final\\)?")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
624 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
625 (when (memq 'dojo js-enabled-frameworks) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
626 "dojo\\.declare[ \t]*\(") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
627 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
628 (when (memq 'mochikit js-enabled-frameworks) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
629 "MochiKit\\.Base\\.update[ \t]*\(") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
630 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
631 ;; mumble.prototypeTHING |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
632 (js--maybe-join |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
633 "[a-zA-Z_$0-9.]+\\.prototype\\(?:" "\\|" "\\)" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
634 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
635 (when (memq 'javascript js-enabled-frameworks) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
636 '( ;; foo.prototype.bar = function( |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
637 "\\.[a-zA-Z_$0-9]+[ \t]*=[ \t]*function[ \t]*\(" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
638 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
639 ;; mumble.prototype = { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
640 "[ \t]*=[ \t]*{"))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
641 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
642 (setq js--quick-match-re-func |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
643 (concat "function\\|" js--quick-match-re))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
644 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
645 (defun js--forward-text-property (propname) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
646 "Move over the next value of PROPNAME in the buffer. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
647 If found, return that value and leave point after the character |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
648 having that value; otherwise, return nil and leave point at EOB." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
649 (let ((next-value (get-text-property (point) propname))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
650 (if next-value |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
651 (forward-char) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
652 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
653 (goto-char (next-single-property-change |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
654 (point) propname nil (point-max))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
655 (unless (eobp) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
656 (setq next-value (get-text-property (point) propname)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
657 (forward-char))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
658 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
659 next-value)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
660 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
661 (defun js--backward-text-property (propname) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
662 "Move over the previous value of PROPNAME in the buffer. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
663 If found, return that value and leave point just before the |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
664 character that has that value, otherwise return nil and leave |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
665 point at BOB." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
666 (unless (bobp) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
667 (let ((prev-value (get-text-property (1- (point)) propname))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
668 (if prev-value |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
669 (backward-char) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
670 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
671 (goto-char (previous-single-property-change |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
672 (point) propname nil (point-min))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
673 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
674 (unless (bobp) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
675 (backward-char) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
676 (setq prev-value (get-text-property (point) propname)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
677 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
678 prev-value))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
679 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
680 (defsubst js--forward-pstate () |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
681 (js--forward-text-property 'js--pstate)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
682 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
683 (defsubst js--backward-pstate () |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
684 (js--backward-text-property 'js--pstate)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
685 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
686 (defun js--pitem-goto-h-end (pitem) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
687 (goto-char (js--pitem-h-begin pitem)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
688 (js--forward-pstate)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
689 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
690 (defun js--re-search-forward-inner (regexp &optional bound count) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
691 "Helper function for `js--re-search-forward'." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
692 (let ((parse) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
693 str-terminator |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
694 (orig-macro-end (save-excursion |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
695 (when (js--beginning-of-macro) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
696 (c-end-of-macro) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
697 (point))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
698 (while (> count 0) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
699 (re-search-forward regexp bound) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
700 (setq parse (syntax-ppss)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
701 (cond ((setq str-terminator (nth 3 parse)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
702 (when (eq str-terminator t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
703 (setq str-terminator ?/)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
704 (re-search-forward |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
705 (concat "\\([^\\]\\|^\\)" (string str-terminator)) |
111433
05dc9dca8729
Replace end-of-line, save-excursion etc with point-at-eol, point-at-bol.
Glenn Morris <rgm@gnu.org>
parents:
110403
diff
changeset
|
706 (point-at-eol) t)) |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
707 ((nth 7 parse) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
708 (forward-line)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
709 ((or (nth 4 parse) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
710 (and (eq (char-before) ?\/) (eq (char-after) ?\*))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
711 (re-search-forward "\\*/")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
712 ((and (not (and orig-macro-end |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
713 (<= (point) orig-macro-end))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
714 (js--beginning-of-macro)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
715 (c-end-of-macro)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
716 (t |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
717 (setq count (1- count)))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
718 (point)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
719 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
720 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
721 (defun js--re-search-forward (regexp &optional bound noerror count) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
722 "Search forward, ignoring strings, cpp macros, and comments. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
723 This function invokes `re-search-forward', but treats the buffer |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
724 as if strings, cpp macros, and comments have been removed. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
725 |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
726 If invoked while inside a macro, it treats the contents of the |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
727 macro as normal text." |
110270
c7809974cd64
Misc cleanups and simplifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110015
diff
changeset
|
728 (unless count (setq count 1)) |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
729 (let ((saved-point (point)) |
110270
c7809974cd64
Misc cleanups and simplifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110015
diff
changeset
|
730 (search-fun |
c7809974cd64
Misc cleanups and simplifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110015
diff
changeset
|
731 (cond ((< count 0) (setq count (- count)) |
c7809974cd64
Misc cleanups and simplifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110015
diff
changeset
|
732 #'js--re-search-backward-inner) |
c7809974cd64
Misc cleanups and simplifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110015
diff
changeset
|
733 ((> count 0) #'js--re-search-forward-inner) |
c7809974cd64
Misc cleanups and simplifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110015
diff
changeset
|
734 (t #'ignore)))) |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
735 (condition-case err |
110270
c7809974cd64
Misc cleanups and simplifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110015
diff
changeset
|
736 (funcall search-fun regexp bound count) |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
737 (search-failed |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
738 (goto-char saved-point) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
739 (unless noerror |
110270
c7809974cd64
Misc cleanups and simplifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110015
diff
changeset
|
740 (signal (car err) (cdr err))))))) |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
741 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
742 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
743 (defun js--re-search-backward-inner (regexp &optional bound count) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
744 "Auxiliary function for `js--re-search-backward'." |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
745 (let ((parse) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
746 str-terminator |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
747 (orig-macro-start |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
748 (save-excursion |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
749 (and (js--beginning-of-macro) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
750 (point))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
751 (while (> count 0) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
752 (re-search-backward regexp bound) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
753 (when (and (> (point) (point-min)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
754 (save-excursion (backward-char) (looking-at "/[/*]"))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
755 (forward-char)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
756 (setq parse (syntax-ppss)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
757 (cond ((setq str-terminator (nth 3 parse)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
758 (when (eq str-terminator t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
759 (setq str-terminator ?/)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
760 (re-search-backward |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
761 (concat "\\([^\\]\\|^\\)" (string str-terminator)) |
111433
05dc9dca8729
Replace end-of-line, save-excursion etc with point-at-eol, point-at-bol.
Glenn Morris <rgm@gnu.org>
parents:
110403
diff
changeset
|
762 (point-at-bol) t)) |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
763 ((nth 7 parse) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
764 (goto-char (nth 8 parse))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
765 ((or (nth 4 parse) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
766 (and (eq (char-before) ?/) (eq (char-after) ?*))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
767 (re-search-backward "/\\*")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
768 ((and (not (and orig-macro-start |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
769 (>= (point) orig-macro-start))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
770 (js--beginning-of-macro))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
771 (t |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
772 (setq count (1- count)))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
773 (point)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
774 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
775 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
776 (defun js--re-search-backward (regexp &optional bound noerror count) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
777 "Search backward, ignoring strings, preprocessor macros, and comments. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
778 |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
779 This function invokes `re-search-backward' but treats the buffer |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
780 as if strings, preprocessor macros, and comments have been |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
781 removed. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
782 |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
783 If invoked while inside a macro, treat the macro as normal text." |
110270
c7809974cd64
Misc cleanups and simplifications.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110015
diff
changeset
|
784 (js--re-search-forward regexp bound noerror (if count (- count) -1))) |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
785 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
786 (defun js--forward-expression () |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
787 "Move forward over a whole JavaScript expression. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
788 This function doesn't move over expressions continued across |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
789 lines." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
790 (loop |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
791 ;; non-continued case; simplistic, but good enough? |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
792 do (loop until (or (eolp) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
793 (progn |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
794 (forward-comment most-positive-fixnum) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
795 (memq (char-after) '(?\, ?\; ?\] ?\) ?\})))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
796 do (forward-sexp)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
797 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
798 while (and (eq (char-after) ?\n) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
799 (save-excursion |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
800 (forward-char) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
801 (js--continued-expression-p))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
802 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
803 (defun js--forward-function-decl () |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
804 "Move forward over a JavaScript function declaration. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
805 This puts point at the 'function' keyword. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
806 |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
807 If this is a syntactically-correct non-expression function, |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
808 return the name of the function, or t if the name could not be |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
809 determined. Otherwise, return nil." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
810 (assert (looking-at "\\_<function\\_>")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
811 (let ((name t)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
812 (forward-word) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
813 (forward-comment most-positive-fixnum) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
814 (when (looking-at js--name-re) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
815 (setq name (match-string-no-properties 0)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
816 (goto-char (match-end 0))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
817 (forward-comment most-positive-fixnum) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
818 (and (eq (char-after) ?\( ) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
819 (ignore-errors (forward-list) t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
820 (progn (forward-comment most-positive-fixnum) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
821 (and (eq (char-after) ?{) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
822 name))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
823 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
824 (defun js--function-prologue-beginning (&optional pos) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
825 "Return the start of the JavaScript function prologue containing POS. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
826 A function prologue is everything from start of the definition up |
104683
2b8eeeaa8c1d
* international/ucs-normalize.el (ucs-normalize-sort, quick-check-list):
Juanma Barranquero <lekktu@gmail.com>
parents:
104391
diff
changeset
|
827 to and including the opening brace. POS defaults to point. |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
828 If POS is not in a function prologue, return nil." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
829 (let (prologue-begin) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
830 (save-excursion |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
831 (if pos |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
832 (goto-char pos) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
833 (setq pos (point))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
834 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
835 (when (save-excursion |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
836 (forward-line 0) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
837 (or (looking-at js--function-heading-2-re) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
838 (looking-at js--function-heading-3-re))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
839 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
840 (setq prologue-begin (match-beginning 1)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
841 (when (<= prologue-begin pos) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
842 (goto-char (match-end 0)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
843 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
844 (skip-syntax-backward "w_") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
845 (and (or (looking-at "\\_<function\\_>") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
846 (js--re-search-backward "\\_<function\\_>" nil t)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
847 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
848 (save-match-data (goto-char (match-beginning 0)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
849 (js--forward-function-decl)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
850 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
851 (<= pos (point)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
852 (or prologue-begin (match-beginning 0)))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
853 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
854 (defun js--beginning-of-defun-raw () |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
855 "Helper function for `js-beginning-of-defun'. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
856 Go to previous defun-beginning and return the parse state for it, |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
857 or nil if we went all the way back to bob and don't find |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
858 anything." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
859 (js--ensure-cache) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
860 (let (pstate) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
861 (while (and (setq pstate (js--backward-pstate)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
862 (not (eq 'function (js--pitem-type (car pstate)))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
863 (and (not (bobp)) pstate))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
864 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
865 (defun js--pstate-is-toplevel-defun (pstate) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
866 "Helper function for `js--beginning-of-defun-nested'. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
867 If PSTATE represents a non-empty top-level defun, return the |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
868 top-most pitem. Otherwise, return nil." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
869 (loop for pitem in pstate |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
870 with func-depth = 0 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
871 with func-pitem |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
872 if (eq 'function (js--pitem-type pitem)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
873 do (incf func-depth) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
874 and do (setq func-pitem pitem) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
875 finally return (if (eq func-depth 1) func-pitem))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
876 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
877 (defun js--beginning-of-defun-nested () |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
878 "Helper function for `js--beginning-of-defun'. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
879 Return the pitem of the function we went to the beginning of." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
880 (or |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
881 ;; Look for the smallest function that encloses point... |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
882 (loop for pitem in (js--parse-state-at-point) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
883 if (and (eq 'function (js--pitem-type pitem)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
884 (js--inside-pitem-p pitem)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
885 do (goto-char (js--pitem-h-begin pitem)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
886 and return pitem) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
887 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
888 ;; ...and if that isn't found, look for the previous top-level |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
889 ;; defun |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
890 (loop for pstate = (js--backward-pstate) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
891 while pstate |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
892 if (js--pstate-is-toplevel-defun pstate) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
893 do (goto-char (js--pitem-h-begin it)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
894 and return it))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
895 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
896 (defun js--beginning-of-defun-flat () |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
897 "Helper function for `js-beginning-of-defun'." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
898 (let ((pstate (js--beginning-of-defun-raw))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
899 (when pstate |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
900 (goto-char (js--pitem-h-begin (car pstate)))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
901 |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
902 (defun js-beginning-of-defun (&optional arg) |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
903 "Value of `beginning-of-defun-function' for `js-mode'." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
904 (setq arg (or arg 1)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
905 (while (and (not (eobp)) (< arg 0)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
906 (incf arg) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
907 (when (and (not js-flat-functions) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
908 (or (eq (js-syntactic-context) 'function) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
909 (js--function-prologue-beginning))) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
910 (js-end-of-defun)) |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
911 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
912 (if (js--re-search-forward |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
913 "\\_<function\\_>" nil t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
914 (goto-char (js--function-prologue-beginning)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
915 (goto-char (point-max)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
916 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
917 (while (> arg 0) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
918 (decf arg) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
919 ;; If we're just past the end of a function, the user probably wants |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
920 ;; to go to the beginning of *that* function |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
921 (when (eq (char-before) ?}) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
922 (backward-char)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
923 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
924 (let ((prologue-begin (js--function-prologue-beginning))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
925 (cond ((and prologue-begin (< prologue-begin (point))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
926 (goto-char prologue-begin)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
927 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
928 (js-flat-functions |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
929 (js--beginning-of-defun-flat)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
930 (t |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
931 (js--beginning-of-defun-nested)))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
932 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
933 (defun js--flush-caches (&optional beg ignored) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
934 "Flush the `js-mode' syntax cache after position BEG. |
104683
2b8eeeaa8c1d
* international/ucs-normalize.el (ucs-normalize-sort, quick-check-list):
Juanma Barranquero <lekktu@gmail.com>
parents:
104391
diff
changeset
|
935 BEG defaults to `point-min', meaning to flush the entire cache." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
936 (interactive) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
937 (setq beg (or beg (save-restriction (widen) (point-min)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
938 (setq js--cache-end (min js--cache-end beg))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
939 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
940 (defmacro js--debug (&rest arguments) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
941 ;; `(message ,@arguments) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
942 ) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
943 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
944 (defun js--ensure-cache--pop-if-ended (open-items paren-depth) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
945 (let ((top-item (car open-items))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
946 (when (<= paren-depth (js--pitem-paren-depth top-item)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
947 (assert (not (get-text-property (1- (point)) 'js-pend))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
948 (put-text-property (1- (point)) (point) 'js--pend top-item) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
949 (setf (js--pitem-b-end top-item) (point)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
950 (setq open-items |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
951 ;; open-items must contain at least two items for this to |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
952 ;; work, but because we push a dummy item to start with, |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
953 ;; that assumption holds. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
954 (cons (js--pitem-add-child (second open-items) top-item) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
955 (cddr open-items))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
956 open-items) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
957 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
958 (defmacro js--ensure-cache--update-parse () |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
959 "Helper function for `js--ensure-cache'. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
960 Update parsing information up to point, referring to parse, |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
961 prev-parse-point, goal-point, and open-items bound lexically in |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
962 the body of `js--ensure-cache'." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
963 `(progn |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
964 (setq goal-point (point)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
965 (goto-char prev-parse-point) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
966 (while (progn |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
967 (setq open-items (js--ensure-cache--pop-if-ended |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
968 open-items (car parse))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
969 ;; Make sure parse-partial-sexp doesn't stop because we *entered* |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
970 ;; the given depth -- i.e., make sure we're deeper than the target |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
971 ;; depth. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
972 (assert (> (nth 0 parse) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
973 (js--pitem-paren-depth (car open-items)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
974 (setq parse (parse-partial-sexp |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
975 prev-parse-point goal-point |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
976 (js--pitem-paren-depth (car open-items)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
977 nil parse)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
978 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
979 ;; (let ((overlay (make-overlay prev-parse-point (point)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
980 ;; (overlay-put overlay 'face '(:background "red")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
981 ;; (unwind-protect |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
982 ;; (progn |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
983 ;; (js--debug "parsed: %S" parse) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
984 ;; (sit-for 1)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
985 ;; (delete-overlay overlay))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
986 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
987 (setq prev-parse-point (point)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
988 (< (point) goal-point))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
989 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
990 (setq open-items (js--ensure-cache--pop-if-ended |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
991 open-items (car parse))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
992 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
993 (defun js--show-cache-at-point () |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
994 (interactive) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
995 (require 'pp) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
996 (let ((prop (get-text-property (point) 'js--pstate))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
997 (with-output-to-temp-buffer "*Help*" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
998 (pp prop)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
999 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1000 (defun js--split-name (string) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1001 "Split a JavaScript name into its dot-separated parts. |
104683
2b8eeeaa8c1d
* international/ucs-normalize.el (ucs-normalize-sort, quick-check-list):
Juanma Barranquero <lekktu@gmail.com>
parents:
104391
diff
changeset
|
1002 This also removes any prototype parts from the split name |
2b8eeeaa8c1d
* international/ucs-normalize.el (ucs-normalize-sort, quick-check-list):
Juanma Barranquero <lekktu@gmail.com>
parents:
104391
diff
changeset
|
1003 \(unless the name is just \"prototype\" to start with)." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1004 (let ((name (save-match-data |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1005 (split-string string "\\." t)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1006 (unless (and (= (length name) 1) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1007 (equal (car name) "prototype")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1008 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1009 (setq name (remove "prototype" name))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1010 |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1011 (defvar js--guess-function-name-start nil) |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1012 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1013 (defun js--guess-function-name (position) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1014 "Guess the name of the JavaScript function at POSITION. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1015 POSITION should be just after the end of the word \"function\". |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1016 Return the name of the function, or nil if the name could not be |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1017 guessed. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1018 |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1019 This function clobbers match data. If we find the preamble |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1020 begins earlier than expected while guessing the function name, |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1021 set `js--guess-function-name-start' to that position; otherwise, |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1022 set that variable to nil." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1023 (setq js--guess-function-name-start nil) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1024 (save-excursion |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1025 (goto-char position) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1026 (forward-line 0) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1027 (cond |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1028 ((looking-at js--function-heading-3-re) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1029 (and (eq (match-end 0) position) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1030 (setq js--guess-function-name-start (match-beginning 1)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1031 (match-string-no-properties 1))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1032 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1033 ((looking-at js--function-heading-2-re) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1034 (and (eq (match-end 0) position) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1035 (setq js--guess-function-name-start (match-beginning 1)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1036 (match-string-no-properties 1)))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1037 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1038 (defun js--clear-stale-cache () |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1039 ;; Clear any endings that occur after point |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1040 (let (end-prop) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1041 (save-excursion |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1042 (while (setq end-prop (js--forward-text-property |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1043 'js--pend)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1044 (setf (js--pitem-b-end end-prop) nil)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1045 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1046 ;; Remove any cache properties after this point |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1047 (remove-text-properties (point) (point-max) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1048 '(js--pstate t js--pend t))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1049 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1050 (defun js--ensure-cache (&optional limit) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1051 "Ensures brace cache is valid up to the character before LIMIT. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1052 LIMIT defaults to point." |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1053 (setq limit (or limit (point))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1054 (when (< js--cache-end limit) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1055 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1056 (c-save-buffer-state |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1057 (open-items |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1058 orig-match-start |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1059 orig-match-end |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1060 orig-depth |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1061 parse |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1062 prev-parse-point |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1063 name |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1064 case-fold-search |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1065 filtered-class-styles |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1066 new-item |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1067 goal-point |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1068 end-prop) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1069 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1070 ;; Figure out which class styles we need to look for |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1071 (setq filtered-class-styles |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1072 (loop for style in js--class-styles |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1073 if (memq (plist-get style :framework) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1074 js-enabled-frameworks) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1075 collect style)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1076 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1077 (save-excursion |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1078 (save-restriction |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1079 (widen) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1080 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1081 ;; Find last known good position |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1082 (goto-char js--cache-end) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1083 (unless (bobp) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1084 (setq open-items (get-text-property |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1085 (1- (point)) 'js--pstate)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1086 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1087 (unless open-items |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1088 (goto-char (previous-single-property-change |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1089 (point) 'js--pstate nil (point-min))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1090 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1091 (unless (bobp) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1092 (setq open-items (get-text-property (1- (point)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1093 'js--pstate)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1094 (assert open-items)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1095 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1096 (unless open-items |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1097 ;; Make a placeholder for the top-level definition |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1098 (setq open-items (list js--initial-pitem))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1099 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1100 (setq parse (syntax-ppss)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1101 (setq prev-parse-point (point)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1102 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1103 (js--clear-stale-cache) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1104 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1105 (narrow-to-region (point-min) limit) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1106 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1107 (loop while (re-search-forward js--quick-match-re-func nil t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1108 for orig-match-start = (goto-char (match-beginning 0)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1109 for orig-match-end = (match-end 0) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1110 do (js--ensure-cache--update-parse) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1111 for orig-depth = (nth 0 parse) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1112 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1113 ;; Each of these conditions should return non-nil if |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1114 ;; we should add a new item and leave point at the end |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1115 ;; of the new item's header (h-end in the |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1116 ;; js--pitem diagram). This point is the one |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1117 ;; after the last character we need to unambiguously |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1118 ;; detect this construct. If one of these evaluates to |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1119 ;; nil, the location of the point is ignored. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1120 if (cond |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1121 ;; In comment or string |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1122 ((nth 8 parse) nil) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1123 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1124 ;; Regular function declaration |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1125 ((and (looking-at "\\_<function\\_>") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1126 (setq name (js--forward-function-decl))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1127 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1128 (when (eq name t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1129 (setq name (js--guess-function-name orig-match-end)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1130 (if name |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1131 (when js--guess-function-name-start |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1132 (setq orig-match-start |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1133 js--guess-function-name-start)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1134 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1135 (setq name t))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1136 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1137 (assert (eq (char-after) ?{)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1138 (forward-char) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1139 (make-js--pitem |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1140 :paren-depth orig-depth |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1141 :h-begin orig-match-start |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1142 :type 'function |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1143 :name (if (eq name t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1144 name |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1145 (js--split-name name)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1146 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1147 ;; Macro |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1148 ((looking-at js--macro-decl-re) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1149 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1150 ;; Macros often contain unbalanced parentheses. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1151 ;; Make sure that h-end is at the textual end of |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1152 ;; the macro no matter what the parenthesis say. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1153 (c-end-of-macro) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1154 (js--ensure-cache--update-parse) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1155 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1156 (make-js--pitem |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1157 :paren-depth (nth 0 parse) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1158 :h-begin orig-match-start |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1159 :type 'macro |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1160 :name (list (match-string-no-properties 1)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1161 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1162 ;; "Prototype function" declaration |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1163 ((looking-at js--plain-method-re) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1164 (goto-char (match-beginning 3)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1165 (when (save-match-data |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1166 (js--forward-function-decl)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1167 (forward-char) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1168 (make-js--pitem |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1169 :paren-depth orig-depth |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1170 :h-begin orig-match-start |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1171 :type 'function |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1172 :name (nconc (js--split-name |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1173 (match-string-no-properties 1)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1174 (list (match-string-no-properties 2)))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1175 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1176 ;; Class definition |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1177 ((loop with syntactic-context = |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1178 (js--syntactic-context-from-pstate open-items) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1179 for class-style in filtered-class-styles |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1180 if (and (memq syntactic-context |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1181 (plist-get class-style :contexts)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1182 (looking-at (plist-get class-style |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1183 :class-decl))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1184 do (goto-char (match-end 0)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1185 and return |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1186 (make-js--pitem |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1187 :paren-depth orig-depth |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1188 :h-begin orig-match-start |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1189 :type class-style |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1190 :name (js--split-name |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1191 (match-string-no-properties 1)))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1192 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1193 do (js--ensure-cache--update-parse) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1194 and do (push it open-items) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1195 and do (put-text-property |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1196 (1- (point)) (point) 'js--pstate open-items) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1197 else do (goto-char orig-match-end)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1198 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1199 (goto-char limit) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1200 (js--ensure-cache--update-parse) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1201 (setq js--cache-end limit) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1202 (setq js--last-parse-pos limit) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1203 (setq js--state-at-last-parse-pos open-items) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1204 ))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1205 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1206 (defun js--end-of-defun-flat () |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1207 "Helper function for `js-end-of-defun'." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1208 (loop while (js--re-search-forward "}" nil t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1209 do (js--ensure-cache) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1210 if (get-text-property (1- (point)) 'js--pend) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1211 if (eq 'function (js--pitem-type it)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1212 return t |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1213 finally do (goto-char (point-max)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1214 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1215 (defun js--end-of-defun-nested () |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1216 "Helper function for `js-end-of-defun'." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1217 (message "test") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1218 (let* (pitem |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1219 (this-end (save-excursion |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1220 (and (setq pitem (js--beginning-of-defun-nested)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1221 (js--pitem-goto-h-end pitem) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1222 (progn (backward-char) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1223 (forward-list) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1224 (point))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1225 found) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1226 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1227 (if (and this-end (< (point) this-end)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1228 ;; We're already inside a function; just go to its end. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1229 (goto-char this-end) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1230 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1231 ;; Otherwise, go to the end of the next function... |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1232 (while (and (js--re-search-forward "\\_<function\\_>" nil t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1233 (not (setq found (progn |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1234 (goto-char (match-beginning 0)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1235 (js--forward-function-decl)))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1236 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1237 (if found (forward-list) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1238 ;; ... or eob. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1239 (goto-char (point-max)))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1240 |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1241 (defun js-end-of-defun (&optional arg) |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1242 "Value of `end-of-defun-function' for `js-mode'." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1243 (setq arg (or arg 1)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1244 (while (and (not (bobp)) (< arg 0)) |
105076
8a45209e673f
(js-end-of-defun): Remove malformed and unneeded let.
Glenn Morris <rgm@gnu.org>
parents:
104966
diff
changeset
|
1245 (incf arg) |
8a45209e673f
(js-end-of-defun): Remove malformed and unneeded let.
Glenn Morris <rgm@gnu.org>
parents:
104966
diff
changeset
|
1246 (js-beginning-of-defun) |
8a45209e673f
(js-end-of-defun): Remove malformed and unneeded let.
Glenn Morris <rgm@gnu.org>
parents:
104966
diff
changeset
|
1247 (js-beginning-of-defun) |
8a45209e673f
(js-end-of-defun): Remove malformed and unneeded let.
Glenn Morris <rgm@gnu.org>
parents:
104966
diff
changeset
|
1248 (unless (bobp) |
8a45209e673f
(js-end-of-defun): Remove malformed and unneeded let.
Glenn Morris <rgm@gnu.org>
parents:
104966
diff
changeset
|
1249 (js-end-of-defun))) |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1250 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1251 (while (> arg 0) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1252 (decf arg) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1253 ;; look for function backward. if we're inside it, go to that |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1254 ;; function's end. otherwise, search for the next function's end and |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1255 ;; go there |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1256 (if js-flat-functions |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1257 (js--end-of-defun-flat) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1258 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1259 ;; if we're doing nested functions, see whether we're in the |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1260 ;; prologue. If we are, go to the end of the function; otherwise, |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1261 ;; call js--end-of-defun-nested to do the real work |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1262 (let ((prologue-begin (js--function-prologue-beginning))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1263 (cond ((and prologue-begin (<= prologue-begin (point))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1264 (goto-char prologue-begin) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1265 (re-search-forward "\\_<function") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1266 (goto-char (match-beginning 0)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1267 (js--forward-function-decl) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1268 (forward-list)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1269 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1270 (t (js--end-of-defun-nested))))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1271 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1272 (defun js--beginning-of-macro (&optional lim) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1273 (let ((here (point))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1274 (save-restriction |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1275 (if lim (narrow-to-region lim (point-max))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1276 (beginning-of-line) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1277 (while (eq (char-before (1- (point))) ?\\) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1278 (forward-line -1)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1279 (back-to-indentation) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1280 (if (and (<= (point) here) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1281 (looking-at js--opt-cpp-start)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1282 t |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1283 (goto-char here) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1284 nil)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1285 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1286 (defun js--backward-syntactic-ws (&optional lim) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1287 "Simple implementation of `c-backward-syntactic-ws' for `js-mode'." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1288 (save-restriction |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1289 (when lim (narrow-to-region lim (point-max))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1290 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1291 (let ((in-macro (save-excursion (js--beginning-of-macro))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1292 (pos (point))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1293 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1294 (while (progn (unless in-macro (js--beginning-of-macro)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1295 (forward-comment most-negative-fixnum) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1296 (/= (point) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1297 (prog1 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1298 pos |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1299 (setq pos (point))))))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1300 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1301 (defun js--forward-syntactic-ws (&optional lim) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1302 "Simple implementation of `c-forward-syntactic-ws' for `js-mode'." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1303 (save-restriction |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1304 (when lim (narrow-to-region (point-min) lim)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1305 (let ((pos (point))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1306 (while (progn |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1307 (forward-comment most-positive-fixnum) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1308 (when (eq (char-after) ?#) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1309 (c-end-of-macro)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1310 (/= (point) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1311 (prog1 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1312 pos |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1313 (setq pos (point))))))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1314 |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1315 ;; Like (up-list -1), but only considers lists that end nearby" |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1316 (defun js--up-nearby-list () |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1317 (save-restriction |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1318 ;; Look at a very small region so our compuation time doesn't |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1319 ;; explode in pathological cases. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1320 (narrow-to-region (max (point-min) (- (point) 500)) (point)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1321 (up-list -1))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1322 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1323 (defun js--inside-param-list-p () |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1324 "Return non-nil iff point is in a function parameter list." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1325 (ignore-errors |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1326 (save-excursion |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1327 (js--up-nearby-list) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1328 (and (looking-at "(") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1329 (progn (forward-symbol -1) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1330 (or (looking-at "function") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1331 (progn (forward-symbol -1) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1332 (looking-at "function")))))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1333 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1334 (defun js--inside-dojo-class-list-p () |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1335 "Return non-nil iff point is in a Dojo multiple-inheritance class block." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1336 (ignore-errors |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1337 (save-excursion |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1338 (js--up-nearby-list) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1339 (let ((list-begin (point))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1340 (forward-line 0) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1341 (and (looking-at js--dojo-class-decl-re) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1342 (goto-char (match-end 0)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1343 (looking-at "\"\\s-*,\\s-*\\[") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1344 (eq (match-end 0) (1+ list-begin))))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1345 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1346 (defun js--syntax-begin-function () |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1347 (when (< js--cache-end (point)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1348 (goto-char (max (point-min) js--cache-end))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1349 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1350 (let ((pitem)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1351 (while (and (setq pitem (car (js--backward-pstate))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1352 (not (eq 0 (js--pitem-paren-depth pitem))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1353 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1354 (when pitem |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1355 (goto-char (js--pitem-h-begin pitem ))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1356 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1357 ;;; Font Lock |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1358 (defun js--make-framework-matcher (framework &rest regexps) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1359 "Helper function for building `js--font-lock-keywords'. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1360 Create a byte-compiled function for matching a concatenation of |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1361 REGEXPS, but only if FRAMEWORK is in `js-enabled-frameworks'." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1362 (setq regexps (apply #'concat regexps)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1363 (byte-compile |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1364 `(lambda (limit) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1365 (when (memq (quote ,framework) js-enabled-frameworks) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1366 (re-search-forward ,regexps limit t))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1367 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1368 (defvar js--tmp-location nil) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1369 (make-variable-buffer-local 'js--tmp-location) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1370 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1371 (defun js--forward-destructuring-spec (&optional func) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1372 "Move forward over a JavaScript destructuring spec. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1373 If FUNC is supplied, call it with no arguments before every |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1374 variable name in the spec. Return true iff this was actually a |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1375 spec. FUNC must preserve the match data." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1376 (case (char-after) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1377 (?\[ |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1378 (forward-char) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1379 (while |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1380 (progn |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1381 (forward-comment most-positive-fixnum) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1382 (cond ((memq (char-after) '(?\[ ?\{)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1383 (js--forward-destructuring-spec func)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1384 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1385 ((eq (char-after) ?,) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1386 (forward-char) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1387 t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1388 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1389 ((looking-at js--name-re) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1390 (and func (funcall func)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1391 (goto-char (match-end 0)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1392 t)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1393 (when (eq (char-after) ?\]) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1394 (forward-char) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1395 t)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1396 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1397 (?\{ |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1398 (forward-char) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1399 (forward-comment most-positive-fixnum) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1400 (while |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1401 (when (looking-at js--objfield-re) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1402 (goto-char (match-end 0)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1403 (forward-comment most-positive-fixnum) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1404 (and (cond ((memq (char-after) '(?\[ ?\{)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1405 (js--forward-destructuring-spec func)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1406 ((looking-at js--name-re) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1407 (and func (funcall func)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1408 (goto-char (match-end 0)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1409 t)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1410 (progn (forward-comment most-positive-fixnum) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1411 (when (eq (char-after) ?\,) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1412 (forward-char) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1413 (forward-comment most-positive-fixnum) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1414 t))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1415 (when (eq (char-after) ?\}) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1416 (forward-char) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1417 t)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1418 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1419 (defun js--variable-decl-matcher (limit) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1420 "Font-lock matcher for variable names in a variable declaration. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1421 This is a cc-mode-style matcher that *always* fails, from the |
104683
2b8eeeaa8c1d
* international/ucs-normalize.el (ucs-normalize-sort, quick-check-list):
Juanma Barranquero <lekktu@gmail.com>
parents:
104391
diff
changeset
|
1422 point of view of font-lock. It applies highlighting directly with |
2b8eeeaa8c1d
* international/ucs-normalize.el (ucs-normalize-sort, quick-check-list):
Juanma Barranquero <lekktu@gmail.com>
parents:
104391
diff
changeset
|
1423 `font-lock-apply-highlight'." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1424 (condition-case nil |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1425 (save-restriction |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1426 (narrow-to-region (point-min) limit) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1427 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1428 (let ((first t)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1429 (forward-comment most-positive-fixnum) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1430 (while |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1431 (and (or first |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1432 (when (eq (char-after) ?,) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1433 (forward-char) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1434 (forward-comment most-positive-fixnum) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1435 t)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1436 (cond ((looking-at js--name-re) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1437 (font-lock-apply-highlight |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1438 '(0 font-lock-variable-name-face)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1439 (goto-char (match-end 0))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1440 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1441 ((save-excursion |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1442 (js--forward-destructuring-spec)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1443 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1444 (js--forward-destructuring-spec |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1445 (lambda () |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1446 (font-lock-apply-highlight |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1447 '(0 font-lock-variable-name-face))))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1448 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1449 (forward-comment most-positive-fixnum) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1450 (when (eq (char-after) ?=) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1451 (forward-char) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1452 (js--forward-expression) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1453 (forward-comment most-positive-fixnum)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1454 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1455 (setq first nil)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1456 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1457 ;; Conditions to handle |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1458 (scan-error nil) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1459 (end-of-buffer nil)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1460 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1461 ;; Matcher always "fails" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1462 nil) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1463 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1464 (defconst js--font-lock-keywords-3 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1465 `( |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1466 ;; This goes before keywords-2 so it gets used preferentially |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1467 ;; instead of the keywords in keywords-2. Don't use override |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1468 ;; because that will override syntactic fontification too, which |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1469 ;; will fontify commented-out directives as if they weren't |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1470 ;; commented out. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1471 ,@cpp-font-lock-keywords ; from font-lock.el |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1472 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1473 ,@js--font-lock-keywords-2 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1474 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1475 ("\\.\\(prototype\\)\\_>" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1476 (1 font-lock-constant-face)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1477 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1478 ;; Highlights class being declared, in parts |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1479 (js--class-decl-matcher |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1480 ,(concat "\\(" js--name-re "\\)\\(?:\\.\\|.*$\\)") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1481 (goto-char (match-beginning 1)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1482 nil |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1483 (1 font-lock-type-face)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1484 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1485 ;; Highlights parent class, in parts, if available |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1486 (js--class-decl-matcher |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1487 ,(concat "\\(" js--name-re "\\)\\(?:\\.\\|.*$\\)") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1488 (if (match-beginning 2) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1489 (progn |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1490 (setq js--tmp-location (match-end 2)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1491 (goto-char js--tmp-location) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1492 (insert "=") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1493 (goto-char (match-beginning 2))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1494 (setq js--tmp-location nil) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1495 (goto-char (point-at-eol))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1496 (when js--tmp-location |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1497 (save-excursion |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1498 (goto-char js--tmp-location) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1499 (delete-char 1))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1500 (1 font-lock-type-face)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1501 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1502 ;; Highlights parent class |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1503 (js--class-decl-matcher |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1504 (2 font-lock-type-face nil t)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1505 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1506 ;; Dojo needs its own matcher to override the string highlighting |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1507 (,(js--make-framework-matcher |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1508 'dojo |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1509 "^\\s-*dojo\\.declare\\s-*(\"" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1510 "\\(" js--dotted-name-re "\\)" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1511 "\\(?:\"\\s-*,\\s-*\\(" js--dotted-name-re "\\)\\)?") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1512 (1 font-lock-type-face t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1513 (2 font-lock-type-face nil t)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1514 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1515 ;; Match Dojo base classes. Of course Mojo has to be different |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1516 ;; from everything else under the sun... |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1517 (,(js--make-framework-matcher |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1518 'dojo |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1519 "^\\s-*dojo\\.declare\\s-*(\"" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1520 "\\(" js--dotted-name-re "\\)\"\\s-*,\\s-*\\[") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1521 ,(concat "[[,]\\s-*\\(" js--dotted-name-re "\\)\\s-*" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1522 "\\(?:\\].*$\\)?") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1523 (backward-char) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1524 (end-of-line) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1525 (1 font-lock-type-face)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1526 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1527 ;; continued Dojo base-class list |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1528 (,(js--make-framework-matcher |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1529 'dojo |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1530 "^\\s-*" js--dotted-name-re "\\s-*[],]") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1531 ,(concat "\\(" js--dotted-name-re "\\)" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1532 "\\s-*\\(?:\\].*$\\)?") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1533 (if (save-excursion (backward-char) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1534 (js--inside-dojo-class-list-p)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1535 (forward-symbol -1) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1536 (end-of-line)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1537 (end-of-line) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1538 (1 font-lock-type-face)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1539 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1540 ;; variable declarations |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1541 ,(list |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1542 (concat "\\_<\\(const\\|var\\|let\\)\\_>\\|" js--basic-type-re) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1543 (list #'js--variable-decl-matcher nil nil nil)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1544 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1545 ;; class instantiation |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1546 ,(list |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1547 (concat "\\_<new\\_>\\s-+\\(" js--dotted-name-re "\\)") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1548 (list 1 'font-lock-type-face)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1549 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1550 ;; instanceof |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1551 ,(list |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1552 (concat "\\_<instanceof\\_>\\s-+\\(" js--dotted-name-re "\\)") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1553 (list 1 'font-lock-type-face)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1554 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1555 ;; formal parameters |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1556 ,(list |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1557 (concat |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1558 "\\_<function\\_>\\(\\s-+" js--name-re "\\)?\\s-*(\\s-*" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1559 js--name-start-re) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1560 (list (concat "\\(" js--name-re "\\)\\(\\s-*).*\\)?") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1561 '(backward-char) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1562 '(end-of-line) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1563 '(1 font-lock-variable-name-face))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1564 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1565 ;; continued formal parameter list |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1566 ,(list |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1567 (concat |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1568 "^\\s-*" js--name-re "\\s-*[,)]") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1569 (list js--name-re |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1570 '(if (save-excursion (backward-char) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1571 (js--inside-param-list-p)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1572 (forward-symbol -1) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1573 (end-of-line)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1574 '(end-of-line) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1575 '(0 font-lock-variable-name-face)))) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1576 "Level three font lock for `js-mode'.") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1577 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1578 (defun js--inside-pitem-p (pitem) |
104683
2b8eeeaa8c1d
* international/ucs-normalize.el (ucs-normalize-sort, quick-check-list):
Juanma Barranquero <lekktu@gmail.com>
parents:
104391
diff
changeset
|
1579 "Return whether point is inside the given pitem's header or body." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1580 (js--ensure-cache) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1581 (assert (js--pitem-h-begin pitem)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1582 (assert (js--pitem-paren-depth pitem)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1583 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1584 (and (> (point) (js--pitem-h-begin pitem)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1585 (or (null (js--pitem-b-end pitem)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1586 (> (js--pitem-b-end pitem) (point))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1587 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1588 (defun js--parse-state-at-point () |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1589 "Parse the JavaScript program state at point. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1590 Return a list of `js--pitem' instances that apply to point, most |
104683
2b8eeeaa8c1d
* international/ucs-normalize.el (ucs-normalize-sort, quick-check-list):
Juanma Barranquero <lekktu@gmail.com>
parents:
104391
diff
changeset
|
1591 specific first. In the worst case, the current toplevel instance |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1592 will be returned." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1593 (save-excursion |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1594 (save-restriction |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1595 (widen) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1596 (js--ensure-cache) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1597 (let* ((bound (if (eobp) (point) (1+ (point)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1598 (pstate (or (save-excursion |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1599 (js--backward-pstate)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1600 (list js--initial-pitem)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1601 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1602 ;; Loop until we either hit a pitem at BOB or pitem ends after |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1603 ;; point (or at point if we're at eob) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1604 (loop for pitem = (car pstate) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1605 until (or (eq (js--pitem-type pitem) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1606 'toplevel) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1607 (js--inside-pitem-p pitem)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1608 do (pop pstate)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1609 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1610 pstate)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1611 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1612 (defun js--syntactic-context-from-pstate (pstate) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1613 "Return the JavaScript syntactic context corresponding to PSTATE." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1614 (let ((type (js--pitem-type (car pstate)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1615 (cond ((memq type '(function macro)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1616 type) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1617 ((consp type) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1618 'class) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1619 (t 'toplevel)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1620 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1621 (defun js-syntactic-context () |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1622 "Return the JavaScript syntactic context at point. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1623 When called interatively, also display a message with that |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1624 context." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1625 (interactive) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1626 (let* ((syntactic-context (js--syntactic-context-from-pstate |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1627 (js--parse-state-at-point)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1628 |
105372
bd2966850aac
Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents:
105076
diff
changeset
|
1629 (when (called-interactively-p 'interactive) |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1630 (message "Syntactic context: %s" syntactic-context)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1631 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1632 syntactic-context)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1633 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1634 (defun js--class-decl-matcher (limit) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1635 "Font lock function used by `js-mode'. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1636 This performs fontification according to `js--class-styles'." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1637 (loop initially (js--ensure-cache limit) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1638 while (re-search-forward js--quick-match-re limit t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1639 for orig-end = (match-end 0) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1640 do (goto-char (match-beginning 0)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1641 if (loop for style in js--class-styles |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1642 for decl-re = (plist-get style :class-decl) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1643 if (and (memq (plist-get style :framework) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1644 js-enabled-frameworks) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1645 (memq (js-syntactic-context) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1646 (plist-get style :contexts)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1647 decl-re |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1648 (looking-at decl-re)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1649 do (goto-char (match-end 0)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1650 and return t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1651 return t |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1652 else do (goto-char orig-end))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1653 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1654 (defconst js--font-lock-keywords |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1655 '(js--font-lock-keywords-3 js--font-lock-keywords-1 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1656 js--font-lock-keywords-2 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1657 js--font-lock-keywords-3) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1658 "Font lock keywords for `js-mode'. See `font-lock-keywords'.") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1659 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1660 ;; XXX: Javascript can continue a regexp literal across lines so long |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1661 ;; as the newline is escaped with \. Account for that in the regexp |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1662 ;; below. |
110305
b10051866f51
New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110270
diff
changeset
|
1663 (eval-and-compile |
b10051866f51
New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110270
diff
changeset
|
1664 (defconst js--regexp-literal |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1665 "[=(,:]\\(?:\\s-\\|\n\\)*\\(/\\)\\(?:\\\\/\\|[^/*]\\)\\(?:\\\\/\\|[^/]\\)*\\(/\\)" |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1666 "Regexp matching a JavaScript regular expression literal. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1667 Match groups 1 and 2 are the characters forming the beginning and |
110305
b10051866f51
New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110270
diff
changeset
|
1668 end of the literal.")) |
b10051866f51
New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110270
diff
changeset
|
1669 |
b10051866f51
New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110270
diff
changeset
|
1670 |
b10051866f51
New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110270
diff
changeset
|
1671 (defconst js-syntax-propertize-function |
b10051866f51
New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110270
diff
changeset
|
1672 (syntax-propertize-rules |
b10051866f51
New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110270
diff
changeset
|
1673 ;; We want to match regular expressions only at the beginning of |
b10051866f51
New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110270
diff
changeset
|
1674 ;; expressions. |
b10051866f51
New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110270
diff
changeset
|
1675 (js--regexp-literal (1 "\"") (2 "\"")))) |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1676 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1677 ;;; Indentation |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1678 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1679 (defconst js--possibly-braceless-keyword-re |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1680 (js--regexp-opt-symbol |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1681 '("catch" "do" "else" "finally" "for" "if" "try" "while" "with" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1682 "each")) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1683 "Regexp matching keywords optionally followed by an opening brace.") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1684 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1685 (defconst js--indent-operator-re |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1686 (concat "[-+*/%<>=&^|?:.]\\([^-+*/]\\|$\\)\\|" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1687 (js--regexp-opt-symbol '("in" "instanceof"))) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1688 "Regexp matching operators that affect indentation of continued expressions.") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1689 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1690 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1691 (defun js--looking-at-operator-p () |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1692 "Return non-nil if point is on a JavaScript operator, other than a comma." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1693 (save-match-data |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1694 (and (looking-at js--indent-operator-re) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1695 (or (not (looking-at ":")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1696 (save-excursion |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1697 (and (js--re-search-backward "[?:{]\\|\\_<case\\_>" nil t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1698 (looking-at "?"))))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1699 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1700 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1701 (defun js--continued-expression-p () |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1702 "Return non-nil if the current line continues an expression." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1703 (save-excursion |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1704 (back-to-indentation) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1705 (or (js--looking-at-operator-p) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1706 (and (js--re-search-backward "\n" nil t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1707 (progn |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1708 (skip-chars-backward " \t") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1709 (or (bobp) (backward-char)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1710 (and (> (point) (point-min)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1711 (save-excursion (backward-char) (not (looking-at "[/*]/"))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1712 (js--looking-at-operator-p) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1713 (and (progn (backward-char) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1714 (not (looking-at "++\\|--\\|/[/*]")))))))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1715 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1716 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1717 (defun js--end-of-do-while-loop-p () |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1718 "Return non-nil if point is on the \"while\" of a do-while statement. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1719 Otherwise, return nil. A braceless do-while statement spanning |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1720 several lines requires that the start of the loop is indented to |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1721 the same column as the current line." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1722 (interactive) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1723 (save-excursion |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1724 (save-match-data |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1725 (when (looking-at "\\s-*\\_<while\\_>") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1726 (if (save-excursion |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1727 (skip-chars-backward "[ \t\n]*}") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1728 (looking-at "[ \t\n]*}")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1729 (save-excursion |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1730 (backward-list) (forward-symbol -1) (looking-at "\\_<do\\_>")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1731 (js--re-search-backward "\\_<do\\_>" (point-at-bol) t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1732 (or (looking-at "\\_<do\\_>") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1733 (let ((saved-indent (current-indentation))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1734 (while (and (js--re-search-backward "^\\s-*\\_<" nil t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1735 (/= (current-indentation) saved-indent))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1736 (and (looking-at "\\s-*\\_<do\\_>") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1737 (not (js--re-search-forward |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1738 "\\_<while\\_>" (point-at-eol) t)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1739 (= (current-indentation) saved-indent))))))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1740 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1741 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1742 (defun js--ctrl-statement-indentation () |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1743 "Helper function for `js--proper-indentation'. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1744 Return the proper indentation of the current line if it starts |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1745 the body of a control statement without braces; otherwise, return |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1746 nil." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1747 (save-excursion |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1748 (back-to-indentation) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1749 (when (save-excursion |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1750 (and (not (eq (point-at-bol) (point-min))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1751 (not (looking-at "[{]")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1752 (progn |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1753 (js--re-search-backward "[[:graph:]]" nil t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1754 (or (eobp) (forward-char)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1755 (when (= (char-before) ?\)) (backward-list)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1756 (skip-syntax-backward " ") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1757 (skip-syntax-backward "w_") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1758 (looking-at js--possibly-braceless-keyword-re)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1759 (not (js--end-of-do-while-loop-p)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1760 (save-excursion |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1761 (goto-char (match-beginning 0)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1762 (+ (current-indentation) js-indent-level))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1763 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1764 (defun js--get-c-offset (symbol anchor) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1765 (let ((c-offsets-alist |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1766 (list (cons 'c js-comment-lineup-func)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1767 (c-get-syntactic-indentation (list (cons symbol anchor))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1768 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1769 (defun js--proper-indentation (parse-status) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1770 "Return the proper indentation for the current line." |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1771 (save-excursion |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1772 (back-to-indentation) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1773 (cond ((nth 4 parse-status) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1774 (js--get-c-offset 'c (nth 8 parse-status))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1775 ((nth 8 parse-status) 0) ; inside string |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1776 ((js--ctrl-statement-indentation)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1777 ((eq (char-after) ?#) 0) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1778 ((save-excursion (js--beginning-of-macro)) 4) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1779 ((nth 1 parse-status) |
109997
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
1780 ;; A single closing paren/bracket should be indented at the |
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
1781 ;; same level as the opening statement. Same goes for |
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
1782 ;; "case" and "default". |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1783 (let ((same-indent-p (looking-at |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1784 "[]})]\\|\\_<case\\_>\\|\\_<default\\_>")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1785 (continued-expr-p (js--continued-expression-p))) |
109997
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
1786 (goto-char (nth 1 parse-status)) ; go to the opening char |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1787 (if (looking-at "[({[]\\s-*\\(/[/*]\\|$\\)") |
109997
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
1788 (progn ; nothing following the opening paren/bracket |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1789 (skip-syntax-backward " ") |
109997
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
1790 (when (eq (char-before) ?\)) (backward-list)) |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1791 (back-to-indentation) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1792 (cond (same-indent-p |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1793 (current-column)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1794 (continued-expr-p |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1795 (+ (current-column) (* 2 js-indent-level) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1796 js-expr-indent-offset)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1797 (t |
109997
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
1798 (+ (current-column) js-indent-level |
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
1799 (case (char-after (nth 1 parse-status)) |
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
1800 (?\( js-paren-indent-offset) |
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
1801 (?\[ js-square-indent-offset) |
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
1802 (?\{ js-curly-indent-offset)))))) |
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
1803 ;; If there is something following the opening |
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
1804 ;; paren/bracket, everything else should be indented at |
f583ffa8d0d6
* progmodes/js.el: Make indentation more customizable (Bug#6914).
Chong Yidong <cyd@stupidchicken.com>
parents:
109561
diff
changeset
|
1805 ;; the same level. |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1806 (unless same-indent-p |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1807 (forward-char) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1808 (skip-chars-forward " \t")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1809 (current-column)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1810 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1811 ((js--continued-expression-p) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1812 (+ js-indent-level js-expr-indent-offset)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1813 (t 0)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1814 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1815 (defun js-indent-line () |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1816 "Indent the current line as JavaScript." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1817 (interactive) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1818 (save-restriction |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1819 (widen) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1820 (let* ((parse-status |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1821 (save-excursion (syntax-ppss (point-at-bol)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1822 (offset (- (current-column) (current-indentation)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1823 (indent-line-to (js--proper-indentation parse-status)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1824 (when (> offset 0) (forward-char offset))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1825 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1826 ;;; Filling |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1827 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1828 (defun js-c-fill-paragraph (&optional justify) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1829 "Fill the paragraph with `c-fill-paragraph'." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1830 (interactive "*P") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1831 (flet ((c-forward-sws |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1832 (&optional limit) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1833 (js--forward-syntactic-ws limit)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1834 (c-backward-sws |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1835 (&optional limit) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1836 (js--backward-syntactic-ws limit)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1837 (c-beginning-of-macro |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1838 (&optional limit) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1839 (js--beginning-of-macro limit))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1840 (let ((fill-paragraph-function 'c-fill-paragraph)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1841 (c-fill-paragraph justify)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1842 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1843 ;;; Type database and Imenu |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1844 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1845 ;; We maintain a cache of semantic information, i.e., the classes and |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1846 ;; functions we've encountered so far. In order to avoid having to |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1847 ;; re-parse the buffer on every change, we cache the parse state at |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1848 ;; each interesting point in the buffer. Each parse state is a |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1849 ;; modified copy of the previous one, or in the case of the first |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1850 ;; parse state, the empty state. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1851 ;; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1852 ;; The parse state itself is just a stack of js--pitem |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1853 ;; instances. It starts off containing one element that is never |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1854 ;; closed, that is initially js--initial-pitem. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1855 ;; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1856 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1857 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1858 (defun js--pitem-format (pitem) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1859 (let ((name (js--pitem-name pitem)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1860 (type (js--pitem-type pitem))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1861 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1862 (format "name:%S type:%S" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1863 name |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1864 (if (atom type) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1865 type |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1866 (plist-get type :name))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1867 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1868 (defun js--make-merged-item (item child name-parts) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1869 "Helper function for `js--splice-into-items'. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1870 Return a new item that is the result of merging CHILD into |
104683
2b8eeeaa8c1d
* international/ucs-normalize.el (ucs-normalize-sort, quick-check-list):
Juanma Barranquero <lekktu@gmail.com>
parents:
104391
diff
changeset
|
1871 ITEM. NAME-PARTS is a list of parts of the name of CHILD |
2b8eeeaa8c1d
* international/ucs-normalize.el (ucs-normalize-sort, quick-check-list):
Juanma Barranquero <lekktu@gmail.com>
parents:
104391
diff
changeset
|
1872 that we haven't consumed yet." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1873 (js--debug "js--make-merged-item: {%s} into {%s}" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1874 (js--pitem-format child) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1875 (js--pitem-format item)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1876 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1877 ;; If the item we're merging into isn't a class, make it into one |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1878 (unless (consp (js--pitem-type item)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1879 (js--debug "js--make-merged-item: changing dest into class") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1880 (setq item (make-js--pitem |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1881 :children (list item) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1882 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1883 ;; Use the child's class-style if it's available |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1884 :type (if (atom (js--pitem-type child)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1885 js--dummy-class-style |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1886 (js--pitem-type child)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1887 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1888 :name (js--pitem-strname item)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1889 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1890 ;; Now we can merge either a function or a class into a class |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1891 (cons (cond |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1892 ((cdr name-parts) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1893 (js--debug "js--make-merged-item: recursing") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1894 ;; if we have more name-parts to go before we get to the |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1895 ;; bottom of the class hierarchy, call the merger |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1896 ;; recursively |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1897 (js--splice-into-items (car item) child |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1898 (cdr name-parts))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1899 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1900 ((atom (js--pitem-type child)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1901 (js--debug "js--make-merged-item: straight merge") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1902 ;; Not merging a class, but something else, so just prepend |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1903 ;; it |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1904 (cons child (car item))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1905 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1906 (t |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1907 ;; Otherwise, merge the new child's items into those |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1908 ;; of the new class |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1909 (js--debug "js--make-merged-item: merging class contents") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1910 (append (car child) (car item)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1911 (cdr item))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1912 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1913 (defun js--pitem-strname (pitem) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1914 "Last part of the name of PITEM, as a string or symbol." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1915 (let ((name (js--pitem-name pitem))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1916 (if (consp name) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1917 (car (last name)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1918 name))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1919 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1920 (defun js--splice-into-items (items child name-parts) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1921 "Splice CHILD into the `js--pitem' ITEMS at NAME-PARTS. |
104683
2b8eeeaa8c1d
* international/ucs-normalize.el (ucs-normalize-sort, quick-check-list):
Juanma Barranquero <lekktu@gmail.com>
parents:
104391
diff
changeset
|
1922 If a class doesn't exist in the tree, create it. Return |
2b8eeeaa8c1d
* international/ucs-normalize.el (ucs-normalize-sort, quick-check-list):
Juanma Barranquero <lekktu@gmail.com>
parents:
104391
diff
changeset
|
1923 the new items list. NAME-PARTS is a list of strings given |
2b8eeeaa8c1d
* international/ucs-normalize.el (ucs-normalize-sort, quick-check-list):
Juanma Barranquero <lekktu@gmail.com>
parents:
104391
diff
changeset
|
1924 the broken-down class name of the item to insert." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1925 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1926 (let ((top-name (car name-parts)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1927 (item-ptr items) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1928 new-items last-new-item new-cons item) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1929 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1930 (js--debug "js--splice-into-items: name-parts: %S items:%S" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1931 name-parts |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1932 (mapcar #'js--pitem-name items)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1933 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1934 (assert (stringp top-name)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1935 (assert (> (length top-name) 0)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1936 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1937 ;; If top-name isn't found in items, then we build a copy of items |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1938 ;; and throw it away. But that's okay, since most of the time, we |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1939 ;; *will* find an instance. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1940 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1941 (while (and item-ptr |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1942 (cond ((equal (js--pitem-strname (car item-ptr)) top-name) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1943 ;; Okay, we found an entry with the right name. Splice |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1944 ;; the merged item into the list... |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1945 (setq new-cons (cons (js--make-merged-item |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1946 (car item-ptr) child |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1947 name-parts) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1948 (cdr item-ptr))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1949 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1950 (if last-new-item |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1951 (setcdr last-new-item new-cons) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1952 (setq new-items new-cons)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1953 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1954 ;; ...and terminate the loop |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1955 nil) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1956 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1957 (t |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1958 ;; Otherwise, copy the current cons and move onto the |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1959 ;; text. This is tricky; we keep track of the tail of |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1960 ;; the list that begins with new-items in |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1961 ;; last-new-item. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1962 (setq new-cons (cons (car item-ptr) nil)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1963 (if last-new-item |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1964 (setcdr last-new-item new-cons) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1965 (setq new-items new-cons)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1966 (setq last-new-item new-cons) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1967 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1968 ;; Go to the next cell in items |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1969 (setq item-ptr (cdr item-ptr)))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1970 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1971 (if item-ptr |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1972 ;; Yay! We stopped because we found something, not because |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1973 ;; we ran out of items to search. Just return the new |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1974 ;; list. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1975 (progn |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1976 (js--debug "search succeeded: %S" name-parts) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1977 new-items) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1978 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1979 ;; We didn't find anything. If the child is a class and we don't |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1980 ;; have any classes to drill down into, just push that class; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1981 ;; otherwise, make a fake class and carry on. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1982 (js--debug "search failed: %S" name-parts) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1983 (cons (if (cdr name-parts) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1984 ;; We have name-parts left to process. Make a fake |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1985 ;; class for this particular part... |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1986 (make-js--pitem |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1987 ;; ...and recursively digest the rest of the name |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1988 :children (js--splice-into-items |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1989 nil child (cdr name-parts)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1990 :type js--dummy-class-style |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1991 :name top-name) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1992 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1993 ;; Otherwise, this is the only name we have, so stick |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1994 ;; the item on the front of the list |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1995 child) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1996 items)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1997 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1998 (defun js--pitem-add-child (pitem child) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
1999 "Copy `js--pitem' PITEM, and push CHILD onto its list of children." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2000 (assert (integerp (js--pitem-h-begin child))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2001 (assert (if (consp (js--pitem-name child)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2002 (loop for part in (js--pitem-name child) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2003 always (stringp part)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2004 t)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2005 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2006 ;; This trick works because we know (based on our defstructs) that |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2007 ;; the child list is always the first element, and so the second |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2008 ;; element and beyond can be shared when we make our "copy". |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2009 (cons |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2010 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2011 (let ((name (js--pitem-name child)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2012 (type (js--pitem-type child))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2013 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2014 (cond ((cdr-safe name) ; true if a list of at least two elements |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2015 ;; Use slow path because we need class lookup |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2016 (js--splice-into-items (car pitem) child name)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2017 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2018 ((and (consp type) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2019 (plist-get type :prototype)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2020 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2021 ;; Use slow path because we need class merging. We know |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2022 ;; name is a list here because down in |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2023 ;; `js--ensure-cache', we made sure to only add |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2024 ;; class entries with lists for :name |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2025 (assert (consp name)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2026 (js--splice-into-items (car pitem) child name)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2027 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2028 (t |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2029 ;; Fast path |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2030 (cons child (car pitem))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2031 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2032 (cdr pitem))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2033 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2034 (defun js--maybe-make-marker (location) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2035 "Return a marker for LOCATION if `imenu-use-markers' is non-nil." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2036 (if imenu-use-markers |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2037 (set-marker (make-marker) location) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2038 location)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2039 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2040 (defun js--pitems-to-imenu (pitems unknown-ctr) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2041 "Convert PITEMS, a list of `js--pitem' structures, to imenu format." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2042 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2043 (let (imenu-items pitem pitem-type pitem-name subitems) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2044 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2045 (while (setq pitem (pop pitems)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2046 (setq pitem-type (js--pitem-type pitem)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2047 (setq pitem-name (js--pitem-strname pitem)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2048 (when (eq pitem-name t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2049 (setq pitem-name (format "[unknown %s]" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2050 (incf (car unknown-ctr))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2051 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2052 (cond |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2053 ((memq pitem-type '(function macro)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2054 (assert (integerp (js--pitem-h-begin pitem))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2055 (push (cons pitem-name |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2056 (js--maybe-make-marker |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2057 (js--pitem-h-begin pitem))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2058 imenu-items)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2059 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2060 ((consp pitem-type) ; class definition |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2061 (setq subitems (js--pitems-to-imenu |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2062 (js--pitem-children pitem) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2063 unknown-ctr)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2064 (cond (subitems |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2065 (push (cons pitem-name subitems) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2066 imenu-items)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2067 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2068 ((js--pitem-h-begin pitem) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2069 (assert (integerp (js--pitem-h-begin pitem))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2070 (setq subitems (list |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2071 (cons "[empty]" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2072 (js--maybe-make-marker |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2073 (js--pitem-h-begin pitem))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2074 (push (cons pitem-name subitems) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2075 imenu-items)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2076 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2077 (t (error "Unknown item type: %S" pitem-type)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2078 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2079 imenu-items)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2080 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2081 (defun js--imenu-create-index () |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2082 "Return an imenu index for the current buffer." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2083 (save-excursion |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2084 (save-restriction |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2085 (widen) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2086 (goto-char (point-max)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2087 (js--ensure-cache) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2088 (assert (or (= (point-min) (point-max)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2089 (eq js--last-parse-pos (point)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2090 (when js--last-parse-pos |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2091 (let ((state js--state-at-last-parse-pos) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2092 (unknown-ctr (cons -1 nil))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2093 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2094 ;; Make sure everything is closed |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2095 (while (cdr state) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2096 (setq state |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2097 (cons (js--pitem-add-child (second state) (car state)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2098 (cddr state)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2099 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2100 (assert (= (length state) 1)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2101 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2102 ;; Convert the new-finalized state into what imenu expects |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2103 (js--pitems-to-imenu |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2104 (car (js--pitem-children state)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2105 unknown-ctr)))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2106 |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2107 ;; Silence the compiler. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2108 (defvar which-func-imenu-joiner-function) |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2109 |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2110 (defun js--which-func-joiner (parts) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2111 (mapconcat #'identity parts ".")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2112 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2113 (defun js--imenu-to-flat (items prefix symbols) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2114 (loop for item in items |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2115 if (imenu--subalist-p item) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2116 do (js--imenu-to-flat |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2117 (cdr item) (concat prefix (car item) ".") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2118 symbols) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2119 else |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2120 do (let* ((name (concat prefix (car item))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2121 (name2 name) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2122 (ctr 0)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2123 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2124 (while (gethash name2 symbols) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2125 (setq name2 (format "%s<%d>" name (incf ctr)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2126 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2127 (puthash name2 (cdr item) symbols)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2128 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2129 (defun js--get-all-known-symbols () |
104683
2b8eeeaa8c1d
* international/ucs-normalize.el (ucs-normalize-sort, quick-check-list):
Juanma Barranquero <lekktu@gmail.com>
parents:
104391
diff
changeset
|
2130 "Return a hash table of all JavaScript symbols. |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2131 This searches all existing `js-mode' buffers. Each key is the |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2132 name of a symbol (possibly disambiguated with <N>, where N > 1), |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2133 and each value is a marker giving the location of that symbol." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2134 (loop with symbols = (make-hash-table :test 'equal) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2135 with imenu-use-markers = t |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2136 for buffer being the buffers |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2137 for imenu-index = (with-current-buffer buffer |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2138 (when (eq major-mode 'js-mode) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2139 (js--imenu-create-index))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2140 do (js--imenu-to-flat imenu-index "" symbols) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2141 finally return symbols)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2142 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2143 (defvar js--symbol-history nil |
104683
2b8eeeaa8c1d
* international/ucs-normalize.el (ucs-normalize-sort, quick-check-list):
Juanma Barranquero <lekktu@gmail.com>
parents:
104391
diff
changeset
|
2144 "History of entered JavaScript symbols.") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2145 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2146 (defun js--read-symbol (symbols-table prompt &optional initial-input) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2147 "Helper function for `js-find-symbol'. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2148 Read a symbol from SYMBOLS-TABLE, which is a hash table like the |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2149 one from `js--get-all-known-symbols', using prompt PROMPT and |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2150 initial input INITIAL-INPUT. Return a cons of (SYMBOL-NAME |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2151 . LOCATION), where SYMBOL-NAME is a string and LOCATION is a |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2152 marker." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2153 (unless ido-mode |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2154 (ido-mode t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2155 (ido-mode nil)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2156 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2157 (let ((choice (ido-completing-read |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2158 prompt |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2159 (loop for key being the hash-keys of symbols-table |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2160 collect key) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2161 nil t initial-input 'js--symbol-history))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2162 (cons choice (gethash choice symbols-table)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2163 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2164 (defun js--guess-symbol-at-point () |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2165 (let ((bounds (bounds-of-thing-at-point 'symbol))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2166 (when bounds |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2167 (save-excursion |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2168 (goto-char (car bounds)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2169 (when (eq (char-before) ?.) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2170 (backward-char) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2171 (setf (car bounds) (point)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2172 (buffer-substring (car bounds) (cdr bounds))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2173 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2174 (defun js-find-symbol (&optional arg) |
104683
2b8eeeaa8c1d
* international/ucs-normalize.el (ucs-normalize-sort, quick-check-list):
Juanma Barranquero <lekktu@gmail.com>
parents:
104391
diff
changeset
|
2175 "Read a JavaScript symbol and jump to it. |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2176 With a prefix argument, restrict symbols to those from the |
104683
2b8eeeaa8c1d
* international/ucs-normalize.el (ucs-normalize-sort, quick-check-list):
Juanma Barranquero <lekktu@gmail.com>
parents:
104391
diff
changeset
|
2177 current buffer. Pushes a mark onto the tag ring just like |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2178 `find-tag'." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2179 (interactive "P") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2180 (let (symbols marker) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2181 (if (not arg) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2182 (setq symbols (js--get-all-known-symbols)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2183 (setq symbols (make-hash-table :test 'equal)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2184 (js--imenu-to-flat (js--imenu-create-index) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2185 "" symbols)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2186 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2187 (setq marker (cdr (js--read-symbol |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2188 symbols "Jump to: " |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2189 (js--guess-symbol-at-point)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2190 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2191 (ring-insert find-tag-marker-ring (point-marker)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2192 (switch-to-buffer (marker-buffer marker)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2193 (push-mark) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2194 (goto-char marker))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2195 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2196 ;;; MozRepl integration |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2197 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2198 (put 'js-moz-bad-rpc 'error-conditions '(error timeout)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2199 (put 'js-moz-bad-rpc 'error-message "Mozilla RPC Error") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2200 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2201 (put 'js-js-error 'error-conditions '(error js-error)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2202 (put 'js-js-error 'error-message "Javascript Error") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2203 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2204 (defun js--wait-for-matching-output |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2205 (process regexp timeout &optional start) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2206 "Wait TIMEOUT seconds for PROCESS to output a match for REGEXP. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2207 On timeout, return nil. On success, return t with match data |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2208 set. If START is non-nil, look for output starting from START. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2209 Otherwise, use the current value of `process-mark'." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2210 (with-current-buffer (process-buffer process) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2211 (loop with start-pos = (or start |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2212 (marker-position (process-mark process))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2213 with end-time = (+ (float-time) timeout) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2214 for time-left = (- end-time (float-time)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2215 do (goto-char (point-max)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2216 if (looking-back regexp start-pos) return t |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2217 while (> time-left 0) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2218 do (accept-process-output process time-left nil t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2219 do (goto-char (process-mark process)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2220 finally do (signal |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2221 'js-moz-bad-rpc |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2222 (list (format "Timed out waiting for output matching %S" regexp)))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2223 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2224 (defstruct js--js-handle |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2225 ;; Integer, mirrors the value we see in JS |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2226 (id nil :read-only t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2227 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2228 ;; Process to which this thing belongs |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2229 (process nil :read-only t)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2230 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2231 (defun js--js-handle-expired-p (x) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2232 (not (eq (js--js-handle-process x) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2233 (inferior-moz-process)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2234 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2235 (defvar js--js-references nil |
104683
2b8eeeaa8c1d
* international/ucs-normalize.el (ucs-normalize-sort, quick-check-list):
Juanma Barranquero <lekktu@gmail.com>
parents:
104391
diff
changeset
|
2236 "Maps Elisp JavaScript proxy objects to their JavaScript IDs.") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2237 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2238 (defvar js--js-process nil |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2239 "The most recent MozRepl process object.") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2240 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2241 (defvar js--js-gc-idle-timer nil |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2242 "Idle timer for cleaning up JS object references.") |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2243 |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2244 (defvar js--js-last-gcs-done nil) |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2245 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2246 (defconst js--moz-interactor |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2247 (replace-regexp-in-string |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2248 "[ \n]+" " " |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2249 ; */" Make Emacs happy |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2250 "(function(repl) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2251 repl.defineInteractor('js', { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2252 onStart: function onStart(repl) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2253 if(!repl._jsObjects) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2254 repl._jsObjects = {}; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2255 repl._jsLastID = 0; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2256 repl._jsGC = this._jsGC; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2257 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2258 this._input = ''; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2259 }, |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2260 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2261 _jsGC: function _jsGC(ids_in_use) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2262 var objects = this._jsObjects; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2263 var keys = []; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2264 var num_freed = 0; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2265 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2266 for(var pn in objects) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2267 keys.push(Number(pn)); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2268 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2269 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2270 keys.sort(function(x, y) x - y); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2271 ids_in_use.sort(function(x, y) x - y); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2272 var i = 0; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2273 var j = 0; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2274 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2275 while(i < ids_in_use.length && j < keys.length) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2276 var id = ids_in_use[i++]; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2277 while(j < keys.length && keys[j] !== id) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2278 var k_id = keys[j++]; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2279 delete objects[k_id]; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2280 ++num_freed; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2281 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2282 ++j; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2283 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2284 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2285 while(j < keys.length) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2286 var k_id = keys[j++]; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2287 delete objects[k_id]; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2288 ++num_freed; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2289 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2290 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2291 return num_freed; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2292 }, |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2293 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2294 _mkArray: function _mkArray() { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2295 var result = []; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2296 for(var i = 0; i < arguments.length; ++i) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2297 result.push(arguments[i]); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2298 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2299 return result; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2300 }, |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2301 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2302 _parsePropDescriptor: function _parsePropDescriptor(parts) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2303 if(typeof parts === 'string') { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2304 parts = [ parts ]; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2305 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2306 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2307 var obj = parts[0]; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2308 var start = 1; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2309 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2310 if(typeof obj === 'string') { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2311 obj = window; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2312 start = 0; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2313 } else if(parts.length < 2) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2314 throw new Error('expected at least 2 arguments'); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2315 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2316 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2317 for(var i = start; i < parts.length - 1; ++i) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2318 obj = obj[parts[i]]; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2319 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2320 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2321 return [obj, parts[parts.length - 1]]; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2322 }, |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2323 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2324 _getProp: function _getProp(/*...*/) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2325 if(arguments.length === 0) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2326 throw new Error('no arguments supplied to getprop'); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2327 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2328 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2329 if(arguments.length === 1 && |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2330 (typeof arguments[0]) !== 'string') |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2331 { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2332 return arguments[0]; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2333 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2334 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2335 var [obj, propname] = this._parsePropDescriptor(arguments); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2336 return obj[propname]; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2337 }, |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2338 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2339 _putProp: function _putProp(properties, value) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2340 var [obj, propname] = this._parsePropDescriptor(properties); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2341 obj[propname] = value; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2342 }, |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2343 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2344 _delProp: function _delProp(propname) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2345 var [obj, propname] = this._parsePropDescriptor(arguments); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2346 delete obj[propname]; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2347 }, |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2348 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2349 _typeOf: function _typeOf(thing) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2350 return typeof thing; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2351 }, |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2352 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2353 _callNew: function(constructor) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2354 if(typeof constructor === 'string') |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2355 { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2356 constructor = window[constructor]; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2357 } else if(constructor.length === 1 && |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2358 typeof constructor[0] !== 'string') |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2359 { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2360 constructor = constructor[0]; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2361 } else { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2362 var [obj,propname] = this._parsePropDescriptor(constructor); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2363 constructor = obj[propname]; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2364 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2365 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2366 /* Hacky, but should be robust */ |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2367 var s = 'new constructor('; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2368 for(var i = 1; i < arguments.length; ++i) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2369 if(i != 1) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2370 s += ','; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2371 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2372 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2373 s += 'arguments[' + i + ']'; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2374 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2375 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2376 s += ')'; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2377 return eval(s); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2378 }, |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2379 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2380 _callEval: function(thisobj, js) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2381 return eval.call(thisobj, js); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2382 }, |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2383 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2384 getPrompt: function getPrompt(repl) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2385 return 'EVAL>' |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2386 }, |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2387 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2388 _lookupObject: function _lookupObject(repl, id) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2389 if(typeof id === 'string') { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2390 switch(id) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2391 case 'global': |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2392 return window; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2393 case 'nil': |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2394 return null; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2395 case 't': |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2396 return true; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2397 case 'false': |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2398 return false; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2399 case 'undefined': |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2400 return undefined; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2401 case 'repl': |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2402 return repl; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2403 case 'interactor': |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2404 return this; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2405 case 'NaN': |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2406 return NaN; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2407 case 'Infinity': |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2408 return Infinity; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2409 case '-Infinity': |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2410 return -Infinity; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2411 default: |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2412 throw new Error('No object with special id:' + id); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2413 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2414 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2415 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2416 var ret = repl._jsObjects[id]; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2417 if(ret === undefined) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2418 throw new Error('No object with id:' + id + '(' + typeof id + ')'); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2419 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2420 return ret; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2421 }, |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2422 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2423 _findOrAllocateObject: function _findOrAllocateObject(repl, value) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2424 if(typeof value !== 'object' && typeof value !== 'function') { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2425 throw new Error('_findOrAllocateObject called on non-object(' |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2426 + typeof(value) + '): ' |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2427 + value) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2428 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2429 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2430 for(var id in repl._jsObjects) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2431 id = Number(id); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2432 var obj = repl._jsObjects[id]; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2433 if(obj === value) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2434 return id; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2435 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2436 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2437 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2438 var id = ++repl._jsLastID; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2439 repl._jsObjects[id] = value; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2440 return id; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2441 }, |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2442 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2443 _fixupList: function _fixupList(repl, list) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2444 for(var i = 0; i < list.length; ++i) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2445 if(list[i] instanceof Array) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2446 this._fixupList(repl, list[i]); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2447 } else if(typeof list[i] === 'object') { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2448 var obj = list[i]; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2449 if(obj.funcall) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2450 var parts = obj.funcall; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2451 this._fixupList(repl, parts); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2452 var [thisobj, func] = this._parseFunc(parts[0]); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2453 list[i] = func.apply(thisobj, parts.slice(1)); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2454 } else if(obj.objid) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2455 list[i] = this._lookupObject(repl, obj.objid); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2456 } else { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2457 throw new Error('Unknown object type: ' + obj.toSource()); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2458 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2459 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2460 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2461 }, |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2462 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2463 _parseFunc: function(func) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2464 var thisobj = null; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2465 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2466 if(typeof func === 'string') { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2467 func = window[func]; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2468 } else if(func instanceof Array) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2469 if(func.length === 1 && typeof func[0] !== 'string') { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2470 func = func[0]; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2471 } else { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2472 [thisobj, func] = this._parsePropDescriptor(func); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2473 func = thisobj[func]; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2474 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2475 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2476 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2477 return [thisobj,func]; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2478 }, |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2479 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2480 _encodeReturn: function(value, array_as_mv) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2481 var ret; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2482 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2483 if(value === null) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2484 ret = ['special', 'null']; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2485 } else if(value === true) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2486 ret = ['special', 'true']; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2487 } else if(value === false) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2488 ret = ['special', 'false']; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2489 } else if(value === undefined) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2490 ret = ['special', 'undefined']; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2491 } else if(typeof value === 'number') { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2492 if(isNaN(value)) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2493 ret = ['special', 'NaN']; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2494 } else if(value === Infinity) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2495 ret = ['special', 'Infinity']; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2496 } else if(value === -Infinity) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2497 ret = ['special', '-Infinity']; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2498 } else { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2499 ret = ['atom', value]; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2500 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2501 } else if(typeof value === 'string') { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2502 ret = ['atom', value]; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2503 } else if(array_as_mv && value instanceof Array) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2504 ret = ['array', value.map(this._encodeReturn, this)]; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2505 } else { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2506 ret = ['objid', this._findOrAllocateObject(repl, value)]; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2507 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2508 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2509 return ret; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2510 }, |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2511 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2512 _handleInputLine: function _handleInputLine(repl, line) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2513 var ret; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2514 var array_as_mv = false; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2515 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2516 try { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2517 if(line[0] === '*') { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2518 array_as_mv = true; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2519 line = line.substring(1); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2520 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2521 var parts = eval(line); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2522 this._fixupList(repl, parts); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2523 var [thisobj, func] = this._parseFunc(parts[0]); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2524 ret = this._encodeReturn( |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2525 func.apply(thisobj, parts.slice(1)), |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2526 array_as_mv); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2527 } catch(x) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2528 ret = ['error', x.toString() ]; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2529 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2530 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2531 var JSON = Components.classes['@mozilla.org/dom/json;1'].createInstance(Components.interfaces.nsIJSON); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2532 repl.print(JSON.encode(ret)); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2533 repl._prompt(); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2534 }, |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2535 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2536 handleInput: function handleInput(repl, chunk) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2537 this._input += chunk; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2538 var match, line; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2539 while(match = this._input.match(/.*\\n/)) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2540 line = match[0]; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2541 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2542 if(line === 'EXIT\\n') { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2543 repl.popInteractor(); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2544 repl._prompt(); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2545 return; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2546 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2547 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2548 this._input = this._input.substring(line.length); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2549 this._handleInputLine(repl, line); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2550 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2551 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2552 }); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2553 }) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2554 ") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2555 |
104683
2b8eeeaa8c1d
* international/ucs-normalize.el (ucs-normalize-sort, quick-check-list):
Juanma Barranquero <lekktu@gmail.com>
parents:
104391
diff
changeset
|
2556 "String to set MozRepl up into a simple-minded evaluation mode.") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2557 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2558 (defun js--js-encode-value (x) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2559 "Marshall the given value for JS. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2560 Strings and numbers are JSON-encoded. Lists (including nil) are |
104683
2b8eeeaa8c1d
* international/ucs-normalize.el (ucs-normalize-sort, quick-check-list):
Juanma Barranquero <lekktu@gmail.com>
parents:
104391
diff
changeset
|
2561 made into JavaScript array literals and their contents encoded |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2562 with `js--js-encode-value'." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2563 (cond ((stringp x) (json-encode-string x)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2564 ((numberp x) (json-encode-number x)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2565 ((symbolp x) (format "{objid:%S}" (symbol-name x))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2566 ((js--js-handle-p x) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2567 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2568 (when (js--js-handle-expired-p x) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2569 (error "Stale JS handle")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2570 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2571 (format "{objid:%s}" (js--js-handle-id x))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2572 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2573 ((sequencep x) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2574 (if (eq (car-safe x) 'js--funcall) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2575 (format "{funcall:[%s]}" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2576 (mapconcat #'js--js-encode-value (cdr x) ",")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2577 (concat |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2578 "[" (mapconcat #'js--js-encode-value x ",") "]"))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2579 (t |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2580 (error "Unrecognized item: %S" x)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2581 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2582 (defconst js--js-prompt-regexp "\\(repl[0-9]*\\)> $") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2583 (defconst js--js-repl-prompt-regexp "^EVAL>$") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2584 (defvar js--js-repl-depth 0) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2585 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2586 (defun js--js-wait-for-eval-prompt () |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2587 (js--wait-for-matching-output |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2588 (inferior-moz-process) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2589 js--js-repl-prompt-regexp js-js-timeout |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2590 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2591 ;; start matching against the beginning of the line in |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2592 ;; order to catch a prompt that's only partially arrived |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2593 (save-excursion (forward-line 0) (point)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2594 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2595 (defun js--js-enter-repl () |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2596 (inferior-moz-process) ; called for side-effect |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2597 (with-current-buffer inferior-moz-buffer |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2598 (goto-char (point-max)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2599 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2600 ;; Do some initialization the first time we see a process |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2601 (unless (eq (inferior-moz-process) js--js-process) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2602 (setq js--js-process (inferior-moz-process)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2603 (setq js--js-references (make-hash-table :test 'eq :weakness t)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2604 (setq js--js-repl-depth 0) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2605 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2606 ;; Send interactor definition |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2607 (comint-send-string js--js-process js--moz-interactor) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2608 (comint-send-string js--js-process |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2609 (concat "(" moz-repl-name ")\n")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2610 (js--wait-for-matching-output |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2611 (inferior-moz-process) js--js-prompt-regexp |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2612 js-js-timeout)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2613 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2614 ;; Sanity check |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2615 (when (looking-back js--js-prompt-regexp |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2616 (save-excursion (forward-line 0) (point))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2617 (setq js--js-repl-depth 0)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2618 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2619 (if (> js--js-repl-depth 0) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2620 ;; If js--js-repl-depth > 0, we *should* be seeing an |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2621 ;; EVAL> prompt. If we don't, give Mozilla a chance to catch |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2622 ;; up with us. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2623 (js--js-wait-for-eval-prompt) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2624 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2625 ;; Otherwise, tell Mozilla to enter the interactor mode |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2626 (insert (match-string-no-properties 1) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2627 ".pushInteractor('js')") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2628 (comint-send-input nil t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2629 (js--wait-for-matching-output |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2630 (inferior-moz-process) js--js-repl-prompt-regexp |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2631 js-js-timeout)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2632 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2633 (incf js--js-repl-depth))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2634 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2635 (defun js--js-leave-repl () |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2636 (assert (> js--js-repl-depth 0)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2637 (when (= 0 (decf js--js-repl-depth)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2638 (with-current-buffer inferior-moz-buffer |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2639 (goto-char (point-max)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2640 (js--js-wait-for-eval-prompt) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2641 (insert "EXIT") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2642 (comint-send-input nil t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2643 (js--wait-for-matching-output |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2644 (inferior-moz-process) js--js-prompt-regexp |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2645 js-js-timeout)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2646 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2647 (defsubst js--js-not (value) |
106457
c15d1227e860
* progmodes/js.el (js--js-not): Add null to the list of values.
Chong Yidong <cyd@stupidchicken.com>
parents:
105372
diff
changeset
|
2648 (memq value '(nil null false undefined))) |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2649 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2650 (defsubst js--js-true (value) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2651 (not (js--js-not value))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2652 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2653 (eval-and-compile |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2654 (defun js--optimize-arglist (arglist) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2655 "Convert immediate js< and js! references to deferred ones." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2656 (loop for item in arglist |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2657 if (eq (car-safe item) 'js<) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2658 collect (append (list 'list ''js--funcall |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2659 '(list 'interactor "_getProp")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2660 (js--optimize-arglist (cdr item))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2661 else if (eq (car-safe item) 'js>) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2662 collect (append (list 'list ''js--funcall |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2663 '(list 'interactor "_putProp")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2664 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2665 (if (atom (cadr item)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2666 (list (cadr item)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2667 (list |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2668 (append |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2669 (list 'list ''js--funcall |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2670 '(list 'interactor "_mkArray")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2671 (js--optimize-arglist (cadr item))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2672 (js--optimize-arglist (cddr item))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2673 else if (eq (car-safe item) 'js!) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2674 collect (destructuring-bind (ignored function &rest body) item |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2675 (append (list 'list ''js--funcall |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2676 (if (consp function) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2677 (cons 'list |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2678 (js--optimize-arglist function)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2679 function)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2680 (js--optimize-arglist body))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2681 else |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2682 collect item))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2683 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2684 (defmacro js--js-get-service (class-name interface-name) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2685 `(js! ("Components" "classes" ,class-name "getService") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2686 (js< "Components" "interfaces" ,interface-name))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2687 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2688 (defmacro js--js-create-instance (class-name interface-name) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2689 `(js! ("Components" "classes" ,class-name "createInstance") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2690 (js< "Components" "interfaces" ,interface-name))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2691 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2692 (defmacro js--js-qi (object interface-name) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2693 `(js! (,object "QueryInterface") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2694 (js< "Components" "interfaces" ,interface-name))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2695 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2696 (defmacro with-js (&rest forms) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2697 "Run FORMS with the Mozilla repl set up for js commands. |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2698 Inside the lexical scope of `with-js', `js?', `js!', |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2699 `js-new', `js-eval', `js-list', `js<', `js>', `js-get-service', |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2700 `js-create-instance', and `js-qi' are defined." |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2701 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2702 `(progn |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2703 (js--js-enter-repl) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2704 (unwind-protect |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2705 (macrolet ((js? (&rest body) `(js--js-true ,@body)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2706 (js! (function &rest body) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2707 `(js--js-funcall |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2708 ,(if (consp function) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2709 (cons 'list |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2710 (js--optimize-arglist function)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2711 function) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2712 ,@(js--optimize-arglist body))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2713 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2714 (js-new (function &rest body) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2715 `(js--js-new |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2716 ,(if (consp function) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2717 (cons 'list |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2718 (js--optimize-arglist function)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2719 function) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2720 ,@body)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2721 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2722 (js-eval (thisobj js) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2723 `(js--js-eval |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2724 ,@(js--optimize-arglist |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2725 (list thisobj js)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2726 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2727 (js-list (&rest args) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2728 `(js--js-list |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2729 ,@(js--optimize-arglist args))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2730 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2731 (js-get-service (&rest args) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2732 `(js--js-get-service |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2733 ,@(js--optimize-arglist args))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2734 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2735 (js-create-instance (&rest args) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2736 `(js--js-create-instance |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2737 ,@(js--optimize-arglist args))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2738 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2739 (js-qi (&rest args) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2740 `(js--js-qi |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2741 ,@(js--optimize-arglist args))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2742 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2743 (js< (&rest body) `(js--js-get |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2744 ,@(js--optimize-arglist body))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2745 (js> (props value) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2746 `(js--js-funcall |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2747 '(interactor "_putProp") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2748 ,(if (consp props) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2749 (cons 'list |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2750 (js--optimize-arglist props)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2751 props) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2752 ,@(js--optimize-arglist (list value)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2753 )) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2754 (js-handle? (arg) `(js--js-handle-p ,arg))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2755 ,@forms) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2756 (js--js-leave-repl)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2757 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2758 (defvar js--js-array-as-list nil |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2759 "Whether to listify any Array returned by a Mozilla function. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2760 If nil, the whole Array is treated as a JS symbol.") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2761 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2762 (defun js--js-decode-retval (result) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2763 (ecase (intern (first result)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2764 (atom (second result)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2765 (special (intern (second result))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2766 (array |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2767 (mapcar #'js--js-decode-retval (second result))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2768 (objid |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2769 (or (gethash (second result) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2770 js--js-references) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2771 (puthash (second result) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2772 (make-js--js-handle |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2773 :id (second result) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2774 :process (inferior-moz-process)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2775 js--js-references))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2776 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2777 (error (signal 'js-js-error (list (second result)))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2778 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2779 (defun js--js-funcall (function &rest arguments) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2780 "Call the Mozilla function FUNCTION with arguments ARGUMENTS. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2781 If function is a string, look it up as a property on the global |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2782 object and use the global object for `this'. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2783 If FUNCTION is a list with one element, use that element as the |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2784 function with the global object for `this', except that if that |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2785 single element is a string, look it up on the global object. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2786 If FUNCTION is a list with more than one argument, use the list |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2787 up to the last value as a property descriptor and the last |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2788 argument as a function." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2789 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2790 (with-js |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2791 (let ((argstr (js--js-encode-value |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2792 (cons function arguments)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2793 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2794 (with-current-buffer inferior-moz-buffer |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2795 ;; Actual funcall |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2796 (when js--js-array-as-list |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2797 (insert "*")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2798 (insert argstr) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2799 (comint-send-input nil t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2800 (js--wait-for-matching-output |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2801 (inferior-moz-process) "EVAL>" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2802 js-js-timeout) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2803 (goto-char comint-last-input-end) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2804 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2805 ;; Read the result |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2806 (let* ((json-array-type 'list) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2807 (result (prog1 (json-read) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2808 (goto-char (point-max))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2809 (js--js-decode-retval result)))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2810 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2811 (defun js--js-new (constructor &rest arguments) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2812 "Call CONSTRUCTOR as a constructor, with arguments ARGUMENTS. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2813 CONSTRUCTOR is a JS handle, a string, or a list of these things." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2814 (apply #'js--js-funcall |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2815 '(interactor "_callNew") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2816 constructor arguments)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2817 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2818 (defun js--js-eval (thisobj js) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2819 (js--js-funcall '(interactor "_callEval") thisobj js)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2820 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2821 (defun js--js-list (&rest arguments) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2822 "Return a Lisp array resulting from evaluating each of ARGUMENTS." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2823 (let ((js--js-array-as-list t)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2824 (apply #'js--js-funcall '(interactor "_mkArray") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2825 arguments))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2826 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2827 (defun js--js-get (&rest props) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2828 (apply #'js--js-funcall '(interactor "_getProp") props)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2829 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2830 (defun js--js-put (props value) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2831 (js--js-funcall '(interactor "_putProp") props value)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2832 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2833 (defun js-gc (&optional force) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2834 "Tell the repl about any objects we don't reference anymore. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2835 With argument, run even if no intervening GC has happened." |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2836 (interactive) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2837 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2838 (when force |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2839 (setq js--js-last-gcs-done nil)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2840 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2841 (let ((this-gcs-done gcs-done) keys num) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2842 (when (and js--js-references |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2843 (boundp 'inferior-moz-buffer) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2844 (buffer-live-p inferior-moz-buffer) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2845 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2846 ;; Don't bother running unless we've had an intervening |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2847 ;; garbage collection; without a gc, nothing is deleted |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2848 ;; from the weak hash table, so it's pointless telling |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2849 ;; MozRepl about that references we still hold |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2850 (not (eq js--js-last-gcs-done this-gcs-done)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2851 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2852 ;; Are we looking at a normal prompt? Make sure not to |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2853 ;; interrupt the user if he's doing something |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2854 (with-current-buffer inferior-moz-buffer |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2855 (save-excursion |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2856 (goto-char (point-max)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2857 (looking-back js--js-prompt-regexp |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2858 (save-excursion (forward-line 0) (point)))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2859 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2860 (setq keys (loop for x being the hash-keys |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2861 of js--js-references |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2862 collect x)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2863 (setq num (js--js-funcall '(repl "_jsGC") (or keys []))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2864 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2865 (setq js--js-last-gcs-done this-gcs-done) |
105372
bd2966850aac
Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents:
105076
diff
changeset
|
2866 (when (called-interactively-p 'interactive) |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2867 (message "Cleaned %s entries" num)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2868 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2869 num))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2870 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2871 (run-with-idle-timer 30 t #'js-gc) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2872 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2873 (defun js-eval (js) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2874 "Evaluate the JavaScript in JS and return JSON-decoded result." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2875 (interactive "MJavascript to evaluate: ") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2876 (with-js |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2877 (let* ((content-window (js--js-content-window |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2878 (js--get-js-context))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2879 (result (js-eval content-window js))) |
105372
bd2966850aac
Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents:
105076
diff
changeset
|
2880 (when (called-interactively-p 'interactive) |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2881 (message "%s" (js! "String" result))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2882 result))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2883 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2884 (defun js--get-tabs () |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2885 "Enumerate all JavaScript contexts available. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2886 Each context is a list: |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2887 (TITLE URL BROWSER TAB TABBROWSER) for content documents |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2888 (TITLE URL WINDOW) for windows |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2889 |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2890 All tabs of a given window are grouped together. The most recent |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2891 window is first. Within each window, the tabs are returned |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2892 left-to-right." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2893 (with-js |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2894 (let (windows) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2895 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2896 (loop with window-mediator = (js! ("Components" "classes" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2897 "@mozilla.org/appshell/window-mediator;1" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2898 "getService") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2899 (js< "Components" "interfaces" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2900 "nsIWindowMediator")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2901 with enumerator = (js! (window-mediator "getEnumerator") nil) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2902 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2903 while (js? (js! (enumerator "hasMoreElements"))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2904 for window = (js! (enumerator "getNext")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2905 for window-info = (js-list window |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2906 (js< window "document" "title") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2907 (js! (window "location" "toString")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2908 (js< window "closed") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2909 (js< window "windowState")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2910 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2911 unless (or (js? (fourth window-info)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2912 (eq (fifth window-info) 2)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2913 do (push window-info windows)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2914 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2915 (loop for window-info in windows |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2916 for window = (first window-info) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2917 collect (list (second window-info) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2918 (third window-info) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2919 window) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2920 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2921 for gbrowser = (js< window "gBrowser") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2922 if (js-handle? gbrowser) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2923 nconc (loop |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2924 for x below (js< gbrowser "browsers" "length") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2925 collect (js-list (js< gbrowser |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2926 "browsers" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2927 x |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2928 "contentDocument" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2929 "title") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2930 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2931 (js! (gbrowser |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2932 "browsers" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2933 x |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2934 "contentWindow" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2935 "location" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2936 "toString")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2937 (js< gbrowser |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2938 "browsers" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2939 x) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2940 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2941 (js! (gbrowser |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2942 "tabContainer" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2943 "childNodes" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2944 "item") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2945 x) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2946 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2947 gbrowser)))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2948 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2949 (defvar js-read-tab-history nil) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2950 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2951 (defun js--read-tab (prompt) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2952 "Read a Mozilla tab with prompt PROMPT. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2953 Return a cons of (TYPE . OBJECT). TYPE is either 'window or |
104683
2b8eeeaa8c1d
* international/ucs-normalize.el (ucs-normalize-sort, quick-check-list):
Juanma Barranquero <lekktu@gmail.com>
parents:
104391
diff
changeset
|
2954 'tab, and OBJECT is a JavaScript handle to a ChromeWindow or a |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
2955 browser, respectively." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2956 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2957 ;; Prime IDO |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2958 (unless ido-mode |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2959 (ido-mode t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2960 (ido-mode nil)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2961 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2962 (with-js |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2963 (lexical-let ((tabs (js--get-tabs)) selected-tab-cname |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2964 selected-tab prev-hitab) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2965 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2966 ;; Disambiguate names |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2967 (setq tabs (loop with tab-names = (make-hash-table :test 'equal) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2968 for tab in tabs |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2969 for cname = (format "%s (%s)" (second tab) (first tab)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2970 for num = (incf (gethash cname tab-names -1)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2971 if (> num 0) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2972 do (setq cname (format "%s <%d>" cname num)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2973 collect (cons cname tab))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2974 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2975 (labels ((find-tab-by-cname |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2976 (cname) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2977 (loop for tab in tabs |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2978 if (equal (car tab) cname) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2979 return (cdr tab))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2980 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2981 (mogrify-highlighting |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2982 (hitab unhitab) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2983 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2984 ;; Hack to reduce the number of |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2985 ;; round-trips to mozilla |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2986 (let (cmds) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2987 (cond |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2988 ;; Highlighting tab |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2989 ((fourth hitab) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2990 (push '(js! ((fourth hitab) "setAttribute") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2991 "style" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2992 "color: red; font-weight: bold") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2993 cmds) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2994 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2995 ;; Highlight window proper |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2996 (push '(js! ((third hitab) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2997 "setAttribute") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2998 "style" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2999 "border: 8px solid red") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3000 cmds) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3001 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3002 ;; Select tab, when appropriate |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3003 (when js-js-switch-tabs |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3004 (push |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3005 '(js> ((fifth hitab) "selectedTab") (fourth hitab)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3006 cmds))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3007 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3008 ;; Hilighting whole window |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3009 ((third hitab) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3010 (push '(js! ((third hitab) "document" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3011 "documentElement" "setAttribute") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3012 "style" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3013 (concat "-moz-appearance: none;" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3014 "border: 8px solid red;")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3015 cmds))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3016 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3017 (cond |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3018 ;; Unhighlighting tab |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3019 ((fourth unhitab) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3020 (push '(js! ((fourth unhitab) "setAttribute") "style" "") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3021 cmds) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3022 (push '(js! ((third unhitab) "setAttribute") "style" "") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3023 cmds)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3024 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3025 ;; Unhighlighting window |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3026 ((third unhitab) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3027 (push '(js! ((third unhitab) "document" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3028 "documentElement" "setAttribute") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3029 "style" "") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3030 cmds))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3031 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3032 (eval (list 'with-js |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3033 (cons 'js-list (nreverse cmds)))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3034 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3035 (command-hook |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3036 () |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3037 (let* ((tab (find-tab-by-cname (car ido-matches)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3038 (mogrify-highlighting tab prev-hitab) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3039 (setq prev-hitab tab))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3040 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3041 (setup-hook |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3042 () |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3043 ;; Fiddle with the match list a bit: if our first match |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3044 ;; is a tabbrowser window, rotate the match list until |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3045 ;; the active tab comes up |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3046 (let ((matched-tab (find-tab-by-cname (car ido-matches)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3047 (when (and matched-tab |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3048 (null (fourth matched-tab)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3049 (equal "navigator:browser" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3050 (js! ((third matched-tab) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3051 "document" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3052 "documentElement" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3053 "getAttribute") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3054 "windowtype"))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3055 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3056 (loop with tab-to-match = (js< (third matched-tab) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3057 "gBrowser" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3058 "selectedTab") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3059 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3060 with index = 0 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3061 for match in ido-matches |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3062 for candidate-tab = (find-tab-by-cname match) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3063 if (eq (fourth candidate-tab) tab-to-match) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3064 do (setq ido-cur-list (ido-chop ido-cur-list match)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3065 and return t))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3066 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3067 (add-hook 'post-command-hook #'command-hook t t))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3068 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3069 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3070 (unwind-protect |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3071 (setq selected-tab-cname |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3072 (let ((ido-minibuffer-setup-hook |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3073 (cons #'setup-hook ido-minibuffer-setup-hook))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3074 (ido-completing-read |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3075 prompt |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3076 (mapcar #'car tabs) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3077 nil t nil |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3078 'js-read-tab-history))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3079 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3080 (when prev-hitab |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3081 (mogrify-highlighting nil prev-hitab) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3082 (setq prev-hitab nil))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3083 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3084 (add-to-history 'js-read-tab-history selected-tab-cname) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3085 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3086 (setq selected-tab (loop for tab in tabs |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3087 if (equal (car tab) selected-tab-cname) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3088 return (cdr tab))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3089 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3090 (if (fourth selected-tab) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3091 (cons 'browser (third selected-tab)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3092 (cons 'window (third selected-tab))))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3093 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3094 (defun js--guess-eval-defun-info (pstate) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
3095 "Helper function for `js-eval-defun'. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
3096 Return a list (NAME . CLASSPARTS), where CLASSPARTS is a list of |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
3097 strings making up the class name and NAME is the name of the |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
3098 function part." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3099 (cond ((and (= (length pstate) 3) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3100 (eq (js--pitem-type (first pstate)) 'function) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3101 (= (length (js--pitem-name (first pstate))) 1) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3102 (consp (js--pitem-type (second pstate)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3103 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3104 (append (js--pitem-name (second pstate)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3105 (list (first (js--pitem-name (first pstate)))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3106 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3107 ((and (= (length pstate) 2) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3108 (eq (js--pitem-type (first pstate)) 'function)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3109 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3110 (append |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3111 (butlast (js--pitem-name (first pstate))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3112 (list (car (last (js--pitem-name (first pstate))))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3113 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3114 (t (error "Function not a toplevel defun or class member")))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3115 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3116 (defvar js--js-context nil |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
3117 "The current JavaScript context. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
3118 This is a cons like the one returned from `js--read-tab'. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
3119 Change with `js-set-js-context'.") |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3120 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3121 (defconst js--js-inserter |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3122 "(function(func_info,func) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3123 func_info.unshift('window'); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3124 var obj = window; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3125 for(var i = 1; i < func_info.length - 1; ++i) { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3126 var next = obj[func_info[i]]; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3127 if(typeof next !== 'object' && typeof next !== 'function') { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3128 next = obj.prototype && obj.prototype[func_info[i]]; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3129 if(typeof next !== 'object' && typeof next !== 'function') { |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3130 alert('Could not find ' + func_info.slice(0, i+1).join('.') + |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3131 ' or ' + func_info.slice(0, i+1).join('.') + '.prototype'); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3132 return; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3133 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3134 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3135 func_info.splice(i+1, 0, 'prototype'); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3136 ++i; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3137 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3138 } |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3139 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3140 obj[func_info[i]] = func; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3141 alert('Successfully updated '+func_info.join('.')); |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3142 })") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3143 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3144 (defun js-set-js-context (context) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
3145 "Set the JavaScript context to CONTEXT. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
3146 When called interactively, prompt for CONTEXT." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3147 (interactive (list (js--read-tab "Javascript Context: "))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3148 (setq js--js-context context)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3149 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3150 (defun js--get-js-context () |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
3151 "Return a valid JavaScript context. |
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
3152 If one hasn't been set, or if it's stale, prompt for a new one." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3153 (with-js |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3154 (when (or (null js--js-context) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3155 (js--js-handle-expired-p (cdr js--js-context)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3156 (ecase (car js--js-context) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3157 (window (js? (js< (cdr js--js-context) "closed"))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3158 (browser (not (js? (js< (cdr js--js-context) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3159 "contentDocument")))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3160 (setq js--js-context (js--read-tab "Javascript Context: "))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3161 js--js-context)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3162 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3163 (defun js--js-content-window (context) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3164 (with-js |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3165 (ecase (car context) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3166 (window (cdr context)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3167 (browser (js< (cdr context) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3168 "contentWindow" "wrappedJSObject"))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3169 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3170 (defun js--make-nsilocalfile (path) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3171 (with-js |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3172 (let ((file (js-create-instance "@mozilla.org/file/local;1" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3173 "nsILocalFile"))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3174 (js! (file "initWithPath") path) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3175 file))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3176 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3177 (defun js--js-add-resource-alias (alias path) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3178 (with-js |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3179 (let* ((io-service (js-get-service "@mozilla.org/network/io-service;1" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3180 "nsIIOService")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3181 (res-prot (js! (io-service "getProtocolHandler") "resource")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3182 (res-prot (js-qi res-prot "nsIResProtocolHandler")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3183 (path-file (js--make-nsilocalfile path)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3184 (path-uri (js! (io-service "newFileURI") path-file))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3185 (js! (res-prot "setSubstitution") alias path-uri)))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3186 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3187 (defun* js-eval-defun () |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
3188 "Update a Mozilla tab using the JavaScript defun at point." |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3189 (interactive) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3190 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3191 ;; This function works by generating a temporary file that contains |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3192 ;; the function we'd like to insert. We then use the elisp-js bridge |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3193 ;; to command mozilla to load this file by inserting a script tag |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3194 ;; into the document we set. This way, debuggers and such will have |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3195 ;; a way to find the source of the just-inserted function. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3196 ;; |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3197 ;; We delete the temporary file if there's an error, but otherwise |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3198 ;; we add an unload event listener on the Mozilla side to delete the |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3199 ;; file. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3200 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3201 (save-excursion |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3202 (let (begin end pstate defun-info temp-name defun-body) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
3203 (js-end-of-defun) |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3204 (setq end (point)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3205 (js--ensure-cache) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
3206 (js-beginning-of-defun) |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3207 (re-search-forward "\\_<function\\_>") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3208 (setq begin (match-beginning 0)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3209 (setq pstate (js--forward-pstate)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3210 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3211 (when (or (null pstate) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3212 (> (point) end)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3213 (error "Could not locate function definition")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3214 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3215 (setq defun-info (js--guess-eval-defun-info pstate)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3216 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3217 (let ((overlay (make-overlay begin end))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3218 (overlay-put overlay 'face 'highlight) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3219 (unwind-protect |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3220 (unless (y-or-n-p (format "Send %s to Mozilla? " |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3221 (mapconcat #'identity defun-info "."))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3222 (message "") ; question message lingers until next command |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3223 (return-from js-eval-defun)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3224 (delete-overlay overlay))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3225 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3226 (setq defun-body (buffer-substring-no-properties begin end)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3227 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3228 (make-directory js-js-tmpdir t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3229 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3230 ;; (Re)register a Mozilla resource URL to point to the |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3231 ;; temporary directory |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3232 (js--js-add-resource-alias "js" js-js-tmpdir) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3233 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3234 (setq temp-name (make-temp-file (concat js-js-tmpdir |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3235 "/js-") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3236 nil ".js")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3237 (unwind-protect |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3238 (with-js |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3239 (with-temp-buffer |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3240 (insert js--js-inserter) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3241 (insert "(") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3242 (insert (json-encode-list defun-info)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3243 (insert ",\n") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3244 (insert defun-body) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3245 (insert "\n)") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3246 (write-region (point-min) (point-max) temp-name |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3247 nil 1)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3248 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3249 ;; Give Mozilla responsibility for deleting this file |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3250 (let* ((content-window (js--js-content-window |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3251 (js--get-js-context))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3252 (content-document (js< content-window "document")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3253 (head (if (js? (js< content-document "body")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3254 ;; Regular content |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3255 (js< (js! (content-document "getElementsByTagName") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3256 "head") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3257 0) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3258 ;; Chrome |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3259 (js< content-document "documentElement"))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3260 (elem (js! (content-document "createElementNS") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3261 "http://www.w3.org/1999/xhtml" "script"))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3262 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3263 (js! (elem "setAttribute") "type" "text/javascript") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3264 (js! (elem "setAttribute") "src" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3265 (format "resource://js/%s" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3266 (file-name-nondirectory temp-name))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3267 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3268 (js! (head "appendChild") elem) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3269 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3270 (js! (content-window "addEventListener") "unload" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3271 (js! ((js-new |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3272 "Function" "file" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3273 "return function() { file.remove(false) }")) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3274 (js--make-nsilocalfile temp-name)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3275 'false) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3276 (setq temp-name nil) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3277 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3278 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3279 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3280 )) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3281 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3282 ;; temp-name is set to nil on success |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3283 (when temp-name |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3284 (delete-file temp-name)))))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3285 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3286 ;;; Main Function |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3287 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3288 ;;;###autoload |
109561
d7a517f1b312
Derive programming modes from prog-mode.
Juanma Barranquero <lekktu@gmail.com>
parents:
109258
diff
changeset
|
3289 (define-derived-mode js-mode prog-mode "js" |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
3290 "Major mode for editing JavaScript. |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3291 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3292 Key bindings: |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3293 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3294 \\{js-mode-map}" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3295 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3296 :group 'js |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3297 :syntax-table js-mode-syntax-table |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3298 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3299 (set (make-local-variable 'indent-line-function) 'js-indent-line) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3300 (set (make-local-variable 'beginning-of-defun-function) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
3301 'js-beginning-of-defun) |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3302 (set (make-local-variable 'end-of-defun-function) |
104275
3bf815184a6c
* progmodes/js.el: Edit docstrings throughout to follow Emacs
Chong Yidong <cyd@stupidchicken.com>
parents:
104272
diff
changeset
|
3303 'js-end-of-defun) |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3304 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3305 (set (make-local-variable 'open-paren-in-column-0-is-defun-start) nil) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3306 (set (make-local-variable 'font-lock-defaults) |
110403
14dab55b2888
Fix and improve last syntax-propertize patch
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110305
diff
changeset
|
3307 (list js--font-lock-keywords)) |
110305
b10051866f51
New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110270
diff
changeset
|
3308 (set (make-local-variable 'syntax-propertize-function) |
b10051866f51
New syntax-propertize functionality.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
110270
diff
changeset
|
3309 js-syntax-propertize-function) |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3310 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3311 (set (make-local-variable 'parse-sexp-ignore-comments) t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3312 (set (make-local-variable 'parse-sexp-lookup-properties) t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3313 (set (make-local-variable 'which-func-imenu-joiner-function) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3314 #'js--which-func-joiner) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3315 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3316 ;; Comments |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3317 (setq comment-start "// ") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3318 (setq comment-end "") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3319 (set (make-local-variable 'fill-paragraph-function) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3320 'js-c-fill-paragraph) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3321 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3322 ;; Parse cache |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3323 (add-hook 'before-change-functions #'js--flush-caches t t) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3324 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3325 ;; Frameworks |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3326 (js--update-quick-match-re) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3327 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3328 ;; Imenu |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3329 (setq imenu-case-fold-search nil) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3330 (set (make-local-variable 'imenu-create-index-function) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3331 #'js--imenu-create-index) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3332 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3333 (setq major-mode 'js-mode) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3334 (setq mode-name "Javascript") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3335 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3336 ;; for filling, pretend we're cc-mode |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3337 (setq c-comment-prefix-regexp "//+\\|\\**" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3338 c-paragraph-start "$" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3339 c-paragraph-separate "$" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3340 c-block-comment-prefix "* " |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3341 c-line-comment-starter "//" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3342 c-comment-start-regexp "/[*/]\\|\\s!" |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3343 comment-start-skip "\\(//+\\|/\\*+\\)\\s *") |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3344 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3345 (let ((c-buffer-is-cc-mode t)) |
108363
642b031fce0f
Make paragraph vars local for js-mode (Bug#6071).
Chong Yidong <cyd@stupidchicken.com>
parents:
107692
diff
changeset
|
3346 ;; FIXME: These are normally set by `c-basic-common-init'. Should |
642b031fce0f
Make paragraph vars local for js-mode (Bug#6071).
Chong Yidong <cyd@stupidchicken.com>
parents:
107692
diff
changeset
|
3347 ;; we call it instead? (Bug#6071) |
642b031fce0f
Make paragraph vars local for js-mode (Bug#6071).
Chong Yidong <cyd@stupidchicken.com>
parents:
107692
diff
changeset
|
3348 (make-local-variable 'paragraph-start) |
642b031fce0f
Make paragraph vars local for js-mode (Bug#6071).
Chong Yidong <cyd@stupidchicken.com>
parents:
107692
diff
changeset
|
3349 (make-local-variable 'paragraph-separate) |
642b031fce0f
Make paragraph vars local for js-mode (Bug#6071).
Chong Yidong <cyd@stupidchicken.com>
parents:
107692
diff
changeset
|
3350 (make-local-variable 'paragraph-ignore-fill-prefix) |
642b031fce0f
Make paragraph vars local for js-mode (Bug#6071).
Chong Yidong <cyd@stupidchicken.com>
parents:
107692
diff
changeset
|
3351 (make-local-variable 'adaptive-fill-mode) |
642b031fce0f
Make paragraph vars local for js-mode (Bug#6071).
Chong Yidong <cyd@stupidchicken.com>
parents:
107692
diff
changeset
|
3352 (make-local-variable 'adaptive-fill-regexp) |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3353 (c-setup-paragraph-variables)) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3354 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3355 (set (make-local-variable 'syntax-begin-function) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3356 #'js--syntax-begin-function) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3357 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3358 ;; Important to fontify the whole buffer syntactically! If we don't, |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3359 ;; then we might have regular expression literals that aren't marked |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3360 ;; as strings, which will screw up parse-partial-sexp, scan-lists, |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3361 ;; etc. and and produce maddening "unbalanced parenthesis" errors. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3362 ;; When we attempt to find the error and scroll to the portion of |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3363 ;; the buffer containing the problem, JIT-lock will apply the |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3364 ;; correct syntax to the regular expresion literal and the problem |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3365 ;; will mysteriously disappear. |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3366 (font-lock-set-defaults) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3367 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3368 (let (font-lock-keywords) ; leaves syntactic keywords intact |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3369 (font-lock-fontify-buffer))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3370 |
106794
c177971c1cec
* progmodes/js.el: Autoload javascript-mode alias.
Chong Yidong <cyd@stupidchicken.com>
parents:
106457
diff
changeset
|
3371 ;;;###autoload |
104272
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3372 (defalias 'javascript-mode 'js-mode) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3373 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3374 (eval-after-load 'folding |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3375 '(when (fboundp 'folding-add-to-marks-list) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3376 (folding-add-to-marks-list 'js-mode "// {{{" "// }}}" ))) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3377 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3378 (provide 'js) |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3379 |
ea67ac46d172
* progmodes/js2-mode.el: File removed.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3380 ;; js.el ends here |