Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 105 lines (85 sloc) 4.481 kB
511dc44 initial import
Laurent Sansonetti authored
1 (require 'gud)
2 (provide 'rubydb)
3
4 ;; ======================================================================
5 ;; rubydb functions
6
7 ;;; History of argument lists passed to rubydb.
8 (defvar gud-rubydb-history nil)
9
10 (defun gud-rubydb-massage-args (file args)
11 (cons "-I" (cons "." (cons "-r" (cons "debug" (cons file args))))))
12
13 ;; There's no guarantee that Emacs will hand the filter the entire
14 ;; marker at once; it could be broken up across several strings. We
15 ;; might even receive a big chunk with several markers in it. If we
16 ;; receive a chunk of text which looks like it might contain the
17 ;; beginning of a marker, we save it here between calls to the
18 ;; filter.
19 (defvar gud-rubydb-marker-acc "")
20
21 (defun gud-rubydb-marker-filter (string)
22 (save-match-data
23 (setq gud-marker-acc (concat gud-marker-acc string))
24 (let ((output ""))
25
26 ;; Process all the complete markers in this chunk.
27 (while (string-match "\032\032\\([^:\n]*\\):\\([0-9]*\\):.*\n"
28 gud-marker-acc)
29 (setq
30
31 ;; Extract the frame position from the marker.
32 gud-last-frame
33 (cons (substring gud-marker-acc (match-beginning 1) (match-end 1))
34 (string-to-int (substring gud-marker-acc
35 (match-beginning 2)
36 (match-end 2))))
37
38 ;; Append any text before the marker to the output we're going
39 ;; to return - we don't include the marker in this text.
40 output (concat output
41 (substring gud-marker-acc 0 (match-beginning 0)))
42
43 ;; Set the accumulator to the remaining text.
44 gud-marker-acc (substring gud-marker-acc (match-end 0))))
45
46 ;; Does the remaining text look like it might end with the
47 ;; beginning of another marker? If it does, then keep it in
48 ;; gud-marker-acc until we receive the rest of it. Since we
49 ;; know the full marker regexp above failed, it's pretty simple to
50 ;; test for marker starts.
51 (if (string-match "\032.*\\'" gud-marker-acc)
52 (progn
53 ;; Everything before the potential marker start can be output.
54 (setq output (concat output (substring gud-marker-acc
55 0 (match-beginning 0))))
56
57 ;; Everything after, we save, to combine with later input.
58 (setq gud-marker-acc
59 (substring gud-marker-acc (match-beginning 0))))
60
61 (setq output (concat output gud-marker-acc)
62 gud-marker-acc ""))
63
64 output)))
65
66 (defun gud-rubydb-find-file (f)
67 (find-file-noselect f))
68
69 (defvar rubydb-command-name "ruby"
70 "File name for executing ruby.")
71
72 ;;;###autoload
73 (defun rubydb (command-line)
74 "Run rubydb on program FILE in buffer *gud-FILE*.
75 The directory containing FILE becomes the initial working directory
76 and source-file directory for your debugger."
77 (interactive
78 (list (read-from-minibuffer "Run rubydb (like this): "
79 (if (consp gud-rubydb-history)
80 (car gud-rubydb-history)
81 (concat rubydb-command-name " "))
82 nil nil
83 '(gud-rubydb-history . 1))))
84
85 (gud-overload-functions '((gud-massage-args . gud-rubydb-massage-args)
86 (gud-marker-filter . gud-rubydb-marker-filter)
87 (gud-find-file . gud-rubydb-find-file)
88 ))
89 (gud-common-init command-line)
90
91 (gud-def gud-break "b %l" "\C-b" "Set breakpoint at current line.")
92 ; (gud-def gud-remove "clear %l" "\C-d" "Remove breakpoint at current line")
93 (gud-def gud-step "s" "\C-s" "Step one source line with display.")
94 (gud-def gud-next "n" "\C-n" "Step one line (skip functions).")
95 (gud-def gud-cont "c" "\C-r" "Continue with display.")
96 (gud-def gud-finish "finish" "\C-f" "Finish executing current function.")
97 (gud-def gud-up "up %p" "<" "Up N stack frames (numeric arg).")
98 (gud-def gud-down "down %p" ">" "Down N stack frames (numeric arg).")
99 (gud-def gud-print "p %e" "\C-p" "Evaluate ruby expression at point.")
100
101 (setq comint-prompt-regexp "^(rdb:-) ")
102 (setq paragraph-start comint-prompt-regexp)
103 (run-hooks 'rubydb-mode-hook)
104 )
Something went wrong with that request. Please try again.