ruby-changes:52523
From: kazu <ko1@a...>
Date: Thu, 13 Sep 2018 21:06:24 +0900 (JST)
Subject: [ruby-changes:52523] kazu:r64734: Remove old ruby-mode.el
kazu 2018-09-13 21:06:18 +0900 (Thu, 13 Sep 2018) New Revision: 64734 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64734 Log: Remove old ruby-mode.el Use emacs bundled ruby-mode.el instead. [Feature #6823] [ci skip] Removed files: trunk/misc/ruby-mode.el Index: misc/ruby-mode.el =================================================================== --- misc/ruby-mode.el (revision 64733) +++ misc/ruby-mode.el (nonexistent) @@ -1,1584 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/misc/ruby-mode.el#L0 -;;; ruby-mode.el --- Major mode for editing Ruby files - -;; Copyright (C) 1994, 1995, 1996 1997, 1998, 1999, 2000, 2001, -;; 2002,2003, 2004, 2005, 2006, 2007, 2008 -;; Free Software Foundation, Inc. - -;; Authors: Yukihiro Matsumoto, Nobuyoshi Nakada -;; URL: http://www.emacswiki.org/cgi-bin/wiki/RubyMode -;; Created: Fri Feb 4 14:49:13 JST 1994 -;; Keywords: languages ruby -;; Version: 0.9 - -;; This file is not part of GNU Emacs. However, a newer version of -;; ruby-mode is included in recent releases of GNU Emacs (version 23 -;; and up), but the new version is not guaranteed to be compatible -;; with older versions of Emacs or XEmacs. This file is the last -;; version that aims to keep this compatibility. - -;; You can also get the latest version from the Emacs Lisp Package -;; Archive: http://tromey.com/elpa - -;; This file is free software: you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; It is distributed in the hope that it will be useful, but WITHOUT -;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -;; License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with it. If not, see <http://www.gnu.org/licenses/>. - -;;; Commentary: - -;; Provides font-locking, indentation support, and navigation for Ruby code. -;; -;; If you're installing manually, you should add this to your .emacs -;; file after putting it on your load path: -;; -;; (autoload 'ruby-mode "ruby-mode" "Major mode for ruby files" t) -;; (add-to-list 'auto-mode-alist '("\\.rb$" . ruby-mode)) -;; (add-to-list 'interpreter-mode-alist '("ruby" . ruby-mode)) -;; - -;;; Code: - -(defconst ruby-mode-revision "$Revision$" - "Ruby mode revision string.") - -(defconst ruby-mode-version - (and (string-match "[0-9.]+" ruby-mode-revision) - (substring ruby-mode-revision (match-beginning 0) (match-end 0))) - "Ruby mode version number.") - -(defconst ruby-keyword-end-re - (if (string-match "\\_>" "ruby") - "\\_>" - "\\>")) - -(defconst ruby-block-beg-keywords - '("class" "module" "def" "if" "unless" "case" "while" "until" "for" "begin" "do") - "Keywords at the beginning of blocks.") - -(defconst ruby-block-beg-re - (regexp-opt ruby-block-beg-keywords) - "Regexp to match the beginning of blocks.") - -(defconst ruby-non-block-do-re - (concat (regexp-opt '("while" "until" "for" "rescue") t) ruby-keyword-end-re) - "Regexp to match") - -(defconst ruby-indent-beg-re - (concat "\\(\\s *" (regexp-opt '("class" "module" "def") t) "\\)\\|" - (regexp-opt '("if" "unless" "case" "while" "until" "for" "begin"))) - "Regexp to match where the indentation gets deeper.") - -(defconst ruby-modifier-beg-keywords - '("if" "unless" "while" "until") - "Modifiers that are the same as the beginning of blocks.") - -(defconst ruby-modifier-beg-re - (regexp-opt ruby-modifier-beg-keywords) - "Regexp to match modifiers same as the beginning of blocks.") - -(defconst ruby-modifier-re - (regexp-opt (cons "rescue" ruby-modifier-beg-keywords)) - "Regexp to match modifiers.") - -(defconst ruby-block-mid-keywords - '("then" "else" "elsif" "when" "rescue" "ensure") - "Keywords where the indentation gets shallower in middle of block statements.") - -(defconst ruby-block-mid-re - (regexp-opt ruby-block-mid-keywords) - "Regexp to match where the indentation gets shallower in middle of block statements.") - -(defconst ruby-block-op-keywords - '("and" "or" "not") - "Block operators.") - -(defconst ruby-block-hanging-re - (regexp-opt (append ruby-modifier-beg-keywords ruby-block-op-keywords)) - "Regexp to match hanging block modifiers.") - -(defconst ruby-block-end-re "\\_<end\\_>") - -(defconst ruby-here-doc-beg-re - "\\(<\\)<\\([-~]\\)?\\(\\([a-zA-Z0-9_]+\\)\\|[\"]\\([^\"]+\\)[\"]\\|[']\\([^']+\\)[']\\)") - -(defconst ruby-here-doc-end-re - "^\\([ \t]+\\)?\\(.*\\)\\(.\\)$") - -(defun ruby-here-doc-end-match () - (concat "^" - (if (match-string 2) "[ \t]*" nil) - (regexp-quote - (or (match-string 4) - (match-string 5) - (match-string 6))))) - -(defun ruby-here-doc-beg-match () - (let ((contents (concat - (regexp-quote (concat (match-string 2) (match-string 3))) - (if (string= (match-string 3) "_") "\\B" "\\b")))) - (concat "<<" - (let ((match (match-string 1))) - (if (and match (> (length match) 0)) - (concat "\\(?:[-~]\\([\"']?\\)\\|\\([\"']\\)" (match-string 1) "\\)" - contents "\\(\\1\\|\\2\\)") - (concat "[-~]?\\([\"']\\|\\)" contents "\\1")))))) - -(defconst ruby-delimiter - (concat "[?$/%(){}#\"'`.:]\\|<<\\|\\[\\|\\]\\|\\_<\\(" - ruby-block-beg-re - "\\)\\_>\\|" ruby-block-end-re - "\\|^=begin\\|" ruby-here-doc-beg-re) - ) - -(defconst ruby-negative - (concat "^[ \t]*\\(\\(" ruby-block-mid-re "\\)\\>\\|" - ruby-block-end-re "\\|}\\|\\]\\)") - "Regexp to match where the indentation gets shallower.") - -(defconst ruby-operator-chars "-,.+*/%&|^~=<>:") -(defconst ruby-operator-re (concat "[" ruby-operator-chars "]")) - -(defconst ruby-symbol-chars "a-zA-Z0-9_") -(defconst ruby-symbol-re (concat "[" ruby-symbol-chars "]")) - -(defvar ruby-mode-abbrev-table nil - "Abbrev table in use in ruby-mode buffers.") - -(define-abbrev-table 'ruby-mode-abbrev-table ()) - -(defvar ruby-mode-map nil "Keymap used in ruby mode.") - -(if ruby-mode-map - nil - (setq ruby-mode-map (make-sparse-keymap)) - (define-key ruby-mode-map "{" 'ruby-electric-brace) - (define-key ruby-mode-map "}" 'ruby-electric-brace) - (define-key ruby-mode-map "\e\C-a" 'ruby-beginning-of-defun) - (define-key ruby-mode-map "\e\C-e" 'ruby-end-of-defun) - (define-key ruby-mode-map "\e\C-b" 'ruby-backward-sexp) - (define-key ruby-mode-map "\e\C-f" 'ruby-forward-sexp) - (define-key ruby-mode-map "\e\C-p" 'ruby-beginning-of-block) - (define-key ruby-mode-map "\e\C-n" 'ruby-end-of-block) - (define-key ruby-mode-map "\e\C-h" 'ruby-mark-defun) - (define-key ruby-mode-map "\e\C-q" 'ruby-indent-exp) - (define-key ruby-mode-map "\t" 'ruby-indent-command) - (define-key ruby-mode-map "\C-c\C-e" 'ruby-insert-end) - (define-key ruby-mode-map "\C-j" 'ruby-reindent-then-newline-and-indent) - (define-key ruby-mode-map "\C-c{" 'ruby-toggle-block) - (define-key ruby-mode-map "\C-c\C-u" 'uncomment-region)) - -(defvar ruby-mode-syntax-table nil - "Syntax table in use in ruby-mode buffers.") - -(if ruby-mode-syntax-table - () - (setq ruby-mode-syntax-table (make-syntax-table)) - (modify-syntax-entry ?\' "\"" ruby-mode-syntax-table) - (modify-syntax-entry ?\" "\"" ruby-mode-syntax-table) - (modify-syntax-entry ?\` "\"" ruby-mode-syntax-table) - (modify-syntax-entry ?# "<" ruby-mode-syntax-table) - (modify-syntax-entry ?\n ">" ruby-mode-syntax-table) - (modify-syntax-entry ?\\ "\\" ruby-mode-syntax-table) - (modify-syntax-entry ?$ "." ruby-mode-syntax-table) - (modify-syntax-entry ?? "_" ruby-mode-syntax-table) - (modify-syntax-entry ?_ "_" ruby-mode-syntax-table) - (modify-syntax-entry ?: "_" ruby-mode-syntax-table) - (modify-syntax-entry ?< "." ruby-mode-syntax-table) - (modify-syntax-entry ?> "." ruby-mode-syntax-table) - (modify-syntax-entry ?& "." ruby-mode-syntax-table) - (modify-syntax-entry ?| "." ruby-mode-syntax-table) - (modify-syntax-entry ?% "." ruby-mode-syntax-table) - (modify-syntax-entry ?= "." ruby-mode-syntax-table) - (modify-syntax-entry ?/ "." ruby-mode-syntax-table) - (modify-syntax-entry ?+ "." ruby-mode-syntax-table) - (modify-syntax-entry ?* "." ruby-mode-syntax-table) - (modify-syntax-entry ?- "." ruby-mode-syntax-table) - (modify-syntax-entry ?\; "." ruby-mode-syntax-table) - (modify-syntax-entry ?\( "()" ruby-mode-syntax-table) - (modify-syntax-entry ?\) ")(" ruby-mode-syntax-table) - (modify-syntax-entry ?\{ "(}" ruby-mode-syntax-table) - (modify-syntax-entry ?\} "){" ruby-mode-syntax-table) - (modify-syntax-entry ?\[ "(]" ruby-mode-syntax-table) - (modify-syntax-entry ?\] ")[" ruby-mode-syntax-table) - ) - -(defcustom ruby-indent-tabs-mode nil - "*Indentation can insert tabs in ruby mode if this is non-nil." - :type 'boolean :group 'ruby) -(put 'ruby-indent-tabs-mode 'safe-local-variable 'booleanp) - -(defcustom ruby-indent-level 2 - "*Indentation of ruby statements." - :type 'integer :group 'ruby) -(put 'ruby-indent-level 'safe-local-variable 'integerp) - -(defcustom ruby-comment-column 32 - "*Indentation column of comments." - :type 'integer :group 'ruby) -(put 'ruby-comment-column 'safe-local-variable 'integerp) - -(defcustom ruby-deep-arglist t - "*Deep indent lists in parenthesis when non-nil. -Also ignores spaces after parenthesis when 'space." - :group 'ruby) -(put 'ruby-deep-arglist 'safe-local-variable 'booleanp) - -(defcustom ruby-deep-indent-paren '(?\( ?\[ ?\] t) - "*Deep indent lists in parenthesis when non-nil. t means continuous line. -Also ignores spaces after parenthesis when 'space." - :group 'ruby) - -(defcustom ruby-deep-indent-paren-style 'space - "Default deep indent style." - :options '(t nil space) :group 'ruby) - -(defcustom ruby-encoding-map - '((us-ascii . nil) ;; Do not put coding: us-ascii - (utf-8 . nil) ;; Do not put coding: utf-8 - (shift-jis . cp932) ;; Emacs charset name of Shift_JIS - (shift_jis . cp932) ;; MIME charset name of Shift_JIS - (japanese-cp932 . cp932)) ;; Emacs charset name of CP932 - "Alist to map encoding name from Emacs to Ruby. -Associating an encoding name with nil means it needs not be -explicitly declared in magic comment." - :type '(repeat (cons (symbol :tag "From") (symbol :tag "To"))) - :group 'ruby) - -(defcustom ruby-use-encoding-map t - "*Use `ruby-encoding-map' to set encoding magic comment if this is non-nil." - :type 'boolean :group 'ruby) - -(defvar ruby-indent-point nil "internal variable") - -(eval-when-compile (require 'cl)) -(defun ruby-imenu-create-index-in-block (prefix beg end) - (let ((index-alist '()) (case-fold-search nil) - name next pos decl sing) - (goto-char beg) - (while (re-search-forward "^\\s *\\(\\(class\\s +\\|\\(class\\s *<<\\s *\\)\\|module\\s +\\)\\([^\(<\n ]+\\)\\|\\(def\\|alias\\)\\s +\\([^\(\n ]+\\)\\)" end t) - (setq sing (match-beginning 3)) - (setq decl (match-string 5)) - (setq next (match-end 0)) - (setq name (or (match-string 4) (match-string 6))) - (setq pos (match-beginning 0)) - (cond - ((string= "alias" decl) - (if prefix (setq name (concat prefix name))) - (push (cons name pos) index-alist)) - ((string= "def" decl) - (if prefix - (setq name - (cond - ((string-match "^self\." name) - (concat (substring prefix 0 -1) (substring name 4))) - (t (concat prefix name))))) - (push (cons name pos) index-alist) - (ruby-accurate-end-of-block end)) - (t - (if (string= "self" name) - (if prefix (setq name (substring prefix 0 -1))) - (if prefix (setq name (concat (substring prefix 0 -1) "::" name))) - (push (cons name pos) index-alist)) - (ruby-accurate-end-of-block end) - (setq beg (point)) - (setq index-alist - (nconc (ruby-imenu-create-index-in-block - (concat name (if sing "." "#")) - next beg) index-alist)) - (goto-char beg)))) - index-alist)) - -(defun ruby-imenu-create-index () - (nreverse (ruby-imenu-create-index-in-block nil (point-min) nil))) - -(defun ruby-accurate-end-of-block (&optional end) - (let (state) - (or end (setq end (point-max))) - (while (and (setq state (apply 'ruby-parse-partial end state)) - (>= (nth 2 state) 0) (< (point) end))))) - -(defun ruby-mode-variables () - (set-syntax-table ruby-mode-syntax-table) - (setq show-trailing-whitespace t) - (setq local-abbrev-table ruby-mode-abbrev-table) - (make-local-variable 'indent-line-function) - (setq indent-line-function 'ruby-indent-line) - (make-local-variable 'require-final-newline) - (setq require-final-newline t) - (make-local-variable 'comment-start) - (setq comment-start "# ") - (make-local-variable 'comment-end) - (setq comment-end "") - (make-local-variable 'comment-column) - (setq comment-column ruby-comment-column) - (make-local-variable 'comment-start-skip) - (setq comment-start-skip "#+ *") - (setq indent-tabs-mode ruby-indent-tabs-mode) - (make-local-variable 'parse-sexp-ignore-comments) - (setq parse-sexp-ignore-comments t) - (make-local-variable 'parse-sexp-lookup-properties) - (setq parse-sexp-lookup-properties t) - (make-local-variable 'paragraph-start) - (setq paragraph-start (concat "$\\|" page-delimiter)) - (make-local-variable 'paragraph-separate) - (setq paragraph-separate paragraph-start) - (make-local-variable 'paragraph-ignore-fill-prefix) - (setq paragraph-ignore-fill-prefix t)) - -(defun ruby-mode-set-encoding () - "Insert or update a magic comment header with the proper encoding. -`ruby-encoding-map' is looked up to convert an encoding name from -Emacs to Ruby." - (let* ((nonascii - (save-excursion - (widen) - (goto-char (point-min)) - (re-search-forward "[^\0-\177]" nil t))) - (coding-system - (or coding-system-for-write - buffer-file-coding-system)) - (coding-system - (and coding-system - (coding-system-change-eol-conversion coding-system nil))) - (coding-system - (and coding-system - (or - (coding-system-get coding-system :mime-charset) - (let ((coding-type (coding-system-get coding-system :coding-type))) - (cond ((eq coding-type 'undecided) - (if nonascii - (or (and (coding-system-get coding-system :prefer-utf-8) - 'utf-8) - (coding-system-get default-buffer-file-coding-system :coding-type) - 'ascii-8bit))) - ((memq coding-type '(utf-8 shift-jis)) - coding-type) - (t coding-system)))))) - (coding-system - (or coding-system - 'us-ascii)) - (coding-system - (let ((cons (assq coding-system ruby-encoding-map))) - (if cons (cdr cons) coding-system))) - (coding-system - (and coding-system - (symbol-name coding-system)))) - (if coding-system - (save-excursion - (widen) - (goto-char (point-min)) - (if (looking-at "^#!") (beginning-of-line 2)) - (cond ((looking-at "\\s *#.*-\*-\\s *\\(en\\)?coding\\s *:\\s *\\([-a-z0-9_]*\\)\\s *\\(;\\|-\*-\\)") - (unless (string= (match-string 2) coding-system) - (goto-char (match-beginning 2)) - (delete-region (point) (match-end 2)) - (and (looking-at "-\*-") - (let ((n (skip-chars-backward " "))) - (cond ((= n 0) (insert " ") (backward-char)) - ((= n -1) (insert " ")) - ((forward-char))))) - (insert coding-system))) - ((looking-at "\\s *#.*coding\\s *[:=]")) - (t (when ruby-insert-encoding-magic-comment - (insert "# -*- coding: " coding-system " -*-\n")))))))) - -(defun ruby-current-indentation () - (save-excursion - (beginning-of-line) - (back-to-indentation) - (current-column))) - -(defun ruby-indent-line (&optional flag) - "Correct indentation of the current ruby line." - (ruby-indent-to (ruby-calculate-indent))) - -(defun ruby-indent-command () - (interactive) - (ruby-indent-line t)) - -(defun ruby-indent-to (x) - (if x - (let (shift top beg) - (and (< x 0) (error "invalid nest")) - (setq shift (current-column)) - (beginning-of-line) - (setq beg (point)) - (back-to-indentation) - (setq top (current-column)) - (skip-chars-backward " \t") - (if (>= shift top) (setq shift (- shift top)) - (setq shift 0)) - (if (and (bolp) - (= x top)) - (move-to-column (+ x shift)) - (move-to-column top) - (delete-region beg (point)) - (beginning-of-line) - (indent-to x) - (move-to-column (+ x shift)))))) - -(defun ruby-special-char-p (&optional pnt) - (setq pnt (or pnt (point))) - (let ((c (char-before pnt)) (b (and (< (point-min) pnt) (char-before (1- pnt))))) - (cond ((or (eq c ??) (eq c ?$))) - ((and (eq c ?:) (or (not b) (eq (char-syntax b) ? )))) - ((eq c ?\\) (eq b ??))))) - -(defun ruby-singleton-class-p () - (save-excursion - (forward-word -1) - (and (or (bolp) (not (eq (char-before (point)) ?_))) - (looking-at "class\\s *<<")))) - -(defun ruby-expr-beg (&optional option) - (save-excursion - (store-match-data nil) - (let ((space (skip-chars-backward " \t")) - (start (point))) - (cond - ((bolp) t) - ((progn - (forward-char -1) - (and (looking-at "\\?") - (or (eq (char-syntax (preceding-char)) ?w) - (ruby-special-char-p)))) - nil) - ((and (eq option 'heredoc) (< space 0)) - (not (progn (goto-char start) (ruby-singleton-class-p)))) - ((or (looking-at ruby-operator-re) - (looking-at "[\\[({,;]") - (and (looking-at "[!?]") - (or (not (eq option 'modifier)) - (bolp) - (save-excursion (forward-char -1) (looking-at "\\Sw$")))) - (and (looking-at ruby-symbol-re) - (skip-chars-backward ruby-symbol-chars) - (cond - ((looking-at (regexp-opt - (append ruby-block-beg-keywords - ruby-block-op-keywords - ruby-block-mid-keywords) - 'words)) - (goto-char (match-end 0)) - (not (looking-at "\\s_\\|[!?:]"))) - ((eq option 'expr-qstr) - (looking-at "[a-zA-Z][a-zA-z0-9_]* +%[^ \t]")) - ((eq option 'expr-re) - (looking-at "[a-zA-Z][a-zA-z0-9_]* +/[^ \t]")) - (t nil))))))))) - -(defun ruby-forward-string (term &optional end no-error expand) - (let ((n 1) (c (string-to-char term)) - (re (if expand - (concat "[^\\]\\(\\\\\\\\\\)*\\([" term "]\\|\\(#{\\)\\)") - (concat "[^\\]\\(\\\\\\\\\\)*[" term "]")))) - (while (and (re-search-forward re end no-error) - (if (match-beginning 3) - (ruby-forward-string "}{" end no-error nil) - (> (setq n (if (eq (char-before (point)) c) - (1- n) (1+ n))) 0))) - (forward-char -1)) - (cond ((zerop n)) - (no-error nil) - ((error "unterminated string"))))) - -(defun ruby-deep-indent-paren-p (c &optional pos) - (cond ((save-excur (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/