From ae846f9fb810ecd241a20579495a94a15212ca56 Mon Sep 17 00:00:00 2001 From: knu Date: Fri, 3 Apr 2009 05:04:02 +0000 Subject: [PATCH] * lib/irb/completion.rb (IRB::InputCompletor::Operators): Add overloadable negative operators. * lib/irb/ruby-lex.rb (RubyLex#lex_init): Support overloadable negative operators. * lib/irb/ruby-lex.rb (RubyLex#identify_identifier): Minus signs need to be escaped in regexp character class. * misc/ruby-mode.el (ruby-font-lock-keywords, ruby-parse-partial): Support overloadable negative operators. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23129 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 14 ++++++++++++++ lib/irb/completion.rb | 2 +- lib/irb/ruby-lex.rb | 15 +++++---------- misc/ruby-mode.el | 4 ++-- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index c3e58a57f0..e56bdcbd90 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Fri Apr 3 14:02:42 2009 Akinori MUSHA + + * lib/irb/completion.rb (IRB::InputCompletor::Operators): Add + overloadable negative operators. + + * lib/irb/ruby-lex.rb (RubyLex#lex_init): Support overloadable + negative operators. + + * lib/irb/ruby-lex.rb (RubyLex#identify_identifier): Minus signs + need to be escaped in regexp character class. + + * misc/ruby-mode.el (ruby-font-lock-keywords, ruby-parse-partial): + Support overloadable negative operators. + Fri Apr 3 12:45:55 2009 Nobuyoshi Nakada * ext/extmk.rb: quotes arguments with spaces always. diff --git a/lib/irb/completion.rb b/lib/irb/completion.rb index a31bee0c76..459f856dfe 100644 --- a/lib/irb/completion.rb +++ b/lib/irb/completion.rb @@ -184,7 +184,7 @@ module IRB Operators = ["%", "&", "*", "**", "+", "-", "/", "<", "<<", "<=", "<=>", "==", "===", "=~", ">", ">=", ">>", - "[]", "[]=", "^",] + "[]", "[]=", "^", "!", "!=", "!~"] def self.select_message(receiver, message, candidates) candidates.grep(/^#{message}/).collect do |e| diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb index 13b101ffc8..1def148885 100644 --- a/lib/irb/ruby-lex.rb +++ b/lib/irb/ruby-lex.rb @@ -389,7 +389,8 @@ class RubyLex "=", "==", "===", "=~", "<=>", "<", "<=", - ">", ">=", ">>") do + ">", ">=", ">>", + "!", "!=", "!~") do |op, io| case @lex_state when EXPR_FNAME, EXPR_DOT @@ -400,12 +401,6 @@ class RubyLex Token(op) end - @OP.def_rules("!", "!=", "!~") do - |op, io| - @lex_state = EXPR_BEG - Token(op) - end - @OP.def_rules("<<") do |op, io| tk = nil @@ -822,11 +817,11 @@ class RubyLex when "class" valid = false unless peek_match?(/^\s*(<<|\w|::)/) when "def" - valid = false if peek_match?(/^\s*(([+-\/*&\|^]|<<|>>|\|\||\&\&)=|\&\&|\|\|)/) + valid = false if peek_match?(/^\s*(([+\-\/*&\|^]|<<|>>|\|\||\&\&)=|\&\&|\|\|)/) when "do" - valid = false if peek_match?(/^\s*([+-\/*]?=|\*|<|>|\&)/) + valid = false if peek_match?(/^\s*([+\-\/*]?=|\*|<|>|\&)/) when *ENINDENT_CLAUSE - valid = false if peek_match?(/^\s*([+-\/*]?=|\*|<|>|\&|\|)/) + valid = false if peek_match?(/^\s*([+\-\/*]?=|\*|<|>|\&|\|)/) else # no nothing end diff --git a/misc/ruby-mode.el b/misc/ruby-mode.el index 0b8ed825fa..70acd7266b 100644 --- a/misc/ruby-mode.el +++ b/misc/ruby-mode.el @@ -646,7 +646,7 @@ The variable ruby-indent-level controls the amount of indentation. ((looking-at ":\\(['\"]\\)") (goto-char (match-beginning 1)) (ruby-forward-string (buffer-substring (match-beginning 1) (match-end 1)) end)) - ((looking-at ":\\([-,.+*/%&|^~<>]=?\\|===?\\|<=>\\)") + ((looking-at ":\\([-,.+*/%&|^~<>]=?\\|===?\\|<=>\\|![~=]?\\)") (goto-char (match-end 0))) ((looking-at ":\\([a-zA-Z_][a-zA-Z_0-9]*[!?=]?\\)?") (goto-char (match-end 0))) @@ -1386,7 +1386,7 @@ buffer position `limit' or the end of the buffer." '("\\(^\\|[^_]\\)\\b\\([A-Z]+\\(\\w\\|_\\)*\\)" 2 font-lock-type-face) ;; symbols - '("\\(^\\|[^:]\\)\\(:\\([-+~]@?\\|[/%&|^`]\\|\\*\\*?\\|<\\(<\\|=>?\\)?\\|>[>=]?\\|===?\\|=~\\|\\[\\]=?\\|\\(\\w\\|_\\)+\\([!?=]\\|\\b_*\\)\\|#{[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\)\\)" + '("\\(^\\|[^:]\\)\\(:\\([-+~]@?\\|[/%&|^`]\\|\\*\\*?\\|<\\(<\\|=>?\\)?\\|>[>=]?\\|===?\\|=~\\|![~=]?\\|\\[\\]=?\\|\\(\\w\\|_\\)+\\([!?=]\\|\\b_*\\)\\|#{[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\)\\)" 2 font-lock-reference-face) ;; expression expansion '("#\\({[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\|\\(\\$\\|@\\|@@\\)\\(\\w\\|_\\)+\\)"