]> code.delx.au - gnu-emacs-elpa/blob - packages/realgud/realgud/debugger/nodejs/nodejs.el
23b7a381a18d957d9cffcea5f9f911e37e9d248b
[gnu-emacs-elpa] / packages / realgud / realgud / debugger / nodejs / nodejs.el
1 ;;; Copyright (C) 2014-2015 Rocky Bernstein <rocky@gnu.org>
2 ;; `nodejs' Main interface to nodejs debugger via Emacs
3 (require 'list-utils)
4 (require 'load-relative)
5 (require-relative-list '("../../common/helper") "realgud-")
6 (require-relative-list '("../../common/run") "realgud:")
7 (require-relative-list '("core" "track-mode") "realgud:nodejs-")
8
9 (declare-function realgud:nodejs-remove-ansi-shmutz 'realgud-core)
10 (declare-function realgud:run-debugger 'realgud:run)
11
12 ;; This is needed, or at least the docstring part of it is needed to
13 ;; get the customization menu to work in Emacs 24.
14 (defgroup realgud:nodejs nil
15 "The realgud interface to the nodejs debugger"
16 :group 'realgud
17 :version "24.1")
18
19 ;; -------------------------------------------------------------------
20 ;; User-definable variables
21 ;;
22
23 (defcustom realgud:nodejs-command-name
24 "node debug"
25 "File name for executing the Javascript debugger and command options.
26 This should be an executable on your path, or an absolute file name."
27 :type 'string
28 :group 'realgud:nodejs)
29
30 ;; -------------------------------------------------------------------
31 ;; The end.
32 ;;
33
34 (declare-function nodejs-track-mode 'realgud-nodejs-track-mode)
35 (declare-function nodejs-query-cmdline 'realgud:nodejs-core)
36 (declare-function nodejs-parse-cmd-args 'realgud:nodejs-core)
37 (declare-function realgud:run-process 'realgud:run)
38
39 ;;;###autoload
40 (defun realgud:nodejs (&optional opt-cmd-line no-reset)
41 "Invoke the nodejs shell debugger and start the Emacs user interface.
42
43 String OPT-CMD-LINE specifies how to run nodejs.
44
45 OPT-CMD-LINE is treated like a shell string; arguments are
46 tokenized by `split-string-and-unquote'. The tokenized string is
47 parsed by `nodejs-parse-cmd-args' and path elements found by that
48 are expanded using `realgud:expand-file-name-if-exists'.
49
50 Normally, command buffers are reused when the same debugger is
51 reinvoked inside a command buffer with a similar command. If we
52 discover that the buffer has prior command-buffer information and
53 NO-RESET is nil, then that information which may point into other
54 buffers and source buffers which may contain marks and fringe or
55 marginal icons is reset. See `loc-changes-clear-buffer' to clear
56 fringe and marginal icons.
57 "
58 (interactive)
59 (let ((cmd-buf
60 (realgud:run-debugger "nodejs"
61 'nodejs-query-cmdline 'nodejs-parse-cmd-args
62 'realgud:nodejs-minibuffer-history
63 opt-cmd-line no-reset)))
64 (if cmd-buf
65 (with-current-buffer cmd-buf
66 ;; FIXME should allow customization whether to do or not
67 ;; and also only do if hook is not already there.
68 (realgud:nodejs-remove-ansi-shmutz)
69 )
70 )))
71
72 ;; There is already a nodejs command in `nodejs-repl'.
73 ;; (defalias 'nodejs 'realgud:nodejs)
74
75 (provide-me "realgud-")