+2013-11-12 Dmitry Gutov <dgutov@yandex.ru>
+
+ * 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 Glenn Morris <rgm@gnu.org>
* ps-print.el (ps-face-attribute-list):
("unless" insts "end")
("if" if-body "end")
("case" cases "end"))
- (formal-params ("opening-|" exp "|"))
+ (formal-params ("opening-|" exp "closing-|"))
(for-body (for-head ";" insts))
(for-head (id "in" exp))
- (cases (exp "then" insts) ;; FIXME: Ruby also allows (exp ":" insts).
+ (cases (exp "then" insts)
(cases "when" cases) (insts "else" insts))
(expseq (exp) );;(expseq "," expseq)
(hashvals (id "=>" exp1) (hashvals "," hashvals))
(left ".." "...")
(left "+" "-")
(left "*" "/" "%" "**")
- ;; (left "|") ; FIXME: Conflicts with | after block parameters.
(left "&&" "||")
- (left "^" "&")
+ (left "^" "&" "|")
(nonassoc "<=>")
(nonassoc ">" ">=" "<" "<=")
(nonassoc "==" "===" "!=")
(string-match "\\`\\s." (save-excursion
(ruby-smie--backward-token))))
(and (eq (char-before) ?|)
- (eq (char-before (1- (point))) ?|))
+ (member (save-excursion (ruby-smie--backward-token))
+ '("|" "||")))
(and (eq (car (syntax-after (1- (point)))) 2)
(member (save-excursion (ruby-smie--backward-token))
'("iuwu-mod" "and" "or")))
(or (eq ?\{ (char-before))
(looking-back "\\_<do" (- (point) 2)))))
+(defun ruby-smie--closing-pipe-p ()
+ (save-excursion
+ (if (eq ?| (char-before)) (forward-char -1))
+ (and (re-search-backward "|" (line-beginning-position) t)
+ (ruby-smie--opening-pipe-p))))
+
(defun ruby-smie--args-separator-p (pos)
(and
(< pos (line-end-position))
((string-match-p "\\`|[*&]?\\'" tok)
(forward-char (- 1 (length tok)))
(setq tok "|")
- (if (ruby-smie--opening-pipe-p) "opening-|" tok))
+ (cond
+ ((ruby-smie--opening-pipe-p) "opening-|")
+ ((ruby-smie--closing-pipe-p) "closing-|")
+ (t tok)))
((and (equal tok "") (looking-at "\\\\\n"))
(goto-char (match-end 0)) (ruby-smie--forward-token))
((equal tok "do")
(if (ruby-smie--bosp)
tok "iuwu-mod"))
((equal tok "|")
- (if (ruby-smie--opening-pipe-p) "opening-|" tok))
+ (cond
+ ((ruby-smie--opening-pipe-p) "opening-|")
+ ((ruby-smie--closing-pipe-p) "closing-|")
+ (t tok)))
((string-match-p "\\`|[*&]\\'" tok)
(forward-char 1)
(substring tok 1))
(if (not (smie-rule-sibling-p)) 0)) ;; ruby-indent-level
(`(:after . ,(or "=" "iuwu-mod" "+" "-" "*" "/" "&&" "||" "%" "**" "^" "&"
"<=>" ">" "<" ">=" "<=" "==" "===" "!=" "<<" ">>"
- "+=" "-=" "*=" "/=" "%=" "**=" "&=" "|=" "^="
+ "+=" "-=" "*=" "/=" "%=" "**=" "&=" "|=" "^=" "|"
"<<=" ">>=" "&&=" "||=" "and" "or"))
(if (smie-rule-parent-p ";" nil) ruby-indent-level))
(`(:before . "begin")