Commit graph

225 commits

Author SHA1 Message Date
John Anthony
f73754c923 * lisp/progmodes/ruby-mode.el (ruby-mode-menu): Add a menu
Fixes: debbugs:15600
2013-10-24 19:38:39 -07:00
Dmitry Gutov
369bbf7198 * lisp/progmodes/ruby-mode.el (ruby-smie-rules): Fix the "curly block
with parameters" example.  Simplify the "is it block or is it
hash" check, but also make it more thorough.

* test/indent/ruby.rb: Fix syntax error in the latest example.
2013-10-24 04:47:28 +04:00
Stefan Monnier
03d44565bb * lisp/progmodes/ruby-mode.el (ruby-smie-rules): Only align with parent of
{ if it is hanging.
2013-10-23 13:55:53 -04:00
Stefan Monnier
bc4aaa31e2 * lisp/progmodes/ruby-mode.el (ruby-smie-rules): Don't return 0 for
:before ";".
2013-10-23 13:18:11 -04:00
Dmitry Gutov
ee4282cde2 * lisp/progmodes/ruby-mode.el (ruby-smie--at-dot-call): Use
`following-char'.
2013-10-23 06:59:45 +04:00
Stefan Monnier
7790a27058 * lisp/emacs-lisp/smie.el (smie-rule-parent): Fix opener-test.
* lisp/progmodes/ruby-mode.el (ruby-smie-rules):
Remove corresponding workaround.  Fix indentation rule of ";" so it
also applies when ";" is the parent.
2013-10-22 11:45:56 -04:00
Dmitry Gutov
18cacc392d * lisp/progmodes/ruby-mode.el (ruby-smie-grammar): Remove outdated
TODO.  Add "." after " @ ".
(ruby-smie--at-dot-call): New function.  Checks if point at method
call with explicit target.
(ruby-smie--forward-token, ruby-smie--backward-token): Prepend "."
to the method name tokens when it precedes them.
(ruby-smie--backward-id, ruby-smie--forward-id): Remove.
(ruby-smie-rules): Add rule for indentation before and after "."
token.
2013-10-22 02:25:59 +04:00
Stefan Monnier
df74c4be16 * lisp/progmodes/ruby-mode.el (ruby-smie-rules): Indent after + used as
an instruction.
2013-10-21 09:34:13 -04:00
Dmitry Gutov
cfef16c084 * lisp/progmodes/ruby-mode.el (ruby-smie-grammar): Add (almost) all
infix operators.
(ruby-smie--implicit-semi-p): Add new operator chars.
2013-10-21 09:54:18 +04:00
Dmitry Gutov
8c1ae48154 * lisp/progmodes/ruby-mode.el (ruby-mode-map): Add binding for
`smie-down-list'.
(ruby-smie--args-separator-p): Check that there's no newline
between method call and its arguments.
(ruby-smie-rules): Handle new cases: curly block with and without
parameters, hash surrounded with parens, block passed to
paren-less method call.

* test/indent/ruby.rb: New examples for indentation of blocks.  Example
of hash inside parens that inflooped before this commit.
2013-10-21 07:50:06 +04:00
Dmitry Gutov
1eda1d8d34 * lisp/progmodes/ruby-mode.el (ruby-smie--args-separator-p): Handle
methods ending with `?' and `!'.

* test/indent/ruby.rb: More examples for bug#15594, both failing and
now passing.
2013-10-14 04:51:20 +03:00
Akinori MUSHA
e70181b829 * progmodes/ruby-mode.el (ruby-encoding-map): Add a mapping from
`japanese-cp932' to `cp932' to fix the problem where saving a
source file written in Shift_JIS twice would end up having
`coding: japanese-cp932' which Ruby could not recognize.
(ruby-mode-set-encoding): Add support for encodings mapped to nil
in `ruby-encoding-map'.
(ruby-encoding-map): Map `us-ascii' to nil by default, meaning it
doesn't need to be explicitly declared in magic comment.
(ruby-encoding-map): Add type declaration for better customize UI.
2013-10-14 03:23:29 +03:00
Dmitry Gutov
a9ba094b81 * lisp/progmodes/ruby-mode.el (ruby-mode): Add `ruby-mode-set-encoding'
to `after-save-hook' instead of `before-save-hook'.
(ruby-mode-set-encoding): Use the value of coding system used to
write the file.  Call `basic-save-buffer-1' after modifying the
buffer.
2013-10-14 00:35:31 +03:00
Stefan Monnier
650fa7bfb4 * lisp/progmodes/ruby-mode.el (ruby-smie-grammar): Add rule for paren-free
method calls (bug#bug#15594).
(ruby-smie--args-separator-p): New function.
(ruby-smie--forward-token, ruby-smie--backward-token): Use it to
recognize paren-free method calls.
2013-10-12 16:40:50 -04:00
Dmitry Gutov
b68e29263f * lisp/progmodes/ruby-mode.el (ruby-smie--implicit-semi-p): Split the
cases of ? and =.
(ruby-smie-rules): Simplify the "do" rule.  The cases when the
predicate would return nil are almost non-existent.
(ruby-smie--redundant-do-p): Include "until" and "for" statements.
2013-10-11 05:11:37 +03:00
Dmitry Gutov
238150c8ff * lisp/progmodes/ruby-mode.el (ruby-smie-rules): Indent after hanging
iuwu-mod token.
(ruby-smie--implicit-semi-p): Prohibit implicit semicolon after
hanging iuwu-mod token.
(ruby-smie--forward-token): Do not include a dot after a token in
that token.
(ruby-smie--backward-token): Likewise.
2013-10-09 06:18:01 +03:00
Dmitry Gutov
35ece233a8 Refine the last change 2013-10-08 02:03:16 +03:00
Dmitry Gutov
0ea1599d34 * lisp/progmodes/ruby-mode.el (ruby-smie--implicit-semi-p): Handle the
case of the dot in a chained method call being on the following
line.
2013-10-08 02:01:23 +03:00
Stefan Monnier
d2e0e79548 * lisp/emacs-lisp/smie.el (smie-next-sexp): Refine last fix.
* lisp/progmodes/ruby-mode.el (ruby-smie-rules): Tweak handling of
open braces.
2013-10-07 12:56:51 -04:00
Stefan Monnier
7ccae3b126 * lisp/progmodes/ruby-mode.el: Fix recently added tests.
(ruby-smie-grammar): Add - and +.
(ruby-smie--redundant-do-p, ruby-smie--forward-id)
(ruby-smie--backward-id): New functions.
(ruby-smie--forward-token, ruby-smie--backward-token): Use them.
(ruby-smie-rules): Handle hanging do.  Get rid of hack, not needed
any more.
* test/indent/ruby.rb: Add a few more tests; adjust some indentation.
2013-10-06 23:38:26 -04:00
Dmitry Gutov
5cd9cda9b6 * lisp/progmodes/ruby-mode.el (ruby-smie-rules): Dedent `ensure'
keyword, too.

* test/indent/ruby.rb: Fix a syntax error, add a few failing examples.
2013-10-06 03:46:28 +03:00
Stefan Monnier
34d1a1337d Get Ruby's SMIE code to pass the test suite.
* lisp/progmodes/ruby-mode.el (ruby-use-smie): Change default.
(ruby-comment-column): Follow the global default, by default.
(ruby-smie-grammar): Add assignment syntax.
(ruby-smie--implicit-semi-p): No implicit semi-colon after an
open-paren, a comma, or a \.
(ruby-smie--forward-token, ruby-smie--backward-token): Handle heredocs,
and line continuations.
(ruby-smie-rules): Adjust handling of open-paren, now that it's never
followed by implicit semi-colons.  Add rule for string concatenation
and for indentation at BOB.
(ruby-forward-sexp, ruby-backward-sexp): Adjust for when smie is in use.

* lisp/emacs-lisp/smie.el (smie-next-sexp): Don't go back to pos before
calling next-sexp, since next-token may have skipped chars which
next-sexp doesn't know should be skipped!

* test/indent/ruby.rb: Port a few cases from automated/ruby-mode-tests.el.
Adjust indentation of continued line to the new SMIE behavior.
2013-10-05 14:37:08 -04:00
Dmitry Gutov
aa0214dae5 Revert 2013-10-05T02:26:39Z!dgutov@yandex.ru
`last-coding-system-used' is unreliable: it can be modified by other functions
in `after-save-hook'.
2013-10-05 20:21:22 +03:00
Dmitry Gutov
0106e5b399 * lisp/progmodes/ruby-mode.el (ruby-mode): Add `ruby-mode-set-encoding'
to `after-save-hook' instead of `before-save-hook', because then
we know exactly what encoding was used to write the file.
(ruby-mode-set-encoding): Use `last-coding-system-used' instead of
guessing.  Call `basic-save-buffer-1' after modifying the buffer.
2013-10-05 05:26:39 +03:00
Dmitry Gutov
578c21bc03 * lisp/progmodes/ruby-mode.el (ruby-operator-re): Consider line
continuation character an operator, as far as indentation is
concerned.

Fixes: debbugs:15369
2013-09-16 02:42:26 +03:00
Glenn Morris
08d664200f * lisp/progmodes/ruby-mode.el (ruby-syntax-propertize-function): Declare. 2013-09-11 22:43:55 -07:00
Glenn Morris
2a08047aed Improve previous interpreter-mode-alist change
* lisp/files.el (interpreter-mode-alist): Remove \\` \\' parts.
(set-auto-mode): Don't regexp-quote elements.

* lisp/progmodes/python.el (interpreter-mode-alist): Remove \\` \\'.

* lisp/progmodes/cc-mode.el (interpreter-mode-alist):
* lisp/progmodes/ruby-mode.el (interpreter-mode-alist):
Revert previous change.

* etc/NEWS: Update.
2013-09-10 23:44:35 -07:00
Glenn Morris
1af4c2203c Treat interpreter-mode-alist as alist of regexps, not literals
Cf http://lists.gnu.org/archive/html/emacs-devel/2005-08/msg00472.html

* lisp/files.el (interpreter-mode-alist): Convert to regexps.
(set-auto-mode): Adapt for this. 

* lisp/progmodes/cperl-mode.el (cperl-clobber-mode-lists):
Comment out unused variable.

* lisp/progmodes/cc-mode.el (interpreter-mode-alist):
* lisp/progmodes/python.el (interpreter-mode-alist):
* lisp/progmodes/ruby-mode.el (interpreter-mode-alist): Convert to regexps.

* lisp/progmodes/sh-script.el (sh-set-shell):
No longer use interpreter-mode-alist to get list of shells.

* etc/NEWS: Mention this.

Fixes: debbugs:15306
2013-09-10 16:38:52 -04:00
Dmitry Gutov
1f896cb7ed * lisp/progmodes/ruby-mode.el (ruby-font-lock-keywords): Move "Perl-ish
keywords" below "here-doc beginnings".

Fixes: debbugs:15270
2013-09-05 16:05:01 +03:00
Dmitry Gutov
88527bc0a2 * lisp/progmodes/ruby-mode.el (ruby-calculate-indent): Consider
two-character operators and whether the character preceding them
changes their meaning.

Fixes: debbugs:15208
2013-09-03 03:29:10 +03:00
Stefan Monnier
f069bba87c * lisp/progmodes/ruby-mode.el (ruby-smie-grammar): Add rule for formal
params of lambda expressions.
(ruby-smie--implicit-semi-p): Refine rule.
(ruby-smie--opening-pipe-p): New function.
(ruby-smie--forward-token, ruby-smie--backward-token): Handle Ruby
symbols and matched |...| for formal params.
(ruby-smie-rules): Don't let the formal params of a "do" prevent it
from being treated as hanging.  Handle "rescue".

Fixes: debbugs:15208
2013-08-29 14:06:46 -04:00
Dmitry Gutov
ac72c08d12 * lisp/progmodes/ruby-mode.el (ruby-block-beg-keywords): Inline.
(ruby-font-lock-keyword-beg-re): Extract from
`ruby-font-lock-keywords'.
2013-07-16 23:16:51 +04:00
Dmitry Gutov
77aea2fbb3 * lisp/progmodes/ruby-mode.el (ruby-font-lock-keywords): Do not
highlight question marks in the method names as strings.
2013-07-16 18:47:23 +04:00
Dmitry Gutov
2ce3c56586 * lisp/progmodes/ruby-mode.el (ruby-font-lock-keywords): Highlight
conversion methods on Kernel.
2013-07-13 23:10:19 +04:00
Dmitry Gutov
481861772a * progmodes/ruby-mode.el (ruby-font-lock-keywords): Simplify the last
change.
2013-07-13 03:36:14 +04:00
Dmitry Gutov
0880a9520e * 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.
2013-07-13 00:28:53 +04:00
Dmitry Gutov
70c46b2816 * 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.
2013-07-09 05:17:48 +04:00
Dmitry Gutov
56f75efcbc * lisp/progmodes/ruby-mode.el (ruby-font-lock-keywords): Highlight more
keywords and built-ins.
2013-07-03 19:46:45 +04:00
Dmitry Gutov
3086ca2e2c * lisp/progmodes/ruby-mode.el (ruby-move-to-block): When we're at a
middle of block statement initially, lower the depth.  Remove
FIXME comment, not longer valid.  Remove middle of block statement
detection, no need to do that anymore since we've been using
`ruby-parse-region' here.
2013-07-03 05:02:18 +04:00
Dmitry Gutov
6dbafa3000 * lisp/progmodes/ruby-mode.el (ruby-syntax-propertize-function): Don't
start heredoc inside a string or comment.
2013-06-30 06:23:10 +04:00
Dmitry Gutov
12adebe94e * lisp/progmodes/ruby-mode.el (ruby-font-lock-keywords): Move `catch',
add some more keyword-like methods.
http://lists.gnu.org/archive/html/emacs-devel/2013-06/msg00911.html
2013-06-22 17:25:43 +04:00
Dmitry Gutov
f72e2fdb68 * lisp/progmodes/ruby-mode.el (auto-mode-alist): Do not use
`regexp-opt', it breaks the build during dumping.
2013-06-22 04:11:24 +04:00
Dmitry Gutov
7bcf66280c * progmodes/ruby-mode.el (auto-mode-alist): Forgot "Guardfile". 2013-06-22 03:20:54 +04:00
Dmitry Gutov
5cf8176d55 * lisp/progmodes/ruby-mode.el (auto-mode-alist): Consolidate different
entries into one regexp and add more *file-s.
2013-06-22 03:14:38 +04:00
Dmitry Gutov
73eab938a0 * lisp/progmodes/ruby-mode.el (ruby-font-lock-keywords): Highlight
keyword-like methods on Kernel and Module with
font-lock-builtin-face.
2013-06-22 03:07:49 +04:00
Dmitry Gutov
d1bbba4fa5 * lisp/progmodes/ruby-mode.el (ruby-syntax-before-regexp-re):
Distinguish ternary operator tokens from slash symbol and slash
char literal.
2013-06-19 02:17:56 +04:00
Dmitry Gutov
973d1e126c * lisp/progmodes/ruby-mode.el (ruby-syntax-expansion-allowed-p):
Highlight expansions inside regexp literals.
2013-05-31 20:55:03 +04:00
Dmitry Gutov
19bb8e6293 * lisp/progmodes/ruby-mode.el (ruby-syntax-expansion-allowed-p): New
function, checks if expression expansion is allowed in given parse
state.
(ruby-syntax-propertize-expansion): Use it.
(ruby-syntax-propertize-function): Bind `case-fold-search' to nil
around the body.

* test/automated/ruby-mode-tests.el: New tests, for percent literals
and expression expansion.
2013-05-31 10:04:33 +04:00
Glenn Morris
dab49a3b21 * progmodes/ruby-mode.el (ruby-syntax-propertize-expansion): Declare. 2013-05-23 20:49:52 -07:00
Dmitry Gutov
462388b673 * lisp/progmodes/ruby-mode.el (ruby-syntax-propertize-heredoc): Leave
point at bol following the heredoc openers.
(ruby-syntax-propertize-expansions): Remove.
2013-05-19 10:52:22 +04:00