From: Dmitry Gutov <dgutov@yandex.ru>
To: Bozhidar Batsov <bozhidar@batsov.com>
Cc: Stefan Monnier <monnier@iro.umontreal.ca>,
emacs-devel <emacs-devel@gnu.org>
Subject: Re: [ruby-mode] Private/protected method definition layout in Ruby 2.1
Date: Thu, 16 Jan 2014 07:47:01 +0200 [thread overview]
Message-ID: <87r4884gx6.fsf@yandex.ru> (raw)
In-Reply-To: <0E94BE5F9874463D9B4C2A039A3C24E9@gmail.com> (Bozhidar Batsov's message of "Wed, 15 Jan 2014 16:41:33 +0200")
Bozhidar Batsov <bozhidar@batsov.com> writes:
> recent changes we did to accommodate similar alignment for `if/unless
> ` it seems like a good idea to add a defcustom supporting the first
> style as well.
Come to think of it, why not reuse the same mechanism and defcustom?
The patch below seems to work. Comments?
=== modified file 'lisp/progmodes/ruby-mode.el'
--- lisp/progmodes/ruby-mode.el 2014-01-10 16:32:45 +0000
+++ lisp/progmodes/ruby-mode.el 2014-01-16 05:35:37 +0000
@@ -226,7 +226,10 @@
:group 'ruby
:safe 'integerp)
-(defcustom ruby-align-to-stmt-keywords nil
+(defconst ruby-alignable-keywords '(if while unless until begin case for def)
+ "Keywords that can be used in `ruby-align-to-stmt-keywords'.")
+
+(defcustom ruby-align-to-stmt-keywords '(def)
"Keywords after which we align the expression body to statement.
When nil, an expression that begins with one these keywords is
@@ -250,17 +253,13 @@
Only has effect when `ruby-use-smie' is t.
"
- :type '(choice
+ :type `(choice
(const :tag "None" nil)
(const :tag "All" t)
(repeat :tag "User defined"
- (choice (const if)
- (const while)
- (const unless)
- (const until)
- (const begin)
- (const case)
- (const for))))
+ (choice ,@(mapcar
+ (lambda (kw) (list 'const kw))
+ ruby-alignable-keywords))))
:group 'ruby
:safe 'listp
:version "24.4")
@@ -639,7 +638,7 @@
(smie-indent--hanging-p)
ruby-indent-level))
(`(:after . ,(or "?" ":")) ruby-indent-level)
- (`(:before . ,(or "if" "while" "unless" "until" "begin" "case" "for"))
+ (`(:before . ,(guard (memq (intern token) ruby-alignable-keywords)))
(when (not (ruby--at-indentation-p))
(if (ruby-smie--indent-to-stmt-p token)
(ruby-smie--indent-to-stmt)
next prev parent reply other threads:[~2014-01-16 5:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-15 14:41 [ruby-mode] Private/protected method definition layout in Ruby 2.1 Bozhidar Batsov
2014-01-15 16:24 ` Stefan Monnier
2014-01-15 18:18 ` Dmitry Gutov
2014-01-15 18:51 ` Stefan Monnier
2014-01-16 5:47 ` Dmitry Gutov [this message]
2014-01-16 10:15 ` Bozhidar Batsov
2014-01-16 13:37 ` Dmitry Gutov
2014-01-16 14:26 ` Bozhidar Batsov
2014-01-16 18:40 ` Dmitry Gutov
2014-01-16 19:38 ` Bozhidar Batsov
2014-01-17 3:17 ` Dmitry Gutov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r4884gx6.fsf@yandex.ru \
--to=dgutov@yandex.ru \
--cc=bozhidar@batsov.com \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.