[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] trunk r115011: * lisp/progmodes/ruby-mode.el (ruby-smie--i
From: |
Dmitry Gutov |
Subject: |
[Emacs-diffs] trunk r115011: * lisp/progmodes/ruby-mode.el (ruby-smie--implicit-semi-p): |
Date: |
Thu, 07 Nov 2013 03:02:08 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 115011
revision-id: address@hidden
parent: address@hidden
committer: Dmitry Gutov <address@hidden>
branch nick: trunk
timestamp: Thu 2013-11-07 05:02:01 +0200
message:
* 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.
modified:
lisp/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1432
lisp/progmodes/ruby-mode.el
rubymode.el-20091113204419-o5vbwnq5f7feedwu-8804
test/indent/ruby.rb ruby.rb-20120424165921-h044139hbrd7snvw-1
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2013-11-07 01:58:12 +0000
+++ b/lisp/ChangeLog 2013-11-07 03:02:01 +0000
@@ -1,7 +1,16 @@
2013-11-07 Dmitry Gutov <address@hidden>
* progmodes/ruby-mode.el (ruby-smie-grammar): Lower priority of
- "." compared to "do".
+ "." compared to " @ ". This incidentally fixes some indentation
+ examples with "do".
+ (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-06 Glenn Morris <address@hidden>
=== modified file 'lisp/progmodes/ruby-mode.el'
--- a/lisp/progmodes/ruby-mode.el 2013-11-07 01:58:12 +0000
+++ b/lisp/progmodes/ruby-mode.el 2013-11-07 03:02:01 +0000
@@ -329,7 +329,8 @@
(nonassoc "==" "===" "!=")
(nonassoc "=~" "!~")
(left "<<" ">>")
- (left "&&" "||"))))))
+ (left "&&" "||")
+ (left "and" "or"))))))
(defun ruby-smie--bosp ()
(save-excursion (skip-chars-backward " \t")
@@ -340,7 +341,7 @@
(skip-chars-backward " \t")
(not (or (bolp)
(and (memq (char-before)
- '(?\; ?- ?+ ?* ?/ ?: ?. ?, ?\[ ?\( ?\{ ?\\ ?& ?> ?< ?%
?~))
+ '(?\; ?- ?+ ?* ?/ ?: ?. ?, ?\[ ?\( ?\{ ?\\ ?& ?> ?< ?%
?~ ?^))
;; Make sure it's not the end of a regexp.
(not (eq (car (syntax-after (1- (point)))) 7)))
(and (eq (char-before) ?\?)
@@ -349,8 +350,8 @@
(string-match "\\`\\s." (save-excursion
(ruby-smie--backward-token))))
(and (eq (car (syntax-after (1- (point)))) 2)
- (equal (save-excursion (ruby-smie--backward-token))
- "iuwu-mod"))
+ (member (save-excursion (ruby-smie--backward-token))
+ '("iuwu-mod" "and" "or")))
(save-excursion
(forward-comment 1)
(eq (char-after) ?.))))))
@@ -375,13 +376,15 @@
;; This isn't very important most of the time, though.
(and (memq (preceding-char) '(?! ??))
(eq (char-syntax (char-before (1- (point)))) '?w)))
- (or (and (eq (char-syntax (char-after pos)) ?w)
- (not (looking-at (regexp-opt '("unless" "if" "while" "until"
- "else" "elsif" "do" "end")
- 'symbols))))
- (memq (syntax-after pos) '(7 15))
- (save-excursion
- (goto-char pos)
+ (save-excursion
+ (goto-char pos)
+ (or (and (eq (char-syntax (char-after)) ?w)
+ ;; FIXME: Also "do". But alas, that breaks some
+ ;; indentation cases.
+ (not (looking-at (regexp-opt '("unless" "if" "while" "until"
+ "else" "elsif" "end" "and" "or")
+ 'symbols))))
+ (memq (syntax-after pos) '(7 15))
(looking-at "\\s(\\|[-+!~:]\\sw")))))
(defun ruby-smie--at-dot-call ()
@@ -504,7 +507,6 @@
(let ((state (smie-backward-sexp 'halfsexp)))
(when (eq t (car state)) (goto-char (cadr state))))
(cons 'column (smie-indent-virtual)))))
- (`(:after . ,(or "=" "iuwu-mod")) 2)
(`(:after . " @ ") (smie-rule-parent))
(`(:before . "do") (smie-rule-parent))
(`(,(or :before :after) . ".")
@@ -513,8 +515,11 @@
(`(:before . ,(or `"else" `"then" `"elsif" `"rescue" `"ensure")) 0)
(`(:before . ,(or `"when"))
(if (not (smie-rule-sibling-p)) 0)) ;; ruby-indent-level
- (`(:after . "+") ;FIXME: Probably applicable to most infix operators.
- (if (smie-rule-parent-p ";") ruby-indent-level))
+ (`(:after . ,(or "=" "iuwu-mod" "+" "-" "*" "/" "&&" "||" "%" "**" "^" "&"
+ "<=>" ">" "<" ">=" "<=" "==" "===" "!=" "<<" ">>"
+ "+=" "-=" "*=" "/=" "%=" "**=" "&=" "|=" "^="
+ "<<=" ">>=" "&&=" "||=" "and" "or"))
+ (if (smie-rule-parent-p ";" nil) ruby-indent-level))
))
(defun ruby-imenu-create-index-in-block (prefix beg end)
=== modified file 'test/indent/ruby.rb'
--- a/test/indent/ruby.rb 2013-11-07 01:58:12 +0000
+++ b/test/indent/ruby.rb 2013-11-07 03:02:01 +0000
@@ -207,6 +207,12 @@
foo +
bar
+foo and
+ bar
+
+foo ^
+ bar
+
foo_bar_tee(1, 2, 3)
.qux
.bar
@@ -245,3 +251,9 @@
bar.foo do
bar
end
+
+# Examples below still fail with `ruby-use-smie' on:
+
+bar.foo(tee) do # "." is parent to "do"; it shouldn't be.
+ bar
+end
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] trunk r115011: * lisp/progmodes/ruby-mode.el (ruby-smie--implicit-semi-p):,
Dmitry Gutov <=