Commit graph

256 commits

Author SHA1 Message Date
Dmitry Gutov
af67e79a52 Fix Bug#15874
* lisp/progmodes/ruby-mode.el (ruby-mode-syntax-table): Don't modify
syntax for `?'.
(ruby-expr-beg): Expect that `!' will have syntax class "symbol"
where appropriate already.
(ruby-syntax-propertize-function): Propertize `?' and `!' at the
end of method names.
2013-12-06 06:22:08 +02:00
Bozhidar Batsov
15ba218206 * progmodes/ruby-mode.el (ruby-custom-encoding-magic-comment-template),
(ruby-encoding-magic-comment-style): Add :version.
2013-11-22 14:36:38 +02:00
Bozhidar Batsov
d19ffd647d * lisp/progmodes/ruby-mode.el (ruby-custom-encoding-magic-comment-template):
Improve docstring.
2013-11-22 14:28:23 +02:00
Bozhidar Batsov
638af3a10f * lisp/progmodes/ruby-mode.el (ruby-custom-encoding-magic-comment-template):
Change default to "# encoding: %s" to differentiate it from the
default Ruby encoding comment template.
2013-11-20 12:52:07 +02:00
Adam Sokolnicki
56cd894e90 * lisp/progmodes/ruby-mode.el (ruby-toggle-block): Don't stop at
interpolation curlies.

Fixes: debbugs:15914
2013-11-17 23:39:13 +02:00
Dmitry Gutov
43cebc237c * lisp/progmodes/ruby-mode.el (ruby-font-lock-keywords): End regexp for
nil/self/true/false with "end of symbol".
2013-11-15 20:09:10 +02:00
Bozhidar Batsov
99f5d0744e * lisp/progmodes/ruby-mode.el (ruby-mode-set-encoding):
Fix and simplify encoding comment update logic.
2013-11-14 14:39:41 +02:00
Bozhidar Batsov
6c1bf08604 * lisp/progmodes/ruby-mode.el (ruby-mode-set-encoding):
Add support for always inserting an utf-8 encoding comment.
2013-11-14 12:35:49 +02:00
Dmitry Gutov
7b08f97e71 * lisp/progmodes/ruby-mode.el (ruby-smie-grammar): Disambiguate between
binary "|" operator and closing block args delimiter.  Remove
FIXME comment referring to Ruby 1.8-only syntax.
(ruby-smie--implicit-semi-p): Not after "|" operator.
(ruby-smie--closing-pipe-p): New function.
(ruby-smie--forward-token, ruby-smie--backward-token): Use it.
(ruby-smie-rules): Indent after "|".
2013-11-12 16:15:14 +02:00
Dmitry Gutov
1629a32997 * lisp/progmodes/ruby-mode.el (ruby-smie--implicit-semi-p):
Not after "||".
(ruby-smie-rules): Indent non-hanging "begin" blocks as part of
their parent.
2013-11-09 01:59:56 +02:00
Stefan Monnier
ad16897ceb * lisp/progmodes/ruby-mode.el: Don't require cl any more. Use pcase instead.
(ruby-font-lock-keywords): Use backquote.
2013-11-08 17:53:41 -05:00
Bozhidar Batsov
25864c18c5 * lisp/progmodes/ruby-mode.el (ruby-mode-set-encoding):
Fix incorrect case conditions.
2013-11-08 23:41:25 +02:00
Dmitry Gutov
ffa2df72a8 * lisp/progmodes/ruby-mode.el (ruby-smie--forward-token)
(ruby-smie--backward-token): Only consider full-string matches.
2013-11-08 23:23:11 +02:00
Bozhidar Batsov
71731c0338 * lisp/progmodes/ruby-mode.el (ruby-mode-set-encoding): Use
`ruby-encoding-magic-comment-style' to control the
style of the auto-inserted encoding comment.
2013-11-08 18:01:55 +02:00
Dmitry Gutov
da3b328da0 * lisp/progmodes/ruby-mode.el (ruby-smie--indent-to-stmt): Use
`smie-backward-sexp' with token argument.
2013-11-08 13:22:52 +02:00
Dmitry Gutov
1f92392383 * lisp/progmodes/ruby-mode.el (ruby-smie-grammar): Improve precedences
of "and", "or", "&&" and "||".
(ruby-smie--args-separator-p): Prohibit keyword "do" as the first
argument.  Prohibit opening curly brace because it could only be a
block opener in that position.
(ruby-smie--forward-token, ruby-smie--backward-token): Separate
"|" from "&" or "*" going after it.  That can happen in block
arguments.
(ruby-smie--indent-to-stmt): New function, seeks the end of
previous statement or beginning of buffer.
(ruby-smie-rules): Use it.
(ruby-smie-rules): Check if there's a ":" before a curly block
opener candidate; if there is, it's a hash.

