[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Small improvements to ruby-mode
From: |
Dmitry Gutov |
Subject: |
Re: Small improvements to ruby-mode |
Date: |
Wed, 03 Jul 2013 19:46:50 +0400 |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 |
On 02.07.2013 22:38, Dmitry Gutov wrote:
Putting the cursor on one of the 4 lines after "elsif" in the second
example and pressing `C-M-p' moves it to the "add_offence" line.
And pressing `C-M-n' after that moves it to the "end" closing the
"operands.each" block.
Pressing `C-M-p' or `C-M-n' on the `elsif' line misbehaves similarly.
I've fixed the last one and left the other two in. For the most part,
they're intentional, since we're not supposed to stop at "elsif" (it's
not beginning or end of a block, after all).
As far as the keywords go, I've checked in the following patch:
=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog 2013-07-03 03:20:04 +0000
+++ lisp/ChangeLog 2013-07-03 15:45:17 +0000
@@ -1,3 +1,8 @@
+2013-07-03 Dmitry Gutov <address@hidden>
+
+ * progmodes/ruby-mode.el (ruby-font-lock-keywords): Highlight more
+ keywords and built-ins.
+
2013-07-03 Glenn Morris <address@hidden>
* subr.el (y-or-n-p): Handle empty prompts. (Bug#14770)
=== modified file 'lisp/progmodes/ruby-mode.el'
--- lisp/progmodes/ruby-mode.el 2013-07-03 01:02:18 +0000
+++ lisp/progmodes/ruby-mode.el 2013-07-03 15:36:27 +0000
@@ -1762,31 +1762,67 @@
"yield")
'symbols)
"\\|"
- ;; keyword-like methods on Kernel and Module
(regexp-opt
- '("alias_method"
+ ;; built-in methods on Kernel
+ '("__callee__"
+ "__dir__"
+ "__method__"
+ "abort"
+ "at_exit"
+ "autoload"
+ "autoload?"
+ "binding"
+ "block_given?"
+ "caller"
+ "catch"
+ "eval"
+ "exec"
+ "exit"
+ "exit!"
+ "fail"
+ "fork"
+ "format"
+ "lambda"
+ "load"
+ "loop"
+ "open"
+ "p"
+ "print"
+ "printf"
+ "proc"
+ "putc"
+ "puts"
+ "raise"
+ "rand"
+ "readline"
+ "readlines"
+ "require"
+ "require_relative"
+ "sleep"
+ "spawn"
+ "sprintf"
+ "srand"
+ "syscall"
+ "system"
+ "throw"
+ "trap"
+ "warn"
+ ;; keyword-like private methods on Module
+ "alias_method"
"autoload"
"attr"
"attr_accessor"
"attr_reader"
"attr_writer"
- "catch"
"define_method"
"extend"
- "fail"
"include"
- "lambda"
- "loop"
"module_function"
+ "prepend"
"private"
- "proc"
"protected"
"public"
- "raise"
"refine"
- "require"
- "require_relative"
- "throw"
"using")
'symbols)
"\\)")
@@ -1794,12 +1830,16 @@
'(if (match-beginning 4)
font-lock-builtin-face
font-lock-keyword-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
'("\\(^\\|address@hidden|\\.\\.\\)\\_<\\(nil\\|self\\|true\\|false\\)\\>"
2 font-lock-variable-name-face)
+ ;; keywords that evaluate to certain values
+ '("\\_<__\\(?:LINE\\|ENCODING\\|FILE\\)__\\_>" 0
font-lock-variable-name-face)
;; symbols
'("\\(^\\|[^:]\\)\\(:\\(address@hidden|[/%&|^`]\\|\\*\\*?\\|<\\(<\\|=>?\\)?\\|>[>=]?\\|===?\\|=~\\|![~=]?\\|\\[\\]=?\\|@?\\(\\w\\|_\\)+\\([!?=]\\|\\b_*\\)\\|#{[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\)\\)"
2 font-lock-constant-face)
- Re: Small improvements to ruby-mode, Dmitry Gutov, 2013/07/01
- Re: Small improvements to ruby-mode, Bozhidar Batsov, 2013/07/01
- Re: Small improvements to ruby-mode, Dmitry Gutov, 2013/07/01
- Message not available
- Re: Small improvements to ruby-mode, Dmitry Gutov, 2013/07/02
- Re: Small improvements to ruby-mode,
Dmitry Gutov <=
- Message not available
- Re: Small improvements to ruby-mode, Dmitry Gutov, 2013/07/05
- Re: Small improvements to ruby-mode, Stefan Monnier, 2013/07/05
- Re: Small improvements to ruby-mode, Dmitry Gutov, 2013/07/05
- Re: Small improvements to ruby-mode, Stefan Monnier, 2013/07/05
- Re: Small improvements to ruby-mode, Bozhidar Batsov, 2013/07/05
- Re: Small improvements to ruby-mode, Dmitry Gutov, 2013/07/05
- Re: Small improvements to ruby-mode, Bozhidar Batsov, 2013/07/06
- Re: Small improvements to ruby-mode, Dmitry Gutov, 2013/07/06
- Re: Small improvements to ruby-mode, Bozhidar Batsov, 2013/07/06
- Re: Small improvements to ruby-mode, Dmitry Gutov, 2013/07/06