aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorDmitry Gutov2016-02-23 02:27:49 +0200
committerDmitry Gutov2016-02-23 02:28:40 +0200
commitc1ec7434c38a8ee59e7ce895fbfd317e133ad40e (patch)
tree6b5235438da190dff7c6f294fdef6e79fb12e83f /lisp
parente72a26e00981a508569a0856125061310a3f64ac (diff)
downloademacs-c1ec7434c38a8ee59e7ce895fbfd317e133ad40e.tar.gz
emacs-c1ec7434c38a8ee59e7ce895fbfd317e133ad40e.zip
Make $, : and @ "prefix characters" in ruby-mode
* lisp/progmodes/ruby-mode.el (ruby-mode-syntax-table): Change the syntax classes of $, : and @ to "prefix character" (http://lists.gnu.org/archive/html/emacs-devel/2016-01/msg00272.html). (ruby-syntax-propertize): Undo that specifically for colons followed by an opening paren or bracket. (ruby-font-lock-keyword-beg-re): Include colon character. (ruby-font-lock-keywords): Adjust the constants matcher for `:' not being a symbol constituent anymore.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/progmodes/ruby-mode.el15
1 files changed, 10 insertions, 5 deletions
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index 9fbebebe594..cebc1dc9823 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -32,7 +32,7 @@
32;; file after putting it on your load path: 32;; file after putting it on your load path:
33;; 33;;
34;; (autoload 'ruby-mode "ruby-mode" "Major mode for ruby files" t) 34;; (autoload 'ruby-mode "ruby-mode" "Major mode for ruby files" t)
35;; (add-to-list 'auto-mode-alist '("\\.rb$" . ruby-mode)) 35;; (add-to-list 'auto-mode-alist '("\\.rb\\'" . ruby-mode))
36;; (add-to-list 'interpreter-mode-alist '("ruby" . ruby-mode)) 36;; (add-to-list 'interpreter-mode-alist '("ruby" . ruby-mode))
37;; 37;;
38;; Still needs more docstrings; search below for TODO. 38;; Still needs more docstrings; search below for TODO.
@@ -188,9 +188,10 @@ This should only be called after matching against `ruby-here-doc-beg-re'."
188 (modify-syntax-entry ?# "<" table) 188 (modify-syntax-entry ?# "<" table)
189 (modify-syntax-entry ?\n ">" table) 189 (modify-syntax-entry ?\n ">" table)
190 (modify-syntax-entry ?\\ "\\" table) 190 (modify-syntax-entry ?\\ "\\" table)
191 (modify-syntax-entry ?$ "." table) 191 (modify-syntax-entry ?$ "'" table)
192 (modify-syntax-entry ?_ "_" table) 192 (modify-syntax-entry ?_ "_" table)
193 (modify-syntax-entry ?: "_" table) 193 (modify-syntax-entry ?: "'" table)
194 (modify-syntax-entry ?@ "'" table)
194 (modify-syntax-entry ?< "." table) 195 (modify-syntax-entry ?< "." table)
195 (modify-syntax-entry ?> "." table) 196 (modify-syntax-entry ?> "." table)
196 (modify-syntax-entry ?& "." table) 197 (modify-syntax-entry ?& "." table)
@@ -1859,6 +1860,10 @@ It will be properly highlighted even when the call omits parens.")
1859 (string-to-syntax "_")))) 1860 (string-to-syntax "_"))))
1860 ;; Backtick method redefinition. 1861 ;; Backtick method redefinition.
1861 ("^[ \t]*def +\\(`\\)" (1 "_")) 1862 ("^[ \t]*def +\\(`\\)" (1 "_"))
1863 ;; Ternary operator colon followed by opening paren or bracket
1864 ;; (semi-important for indentation).
1865 ("\\(:\\)\\(?:[\({]\\|\\[[^]]\\)"
1866 (1 (string-to-syntax ".")))
1862 ;; Regular expressions. Start with matching unescaped slash. 1867 ;; Regular expressions. Start with matching unescaped slash.
1863 ("\\(?:\\=\\|[^\\]\\)\\(?:\\\\\\\\\\)*\\(/\\)" 1868 ("\\(?:\\=\\|[^\\]\\)\\(?:\\\\\\\\\\)*\\(/\\)"
1864 (1 (let ((state (save-excursion (syntax-ppss (match-beginning 1))))) 1869 (1 (let ((state (save-excursion (syntax-ppss (match-beginning 1)))))
@@ -2024,7 +2029,7 @@ It will be properly highlighted even when the call omits parens.")
2024 "The syntax table to use for fontifying Ruby mode buffers. 2029 "The syntax table to use for fontifying Ruby mode buffers.
2025See `font-lock-syntax-table'.") 2030See `font-lock-syntax-table'.")
2026 2031
2027(defconst ruby-font-lock-keyword-beg-re "\\(?:^\\|[^.@$]\\|\\.\\.\\)") 2032(defconst ruby-font-lock-keyword-beg-re "\\(?:^\\|[^.@$:]\\|\\.\\.\\)")
2028 2033
2029(defconst ruby-font-lock-keywords 2034(defconst ruby-font-lock-keywords
2030 `(;; Functions. 2035 `(;; Functions.
@@ -2197,7 +2202,7 @@ See `font-lock-syntax-table'.")
2197 ("\\(\\$\\|@\\|@@\\)\\(\\w\\|_\\)+" 2202 ("\\(\\$\\|@\\|@@\\)\\(\\w\\|_\\)+"
2198 0 font-lock-variable-name-face) 2203 0 font-lock-variable-name-face)
2199 ;; Constants. 2204 ;; Constants.
2200 ("\\(?:\\_<\\|::\\)\\([A-Z]+\\(\\w\\|_\\)*\\)" 2205 ("\\_<\\([A-Z]+\\(\\w\\|_\\)*\\)"
2201 1 (unless (eq ?\( (char-after)) font-lock-type-face)) 2206 1 (unless (eq ?\( (char-after)) font-lock-type-face))
2202 ;; Ruby 1.9-style symbol hash keys. 2207 ;; Ruby 1.9-style symbol hash keys.
2203 ("\\(?:^\\s *\\|[[{(,]\\s *\\|\\sw\\s +\\)\\(\\(\\sw\\|_\\)+:\\)[^:]" 2208 ("\\(?:^\\s *\\|[[{(,]\\s *\\|\\sw\\s +\\)\\(\\(\\sw\\|_\\)+:\\)[^:]"