summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-03-19 05:59:14 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-03-19 05:59:14 +0000
commit2b12a477ab16008aa4f57f98bde06e0887ddc13f (patch)
treefdbdee81e3f072ab27469c2d67e8346359493b2c
parent6b7054a0061268f5d3c06f6dc730357fb2a44530 (diff)
* misc/ruby-style.el (ruby-style-{case,label}-indent): fix for labels
inside blocks in switch and function top level. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15801 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--misc/ruby-style.el35
2 files changed, 34 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 035bf06..7f5d9aa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Mar 19 14:59:12 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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@ruby-lang.org>
* bignum.c (rb_cstr_to_inum): treat successive underscores as
diff --git a/misc/ruby-style.el b/misc/ruby-style.el
index e0ed41f..ef05ea0 100644
--- a/misc/ruby-style.el
+++ b/misc/ruby-style.el
@@ -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