From 73eab938a0ff50e744a769c89816e621a11e0ac3 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Sat, 22 Jun 2013 03:07:49 +0400 Subject: [PATCH] * lisp/progmodes/ruby-mode.el (ruby-font-lock-keywords): Highlight keyword-like methods on Kernel and Module with font-lock-builtin-face. --- lisp/ChangeLog | 6 ++++++ lisp/progmodes/ruby-mode.el | 40 +++++++++++++++++++++++-------------- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5066f9595a2..64cb8574db3 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2013-06-21 Dmitry Gutov + + * progmodes/ruby-mode.el (ruby-font-lock-keywords): Highlight + keyword-like methods on Kernel and Module with + font-lock-builtin-face. + 2013-06-21 Stephen Berman * obsolete/otodo-mode.el: Move and rename from calendar/todo-mode.el. diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index 8a1548bc940..fe44647dcce 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -1726,12 +1726,11 @@ See `font-lock-syntax-table'.") ;; functions '("^\\s *def\\s +\\([^( \t\n]+\\)" 1 font-lock-function-name-face) - ;; keywords - (cons (concat - "\\(^\\|[^.@$]\\|\\.\\.\\)\\_<\\(defined\\?\\|" + (list (concat + "\\(^\\|[^.@$]\\|\\.\\.\\)\\(" + ;; keywords (regexp-opt - '("alias_method" - "alias" + '("alias" "and" "begin" "break" @@ -1739,6 +1738,7 @@ See `font-lock-syntax-table'.") "catch" "class" "def" + "defined?" "do" "elsif" "else" @@ -1748,21 +1748,15 @@ See `font-lock-syntax-table'.") "end" "if" "in" - "module_function" "module" "next" "not" "or" - "public" - "private" - "protected" - "raise" "redo" "rescue" "retry" "return" "then" - "throw" "super" "unless" "undef" @@ -1770,10 +1764,26 @@ See `font-lock-syntax-table'.") "when" "while" "yield") - t) - "\\)" - ruby-keyword-end-re) - 2) + 'symbols) + "\\|" + ;; keyword-like methods on Kernel and Module + (regexp-opt + '("alias_method" + "autoload" + "module_function" + "private" + "protected" + "public" + "raise" + "require" + "require_relative" + "throw") + 'symbols) + "\\)") + 2 + '(if (match-beginning 4) + font-lock-builtin-face + font-lock-keyword-face)) ;; here-doc beginnings `(,ruby-here-doc-beg-re 0 (unless (ruby-singleton-class-p (match-beginning 0)) 'font-lock-string-face)) -- 2.39.5