From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: [ruby-mode] Private/protected method definition layout in Ruby 2.1 Date: Thu, 16 Jan 2014 07:47:01 +0200 Message-ID: <87r4884gx6.fsf@yandex.ru> References: <0E94BE5F9874463D9B4C2A039A3C24E9@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1389851240 24856 80.91.229.3 (16 Jan 2014 05:47:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 16 Jan 2014 05:47:20 +0000 (UTC) Cc: Stefan Monnier , emacs-devel To: Bozhidar Batsov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jan 16 06:47:27 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1W3fna-0005E5-0p for ged-emacs-devel@m.gmane.org; Thu, 16 Jan 2014 06:47:26 +0100 Original-Received: from localhost ([::1]:58490 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W3fnZ-0002xG-It for ged-emacs-devel@m.gmane.org; Thu, 16 Jan 2014 00:47:25 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57605) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W3fnR-0002wx-Ra for emacs-devel@gnu.org; Thu, 16 Jan 2014 00:47:23 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W3fnJ-00043x-SU for emacs-devel@gnu.org; Thu, 16 Jan 2014 00:47:17 -0500 Original-Received: from mail-ee0-x236.google.com ([2a00:1450:4013:c00::236]:41952) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W3fnJ-00043l-Lw for emacs-devel@gnu.org; Thu, 16 Jan 2014 00:47:09 -0500 Original-Received: by mail-ee0-f54.google.com with SMTP id e53so511599eek.27 for ; Wed, 15 Jan 2014 21:47:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=ciCE8OfAm1TVXlCYH41oQA34tUrqniA3vcMT9DsC5zk=; b=Aos78Xa/AKcNl4tNZL3VBjncyIxinFIkgE7zxGtsTEIo8sdkVbqR6E+Ls2+oaJ/1/l vni53ItVtG0swiY7tFNzvJrxAu/pbJfAK2cMv0SdMhr5PT+GvsHH3Ro0zJ2FAHJhZSbB xekhn5t9meDvMrcvKZgC8qCJtrVIz2rPp/jS1NYEQSJOvQQwOwfi9ASSQ5p6SkLpwfOl oqNl//KL0Frr+zArlJGueGHh4YSft3cZ4j6TskwPcFCPzsDeqRuCei6X5W7wNPIPovJB R5DrhA7XgEmcecMN0piDgF36z+qtLDMlZbkq60wUR2CVMS+BGXn4yhIi/+gSGexjkWcp g4ag== X-Received: by 10.14.184.66 with SMTP id r42mr1732992eem.86.1389851228675; Wed, 15 Jan 2014 21:47:08 -0800 (PST) Original-Received: from axl ([93.109.205.233]) by mx.google.com with ESMTPSA id m1sm15595675eeg.0.2014.01.15.21.47.06 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 15 Jan 2014 21:47:07 -0800 (PST) In-Reply-To: <0E94BE5F9874463D9B4C2A039A3C24E9@gmail.com> (Bozhidar Batsov's message of "Wed, 15 Jan 2014 16:41:33 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4013:c00::236 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:168517 Archived-At: Bozhidar Batsov 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)