* test/indent/ruby.rb: New examples.
2013-11-08 04:31:51 +02:00
Dmitry Gutov
1d1c86daf7 * lisp/progmodes/ruby-mode.el (ruby-smie--implicit-semi-p):
No implicit semi after "^", "and" or "or".
(ruby-smie-grammar): New tokens: "and" and "or".
(ruby-smie--args-separator-p): Fix the check for tokens at POS.
Exclude "and" and "or".  Remove "do" in order to work around token
priorities.
(ruby-smie-rules): Add all infix tokens.  Handle the case of
beginning-of-buffer.
2013-11-07 05:02:01 +02:00
Dmitry Gutov
b420ccfc4c * lisp/progmodes/ruby-mode.el (ruby-smie-grammar): Lower priority of
"." compared to "do".
2013-11-07 03:58:12 +02:00
Bozhidar Batsov
03177f98c9 * lisp/progmodes/ruby-mode.el: Improve a few error messages. 2013-11-05 18:28:40 +02:00
Bozhidar Batsov
ae93bc7480 * lisp/progmodes/ruby-mode.el (ruby-mode): Remove incorrect text from docstring. 2013-11-05 11:30:15 +02:00
Bozhidar Batsov
2ea53115b4 * lisp/progmodes/ruby-mode.el (ruby-mode): Clean up docstring. 2013-11-04 16:20:58 +02:00
Dmitry Gutov
dca01b0923 * lisp/progmodes/ruby-mode.el (ruby-smie--forward-token)
(ruby-smie--backward-token): Tokenize heredocs as semicolons.

* test/automated/ruby-mode-tests.el: Remove outdated comment.

* test/indent/ruby.rb: Add a statement on the line after heredoc.
2013-11-04 12:50:47 +02:00
Stefan Monnier
e61845c1db * lisp/emacs-lisp/smie.el (smie-rule-parent): Always call
smie-indent-virtual rather than only for hanging tokens.
(smie--next-indent-change): New helper command.
* lisp/progmodes/ruby-mode.el (ruby-smie--rule-parent-skip-assign): Remove.
(ruby-smie-rules): Use smie-rule-parent instead.
2013-11-03 17:56:03 -05:00
Dmitry Gutov
3d42b96899 * lisp/progmodes/ruby-mode.el (ruby-smie--rule-parent-skip-assign): New
function, replacement for `smie-rule-parent' for when we want to
skip over our direct parent if it's an assignment token..
(ruby-smie-rules): Use it.
2013-11-02 09:18:11 +04:00
Dmitry Gutov
7ffd37219b * lisp/progmodes/ruby-mode.el Use `syntax-propertize-function'
unconditionally.  Remove now unnecessary forward declarations.
Remove XEmacs-specific setup.
(ruby-here-doc-end-re, ruby-here-doc-beg-match)
(ruby-font-lock-syntactic-keywords)
(ruby-comment-beg-syntax, ruby-in-here-doc-p)
(ruby-here-doc-find-end, ruby-here-doc-beg-syntax)
(ruby-here-doc-end-syntax): Remove.
(ruby-mode): Don't check whether `syntax-propertize-rules' is
defined as function.
2013-11-02 05:10:10 +04:00
Bozhidar Batsov
a3996a2eba * lisp/progmodes/ruby-mode.el (ruby-mode-variables, ruby-mode): Use `setq-local'. 2013-11-02 04:17:54 +04:00
Bozhidar Batsov
6f9260e8f8 * lisp/progmodes/ruby-mode.el (ruby-mode-variables): Don't set syntax
table and abbrev table, `define-derived-mode' does that for us
anyway.
2013-11-02 03:55:15 +04:00
Bozhidar Batsov
983d0df5e1 * lisp/progmodes/ruby-mode.el (ruby-indent-tabs-mode)
(ruby-indent-level, ruby-comment-column, ruby-deep-arglist):
Add property :safe.
(ruby-deep-arglist): Add property :type.
2013-11-01 07:35:35 +04:00
Dmitry Gutov
c8c605ac9c * lisp/progmodes/ruby-mode.el (ruby-smie--bosp): Anything that goes
after `=' is probably a new expression.
2013-10-27 07:25:03 +04:00
Dmitry Gutov
bae91342a4 * lisp/progmodes/ruby-mode.el (ruby-smie--args-separator-p): Be more
specific in what the first arg can be: a non-keyword word,
string/regexp/percent literal opener, opening paren, or unary
operator followed directly by word.

* test/automated/ruby-mode-tests.el (ruby-toggle-block-to-brace): Fix
the test, in respect to adding the space after the curly.
2013-10-26 05:16:37 +04:00
Dmitry Gutov
963ce6361a * lisp/progmodes/ruby-mode.el (ruby-mode-menu): Use proper
capitalization.  Use :visible instead of :active.  Fix
`ruby-indent-exp' reference.  Add menu items for the generic
commands that are used with SMIE.
(ruby-do-end-to-brace): Insert space after `{'.
2013-10-25 08:35:56 +04:00
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