--dNVw/oxT6P3NptCZqjm
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hello, 

attached is a patch with some trivial changes to ruby-mode.el and
inf-ruby.el, mainly to enable configuration of these modes through the
customization menu, as well as some little documentation tuneups.  I did
this while I was adding these to XEmacs prog-modes package, see
http://cvs.xemacs.org/viewcvs.cgi/XEmacs/packages/xemacs-packages/prog-modes/

The patch is against ruby-mode.el version 1.25.2.8 and inf-ruby.el
version 1.3.  Note that I have messed around with the CVS-generated tags
in the top of ruby-mode.el, please ignore these changes.  They are there
only because otherwise the XEmacs CVS would clobber them. 

It would be cool if someone could add Ruby's copyright statement (or
just the GPL, whatever the policy is) into the top of all misc/*.el
files so people browsing the XEmacs CVS repository and/or source files
would have a better idea where do they come from. 

I will be adding rubydb3x.el to XEmacs soonish, too. 

-- 
Ville Skyttville.skytta / xemacs.org

--dNVw/oxT6P3NptCZqjm
Content-Disposition: attachment; filename=inf-ruby.patch
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; CHARSET=ISO-8859-1

--- inf-ruby.el.orig	Thu Feb 28 02:06:41 2002
+++ inf-ruby.el	Thu Feb 28 10:46:33 2002
@@ -72,35 +72,37 @@
 (require 'comint)
 (require 'ruby-mode)
 
-;;
-;; you may change these variables
-;;
-;(defvar ruby-program-name "rbc --noreadline"
-;  "*Program invoked by the run-ruby command")
-;
-;(defvar inferior-ruby-first-prompt-pattern "^rbc0> *"
-;  "first prompt regex pattern of ruby interpreter.")
-;
-;(defvar inferior-ruby-prompt-pattern "^\\(rbc.[>*\"'] *\\)+"
-;  "prompt regex pattern of ruby interpreter.")
+(defgroup ruby-inferior-mode nil
+  "Major mode for interacting with an inferior ruby (irb) process."
+  :group 'ruby
+  :prefix "inferior-ruby-")
 
 ;;;; for irb
-(defvar ruby-program-name "irb --inf-ruby-mode"
-  "*Program invoked by the run-ruby command")
-
-(defvar inferior-ruby-first-prompt-pattern "^irb(.*)[0-9:]+0> *"
-  "first prompt regex pattern of ruby interpreter.")
-
-(defvar inferior-ruby-prompt-pattern "^\\(irb(.*)[0-9:]+[>*\"'] *\\)+"
-  "prompt regex pattern of ruby interpreter.")
+(defcustom ruby-program-name "irb --inf-ruby-mode"
+  "*Program invoked by the `run-ruby' command."
+  :type 'string
+  :group 'ruby-inferior-mode)
+
+(defcustom inferior-ruby-first-prompt-pattern "^irb(.*)[0-9:]+0> *"
+  "*First prompt regex pattern of ruby interpreter."
+  :type 'regexp
+  :group 'ruby-inferior-mode)
+
+(defcustom inferior-ruby-prompt-pattern "^\\(irb(.*)[0-9:]+[>*\"'] *\\)+"
+  "*Prompt regex pattern of ruby interpreter."
+  :type 'regexp
+  :group 'ruby-inferior-mode)
 
 ;;
 ;; mode variables
 ;;
-(defvar inferior-ruby-mode-hook nil
-  "*Hook for customising inferior-ruby mode.")
+(defcustom inferior-ruby-mode-hook nil
+  "*Hook for customising `inferior-ruby-mode'."
+  :type 'hook
+  :group 'ruby-inferior-mode)
+
 (defvar inferior-ruby-mode-map nil
-  "*Mode map for inferior-ruby-mode")
+  "*Mode map for `inferior-ruby-mode'.")
 
 (cond ((not inferior-ruby-mode-map)
        (setq inferior-ruby-mode-map
@@ -111,8 +113,15 @@
        (define-key inferior-ruby-mode-map "\C-c\C-l" 'ruby-load-file)
 ))
 
+(defcustom inferior-ruby-filter-regexp "\\`\\s *\\S ?\\S ?\\s *\\'"
+  "*Input matching this regexp are not saved on the history list.
+Defaults to a regexp ignoring all inputs of 0, 1, or 2 letters."
+  :type 'regexp
+  :group 'ruby-inferior-mode)
+
+;;;###autoload
 (defun inf-ruby-keys ()
-  "Set local key defs for inf-ruby in ruby-mode"
+  "Set local key defs for inf-ruby in `ruby-mode'."
   (define-key ruby-mode-map "\M-\C-x" 'ruby-send-definition)
 ;  (define-key ruby-mode-map "\C-x\C-e" 'ruby-send-last-sexp)
   (define-key ruby-mode-map "\C-c\C-e" 'ruby-send-definition)
@@ -124,7 +133,8 @@
   (define-key ruby-mode-map "\C-c\C-s" 'run-ruby)
 )
 
-(defvar ruby-buffer nil "current ruby (actually irb) process buffer.")
+(defvar ruby-buffer nil
+  "Current ruby (actually irb) process buffer.")
 
 (defun inferior-ruby-mode ()
   "Major mode for interacting with an inferior ruby (irb) process.
@@ -132,32 +142,44 @@
 The following commands are available:
 \\{inferior-ruby-mode-map}
 
-A ruby process can be fired up with M-x run-ruby.
+A ruby process can be fired up with \\[run-ruby].
+
+Customisation:
 
-Customisation: Entry to this mode runs the hooks on comint-mode-hook and
-inferior-ruby-mode-hook (in that order).
+Entry to this mode runs the hooks on `comint-mode-hook' and
+`inferior-ruby-mode-hook' (in that order).
 
 You can send text to the inferior ruby process from other buffers containing
 Ruby source.
-    switch-to-ruby switches the current buffer to the ruby process buffer.
-    ruby-send-definition sends the current definition to the ruby process.
-    ruby-send-region sends the current region to the ruby process.
+    `switch-to-ruby' switches the current buffer to the ruby process buffer.
+    `ruby-send-definition' sends the current definition to the ruby process.
+    `ruby-send-region' sends the current region to the ruby process.
 
-    ruby-send-definition-and-go, ruby-send-region-and-go,
+    `ruby-send-definition-and-go', `ruby-send-region-and-go',
         switch to the ruby process buffer after sending their text.
+
 For information on running multiple processes in multiple buffers, see
-documentation for variable ruby-buffer.
+documentation for variable `ruby-buffer'.
 
 Commands:
-Return after the end of the process' output sends the text from the 
-    end of process to point.
-Return before the end of the process' output copies the sexp ending at point
-    to the end of the process' output, and sends it.
+
+Return after the end of the process' output sends the text from the end of
+process to point.
+
+Return before the end of the process' output copies the sexp ending at
+point to the end of the process' output, and sends it.
+
 Delete converts tabs to spaces as it moves back.
-Tab indents for ruby; with argument, shifts rest
-    of expression rigidly with the current line.
+
+Tab indents for ruby; with argument, shifts rest of expression rigidly with
+the current line.
+
 C-M-q does Tab on each line starting within following expression.
-Paragraphs are separated only by blank lines.  # start comments.
+
+Paragraphs are separated only by blank lines.
+
+# start comments.
+
 If you accidentally suspend your process, use \\[comint-continue-subjob]
 to continue it."
   (interactive)
@@ -175,12 +197,8 @@
   (setq comint-get-old-input (function ruby-get-old-input))
   (run-hooks 'inferior-ruby-mode-hook))
 
-(defvar inferior-ruby-filter-regexp "\\`\\s *\\S ?\\S ?\\s *\\'"
-  "*Input matching this regexp are not saved on the history list.
-Defaults to a regexp ignoring all inputs of 0, 1, or 2 letters.")
-
 (defun ruby-input-filter (str)
-  "Don't save anything matching inferior-ruby-filter-regexp"
+  "Don't save anything matching `inferior-ruby-filter-regexp'."
   (not (string-match inferior-ruby-filter-regexp str)))
 
 ;; adapted from replace-in-string in XEmacs (subr.el)
@@ -194,7 +212,7 @@
     (concat rtn-str (substring str start))))
 
 (defun ruby-get-old-input ()
-  "Snarf the sexp ending at point"
+  "Snarf the sexp ending at point."
   (save-excursion
     (let ((end (point)))
       (re-search-backward inferior-ruby-first-prompt-pattern)
@@ -215,6 +233,7 @@
 		 (ruby-args-to-list (substring string pos
 						 (length string)))))))))
 
+;;;###autoload
 (defun run-ruby (cmd)
   "Run an inferior Ruby process, input and output via buffer *ruby*.
 If there is a process already running in `*ruby*', switch to that buffer.
@@ -261,7 +280,7 @@
   (interactive "P")
   (if (get-buffer ruby-buffer)
       (pop-to-buffer ruby-buffer)
-      (error "No current process buffer. See variable ruby-buffer."))
+      (error "No current process buffer. See variable `ruby-buffer'."))
   (cond (eob-p
 	 (push-mark)
 	 (goto-char (point-max)))))
@@ -283,14 +302,13 @@
 (defvar ruby-source-modes '(ruby-mode)
   "*Used to determine if a buffer contains Ruby source code.
 If it's loaded into a buffer that is in one of these major modes, it's
-considered a ruby source file by ruby-load-file.
+considered a ruby source file by `ruby-load-file'.
 Used by these commands to determine defaults.")
 
 (defvar ruby-prev-l/c-dir/file nil
   "Caches the last (directory . file) pair.
-Caches the last pair used in the last ruby-load-file command.
-Used for determining the default in the 
-next one.")
+Caches the last pair used in the last `ruby-load-file' command.
+Used for determining the default in the next one.")
 
 (defun ruby-load-file (file-name)
   "Load a Ruby file into the inferior Ruby process."
@@ -305,12 +323,12 @@
 					    "\"\)\n")))
 
 (defun ruby-proc ()
-  "Returns the current ruby process. See variable ruby-buffer."
+  "Returns the current ruby process. See variable `ruby-buffer'."
   (let ((proc (get-buffer-process (if (eq major-mode 'inferior-ruby-mode)
 				      (current-buffer)
 				    ruby-buffer))))
     (or proc
-	(error "No current process. See variable ruby-buffer"))))
+	(error "No current process. See variable `ruby-buffer'."))))
 
 ;;; Do the user's customisation...
 
@@ -320,6 +338,12 @@
 	
 (run-hooks 'inf-ruby-load-hook)
 
+;;;###autoload
+(add-to-list 'interpreter-mode-alist '("ruby" . ruby-mode))
+
+;;;###autoload
+(add-hook 'ruby-mode-hook '(lambda () (inf-ruby-keys)))
+
 (provide 'inf-ruby)
 
 ;;; inf-ruby.el ends here

--dNVw/oxT6P3NptCZqjm
Content-Disposition: attachment; filename=ruby-mode.el.patch
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; CHARSET=ISO-8859-1

--- ruby-mode.el.orig	Thu Feb 28 10:54:53 2002
+++ ruby-mode.el	Thu Feb 28 10:59:50 2002
@@ -1,18 +1,28 @@
 ;;;
 ;;;  ruby-mode.el -
 ;;;
-;;;  $Author: nobu $
-;;;  $Date: 2002/02/22 11:24:27 $
+;;;  Author: nobu
+;;;  Date: 2002/02/22 11:24:27
 ;;;  created at: Fri Feb  4 14:49:13 JST 1994
 ;;;
 
-(defconst ruby-mode-revision "$Revision: 1.25.2.8 $")
+(defconst ruby-mode-revision "Revision: 1.25.2.8")
 
 (defconst ruby-mode-version
   (progn
    (string-match "[0-9.]+" ruby-mode-revision)
    (substring ruby-mode-revision (match-beginning 0) (match-end 0))))
 
+(defgroup ruby nil
+  "Major mode for editing ruby scripts."
+  :group 'languages
+  :prefix "ruby-")
+
+(defcustom ruby-indent-level 2
+  "*Indentation of ruby statements."
+  :type 'integer
+  :group 'ruby)
+
 (defconst ruby-block-beg-re
   "class\\|module\\|def\\|if\\|unless\\|case\\|while\\|until\\|for\\|begin\\|do"
   )
@@ -66,11 +76,11 @@
 (defconst ruby-symbol-re (concat "[" ruby-symbol-chars "]"))
 
 (defvar ruby-mode-abbrev-table nil
-  "Abbrev table in use in ruby-mode buffers.")
+  "Abbrev table in use in `ruby-mode' buffers.")
 
 (define-abbrev-table 'ruby-mode-abbrev-table ())
 
-(defvar ruby-mode-map nil "Keymap used in ruby mode.")
+(defvar ruby-mode-map nil "Keymap used in `ruby-mode'.")
 
 (if ruby-mode-map
     nil
@@ -90,7 +100,7 @@
   (define-key ruby-mode-map "\C-m" 'newline))
 
 (defvar ruby-mode-syntax-table nil
-  "Syntax table in use in ruby-mode buffers.")
+  "Syntax table in use in `ruby-mode' buffers.")
 
 (if ruby-mode-syntax-table
     ()
@@ -123,9 +133,6 @@
   (modify-syntax-entry ?\] ")[" ruby-mode-syntax-table)
   )
 
-(defvar ruby-indent-level 2
-  "*Indentation of ruby statements.")
-
 (eval-when-compile (require 'cl))
 (defun ruby-imenu-create-index ()
   (let ((index-alist '())
@@ -175,13 +182,14 @@
   (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
 class, module, def, if, while, for, do, and case statements, taking
 nesting into account.
 
-The variable ruby-indent-level controls the amount of indentation.
+The variable `ruby-indent-level' controls the amount of indentation.
 \\{ruby-mode-map}"
   (interactive)
   (kill-all-local-variables)
@@ -642,12 +650,12 @@
   (back-to-indentation))
 
 (defun ruby-beginning-of-block ()
-  "Move backward to next beginning-of-block"
+  "Move backward to next beginning-of-block."
   (interactive)
   (ruby-move-to-block -1))
 
 (defun ruby-end-of-block ()
-  "Move forward to next beginning-of-block"
+  "Move forward to next beginning-of-block."
   (interactive)
   (ruby-move-to-block 1))
 
@@ -837,7 +845,7 @@
      ;; expression expansion
      '("#\\({[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\|\\(\\$\\|@\\|@@\\)\\(\\w\\|_\\)+\\)"
        0 font-lock-variable-name-face t))
-    "*Additional expressions to highlight in ruby mode."))
+    "Additional expressions to highlight in `ruby-mode'."))
 
  ((featurep 'hilit19)
   (hilit-set-mode-patterns
@@ -858,5 +866,9 @@
      ("^__END__" nil label))))
  )
 
+;;;###autoload
+(add-to-list 'auto-mode-alist '("\\.rb$" . ruby-mode))
 
 (provide 'ruby-mode)
+
+;;; ruby-mode.el ends here

--dNVw/oxT6P3NptCZqjm--