-
Notifications
You must be signed in to change notification settings - Fork 0
/
nodejs-repl.elc
97 lines (87 loc) · 10.7 KB
/
nodejs-repl.elc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
;ELC
;;; Compiled by shant@ultraio on Sat Sep 27 19:36:33 2014
;;; from file /home/shant/.emacs.d/nodejs-repl.el
;;; in Emacs version 24.3.1
;;; with all optimizations.
;;; This file uses dynamic docstrings, first added in Emacs 19.29.
;;; This file does not contain utf-8 non-ASCII characters,
;;; and so can be loaded in Emacs versions earlier than 23.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(byte-code "\300\301!\210\300\302!\210\300\303!\210\304\305\306\307\310\311%\207" [require cc-mode comint ansi-color custom-declare-group nodejs-repl nil "Run Node.js REPL and communicate the process." :group processes] 6)
#@23 Node.js mode Version.
(defconst nodejs-repl-version "0.0.2" (#$ . 728))
(byte-code "\300\301\302\303\304\305\306\307&\210\300\310\311\312\304\305\306\307&\207" [custom-declare-variable nodejs-repl-command "node" "Node.js command used in `nodejs-repl-mode'." :group nodejs-repl :type string nodejs-repl-prompt "> " "Node.js prompt used in `nodejs-repl-mode'."] 8)
#@31 process name of Node.js REPL.
(defvar nodejs-repl-process-name "nodejs" (#$ . 1099))
(defvar nodejs-repl-temp-buffer-name "*nodejs-repl-command-output*")
(defvar nodejs-repl-mode-syntax-table (byte-code "\301 \302!\210\303\304\305#\210)\207" [st make-syntax-table c-populate-syntax-table modify-syntax-entry 36 "_"] 4))
(defvar nodejs-repl-mode-map (byte-code "\301 \302\303\304#\210\302\305\306#\210)\207" [map make-sparse-keymap define-key " " comint-dynamic-complete "" nodejs-repl-quit-or-cancel] 4))
(defvar nodejs-repl-code "process.stdout.columns = %d;require('repl').start('%s', null, null, true, false)")
#@102 If non-nil, don't add input matching the last on the input ring.
See also `comint-input-ignoredups'
(defvar nodejs-repl-input-ignoredups t (#$ . 1730))
#@80 If non-nil, Node.js does not echo any input.
See also `comint-process-echoes'
(defvar nodejs-repl-process-echoes t (#$ . 1889))
(defvar nodejs-repl-extra-espace-sequence-re "\\(\\[[0-9]+[GJK]\\)")
(defvar nodejs-repl-ansi-color-sequence-re "\\(\\[[0-9]+m\\)")
(defvar nodejs-repl-prompt-re-format "\\[1G\\(\\[0J%s.*\\[[0-9]+G\\|%s.*\\[0K\\[[0-9]+G\\)$")
(defvar nodejs-repl-prompt-re (byte-code "\302 \211#\207" [nodejs-repl-prompt-re-format nodejs-repl-prompt format] 4))
(defvar nodejs-repl-require-re "\\(?:^\\|\\s-\\|[-+*/%&|><!;{}()[]\\|\\]\\)require\\s-*(\\s-*\\(\"[^\"\\]*\\(?:\\\\.[^\"\\]*\\)*\\|'[^'\\]*\\(?:\\\\.[^'\\]*\\)*\\)$")
(defvar nodejs-repl-cache-token "")
(defvar nodejs-repl-cache-candidates nil)
#@42 Return non-nil if point is inside string
(defalias 'nodejs-repl--in-string-p #[(&optional pos) "\301\302!8\207" [pos 3 syntax-ppss] 3 (#$ . 2622)])
(defalias 'nodejs-repl--extract-require-argument #[(string) "\302 \"\205 \303\304 \"\207" [nodejs-repl-require-re string string-match match-string 1] 3])
#@38 Return the last token in the string.
(defalias 'nodejs-repl--get-last-token #[(string) "\301\302\"\205 \303\304\"\207" [string string-match "\\([._$]\\|\\w\\)+$" match-string 0] 3 (#$ . 2933)])
#@55 Send string to Node.js process and return the output.
(defalias 'nodejs-repl--send-string #[(string) "\306\307!rq\210\310\216\311 !\312\313\n!!\314\n!\315\n!\316\216\317\np\"\210\320\n\321\"\210\313\n!e\322\223\210\323\n\"\210\324\n\325#\210)\326 .\207" [#1=#:temp-buffer nodejs-repl-process-name proc orig-marker orig-filter orig-buf generate-new-buffer " *temp*" ((byte-code "\301!\203\n \302!\210\301\207" [#1# buffer-name kill-buffer] 2)) get-process marker-position process-mark process-filter process-buffer ((byte-code "\304 \"\210\305\n\"\210\306! \223\207" [proc orig-buf orig-filter orig-marker set-process-buffer set-process-filter process-mark] 3)) set-process-buffer set-process-filter nodejs-repl--insert-and-update-status nil process-send-string nodejs-repl--wait-for-process 0.01 buffer-string string] 4 (#$ . 3136)])
#@49 Wait for Node.js process to output all results.
(defalias 'nodejs-repl--wait-for-process #[(proc string interval) "\306\302\307#\210\306\310\311#\210\312\313\307 #\314\310\"\204J \314\302\"\n\315\311\316 \f#,\206E \317\n\315\311\316 \f#,\206E \n \230)?\205Y \306\310\315#\210\320\"\210\202 \207" [proc string last-line nodejs-repl-prompt-re start regexp process-put "" running-p t replace-regexp-in-string "\\s-*$" process-get nil string-match "^[[0-9]+D$" accept-process-output inhibit-changing-match-data interval] 4 (#$ . 3993)])
#@100 Insert the output string and update the process status (properties)
when receive the output string
(defalias 'nodejs-repl--insert-and-update-status #[(proc string) "\302\303\304#\210r\305!q\210 c\210db\210\302\306\307 `{#)\207" [proc string process-put running-p t process-buffer last-line point-at-bol] 5 (#$ . 4558)])
#@59 Get copmletion candidates sending TAB to Node.js process.
(defalias 'nodejs-repl--get-candidates-from-process #[(token) "\306\307P!\310\311 \210\n\232\204Z \312\n\310\313\314\f#,\203N \315\316\317\n#\315\320\312\n#\315\321\317\n#\322\n\312\"\323\211 A!A!\322\324\325 \326#\327\"\202Z \315\317\n#\330\n!C *\207" [token candidates ret start string regexp nodejs-repl--send-string " " nil nodejs-repl-clear-line "\n" t string-match replace-regexp-in-string "" "" "\n\\{2,\\}" "\\s-*$" split-string reverse mapconcat identity " " "\\s-+" nodejs-repl--get-last-token inhibit-changing-match-data nodejs-repl-extra-espace-sequence-re] 5 (#$ . 4887)])
#@29 Send ^C to Node.js process.
(defalias 'nodejs-repl-quit-or-cancel #[nil "\300\301\302!\303\"\207" [process-send-string get-process "node" ""] 3 (#$ . 5559) nil])
#@29 Send ^U to Node.js process.
(defalias 'nodejs-repl-clear-line #[nil "\300\301!\207" [nodejs-repl--send-string ""] 2 (#$ . 5728)])
#@66 Execute a command and output the result to the temporary buffer.
(defalias 'nodejs-repl-execute #[(command &optional buf) "\304\305P!r\306\n!q\210\307 \210\310\311 #\310\312\311 #\310\313\311 #\211c\210db\210\314 `|*\207" [command ret nodejs-repl-temp-buffer-name nodejs-repl-ansi-color-sequence-re nodejs-repl--send-string "\n" get-buffer-create erase-buffer replace-regexp-in-string "" "\\(\\w\\|\\W\\)+\n" "" point-at-bol] 5 (#$ . 5865)])
#@43 Dynamically complete tokens at the point.
(defalias 'nodejs-repl-complete-from-process #[nil "\306 \205o \307 `{\310\211\310\211\311 \203L \312!\211\203F G\313U\204? \314 \313\315O\310\316\317#,\204F \320 P\202P \321 \202P \322!\n\203c \323\n!\324\325\326\n#\327\n\"\f\330=\203m \331\332!\210\f-\207" [input require-arg token candidates ret start comint-after-pmark-p comint-line-beginning-position nil nodejs-repl--in-string-p nodejs-repl--extract-require-argument 1 "[./]" 2 t string-match "require(" comint-dynamic-complete-as-filename nodejs-repl--get-last-token nodejs-repl-get-candidates replace-regexp-in-string "^require(['\"]" "" comint-dynamic-simple-complete sole delete-char -1 string regexp inhibit-changing-match-data] 5 (#$ . 6322)])
#@28 Get copmletion candidates.
(defalias 'nodejs-repl-get-candidates #[(token) "\306 \307\232\2047 \310 P\n\306\311\312\f#,\2037 \310 \313Q\n\306\311\312\f#,\2047 \202K \n\314\232\203B \306\202F \315\n!\n)\207" [candidates nodejs-repl-cache-token token start string regexp nil "" "^" t string-match ".*?[.(/'\"]" "require(" nodejs-repl--get-candidates-from-process inhibit-changing-match-data nodejs-repl-cache-candidates] 4 (#$ . 7105)])
#@44 Filter extra escape sequences from output.
(defalias 'nodejs-repl-filter-escape-sequnces #[(string) "\206 \304 \305\306p!!\212\nb\210\307 \310#\205 \311\312!\210\202 +\207" [comint-last-output-start end beg nodejs-repl-extra-espace-sequence-re point-min-marker process-mark get-buffer-process re-search-forward t replace-match ""] 4 (#$ . 7571)])
#@42 Clear caches when outputting the result.
(defalias 'nodejs-repl-clear-cache #[(string) "\302\303\211\207" [nodejs-repl-cache-token nodejs-repl-cache-candidates "" nil] 2 (#$ . 7931)])
(byte-code "\300\301N\204 \302\300\301\303\304!#\210\305\306!\204 \302\306\307\310#\210\300\207" [nodejs-repl-mode-hook variable-documentation put purecopy "Hook run when entering Node.js REPL mode.\nNo problems result if this variable is not bound.\n`add-hook' automatically binds it. (This is true for all hook variables.)" boundp nodejs-repl-mode-map definition-name nodejs-repl-mode] 5)
(defvar nodejs-repl-mode-map (make-sparse-keymap))
(byte-code "\300\301N\204 \302\300\301\303\304!#\210\302\305\306\307#\207" [nodejs-repl-mode-map variable-documentation put purecopy "Keymap for `nodejs-repl-mode'." nodejs-repl-mode-abbrev-table definition-name nodejs-repl-mode] 5)
(defvar nodejs-repl-mode-abbrev-table (progn (define-abbrev-table 'nodejs-repl-mode-abbrev-table nil) nodejs-repl-mode-abbrev-table))
(byte-code "\300\301N\204 \302\300\301\303\304!#\210\302\305\306\307#\207" [nodejs-repl-mode-abbrev-table variable-documentation put purecopy "Abbrev table for `nodejs-repl-mode'." nodejs-repl-mode derived-mode-parent comint-mode] 5)
#@216 Major mode for Node.js REPL
In addition to any hooks its parent mode `comint-mode' might have run,
this mode runs the hook `nodejs-repl-mode-hook', as the final step
during initialization.
\{nodejs-repl-mode-map}
(defalias 'nodejs-repl-mode #[nil "\306\300!\210\307\310 \210\311\312\310\313N\203 \314\311\313\310\313N#\210\315!\204'