* misc/ruby-mode.el, misc/ruby-electric.el: use regexp-opt where
possible for more efficient regexps. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3f3584d623
commit
d250d79e5b
@ -11,6 +11,9 @@ Sun Sep 7 07:24:09 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
|||||||
* misc/ruby-mode.el: don't highlight keywords when they're the
|
* misc/ruby-mode.el: don't highlight keywords when they're the
|
||||||
beginning of non-keyword symbols.
|
beginning of non-keyword symbols.
|
||||||
|
|
||||||
|
* misc/ruby-mode.el, misc/ruby-electric.el: use regexp-opt where
|
||||||
|
possible for more efficient regexps.
|
||||||
|
|
||||||
Sun Sep 7 06:31:51 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Sun Sep 7 06:31:51 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* file.c (file_expand_path): applied a patch from Nobuhiro Tachino
|
* file.c (file_expand_path): applied a patch from Nobuhiro Tachino
|
||||||
|
@ -68,7 +68,7 @@
|
|||||||
(?\" . ?\")))
|
(?\" . ?\")))
|
||||||
|
|
||||||
(defcustom ruby-electric-simple-keywords-re
|
(defcustom ruby-electric-simple-keywords-re
|
||||||
"\\(def\\|if\\|class\\|module\\|unless\\|case\\|while\\|do\\|until\\|for\\|begin\\)"
|
(regexp-opt '("def" "if" "class" "module" "unless" "case" "while" "do" "until" "for" "begin") t)
|
||||||
"*Regular expresion matching keywords for which closing 'end'
|
"*Regular expresion matching keywords for which closing 'end'
|
||||||
is to be inserted."
|
is to be inserted."
|
||||||
:type 'regexp :group 'ruby-electric)
|
:type 'regexp :group 'ruby-electric)
|
||||||
|
@ -13,37 +13,50 @@
|
|||||||
(substring ruby-mode-revision (match-beginning 0) (match-end 0)))
|
(substring ruby-mode-revision (match-beginning 0) (match-end 0)))
|
||||||
"Ruby mode version number.")
|
"Ruby mode version number.")
|
||||||
|
|
||||||
|
(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
|
(defconst ruby-block-beg-re
|
||||||
"class\\|module\\|def\\|if\\|unless\\|case\\|while\\|until\\|for\\|begin\\|do"
|
(regexp-opt ruby-block-beg-keywords)
|
||||||
"Regexp to match the beginning of blocks in ruby-mode.")
|
"Regexp to match the beginning of blocks.")
|
||||||
|
|
||||||
(defconst ruby-non-block-do-re
|
(defconst ruby-non-block-do-re
|
||||||
"\\(while\\|until\\|for\\|rescue\\)\\>[^_]"
|
(concat (regexp-opt '("while" "until" "for" "rescue") t) "\\_>")
|
||||||
"Regexp to match")
|
"Regexp to match")
|
||||||
|
|
||||||
(defconst ruby-indent-beg-re
|
(defconst ruby-indent-beg-re
|
||||||
"\\(\\s *\\(class\\|module\\|def\\)\\)\\|if\\|unless\\|case\\|while\\|until\\|for\\|begin"
|
(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.")
|
"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
|
(defconst ruby-modifier-beg-re
|
||||||
"if\\|unless\\|while\\|until"
|
(regexp-opt ruby-modifier-beg-keywords)
|
||||||
"Regexp to match modifiers same as the beginning of blocks.")
|
"Regexp to match modifiers same as the beginning of blocks.")
|
||||||
|
|
||||||
(defconst ruby-modifier-re
|
(defconst ruby-modifier-re
|
||||||
(concat ruby-modifier-beg-re "\\|rescue")
|
(regexp-opt (cons "rescue" ruby-modifier-beg-keywords))
|
||||||
"Regexp to match modifiers.")
|
"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
|
(defconst ruby-block-mid-re
|
||||||
"then\\|else\\|elsif\\|when\\|rescue\\|ensure"
|
(regexp-opt ruby-block-mid-keywords)
|
||||||
"Regexp to match where the indentation gets shallower in middle of block statements.")
|
"Regexp to match where the indentation gets shallower in middle of block statements.")
|
||||||
|
|
||||||
(defconst ruby-block-op-re
|
(defconst ruby-block-ops
|
||||||
"and\\|or\\|not"
|
'("and" "or" "not")
|
||||||
"Regexp to match ")
|
"Block operators.")
|
||||||
|
|
||||||
(defconst ruby-block-hanging-re
|
(defconst ruby-block-hanging-re
|
||||||
(concat ruby-modifier-beg-re "\\|" ruby-block-op-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-block-end-re "\\<end\\>")
|
||||||
|
|
||||||
@ -395,9 +408,11 @@ The variable ruby-indent-level controls the amount of indentation.
|
|||||||
(and (looking-at ruby-symbol-re)
|
(and (looking-at ruby-symbol-re)
|
||||||
(skip-chars-backward ruby-symbol-chars)
|
(skip-chars-backward ruby-symbol-chars)
|
||||||
(cond
|
(cond
|
||||||
((or (looking-at (concat "\\<\\(" ruby-block-beg-re
|
((looking-at (regexp-opt
|
||||||
"|" ruby-block-op-re
|
(append ruby-block-beg-keywords
|
||||||
"|" ruby-block-mid-re "\\)\\>")))
|
ruby-block-op-keywords
|
||||||
|
ruby-block-mid-keywords)
|
||||||
|
'words))
|
||||||
(goto-char (match-end 0))
|
(goto-char (match-end 0))
|
||||||
(not (looking-at "\\s_")))
|
(not (looking-at "\\s_")))
|
||||||
((eq option 'expr-qstr)
|
((eq option 'expr-qstr)
|
||||||
@ -556,7 +571,7 @@ The variable ruby-indent-level controls the amount of indentation.
|
|||||||
((looking-at (concat "\\<\\(" ruby-block-beg-re "\\)\\>"))
|
((looking-at (concat "\\<\\(" ruby-block-beg-re "\\)\\>"))
|
||||||
(and
|
(and
|
||||||
(save-match-data
|
(save-match-data
|
||||||
(or (not (looking-at "do\\>[^_]"))
|
(or (not (looking-at "do\\_>"))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(back-to-indentation)
|
(back-to-indentation)
|
||||||
(not (looking-at ruby-non-block-do-re)))))
|
(not (looking-at ruby-non-block-do-re)))))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user