Commits

scop  committed 5fd8356

Sync with upstream 1.6.8 <1041886539.31380.260.camel@bobcat.ods.org>.

  • Participants
  • Parent commits 145003c

Comments (0)

Files changed (9)

+2003-01-05  Ville Skyttä  <scop@xemacs.org>
+
+	* Sync with upstream 1.6.8.
+
+	* README: New.
+	* rubydb3x.el: New.
+	* rubydb3x.el.upstream: New.
+	
+	* Makefile (PKG_TYPE): Change to regular.
+	(REQUIRES): Add debug.
+	(ELCS): Add rubydb3x.elc.
+	(EXTRA_SOURCES): New, add README.
+	* package-info.in (provides): Add rubydb.
+
 2003-01-06  Ville Skyttä  <scop@xemacs.org>
 
 	* inf-ruby.el: Make auto-mode and interpreter-mode-alist
-# Makefile for Ruby modes lisp code
+# Makefile for Ruby modes lisp code.
 
 # This file is part of XEmacs.
 
 # Boston, MA 02111-1307, USA.
 
 VERSION = 1.00
-AUTHOR_VERSION =
+AUTHOR_VERSION = 1.6.8
 MAINTAINER = XEmacs Development Team <xemacs-beta@xemacs.org>
 PACKAGE = ruby-modes
-PKG_TYPE = single-file
-REQUIRES = xemacs-base
+PKG_TYPE = regular
+REQUIRES = xemacs-base debug
 CATEGORY = standard
 
-ELCS = inf-ruby.elc ruby-mode.elc
+ELCS = inf-ruby.elc ruby-mode.elc rubydb3x.elc
+
+EXTRA_SOURCES = README
 
 include ../../XEmacs.rules
 
+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
 ;;; HISTORY
 ;;; senda -  8 Apr 1998: Created.
 ;;;	 $Log$
+;;;	 Revision 1.3.2.3  2002/09/07 14:37:26  nobu
+;;;	 * misc/inf-ruby.el (inferior-ruby-error-regexp-alist): regexp
+;;;	   alist for error message from ruby.
+;;;	
+;;;	 * misc/inf-ruby.el (inferior-ruby-mode): fixed for Emacs.
+;;;	
+;;;	 * misc/inf-ruby.el (ruby-send-region): compilation-parse-errors
+;;;	   doesn't parse first line, so insert separators before each
+;;;	   evaluations.
+;;;	
 ;;;	 Revision 1.3.2.2  2002/08/19 10:06:20  nobu
 ;;;	 * misc/inf-ruby.el (inf-ruby-keys): ruby-send-definition
 ;;;	   conflicted with ruby-insert-end.
 (defvar inferior-ruby-mode-map nil
   "*Mode map for `inferior-ruby-mode'.")
 
