diff options
| author | Dmitry Gutov | 2013-07-16 23:16:51 +0400 |
|---|---|---|
| committer | Dmitry Gutov | 2013-07-16 23:16:51 +0400 |
| commit | ac72c08d12cb5b86e873148ce52c2403ef2159c6 (patch) | |
| tree | e1cfd03937c683d6e9b357729314aef0acbda3f7 | |
| parent | 4e604a5d70c4f26abe8bb3494346c598389906b3 (diff) | |
| download | emacs-ac72c08d12cb5b86e873148ce52c2403ef2159c6.tar.gz emacs-ac72c08d12cb5b86e873148ce52c2403ef2159c6.zip | |
* lisp/progmodes/ruby-mode.el (ruby-block-beg-keywords): Inline.
(ruby-font-lock-keyword-beg-re): Extract from
`ruby-font-lock-keywords'.
| -rw-r--r-- | lisp/ChangeLog | 3 | ||||
| -rw-r--r-- | lisp/progmodes/ruby-mode.el | 41 |
2 files changed, 22 insertions, 22 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 37c2365cc60..b88f66f98d0 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -2,6 +2,9 @@ | |||
| 2 | 2 | ||
| 3 | * progmodes/ruby-mode.el (ruby-font-lock-keywords): Do not | 3 | * progmodes/ruby-mode.el (ruby-font-lock-keywords): Do not |
| 4 | highlight question marks in the method names as strings. | 4 | highlight question marks in the method names as strings. |
| 5 | (ruby-block-beg-keywords): Inline. | ||
| 6 | (ruby-font-lock-keyword-beg-re): Extract from | ||
| 7 | `ruby-font-lock-keywords'. | ||
| 5 | 8 | ||
| 6 | 2013-07-16 Jan Djärv <jan.h.d@swipnet.se> | 9 | 2013-07-16 Jan Djärv <jan.h.d@swipnet.se> |
| 7 | 10 | ||
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 @@ | |||
| 46 | :prefix "ruby-" | 46 | :prefix "ruby-" |
| 47 | :group 'languages) | 47 | :group 'languages) |
| 48 | 48 | ||
| 49 | (defconst ruby-keyword-end-re | ||
| 50 | (if (string-match "\\_>" "ruby") | ||
| 51 | "\\_>" | ||
| 52 | "\\>")) | ||
| 53 | |||
| 54 | (defconst ruby-block-beg-keywords | 49 | (defconst ruby-block-beg-keywords |
| 55 | '("class" "module" "def" "if" "unless" "case" "while" "until" "for" "begin" "do") | 50 | '("class" "module" "def" "if" "unless" "case" "while" "until" "for" "begin" "do") |
| 56 | "Keywords at the beginning of blocks.") | 51 | "Keywords at the beginning of blocks.") |
| @@ -60,7 +55,7 @@ | |||
| 60 | "Regexp to match the beginning of blocks.") | 55 | "Regexp to match the beginning of blocks.") |
| 61 | 56 | ||
| 62 | (defconst ruby-non-block-do-re | 57 | (defconst ruby-non-block-do-re |
| 63 | (concat (regexp-opt '("while" "until" "for" "rescue") t) ruby-keyword-end-re) | 58 | (regexp-opt '("while" "until" "for" "rescue") 'symbols) |
| 64 | "Regexp to match keywords that nest without blocks.") | 59 | "Regexp to match keywords that nest without blocks.") |
| 65 | 60 | ||
| 66 | (defconst ruby-indent-beg-re | 61 | (defconst ruby-indent-beg-re |
| @@ -696,7 +691,7 @@ Can be one of `heredoc', `modifier', `expr-qstr', `expr-re'." | |||
| 696 | ((looking-at (concat "\\_<\\(" ruby-block-beg-re "\\)\\_>")) | 691 | ((looking-at (concat "\\_<\\(" ruby-block-beg-re "\\)\\_>")) |
| 697 | (and | 692 | (and |
| 698 | (save-match-data | 693 | (save-match-data |
| 699 | (or (not (looking-at (concat "do" ruby-keyword-end-re))) | 694 | (or (not (looking-at "do\\_>")) |
| 700 | (save-excursion | 695 | (save-excursion |
| 701 | (back-to-indentation) | 696 | (back-to-indentation) |
| 702 | (not (looking-at ruby-non-block-do-re))))) | 697 | (not (looking-at ruby-non-block-do-re))))) |
| @@ -1718,14 +1713,16 @@ See the definition of `ruby-font-lock-syntactic-keywords'." | |||
| 1718 | "The syntax table to use for fontifying Ruby mode buffers. | 1713 | "The syntax table to use for fontifying Ruby mode buffers. |
| 1719 | See `font-lock-syntax-table'.") | 1714 | See `font-lock-syntax-table'.") |
| 1720 | 1715 | ||
| 1716 | (defconst ruby-font-lock-keyword-beg-re "\\(?:^\\|[^.@$]\\|\\.\\.\\)") | ||
| 1717 | |||
| 1721 | (defconst ruby-font-lock-keywords | 1718 | (defconst ruby-font-lock-keywords |
| 1722 | (list | 1719 | (list |
| 1723 | ;; functions | 1720 | ;; functions |
| 1724 | '("^\\s *def\\s +\\(?:[^( \t\n.]*\\.\\)?\\([^( \t\n]+\\)" | 1721 | '("^\\s *def\\s +\\(?:[^( \t\n.]*\\.\\)?\\([^( \t\n]+\\)" |
| 1725 | 1 font-lock-function-name-face) | 1722 | 1 font-lock-function-name-face) |
| 1723 | ;; keywords | ||
| 1726 | (list (concat | 1724 | (list (concat |
| 1727 | "\\(^\\|[^.@$]\\|\\.\\.\\)\\(" | 1725 | ruby-font-lock-keyword-beg-re |
| 1728 | ;; keywords | ||
| 1729 | (regexp-opt | 1726 | (regexp-opt |
| 1730 | '("alias" | 1727 | '("alias" |
| 1731 | "and" | 1728 | "and" |
| @@ -1760,11 +1757,14 @@ See `font-lock-syntax-table'.") | |||
| 1760 | "when" | 1757 | "when" |
| 1761 | "while" | 1758 | "while" |
| 1762 | "yield") | 1759 | "yield") |
| 1763 | 'symbols) | 1760 | 'symbols)) |
| 1764 | "\\|" | 1761 | 1 'font-lock-keyword-face) |
| 1762 | ;; some core methods | ||
| 1763 | (list (concat | ||
| 1764 | ruby-font-lock-keyword-beg-re | ||
| 1765 | (regexp-opt | 1765 | (regexp-opt |
| 1766 | ;; built-in methods on Kernel | 1766 | '(;; built-in methods on Kernel |
| 1767 | '("__callee__" | 1767 | "__callee__" |
| 1768 | "__dir__" | 1768 | "__dir__" |
| 1769 | "__method__" | 1769 | "__method__" |
| 1770 | "abort" | 1770 | "abort" |
| @@ -1823,20 +1823,17 @@ See `font-lock-syntax-table'.") | |||
| 1823 | "public" | 1823 | "public" |
| 1824 | "refine" | 1824 | "refine" |
| 1825 | "using") | 1825 | "using") |
| 1826 | 'symbols) | 1826 | 'symbols)) |
| 1827 | "\\)") | 1827 | 1 'font-lock-builtin-face) |
| 1828 | 2 | ||
| 1829 | '(if (match-beginning 4) | ||
| 1830 | font-lock-builtin-face | ||
| 1831 | font-lock-keyword-face)) | ||
| 1832 | ;; Perl-ish keywords | 1828 | ;; Perl-ish keywords |
| 1833 | "\\_<\\(?:BEGIN\\|END\\)\\_>\\|^__END__$" | 1829 | "\\_<\\(?:BEGIN\\|END\\)\\_>\\|^__END__$" |
| 1834 | ;; here-doc beginnings | 1830 | ;; here-doc beginnings |
| 1835 | `(,ruby-here-doc-beg-re 0 (unless (ruby-singleton-class-p (match-beginning 0)) | 1831 | `(,ruby-here-doc-beg-re 0 (unless (ruby-singleton-class-p (match-beginning 0)) |
| 1836 | 'font-lock-string-face)) | 1832 | 'font-lock-string-face)) |
| 1837 | ;; variables | 1833 | ;; variables |
| 1838 | '("\\(^\\|[^.@$]\\|\\.\\.\\)\\_<\\(nil\\|self\\|true\\|false\\)\\>" | 1834 | `(,(concat ruby-font-lock-keyword-beg-re |
| 1839 | 2 font-lock-variable-name-face) | 1835 | "\\_<\\(nil\\|self\\|true\\|false\\)\\>") |
| 1836 | 1 font-lock-variable-name-face) | ||
| 1840 | ;; keywords that evaluate to certain values | 1837 | ;; keywords that evaluate to certain values |
| 1841 | '("\\_<__\\(?:LINE\\|ENCODING\\|FILE\\)__\\_>" 0 font-lock-variable-name-face) | 1838 | '("\\_<__\\(?:LINE\\|ENCODING\\|FILE\\)__\\_>" 0 font-lock-variable-name-face) |
| 1842 | ;; symbols | 1839 | ;; symbols |
| @@ -1852,7 +1849,7 @@ See `font-lock-syntax-table'.") | |||
| 1852 | 1 (unless (eq ?\( (char-after)) font-lock-type-face)) | 1849 | 1 (unless (eq ?\( (char-after)) font-lock-type-face)) |
| 1853 | '("\\(^\\s *\\|[\[\{\(,]\\s *\\|\\sw\\s +\\)\\(\\(\\sw\\|_\\)+\\):[^:]" 2 font-lock-constant-face) | 1850 | '("\\(^\\s *\\|[\[\{\(,]\\s *\\|\\sw\\s +\\)\\(\\(\\sw\\|_\\)+\\):[^:]" 2 font-lock-constant-face) |
| 1854 | ;; conversion methods on Kernel | 1851 | ;; conversion methods on Kernel |
| 1855 | (list (concat "\\(?:^\\|[^.@$]\\|\\.\\.\\)" | 1852 | (list (concat ruby-font-lock-keyword-beg-re |
| 1856 | (regexp-opt '("Array" "Complex" "Float" "Hash" | 1853 | (regexp-opt '("Array" "Complex" "Float" "Hash" |
| 1857 | "Integer" "Rational" "String") 'symbols)) | 1854 | "Integer" "Rational" "String") 'symbols)) |
| 1858 | 1 font-lock-builtin-face) | 1855 | 1 font-lock-builtin-face) |