diff options
| author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-04-26 04:54:01 +0000 |
|---|---|---|
| committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-04-26 04:54:01 +0000 |
| commit | fcab035d5ea141606c89275164c720b60cc9b6d4 (patch) | |
| tree | c8dd1f94fdd83e6db31709c6f05b6327bfd9d521 /misc | |
| parent | 5bd5bfbc8b7594562063521c943f916206ca6b13 (diff) | |
| download | ruby-fcab035d5ea141606c89275164c720b60cc9b6d4.tar.gz ruby-fcab035d5ea141606c89275164c720b60cc9b6d4.tar.xz ruby-fcab035d5ea141606c89275164c720b60cc9b6d4.zip | |
* misc/ruby-style.el: new file. C/C++ style for ruby source code.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@12221 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'misc')
| -rw-r--r-- | misc/ruby-style.el | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/misc/ruby-style.el b/misc/ruby-style.el new file mode 100644 index 000000000..176878947 --- /dev/null +++ b/misc/ruby-style.el @@ -0,0 +1,36 @@ +;;; -*- emacs-lisp -*- +;;; C/C++ mode style for Ruby. + +(defun ruby-style-case-indent (x) + (save-excursion + (goto-char (cdr x)) + (if (looking-at "\\<case\\|default\\>") + (- c-basic-offset + (% (current-column) c-basic-offset))))) + +(require 'cc-styles) +(c-add-style + "ruby" + '("bsd" + (c-basic-offset . 4) + (c-offsets-alist + (case-label . *) + (label . *) + (statement-case-intro . *) + (statement-case-open . *) + (statement-block-intro . (ruby-style-case-indent +)) + (access-label /) + ))) + +(defun ruby-style-c-mode () + (interactive) + (if (or (string-match "/ruby\\>" (buffer-file-name)) + (save-excursion + (goto-char (point-min)) + (let ((head (progn (forward-line 100) (point))) + (case-fold-search nil)) + (goto-char (point-min)) + (re-search-forward "Copyright (C) .* Yukihiro Matsumoto" head t)))) + (setq c-file-style "ruby"))) + +(provide 'ruby-style) |
