ruby-changes:4311
From: ko1@a...
Date: Wed, 19 Mar 2008 14:59:40 +0900 (JST)
Subject: [ruby-changes:4311] nobu - Ruby:r15801 (ruby_1_8): * misc/ruby-style.el (ruby-style-{case,label}-indent): fix for labels
nobu 2008-03-19 14:59:14 +0900 (Wed, 19 Mar 2008) New Revision: 15801 Modified files: branches/ruby_1_8/ChangeLog branches/ruby_1_8/misc/ruby-style.el Log: * misc/ruby-style.el (ruby-style-{case,label}-indent): fix for labels inside blocks in switch and function top level. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/ChangeLog?r1=15801&r2=15800&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/misc/ruby-style.el?r1=15801&r2=15800&diff_format=u Index: ruby_1_8/ChangeLog =================================================================== --- ruby_1_8/ChangeLog (revision 15800) +++ ruby_1_8/ChangeLog (revision 15801) @@ -1,3 +1,8 @@ +Wed Mar 19 14:59:12 2008 Nobuyoshi Nakada <nobu@r...> + + * misc/ruby-style.el (ruby-style-{case,label}-indent): fix for labels + inside blocks in switch and function top level. + Wed Mar 19 14:36:40 2008 Nobuyoshi Nakada <nobu@r...> * bignum.c (rb_cstr_to_inum): treat successive underscores as Index: ruby_1_8/misc/ruby-style.el =================================================================== --- ruby_1_8/misc/ruby-style.el (revision 15800) +++ ruby_1_8/misc/ruby-style.el (revision 15801) @@ -1,17 +1,40 @@ ;;; -*- emacs-lisp -*- +;;; +;;; ruby-style.el - +;;; ;;; C/C++ mode style for Ruby. +;;; +;;; $Author: nobu $ +;;; created at: Thu Apr 26 13:54:01 JST 2007 +;;; +(defconst ruby-style-revision "$Revision: 15588 $" + "Ruby style revision string.") + +(defconst ruby-style-version + (progn + (string-match "[0-9.]+" ruby-style-revision) + (substring ruby-style-revision (match-beginning 0) (match-end 0))) + "Ruby style version number.") + (defun ruby-style-case-indent (x) (save-excursion - (goto-char (cdr x)) - (if (looking-at "\\<case\\|default\\>") '*))) + (unless (progn (backward-up-list) (back-to-indentation) + (> (point) (cdr x))) + (goto-char (cdr x)) + (if (looking-at "\\<case\\|default\\>") '*)))) (defun ruby-style-label-indent (x) (save-excursion - (goto-char (cdr x)) - (backward-up-list) - (backward-sexp 2) - (if (looking-at "\\<switch\\>") '/))) + (unless (progn (backward-up-list) (back-to-indentation) + (>= (point) (cdr x))) + (goto-char (cdr x)) + (condition-case () + (progn + (backward-up-list) + (backward-sexp 2) + (if (looking-at "\\<switch\\>") '/)) + (error))))) (require 'cc-styles) (c-add-style -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/