ruby-changes:8204
From: nobu <ko1@a...>
Date: Thu, 9 Oct 2008 23:53:48 +0900 (JST)
Subject: [ruby-changes:8204] Ruby:r19731 (ruby_1_8, trunk): * misc/ruby-style.el (ruby-style-c-mode): buffer may not have file
nobu 2008-10-09 23:53:26 +0900 (Thu, 09 Oct 2008) New Revision: 19731 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=19731 Log: * misc/ruby-style.el (ruby-style-c-mode): buffer may not have file name. Modified files: branches/ruby_1_8/ChangeLog branches/ruby_1_8/misc/ruby-style.el trunk/ChangeLog trunk/misc/ruby-style.el Index: ChangeLog =================================================================== --- ChangeLog (revision 19730) +++ ChangeLog (revision 19731) @@ -1,3 +1,8 @@ +Thu Oct 9 23:53:23 2008 Nobuyoshi Nakada <nobu@r...> + + * misc/ruby-style.el (ruby-style-c-mode): buffer may not have file + name. + Thu Oct 9 23:30:47 2008 Yusuke Endoh <mame@t...> * process.c (run_exec_dup2): fix resource leak. Index: misc/ruby-style.el =================================================================== --- misc/ruby-style.el (revision 19730) +++ misc/ruby-style.el (revision 19731) @@ -7,6 +7,14 @@ ;;; $Author$ ;;; created at: Thu Apr 26 13:54:01 JST 2007 ;;; +;;; sets ruby style if it seems like a source of ruby. +;;; +;;; (require 'ruby-style) +;;; (add-hook 'c-mode-hook 'ruby-style-c-mode) +;;; (add-hook 'c++-mode-hook 'ruby-style-c-mode) +;;; +;;; uses ruby style always. +;;; (setq-default c-file-style "ruby") (defconst ruby-style-revision "$Revision$" "Ruby style revision string.") @@ -56,7 +64,7 @@ (defun ruby-style-c-mode () (interactive) - (if (or (string-match "/ruby\\>" (buffer-file-name)) + (if (or (let ((name (buffer-file-name))) (and name (string-match "/ruby\\>" name))) (save-excursion (goto-char (point-min)) (let ((head (progn (forward-line 100) (point))) Index: ruby_1_8/ChangeLog =================================================================== --- ruby_1_8/ChangeLog (revision 19730) +++ ruby_1_8/ChangeLog (revision 19731) @@ -1,3 +1,8 @@ +Thu Oct 9 23:53:23 2008 Nobuyoshi Nakada <nobu@r...> + + * misc/ruby-style.el (ruby-style-c-mode): buffer may not have file + name. + Wed Oct 8 11:18:12 2008 Nobuyoshi Nakada <nobu@r...> * variable.c (autoload_delete, autoload_file): should not delete Index: ruby_1_8/misc/ruby-style.el =================================================================== --- ruby_1_8/misc/ruby-style.el (revision 19730) +++ ruby_1_8/misc/ruby-style.el (revision 19731) @@ -7,6 +7,14 @@ ;;; $Author: nobu $ ;;; created at: Thu Apr 26 13:54:01 JST 2007 ;;; +;;; sets ruby style if it seems like a source of ruby. +;;; +;;; (require 'ruby-style) +;;; (add-hook 'c-mode-hook 'ruby-style-c-mode) +;;; (add-hook 'c++-mode-hook 'ruby-style-c-mode) +;;; +;;; uses ruby style always. +;;; (setq-default c-file-style "ruby") (defconst ruby-style-revision "$Revision: 15588 $" "Ruby style revision string.") @@ -19,22 +27,24 @@ (defun ruby-style-case-indent (x) (save-excursion + (back-to-indentation) (unless (progn (backward-up-list) (back-to-indentation) - (> (point) (cdr x))) + (> (point) (cdr x))) (goto-char (cdr x)) (if (looking-at "\\<case\\|default\\>") '*)))) (defun ruby-style-label-indent (x) (save-excursion + (back-to-indentation) (unless (progn (backward-up-list) (back-to-indentation) - (>= (point) (cdr x))) + (>= (point) (cdr x))) (goto-char (cdr x)) (condition-case () - (progn - (backward-up-list) - (backward-sexp 2) - (if (looking-at "\\<switch\\>") '/)) - (error))))) + (progn + (backward-up-list) + (backward-sexp 2) + (if (looking-at "\\<switch\\>") '/)) + (error))))) (require 'cc-styles) (c-add-style @@ -54,7 +64,7 @@ (defun ruby-style-c-mode () (interactive) - (if (or (string-match "/ruby\\>" (buffer-file-name)) + (if (or (let ((name (buffer-file-name))) (and name (string-match "/ruby\\>" name))) (save-excursion (goto-char (point-min)) (let ((head (progn (forward-line 100) (point))) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/