From: Jim Weirich Date: 2002-05-11T23:40:41+09:00 Subject: Re: ruby emacs mode question >>>>> "nobu" == nobu nokada writes: >> This has annoyed me too. So, I've hacked up a version of ruby-mode.el >> that addresses this problem. You can find it at ... >> Set the variable 'ruby-deep-arglist' to non-nil if you want the >> traditional indentation. Set it to nil if you want the new "shallow" >> indentation. nobu> It may be better not to change the default behavior. You are correct >> There seems to be a number of different versions of ruby-mode.el >> laying around. I put the changes in the latest version I had locally. nobu> Your 1.25.2.8 is old a little, the latest for ruby 1.6 is nobu> 1.25.2.9, and 1.49 for ruby 1.7. I found a copy of 1.49 and modified it. The new file is available at ... ftp://ftp.one.net/pub/users/jweirich/ruby/ruby-mode-1.49-deep-arglist.el And here are the actual patches (if you are interested in adding them to the next version). I changed the default to be the original behavior. ---------------------------------------------------------------------- --- ruby-mode-1.49.el Sat May 11 10:14:52 2002 +++ ruby-mode-1.49x.el Sat May 11 10:16:19 2002 @@ -126,6 +126,9 @@ (defvar ruby-indent-level 2 "*Indentation of ruby statements.") +(defvar ruby-deep-arglist t + "*Deep indent argument lists when non-nil.") + (eval-when-compile (require 'cl)) (defun ruby-imenu-create-index () (let ((index-alist '()) @@ -366,18 +369,18 @@ (forward-line 1) (goto-char (point)) ) - ((looking-at "(") + ((and (looking-at "(") ruby-deep-arglist) (setq nest (cons (cons (char-after (point)) pnt) nest)) (setq pcol (cons (cons pnt depth) pcol)) (setq depth 0) (goto-char pnt) ) - ((looking-at "[\\[{]") + ((looking-at "[\\[{(]") (setq nest (cons (cons (char-after (point)) pnt) nest)) (setq depth (1+ depth)) (goto-char pnt) ) - ((looking-at ")") + ((and (looking-at ")") ruby-deep-arglist) (setq nest (cdr nest)) (setq depth (cdr (car pcol))) (setq pcol (cdr pcol)) @@ -478,7 +481,7 @@ (setq indent nil)) ; do nothing ((car (nth 1 state)) ; in paren (goto-char (cdr (nth 1 state))) - (if (eq (car (nth 1 state)) ?\( ) + (if (and (eq (car (nth 1 state)) ?\( ) ruby-deep-arglist) (let ((column (current-column)) (s (ruby-parse-region (point) indent-point))) (cond ---------------------------------------------------------------------- -- -- Jim Weirich jweirich@one.net http://w3.one.net/~jweirich --------------------------------------------------------------------- "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)