mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* misc/README: Add a note about ruby-electric.el.
* misc/ruby-mode.el (ruby-non-block-do-re): Fix ruby-non-block-do-re. [ruby-core:03719] * misc/inf-ruby.el: Synchronize the comment section with trunk. * misc/README, misc/rdebug.el: Add rdebug.el, Emacs ruby-debug interface based on rubydb3x.el; submitted by Martin Nordholts <enselic AT gmail.com> in [ruby-bugs:PR#9023]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@12032 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
949981f691
commit
5fc3a4126c
5 changed files with 176 additions and 16 deletions
13
ChangeLog
13
ChangeLog
|
|
@ -1,3 +1,16 @@
|
|||
Sun Mar 11 19:04:29 2007 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* misc/README: Add a note about ruby-electric.el.
|
||||
|
||||
* misc/ruby-mode.el (ruby-non-block-do-re): Fix
|
||||
ruby-non-block-do-re. [ruby-core:03719]
|
||||
|
||||
* misc/inf-ruby.el: Synchronize the comment section with trunk.
|
||||
|
||||
* misc/README, misc/rdebug.el: Add rdebug.el, Emacs ruby-debug
|
||||
interface based on rubydb3x.el; submitted by Martin Nordholts
|
||||
<enselic AT gmail.com> in [ruby-bugs:PR#9023].
|
||||
|
||||
Sun Mar 11 17:51:46 2007 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* ext/dl/mkcallback.rb (mkfunc): Make sure that a callback
|
||||
|
|
|
|||
12
misc/README
12
misc/README
|
|
@ -1,5 +1,7 @@
|
|||
README this file
|
||||
inf-ruby.el program to run ruby under emacs
|
||||
ruby-mode.el ruby mode for emacs
|
||||
rubydb2x.el ruby debugger support for emacs 19.2x or before
|
||||
rubydb3x.el ruby debugger support for emacs 19.3x or later
|
||||
README this file
|
||||
inf-ruby.el program to run ruby under emacs
|
||||
ruby-mode.el ruby mode for emacs
|
||||
rubydb2x.el ruby debugger support for emacs 19.2x or before
|
||||
rubydb3x.el ruby debugger support for emacs 19.3x or later
|
||||
ruby-electric.el emacs minor mode providing electric commands
|
||||
rdebug.el ruby-debug (rdebug) support for emacs 19.3x or later
|
||||
|
|
|
|||
|
|
@ -35,7 +35,15 @@
|
|||
;;; HISTORY
|
||||
;;; senda - 8 Apr 1998: Created.
|
||||
;;; $Log$
|
||||
;;; Revision 1.6.2.1 2004/07/27 07:51:28 matz
|
||||
;;; Revision 1.7 2004/07/27 08:11:36 matz
|
||||
;;; * eval.c (rb_eval): copy on write for argument local variable
|
||||
;;; assignment.
|
||||
;;;
|
||||
;;; * eval.c (assign): ditto.
|
||||
;;;
|
||||
;;; * eval.c (rb_call0): update ruby_frame->argv with the default
|
||||
;;; value used for the optional arguments.
|
||||
;;;
|
||||
;;; * object.c (Init_Object): "===" calls rb_obj_equal() directly.
|
||||
;;; [ruby-list:39937]
|
||||
;;;
|
||||
|
|
|
|||
136
misc/rdebug.el
Normal file
136
misc/rdebug.el
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
;; This file adds support for ruby-debug (rdebug) in Emacs.
|
||||
;; Copyright (C) 2007 Martin Nordholts <enselic@gmail.com>
|
||||
;;
|
||||
;; This file is based on 'rubydb3x.el' that comes with Ruby which is
|
||||
;; Copyright (C) Yukihiro Matsumoto aka Matz
|
||||
;;
|
||||
;; Installation:
|
||||
;; -------------
|
||||
;;
|
||||
;; 1. Make sure you have ruby-debug on your system (test by running
|
||||
;; the commmand 'rdebug -v' in a shell).
|
||||
;;
|
||||
;; 2. Copy this file into e.g. ~/.elisp and make sure this is in
|
||||
;; your ~/.emacs:
|
||||
;;
|
||||
;; (add-to-list 'load-path "~/.elisp")
|
||||
;; (load-library "rdebug")
|
||||
;;
|
||||
;; you can then start the debugger with M-x rdebug
|
||||
;;
|
||||
;; 3. Setup convenient keybindings etc. This is what I have:
|
||||
;;
|
||||
;; (global-set-key [f9] 'gud-step)
|
||||
;; (global-set-key [f10] 'gud-next)
|
||||
;; (global-set-key [f11] 'gud-cont)
|
||||
;;
|
||||
;; (global-set-key "\C-c\C-d" 'rdebug)
|
||||
;;
|
||||
;; 4. Debug like crazy!
|
||||
;;
|
||||
;; Bugs:
|
||||
;; -----
|
||||
;;
|
||||
;; Basic functionality works fine, though there might be a bug hiding somewhere.
|
||||
|
||||
(require 'gud)
|
||||
(provide 'rdebug)
|
||||
|
||||
;; ======================================================================
|
||||
;; rdebug functions
|
||||
|
||||
;;; History of argument lists passed to rdebug.
|
||||
(defvar gud-rdebug-history nil)
|
||||
|
||||
(if (fboundp 'gud-overload-functions)
|
||||
(defun gud-rdebug-massage-args (file args)
|
||||
(cons file args))
|
||||
(defun gud-rdebug-massage-args (file args)
|
||||
args))
|
||||
|
||||
;; There's no guarantee that Emacs will hand the filter the entire
|
||||
;; marker at once; it could be broken up across several strings. We
|
||||
;; might even receive a big chunk with several markers in it. If we
|
||||
;; receive a chunk of text which looks like it might contain the
|
||||
;; beginning of a marker, we save it here between calls to the
|
||||
;; filter.
|
||||
(defvar gud-rdebug-marker-acc "")
|
||||
(make-variable-buffer-local 'gud-rdebug-marker-acc)
|
||||
|
||||
(defun gud-rdebug-marker-filter (string)
|
||||
(setq gud-rdebug-marker-acc (concat gud-rdebug-marker-acc string))
|
||||
(let ((output ""))
|
||||
|
||||
;; Process all the complete markers in this chunk.
|
||||
(while (string-match "\\([^:\n]*\\):\\([0-9]+\\):.*\n"
|
||||
gud-rdebug-marker-acc)
|
||||
(setq
|
||||
|
||||
;; Extract the frame position from the marker.
|
||||
gud-last-frame
|
||||
(cons (substring gud-rdebug-marker-acc (match-beginning 1) (match-end 1))
|
||||
(string-to-int (substring gud-rdebug-marker-acc
|
||||
(match-beginning 2)
|
||||
(match-end 2))))
|
||||
|
||||
|
||||
;; Append any text before the marker to the output we're going
|
||||
;; to return - we don't include the marker in this text.
|
||||
output (concat output
|
||||
(substring gud-rdebug-marker-acc 0 (match-beginning 0)))
|
||||
|
||||
;; Set the accumulator to the remaining text.
|
||||
gud-rdebug-marker-acc (substring gud-rdebug-marker-acc (match-end 0))))
|
||||
|
||||
(setq output (concat output gud-rdebug-marker-acc)
|
||||
gud-rdebug-marker-acc "")
|
||||
|
||||
output))
|
||||
|
||||
(defun gud-rdebug-find-file (f)
|
||||
(save-excursion
|
||||
(let ((buf (find-file-noselect f)))
|
||||
(set-buffer buf)
|
||||
;; (gud-make-debug-menu)
|
||||
buf)))
|
||||
|
||||
(defvar rdebug-command-name "rdebug"
|
||||
"File name for executing rdebug.")
|
||||
|
||||
;;;###autoload
|
||||
(defun rdebug (command-line)
|
||||
"Run rdebug on program FILE in buffer *gud-FILE*.
|
||||
The directory containing FILE becomes the initial working directory
|
||||
and source-file directory for your debugger."
|
||||
(interactive
|
||||
(list (read-from-minibuffer "Run rdebug (like this): "
|
||||
(if (consp gud-rdebug-history)
|
||||
(car gud-rdebug-history)
|
||||
(concat rdebug-command-name " "))
|
||||
nil nil
|
||||
'(gud-rdebug-history . 1))))
|
||||
|
||||
(if (not (fboundp 'gud-overload-functions))
|
||||
(gud-common-init command-line 'gud-rdebug-massage-args
|
||||
'gud-rdebug-marker-filter 'gud-rdebug-find-file)
|
||||
(gud-overload-functions '((gud-massage-args . gud-rdebug-massage-args)
|
||||
(gud-marker-filter . gud-rdebug-marker-filter)
|
||||
(gud-find-file . gud-rdebug-find-file)))
|
||||
(gud-common-init command-line rdebug-command-name))
|
||||
|
||||
(gud-def gud-break "break %d%f:%l" "\C-b" "Set breakpoint at current line in current file.")
|
||||
; (gud-def gud-remove "delete %d%f:%l" "\C-d" "Remove breakpoint at current line in current file.")
|
||||
(gud-def gud-step "step" "\C-s" "Step one source line with display.")
|
||||
(gud-def gud-next "next" "\C-n" "Step one line (skip functions).")
|
||||
(gud-def gud-cont "cont" "\C-r" "Continue with display.")
|
||||
(gud-def gud-finish "finish" "\C-f" "Finish executing current function.")
|
||||
(gud-def gud-up "up %p" "<" "Up N stack frames (numeric arg).")
|
||||
(gud-def gud-down "down %p" ">" "Down N stack frames (numeric arg).")
|
||||
(gud-def gud-print "p %e" "\C-p" "Evaluate ruby expression at point.")
|
||||
|
||||
(setq comint-prompt-regexp "^(rdb:-) ")
|
||||
(if (boundp 'comint-last-output-start)
|
||||
(set-marker comint-last-output-start (point)))
|
||||
(set (make-local-variable 'paragraph-start) comint-prompt-regexp)
|
||||
(run-hooks 'rdebug-mode-hook)
|
||||
)
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
)
|
||||
|
||||
(defconst ruby-non-block-do-re
|
||||
"\\(while\\|until\\|for\\|rescue\\)\\>"
|
||||
"\\(while\\|until\\|for\\|rescue\\)\\>[^_]"
|
||||
)
|
||||
|
||||
(defconst ruby-indent-beg-re
|
||||
|
|
@ -45,7 +45,7 @@
|
|||
(concat ruby-modifier-beg-re "\\|" ruby-block-op-re)
|
||||
)
|
||||
|
||||
(defconst ruby-block-end-re "end")
|
||||
(defconst ruby-block-end-re "\\<end\\>")
|
||||
|
||||
(defconst ruby-here-doc-beg-re
|
||||
"<<\\(-\\)?\\(\\([a-zA-Z0-9_]+\\)\\|[\"]\\([^\"]+\\)[\"]\\|[']\\([^']+\\)[']\\)")
|
||||
|
|
@ -61,13 +61,13 @@
|
|||
(defconst ruby-delimiter
|
||||
(concat "[?$/%(){}#\"'`.:]\\|<<\\|\\[\\|\\]\\|\\<\\("
|
||||
ruby-block-beg-re
|
||||
"\\|" ruby-block-end-re
|
||||
"\\)\\>\\|^=begin\\|" ruby-here-doc-beg-re)
|
||||
"\\)\\>\\|" ruby-block-end-re
|
||||
"\\|^=begin\\|" ruby-here-doc-beg-re)
|
||||
)
|
||||
|
||||
(defconst ruby-negative
|
||||
(concat "^[ \t]*\\(\\(" ruby-block-mid-re "\\)\\>\\|\\("
|
||||
ruby-block-end-re "\\)\\>\\|}\\|\\]\\)")
|
||||
(concat "^[ \t]*\\(\\(" ruby-block-mid-re "\\)\\>\\|"
|
||||
ruby-block-end-re "\\|}\\|\\]\\)")
|
||||
)
|
||||
|
||||
(defconst ruby-operator-chars "-,.+*/%&|^~=<>:")
|
||||
|
|
@ -383,7 +383,7 @@ The variable ruby-indent-level controls the amount of indentation.
|
|||
(t
|
||||
(setq in-string (point))
|
||||
(goto-char end))))
|
||||
((looking-at "/=")
|
||||
((looking-at "/=")
|
||||
(goto-char pnt))
|
||||
((looking-at "/")
|
||||
(cond
|
||||
|
|
@ -454,7 +454,7 @@ The variable ruby-indent-level controls the amount of indentation.
|
|||
(setq depth (1- depth)))
|
||||
(setq nest (cdr nest))
|
||||
(goto-char pnt))
|
||||
((looking-at (concat "\\<\\(" ruby-block-end-re "\\)\\>"))
|
||||
((looking-at ruby-block-end-re)
|
||||
(if (or (and (not (bolp))
|
||||
(progn
|
||||
(forward-char -1)
|
||||
|
|
@ -782,7 +782,8 @@ An end of a defun is found by moving forward from the beginning of one."
|
|||
(defun ruby-move-to-block (n)
|
||||
(let (start pos done down)
|
||||
(setq start (ruby-calculate-indent))
|
||||
(setq down (looking-at (concat "\\<\\(" (if (< n 0) ruby-block-end-re ruby-block-beg-re) "\\)\\>")))
|
||||
(setq down (looking-at (if (< n 0) ruby-block-end-re
|
||||
(concat "\\<\\(" ruby-block-beg-re "\\)\\>"))))
|
||||
(while (and (not done) (not (if (< n 0) (bobp) (eobp))))
|
||||
(forward-line n)
|
||||
(cond
|
||||
|
|
@ -893,7 +894,7 @@ An end of a defun is found by moving forward from the beginning of one."
|
|||
(?:
|
||||
(forward-char -1)
|
||||
(eq (char-before) :)))))
|
||||
(if (looking-at (concat "\\<\\(" ruby-block-end-re "\\)\\>"))
|
||||
(if (looking-at ruby-block-end-re)
|
||||
(ruby-beginning-of-block))
|
||||
nil))
|
||||
(setq i (1- i)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue