* 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 "|".
This commit is contained in:
parent
9b1ee27c6c
commit
7b08f97e71
3 changed files with 33 additions and 8 deletions
|
@ -1,3 +1,13 @@
|
|||
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):
|
||||
|
|
|
@ -310,10 +310,10 @@ explicitly declared in magic comment."
|
|||
("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))
|
||||
|
@ -337,9 +337,8 @@ explicitly declared in magic comment."
|
|||
(left ".." "...")
|
||||
(left "+" "-")
|
||||
(left "*" "/" "%" "**")
|
||||
;; (left "|") ; FIXME: Conflicts with | after block parameters.
|
||||
(left "&&" "||")
|
||||
(left "^" "&")
|
||||
(left "^" "&" "|")
|
||||
(nonassoc "<=>")
|
||||
(nonassoc ">" ">=" "<" "<=")
|
||||
(nonassoc "==" "===" "!=")
|
||||
|
@ -365,7 +364,8 @@ explicitly declared in magic comment."
|
|||
(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")))
|
||||
|
@ -385,6 +385,12 @@ explicitly declared in magic comment."
|
|||
(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))
|
||||
|
@ -442,7 +448,10 @@ explicitly declared in magic comment."
|
|||
((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")
|
||||
|
@ -482,7 +491,10 @@ explicitly declared in magic comment."
|
|||
(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))
|
||||
|
@ -545,7 +557,7 @@ explicitly declared in magic comment."
|
|||
(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")
|
||||
|
|
|
@ -285,6 +285,9 @@ def bar
|
|||
end
|
||||
end
|
||||
|
||||
foo |
|
||||
bar
|
||||
|
||||
foo ||
|
||||
begin
|
||||
bar
|
||||
|
|
Loading…
Add table
Reference in a new issue