ruby-changes:52531
From: hsbt <ko1@a...>
Date: Fri, 14 Sep 2018 22:19:50 +0900 (JST)
Subject: [ruby-changes:52531] hsbt:r64743 (trunk): Partly reverted for ruby-style.el.
hsbt 2018-09-14 22:19:45 +0900 (Fri, 14 Sep 2018) New Revision: 64743 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64743 Log: Partly reverted for ruby-style.el. Revert "Removed old elisp files. New upstream repository was moved https://github.com/ruby/elisp." This reverts commit 7eedd308b841e7b8eb4bc36211d28faf3521ee92. Added files: trunk/misc/ruby-style.el Modified files: trunk/misc/README Index: misc/README =================================================================== --- misc/README (revision 64742) +++ misc/README (revision 64743) @@ -1,5 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/misc/README#L1 README this file rb_optparse.bash bash completion script rb_optparse.zsh zsh completion script +ruby-style.el Ruby's C/C++ mode style for emacs lldb_cruby.py LLDB port of debug utility test_lldb_cruby.rb test file for LLDB port Index: misc/ruby-style.el =================================================================== --- misc/ruby-style.el (nonexistent) +++ misc/ruby-style.el (revision 64743) @@ -0,0 +1,81 @@ https://github.com/ruby/ruby/blob/trunk/misc/ruby-style.el#L1 +;;; -*- emacs-lisp -*- +;;; +;;; ruby-style.el - +;;; +;;; C/C++ mode style for Ruby. +;;; +;;; $Author$ +;;; created at: Thu Apr 26 13:54:01 JST 2007 +;;; +;;; Put this file under a directory contained in ``load-path'', and +;;; then load it. +;;; To switch to the "ruby" style automatically if it looks like a +;;; source file of ruby, add ruby-style-c-mode to c-mode-hook: +;;; +;;; (require 'ruby-style) +;;; (add-hook 'c-mode-hook 'ruby-style-c-mode) +;;; (add-hook 'c++-mode-hook 'ruby-style-c-mode) +;;; +;;; Customize the c-default-style variable to set the default style +;;; for each CC major mode. + +(defconst ruby-style-revision "$Revision$" + "Ruby style revision string.") + +(defconst ruby-style-version + (and + (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 + (back-to-indentation) + (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 + (back-to-indentation) + (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 + "ruby" + '("bsd" + (c-basic-offset . 4) + (tab-width . 8) + (indent-tabs-mode . nil) + (setq show-trailing-whitespace t) + (c-offsets-alist + (case-label . *) + (label . (ruby-style-label-indent *)) + (statement-case-intro . *) + (statement-case-open . *) + (statement-block-intro . (ruby-style-case-indent +)) + (access-label /) + ))) + +;;;###autoload +(defun ruby-style-c-mode () + (interactive) + (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))) + (case-fold-search nil)) + (goto-char (point-min)) + (re-search-forward "Copyright (C) .* Yukihiro Matsumoto" head t)))) + (c-set-style "ruby"))) + +(provide 'ruby-style) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/