2013-11-07 Dmitry Gutov <dgutov@yandex.ru>
* 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 <rgm@gnu.org>
(nonassoc "==" "===" "!=")
(nonassoc "=~" "!~")
(left "<<" ">>")
- (left "&&" "||"))))))
+ (left "&&" "||")
+ (left "and" "or"))))))
(defun ruby-smie--bosp ()
(save-excursion (skip-chars-backward " \t")
(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) ?\?)
(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) ?.))))))
;; 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 ()
(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) . ".")
(`(: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)