From: "Brian Schröder" Date: 2004-10-05T06:09:33+09:00 Subject: Re: Coding assistance for Emacs Tassilo Horn wrote: > Hi, > > I'm doing my first stept with Ruby now. I really enjoy it. But I'm > missing some editor assistance. > > I use Ruby 1.8.2 preview2, Emacs, ruby-mode.el 1.74, inf-ruby.el. > > How can I get code completion and other fancy things making coding > faster? > > On ruby-lang.org I've found rtags which perhaps could be something I'm > looking for. Is it included in the current CVS Ruby or do I have to get > it elsewhere? > > And is there any documentation for inf-ruby/ruby-mode beside the > sources? > > Much thanks in advance, > > Tassilo My ruby xemacs setup. Has hide-show of functions [f4,f5,f6,f7] automatically chmod +x, ruby-xmp [m-f10], ri lookup of keyword at point [f1]. And some more. Regards, Brian (require 'ruby-mode) ;;; Execute Ruby Command with f3 (define-key ruby-mode-map [f3] 'ruby-load-file) (defun ruby-xmp-region (reg-start reg-end) "Pipe the region through Ruby's xmp utility and replace the region with the result." (interactive "r") (shell-command-on-region reg-start reg-end "ruby -r xmp -n -e 'xmp($_, \"%l\t\t# %r\n\")'" t)) (global-set-key [(meta f10)] 'ruby-xmp-region) (defun ruby-custom-setup () (add-to-list 'hs-special-modes-alist '(ruby-mode "\\(def\\|do\\)" "end" "#" (lambda (arg) (ruby-end-of-block)) nil )) (hs-minor-mode t) ) (add-hook 'ruby-mode-hook '(lambda () (define-key ruby-mode-map "\M-q" 'jw-rb-fill-comment-region) )) (add-hook 'ruby-mode-hook 'ruby-custom-setup) ; Chmod of scripts to u+x (add-hook 'after-save-hook '(lambda () (progn (and (save-excursion (save-restriction (widen) (goto-char (point-min)) (save-match-data (looking-at "^#!")))) (shell-command (concat "chmod u+x " buffer-file-name)) (message (concat "Saved as script: " buffer-file-name)) )))) ;JeffreyRadcliffe -- Here is a method which calls the interpreter on the entire buffer, putting the output in another window: (defun ruby-eval-buffer () (interactive) "Evaluate the buffer with ruby." (shell-command-on-region (point-min) (point-max) "ruby")) (defun ruby-xmp-region (reg-start reg-end) "Pipe the region through Ruby's xmp utility and replace the region with the result." ;PragDave -- This li'l beaut runs Gotoken's xmp processor on a region. This adds the results of evaluating each line to the end of that line. It's how I add values to code examples in my e-mail. Here it's bound to M-F10 (interactive "r") (shell-command-on-region reg-start reg-end "ruby -r xmp -n -e 'xmp($_, \"%l\t\t# %r\n\")'" t)) (global-set-key [(control f10)] 'ruby-xmp-region) (global-set-key [dead-tilde] "~") (setq ri-ruby-script "/home/bschroed/.xemacs/ri-emacs.rb") (autoload 'ri "/home/bschroed/.xemacs/ri-ruby.el" nil t) ;; ;; You may want to bind the ri command to a key. ;; For example to bind it to F1 in ruby-mode: ;; (add-hook 'ruby-mode-hook (lambda () (local-set-key 'f1 'ri))) -- Brian Schr�der http://ruby.brian-schroeder.de/