From 2ce3c56586f4061727ace4daed4582d2aa6f8e98 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Sat, 13 Jul 2013 23:10:19 +0400 Subject: * lisp/progmodes/ruby-mode.el (ruby-font-lock-keywords): Highlight conversion methods on Kernel. --- lisp/progmodes/ruby-mode.el | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lisp/progmodes/ruby-mode.el') diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index 06dffd80d88..0b83921504b 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -1851,6 +1851,11 @@ See `font-lock-syntax-table'.") '("\\(?:\\_<\\|::\\)\\([A-Z]+\\(\\w\\|_\\)*\\)" 1 (unless (eq ?\( (char-after)) font-lock-type-face)) '("\\(^\\s *\\|[\[\{\(,]\\s *\\|\\sw\\s +\\)\\(\\(\\sw\\|_\\)+\\):[^:]" 2 font-lock-constant-face) + ;; conversion methods on Kernel + (list (concat "\\(?:^\\|[^.@$]\\|\\.\\.\\)" + (regexp-opt '("Array" "Complex" "Float" "Hash" + "Integer" "Rational" "String") 'symbols)) + 1 font-lock-builtin-face) ;; expression expansion '(ruby-match-expression-expansion 2 font-lock-variable-name-face t) -- cgit v1.2.3 From 77aea2fbb3fc290a59d84e6534424a09aa8fc41a Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Tue, 16 Jul 2013 18:47:23 +0400 Subject: * lisp/progmodes/ruby-mode.el (ruby-font-lock-keywords): Do not highlight question marks in the method names as strings. --- lisp/ChangeLog | 5 +++++ lisp/progmodes/ruby-mode.el | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'lisp/progmodes/ruby-mode.el') diff --git a/lisp/ChangeLog b/lisp/ChangeLog index d1613283bb7..37c2365cc60 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2013-07-16 Dmitry Gutov + + * progmodes/ruby-mode.el (ruby-font-lock-keywords): Do not + highlight question marks in the method names as strings. + 2013-07-16 Jan Djärv * frame.el (blink-cursor-blinks): New defcustom. diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index 0b83921504b..dc3dec87ba8 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -1864,7 +1864,7 @@ See `font-lock-syntax-table'.") 1 font-lock-negation-char-face) ;; character literals ;; FIXME: Support longer escape sequences. - '("\\?\\\\?\\S " 0 font-lock-string-face) + '("\\_<\\?\\\\?\\S " 0 font-lock-string-face) ) "Additional expressions to highlight in Ruby mode.") -- cgit v1.2.3 From ac72c08d12cb5b86e873148ce52c2403ef2159c6 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Tue, 16 Jul 2013 23:16:51 +0400 Subject: * lisp/progmodes/ruby-mode.el (ruby-block-beg-keywords): Inline. (ruby-font-lock-keyword-beg-re): Extract from `ruby-font-lock-keywords'. --- lisp/ChangeLog | 3 +++ lisp/progmodes/ruby-mode.el | 41 +++++++++++++++++++---------------------- 2 files changed, 22 insertions(+), 22 deletions(-) (limited to 'lisp/progmodes/ruby-mode.el') diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 37c2365cc60..b88f66f98d0 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -2,6 +2,9 @@ * progmodes/ruby-mode.el (ruby-font-lock-keywords): Do not highlight question marks in the method names as strings. + (ruby-block-beg-keywords): Inline. + (ruby-font-lock-keyword-beg-re): Extract from + `ruby-font-lock-keywords'. 2013-07-16 Jan Djärv diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index dc3dec87ba8..c8fae7ba1e6 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -46,11 +46,6 @@ :prefix "ruby-" :group 'languages) -(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.") @@ -60,7 +55,7 @@ "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-opt '("while" "until" "for" "rescue") 'symbols) "Regexp to match keywords that nest without blocks.") (defconst ruby-indent-beg-re @@ -696,7 +691,7 @@ Can be one of `heredoc', `modifier', `expr-qstr', `expr-re'." ((looking-at (concat "\\_<\\(" ruby-block-beg-re "\\)\\_>")) (and (save-match-data - (or (not (looking-at (concat "do" ruby-keyword-end-re))) + (or (not (looking-at "do\\_>")) (save-excursion (back-to-indentation) (not (looking-at ruby-non-block-do-re))))) @@ -1718,14 +1713,16 @@ See the definition of `ruby-font-lock-syntactic-keywords'." "The syntax table to use for fontifying Ruby mode buffers. See `font-lock-syntax-table'.") +(defconst ruby-font-lock-keyword-beg-re "\\(?:^\\|[^.@$]\\|\\.\\.\\)") + (defconst ruby-font-lock-keywords (list ;; functions '("^\\s *def\\s +\\(?:[^( \t\n.]*\\.\\)?\\([^( \t\n]+\\)" 1 font-lock-function-name-face) + ;; keywords (list (concat - "\\(^\\|[^.@$]\\|\\.\\.\\)\\(" - ;; keywords + ruby-font-lock-keyword-beg-re (regexp-opt '("alias" "and" @@ -1760,11 +1757,14 @@ See `font-lock-syntax-table'.") "when" "while" "yield") - 'symbols) - "\\|" + 'symbols)) + 1 'font-lock-keyword-face) + ;; some core methods + (list (concat + ruby-font-lock-keyword-beg-re (regexp-opt - ;; built-in methods on Kernel - '("__callee__" + '(;; built-in methods on Kernel + "__callee__" "__dir__" "__method__" "abort" @@ -1823,20 +1823,17 @@ See `font-lock-syntax-table'.") "public" "refine" "using") - 'symbols) - "\\)") - 2 - '(if (match-beginning 4) - font-lock-builtin-face - font-lock-keyword-face)) + 'symbols)) + 1 'font-lock-builtin-face) ;; Perl-ish keywords "\\_<\\(?:BEGIN\\|END\\)\\_>\\|^__END__$" ;; here-doc beginnings `(,ruby-here-doc-beg-re 0 (unless (ruby-singleton-class-p (match-beginning 0)) 'font-lock-string-face)) ;; variables - '("\\(^\\|[^.@$]\\|\\.\\.\\)\\_<\\(nil\\|self\\|true\\|false\\)\\>" - 2 font-lock-variable-name-face) + `(,(concat ruby-font-lock-keyword-beg-re + "\\_<\\(nil\\|self\\|true\\|false\\)\\>") + 1 font-lock-variable-name-face) ;; keywords that evaluate to certain values '("\\_<__\\(?:LINE\\|ENCODING\\|FILE\\)__\\_>" 0 font-lock-variable-name-face) ;; symbols @@ -1852,7 +1849,7 @@ See `font-lock-syntax-table'.") 1 (unless (eq ?\( (char-after)) font-lock-type-face)) '("\\(^\\s *\\|[\[\{\(,]\\s *\\|\\sw\\s +\\)\\(\\(\\sw\\|_\\)+\\):[^:]" 2 font-lock-constant-face) ;; conversion methods on Kernel - (list (concat "\\(?:^\\|[^.@$]\\|\\.\\.\\)" + (list (concat ruby-font-lock-keyword-beg-re (regexp-opt '("Array" "Complex" "Float" "Hash" "Integer" "Rational" "String") 'symbols)) 1 font-lock-builtin-face) -- cgit v1.2.3