-(pushnew '(ruby ("^\tfrom \\([^\(].*\\):\\([1-9][0-9]*\\):in \`.*\'$" 1 2))
-	 compilation-error-regexp-alist-alist)
-(pushnew '(ruby ("SyntaxError: compile error\n^\\([^\(].*\\):\\([1-9][0-9]*\\):" 1 2))
-	 compilation-error-regexp-alist-alist)
+(defconst inferior-ruby-error-regexp-alist
+       '(("SyntaxError: compile error\n^\\([^\(].*\\):\\([1-9][0-9]*\\):" 1 2)
+	 ("^\tfrom \\([^\(].*\\):\\([1-9][0-9]*\\)\\(:in `.*'\\)?$" 1 2)))
 
 (cond ((not inferior-ruby-mode-map)
        (setq inferior-ruby-mode-map
   (use-local-map inferior-ruby-mode-map)
   (setq comint-input-filter (function ruby-input-filter))
   (setq comint-get-old-input (function ruby-get-old-input))
-  (compilation-minor-mode)
-  (compilation-build-compilation-error-regexp-alist)
+  (compilation-shell-minor-mode t)
+  (make-local-variable 'compilation-error-regexp-alist)
+  (setq compilation-error-regexp-alist inferior-ruby-error-regexp-alist)
   (run-hooks 'inferior-ruby-mode-hook))
 
 (defun ruby-input-filter (str)
   "Template for irb here document terminator.
 Must not contain ruby meta characters.")
 
+(defconst ruby-eval-separator "")
+
 (defun ruby-send-region (start end)
   "Send the current region to the inferior Ruby process."
   (interactive "r")
   (let (term (file (buffer-file-name)) line)
     (save-excursion
-      (goto-char start)
-      (setq line (line-number))
-      (while (progn
-	       (setq term (apply 'format ruby-send-terminator (random) (current-time)))
-	       (re-search-forward (concat "^" (regexp-quote term) "$") end t))))
+      (save-restriction
+	(widen)
+	(goto-char start)
+	(setq line (+ start (forward-line (- start)) 1))
+	(goto-char start)
+	(while (progn
+		 (setq term (apply 'format ruby-send-terminator (random) (current-time)))
+		 (re-search-forward (concat "^" (regexp-quote term) "$") end t)))))
+    ;; compilation-parse-errors parses from second line.
+    (save-excursion
+      (let ((m (process-mark (ruby-proc))))
+	(set-buffer (marker-buffer m))
+	(goto-char m)
+	(insert ruby-eval-separator "\n")
+	(set-marker m (point))))
     (comint-send-string (ruby-proc) (format "eval <<'%s', nil, %S, %d\n" term file line))
     (comint-send-region (ruby-proc) start end)
     (comint-send-string (ruby-proc) (concat "\n" term "\n"))))

File inf-ruby.el.upstream

 ;;; HISTORY
 ;;; senda -  8 Apr 1998: Created.
 ;;;	 $Log$
+;;;	 Revision 1.3.2.3  2002/09/07 14:37:26  nobu
+;;;	 * misc/inf-ruby.el (inferior-ruby-error-regexp-alist): regexp
+;;;	   alist for error message from ruby.
+;;;	
+;;;	 * misc/inf-ruby.el (inferior-ruby-mode): fixed for Emacs.
+;;;	
+;;;	 * misc/inf-ruby.el (ruby-send-region): compilation-parse-errors
+;;;	   doesn't parse first line, so insert separators before each
+;;;	   evaluations.
+;;;	
 ;;;	 Revision 1.3.2.2  2002/08/19 10:06:20  nobu
 ;;;	 * misc/inf-ruby.el (inf-ruby-keys): ruby-send-definition
 ;;;	   conflicted with ruby-insert-end.
 (defvar inferior-ruby-mode-map nil
   "*Mode map for inferior-ruby-mode")
 
-(pushnew '(ruby ("^\tfrom \\([^\(].*\\):\\([1-9][0-9]*\\):in \`.*\'$" 1 2))
-	 compilation-error-regexp-alist-alist)
-(pushnew '(ruby ("SyntaxError: compile error\n^\\([^\(].*\\):\\([1-9][0-9]*\\):" 1 2))
-	 compilation-error-regexp-alist-alist)
+(defconst inferior-ruby-error-regexp-alist
+       '(("SyntaxError: compile error\n^\\([^\(].*\\):\\([1-9][0-9]*\\):" 1 2)
+	 ("^\tfrom \\([^\(].*\\):\\([1-9][0-9]*\\)\\(:in `.*'\\)?$" 1 2)))
 
 (cond ((not inferior-ruby-mode-map)
        (setq inferior-ruby-mode-map
   (use-local-map inferior-ruby-mode-map)
   (setq comint-input-filter (function ruby-input-filter))
   (setq comint-get-old-input (function ruby-get-old-input))
-  (compilation-minor-mode)
-  (compilation-build-compilation-error-regexp-alist)
+  (compilation-shell-minor-mode t)
+  (make-local-variable 'compilation-error-regexp-alist)
+  (setq compilation-error-regexp-alist inferior-ruby-error-regexp-alist)
   (run-hooks 'inferior-ruby-mode-hook))
 
 (defvar inferior-ruby-filter-regexp "\\`\\s *\\S ?\\S ?\\s *\\'"
   "Template for irb here document terminator.
 Must not contain ruby meta characters.")
 
+(defconst ruby-eval-separator "")
+
 (defun ruby-send-region (start end)
   "Send the current region to the inferior Ruby process."
   (interactive "r")
   (let (term (file (buffer-file-name)) line)
     (save-excursion
-      (goto-char start)
-      (setq line (line-number))
-      (while (progn
-	       (setq term (apply 'format ruby-send-terminator (random) (current-time)))
-	       (re-search-forward (concat "^" (regexp-quote term) "$") end t))))
+      (save-restriction
+	(widen)
+	(goto-char start)
+	(setq line (+ start (forward-line (- start)) 1))
+	(goto-char start)
+	(while (progn
+		 (setq term (apply 'format ruby-send-terminator (random) (current-time)))
+		 (re-search-forward (concat "^" (regexp-quote term) "$") end t)))))
+    ;; compilation-parse-errors parses from second line.
+    (save-excursion
+      (let ((m (process-mark (ruby-proc))))
+	(set-buffer (marker-buffer m))
+	(goto-char m)
+	(insert ruby-eval-separator "\n")
+	(set-marker m (point))))
     (comint-send-string (ruby-proc) (format "eval <<'%s', nil, %S, %d\n" term file line))
     (comint-send-region (ruby-proc) start end)
     (comint-send-string (ruby-proc) (concat "\n" term "\n"))))

File package-info.in

    filename FILENAME
    md5sum MD5SUM
    size SIZE
-   provides (inf-ruby ruby-mode)
+   provides (inf-ruby ruby-mode rubydb)
    requires (REQUIRES)
    type regular
 ))

File ruby-mode.el.upstream

   (make-local-variable 'paragraph-ignore-fill-prefix)
   (setq paragraph-ignore-fill-prefix t))
 
+;;;###autoload
 (defun ruby-mode ()
   "Major mode for editing ruby scripts.
 \\[ruby-indent-command] properly indents subexpressions of multi-line
+(require 'gud)
+(provide 'rubydb)
+
+;; ======================================================================
+;; rubydb functions
+
+(defgroup ruby-debug nil
+  "Ruby debugging."
+  :group 'ruby
+  :prefix "rubydb-")
+
+(defcustom rubydb-command-name "ruby"
+  "*Command for executing ruby."
+  :type 'string
+  :group 'ruby-debug)
+
+;;; History of argument lists passed to rubydb.
+(defvar gud-rubydb-history nil)
+
+(if (fboundp 'gud-overload-functions)
+    (defun gud-rubydb-massage-args (file args)
+      (cons "-r" (cons "debug" (cons file args))))
+  (defun gud-rubydb-massage-args (file args)
+      (cons "-r" (cons "debug" 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-rubydb-marker-acc "")
+(make-variable-buffer-local 'gud-rubydb-marker-acc)
+
+(defun gud-rubydb-marker-filter (string)
+  (setq gud-rubydb-marker-acc (concat gud-rubydb-marker-acc string))
+  (let ((output ""))
+
+    ;; Process all the complete markers in this chunk.
+    (while (string-match "\032\032\\([^:\n]*\\):\\([0-9]*\\):.*\n"
+			 gud-rubydb-marker-acc)
+      (setq
+
+       ;; Extract the frame position from the marker.
+       gud-last-frame
+       (cons (substring gud-rubydb-marker-acc (match-beginning 1) (match-end 1))
+	     (string-to-int (substring gud-rubydb-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-rubydb-marker-acc 0 (match-beginning 0)))
+
+       ;; Set the accumulator to the remaining text.
+       gud-rubydb-marker-acc (substring gud-rubydb-marker-acc (match-end 0))))
+
+    ;; Does the remaining text look like it might end with the
+    ;; beginning of another marker?  If it does, then keep it in
+    ;; gud-rubydb-marker-acc until we receive the rest of it.  Since we
+    ;; know the full marker regexp above failed, it's pretty simple to
+    ;; test for marker starts.
+    (if (string-match "\032.*\\'" gud-rubydb-marker-acc)
+	(progn
+	  ;; Everything before the potential marker start can be output.
+	  (setq output (concat output (substring gud-rubydb-marker-acc
+						 0 (match-beginning 0))))
+
+	  ;; Everything after, we save, to combine with later input.
+	  (setq gud-rubydb-marker-acc
+		(substring gud-rubydb-marker-acc (match-beginning 0))))
+
+      (setq output (concat output gud-rubydb-marker-acc)
+	    gud-rubydb-marker-acc ""))
+
+    output))
+
+(defun gud-rubydb-find-file (f)
+  (save-excursion
+    (let ((buf (find-file-noselect f)))
+      (set-buffer buf)
+;;      (gud-make-debug-menu)
+      buf)))
+
+;;;###autoload
+(defun rubydb (command-line)
+  "Run rubydb 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 rubydb (like this): "
+			       (if (consp gud-rubydb-history)
+				   (car gud-rubydb-history)
+				 (concat rubydb-command-name " "))
+			       nil nil
+			       '(gud-rubydb-history . 1))))
+
+  (if (not (fboundp 'gud-overload-functions))
+      (gud-common-init command-line 'gud-rubydb-massage-args
+		       'gud-rubydb-marker-filter 'gud-rubydb-find-file)
+    (gud-overload-functions '((gud-massage-args . gud-rubydb-massage-args)
+			      (gud-marker-filter . gud-rubydb-marker-filter)
+			      (gud-find-file . gud-rubydb-find-file)))
+    (gud-common-init command-line rubydb-command-name))
+
+  (gud-def gud-break  "b %l"         "\C-b" "Set breakpoint at current line.")
+;  (gud-def gud-remove "clear %l"     "\C-d" "Remove breakpoint at current line")
+  (gud-def gud-step   "s"            "\C-s" "Step one source line with display.")
+  (gud-def gud-next   "n"            "\C-n" "Step one line (skip functions).")
+  (gud-def gud-cont   "c"            "\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 'rubydb-mode-hook)
+  )

File rubydb3x.el.upstream

+(require 'gud)
+(provide 'rubydb)
+
+;; ======================================================================
+;; rubydb functions
+
+;;; History of argument lists passed to rubydb.
+(defvar gud-rubydb-history nil)
+
+(if (fboundp 'gud-overload-functions)
+    (defun gud-rubydb-massage-args (file args)
+      (cons "-r" (cons "debug" (cons file args))))
+  (defun gud-rubydb-massage-args (file args)
+      (cons "-r" (cons "debug" 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-rubydb-marker-acc "")
+(make-variable-buffer-local 'gud-rubydb-marker-acc)
+
+(defun gud-rubydb-marker-filter (string)
+  (setq gud-rubydb-marker-acc (concat gud-rubydb-marker-acc string))
+  (let ((output ""))
+
+    ;; Process all the complete markers in this chunk.
+    (while (string-match "\032\032\\([^:\n]*\\):\\([0-9]*\\):.*\n"
+			 gud-rubydb-marker-acc)
+      (setq
+
+       ;; Extract the frame position from the marker.
+       gud-last-frame
+       (cons (substring gud-rubydb-marker-acc (match-beginning 1) (match-end 1))
+	     (string-to-int (substring gud-rubydb-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-rubydb-marker-acc 0 (match-beginning 0)))
+
+       ;; Set the accumulator to the remaining text.
+       gud-rubydb-marker-acc (substring gud-rubydb-marker-acc (match-end 0))))
+
+    ;; Does the remaining text look like it might end with the
+    ;; beginning of another marker?  If it does, then keep it in
+    ;; gud-rubydb-marker-acc until we receive the rest of it.  Since we
+    ;; know the full marker regexp above failed, it's pretty simple to
+    ;; test for marker starts.
+    (if (string-match "\032.*\\'" gud-rubydb-marker-acc)
+	(progn
+	  ;; Everything before the potential marker start can be output.
+	  (setq output (concat output (substring gud-rubydb-marker-acc
+						 0 (match-beginning 0))))
+
+	  ;; Everything after, we save, to combine with later input.
+	  (setq gud-rubydb-marker-acc
+		(substring gud-rubydb-marker-acc (match-beginning 0))))
+
+      (setq output (concat output gud-rubydb-marker-acc)
+	    gud-rubydb-marker-acc ""))
+
+    output))
+
+(defun gud-rubydb-find-file (f)
+  (save-excursion
+    (let ((buf (find-file-noselect f)))
+      (set-buffer buf)
+;;      (gud-make-debug-menu)
+      buf)))
+
+(defvar rubydb-command-name "ruby"
+  "File name for executing ruby.")
+
+;;;###autoload
+(defun rubydb (command-line)
+  "Run rubydb 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 rubydb (like this): "
+			       (if (consp gud-rubydb-history)
+				   (car gud-rubydb-history)
+				 (concat rubydb-command-name " "))
+			       nil nil
+			       '(gud-rubydb-history . 1))))
+
+  (if (not (fboundp 'gud-overload-functions))
+      (gud-common-init command-line 'gud-rubydb-massage-args
+		       'gud-rubydb-marker-filter 'gud-rubydb-find-file)
+    (gud-overload-functions '((gud-massage-args . gud-rubydb-massage-args)
+			      (gud-marker-filter . gud-rubydb-marker-filter)
+			      (gud-find-file . gud-rubydb-find-file)))
+    (gud-common-init command-line rubydb-command-name))
+
+  (gud-def gud-break  "b %l"         "\C-b" "Set breakpoint at current line.")
+;  (gud-def gud-remove "clear %l"     "\C-d" "Remove breakpoint at current line")
+  (gud-def gud-step   "s"            "\C-s" "Step one source line with display.")
+  (gud-def gud-next   "n"            "\C-n" "Step one line (skip functions).")
+  (gud-def gud-cont   "c"            "\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 'rubydb-mode-hook)
+  )