From 70c46b281688a5a04097c56e651282a657c38494 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Tue, 9 Jul 2013 05:17:48 +0400 Subject: * lisp/progmodes/ruby-mode.el (ruby-font-lock-keywords): Remove extra "autoload". Remove "warn lower camel case" section, previously commented out. Highlight negation char. Do not highlight the target in singleton method definitions. --- lisp/progmodes/ruby-mode.el | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'lisp/progmodes/ruby-mode.el') diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index 5f92d197a66..b873606286a 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -1721,7 +1721,7 @@ See `font-lock-syntax-table'.") (defconst ruby-font-lock-keywords (list ;; functions - '("^\\s *def\\s +\\([^( \t\n]+\\)" + '("^\\s *def\\s +\\(?:[^( \t\n.]*\\.\\)?\\([^( \t\n]+\\)" 1 font-lock-function-name-face) (list (concat "\\(^\\|[^.@$]\\|\\.\\.\\)\\(" @@ -1809,7 +1809,6 @@ See `font-lock-syntax-table'.") "warn" ;; keyword-like private methods on Module "alias_method" - "autoload" "attr" "attr_accessor" "attr_reader" @@ -1855,9 +1854,9 @@ See `font-lock-syntax-table'.") ;; expression expansion '(ruby-match-expression-expansion 2 font-lock-variable-name-face t) - ;; warn lower camel case - ;'("\\<[a-z]+[a-z0-9]*[A-Z][A-Za-z0-9]*\\([!?]?\\|\\>\\)" - ; 0 font-lock-warning-face) + ;; negation char + '("[^[:alnum:]_]\\(!\\)[^=]" + 1 font-lock-negation-char-face) ) "Additional expressions to highlight in Ruby mode.") -- cgit v1.2.1 From 0880a9520ed651100f9ca85b5c37399b465c7ea2 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Sat, 13 Jul 2013 00:28:53 +0400 Subject: * lisp/progmodes/ruby-mode.el (ruby-percent-literals-beg-re): (ruby-syntax-expansion-allowed-p): Support array of symbols, for Ruby 2.0. (ruby-font-lock-keywords): Distinguish calls to functions with module-like names from module references. Highlight character literals. --- lisp/progmodes/ruby-mode.el | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'lisp/progmodes/ruby-mode.el') diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index b873606286a..041458233c9 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -1351,7 +1351,7 @@ If the result is do-end block, it will always be multiline." (progn (eval-and-compile (defconst ruby-percent-literal-beg-re - "\\(%\\)[qQrswWx]?\\([[:punct:]]\\)" + "\\(%\\)[qQrswWxIi]?\\([[:punct:]]\\)" "Regexp to match the beginning of percent literal.") (defconst ruby-syntax-methods-before-regexp @@ -1387,7 +1387,7 @@ It will be properly highlighted even when the call omits parens.") (funcall (syntax-propertize-rules ;; $' $" $` .... are variables. - ;; ?' ?" ?` are ascii codes. + ;; ?' ?" ?` are character literals (one-char strings in 1.9+). ("\\([?$]\\)[#\"'`]" (1 (unless (save-excursion ;; Not within a string. @@ -1518,7 +1518,7 @@ It will be properly highlighted even when the call omits parens.") (save-match-data (save-excursion (goto-char (nth 8 parse-state)) - (looking-at "%\\(?:[QWrx]\\|\\W\\)"))))))) + (looking-at "%\\(?:[QWrxI]\\|\\W\\)"))))))) (defun ruby-syntax-propertize-expansions (start end) (save-excursion @@ -1848,8 +1848,11 @@ See `font-lock-syntax-table'.") '("\\(\\$\\|@\\|@@\\)\\(\\w\\|_\\)+" 0 font-lock-variable-name-face) ;; constants - '("\\(?:\\_<\\|::\\)\\([A-Z]+\\(\\w\\|_\\)*\\)" - 1 font-lock-type-face) + '("\\(?:\\_<\\|::\\)\\([A-Z]+\\(\\w\\|_\\)*\\)\\(?:\\_>[^\(]\\|::\\|\\'\\)" + 1 (progn + (when (eq ?: (char-before)) + (forward-char -2)) + font-lock-type-face)) '("\\(^\\s *\\|[\[\{\(,]\\s *\\|\\sw\\s +\\)\\(\\(\\sw\\|_\\)+\\):[^:]" 2 font-lock-constant-face) ;; expression expansion '(ruby-match-expression-expansion @@ -1857,6 +1860,9 @@ See `font-lock-syntax-table'.") ;; negation char '("[^[:alnum:]_]\\(!\\)[^=]" 1 font-lock-negation-char-face) + ;; character literals + ;; FIXME: Support longer escape sequences. + '("\\?\\\\?\\S " 0 font-lock-string-face) ) "Additional expressions to highlight in Ruby mode.") -- cgit v1.2.1 From 481861772a0ba3815d86c814275f0e3b9ff71d4c Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Sat, 13 Jul 2013 03:36:14 +0400 Subject: * progmodes/ruby-mode.el (ruby-font-lock-keywords): Simplify the last change. --- lisp/progmodes/ruby-mode.el | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'lisp/progmodes/ruby-mode.el') diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index 041458233c9..06dffd80d88 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -1848,11 +1848,8 @@ See `font-lock-syntax-table'.") '("\\(\\$\\|@\\|@@\\)\\(\\w\\|_\\)+" 0 font-lock-variable-name-face) ;; constants - '("\\(?:\\_<\\|::\\)\\([A-Z]+\\(\\w\\|_\\)*\\)\\(?:\\_>[^\(]\\|::\\|\\'\\)" - 1 (progn - (when (eq ?: (char-before)) - (forward-char -2)) - font-lock-type-face)) + '("\\(?:\\_<\\|::\\)\\([A-Z]+\\(\\w\\|_\\)*\\)" + 1 (unless (eq ?\( (char-after)) font-lock-type-face)) '("\\(^\\s *\\|[\[\{\(,]\\s *\\|\\sw\\s +\\)\\(\\(\\sw\\|_\\)+\\):[^:]" 2 font-lock-constant-face) ;; expression expansion '(ruby-match-expression-expansion -- cgit v1.2.1