[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ruby-mode] Private/protected method definition layout in Ruby 2.1

From: Dmitry Gutov
Subject: Re: [ruby-mode] Private/protected method definition layout in Ruby 2.1
Date: Wed, 15 Jan 2014 20:18:19 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Stefan Monnier <address@hidden> writes:

>> I’m not saying the first alignment is preferable,
> That's surprising.  The current alignment just looks like a plain bug to
> me and can't think of any reason why someone would prefer it over

I also think it looks like a bug, but it's just indentation of an
arguments in a paren-less function call. `private' is a method, called
with the expression `def ... end`.

That said, I think indenting it to the beginning of `private' would be
preferable, as it's consistent with Vim and examples on the Web.

> In any case, what I wanted to say here, is that in my experience, the
> easiest way to handle such things with SMIE is to make the token code
> treat "private def" as a single token (and to call it "def").  This may
> sound silly, but trying to DTRT (for similar issues in other modes) by
> tweaking grammar plus indentation rules has proved a lot more painful.

I believe we can also handle this in the rules-function. Add a new rule
for (:before . "def"), see if the preceding token is one of `private',
`public', `protected', and if so, indent to its beginning column.

Can we install such a change, with either of the approaches, during the
feature freeze?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]