On 22 January 2014 15:41, Dmitry Gutov wrote: > Hi! > > Bozhidar Batsov writes: > > > Currently when doing method chaining on multiple lines we get the > > following indentation: > > > > something.ala > > .one > > .two > > .three > > > > An alternative style that seems to be popular is: > > > > something.ala > > .one > > .two > > .three > > Good suggestion, but it looks harder than the previous ones, and it'll > require modifying (or maybe "fixing") the SMIE grammar. At the moment, > the parent of a "." token is never the previous ".". > > I have an experimental patch, included at the end, but it throws up some > grammar priority warnings, and it changes the indentation in the > following example: > > zoo.keep.bar!( > {x: y, > z: t}) > > If I modify the code a little, the indentation here will be like this: > > zoo.keep.bar!( > {x: y, > z: t}) > > which corresponds to > > zoo.keep.bar!( > {x: y, > z: t} > ) > > which, in turn, is a small modification of > > zoo.keep > .bar!( > {x: y, > z: t} > ) > > Would you consider this appropriate, for the "fluent interface" > indentation? Or how would you indent it instead? > Hard to read indentation examples in an email, but it seems to me that: zoo.keep.bar!( {x: y, z: t} ) is the only sensible indentation for the third example and the forth should be: zoo.keep .bar!( {x: y, z: t} ) when using the fluent-api-style indentation. > > By the way, do you think it'd be good if the same variable toggled between > > foo = foobar > .baz > > and > > foo = foobar > .baz > > ? Or would that be a different variable? > Didn't notice this until now. Seems to me the default indent should be relative to the `=` (similar to what we do for ops like +, -, etc): foo = foobar .baz > > P.S. Could you use the bug tracker for feature requests next time? Bugs > are easier to keep track of and to get back to later. > Sure. > > > === modified file 'lisp/progmodes/ruby-mode.el' > --- lisp/progmodes/ruby-mode.el 2014-01-17 03:15:02 +0000 > +++ lisp/progmodes/ruby-mode.el 2014-01-22 13:25:38 +0000 > @@ -351,7 +351,7 @@ > (exp "and" exp) (exp "or" exp)) > (exp (exp1) (exp "," exp) (exp "=" exp) > (id " @ " exp) > - (exp "." id)) > + (id "." exp)) > (exp1 (exp2) (exp2 "?" exp1 ":" exp1)) > (exp2 ("def" insts "end") > ("begin" insts-rescue-insts "end") > @@ -380,7 +380,7 @@ > (ielsei (itheni) (itheni "else" insts)) > (if-body (ielsei) (if-body "elsif" if-body))) > '((nonassoc "in") (assoc ";") (right " @ ") > - (assoc ",") (right "=") (assoc ".")) > + (assoc ",") (right "=")) > '((assoc "when")) > '((assoc "elsif")) > '((assoc "rescue" "ensure")) > @@ -399,7 +399,8 @@ > (nonassoc ">" ">=" "<" "<=") > (nonassoc "==" "===" "!=") > (nonassoc "=~" "!~") > - (left "<<" ">>")))))) > + (left "<<" ">>") > + (assoc ".")))))) > > (defun ruby-smie--bosp () > (save-excursion (skip-chars-backward " \t") > @@ -622,7 +623,10 @@ > (unless (or (eolp) (forward-comment 1)) > (cons 'column (current-column))))) > (`(:before . "do") (ruby-smie--indent-to-stmt)) > - (`(:before . ".") ruby-indent-level) > + (`(:before . ".") > + (if (smie-rule-sibling-p) > + 0 > + ruby-indent-level)) > (`(:after . "=>") ruby-indent-level) > (`(:before . ,(or `"else" `"then" `"elsif" `"rescue" `"ensure")) > (smie-rule-parent)) > >