From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#16116: 24.3.50; smie-indent-close aligns inner closing paren with the outer opening paren Date: Sun, 15 Dec 2013 04:44:35 +0200 Message-ID: <52AD1793.50901@yandex.ru> References: <87sity96he.fsf@yandex.ru> <6B783955-B72E-4876-BCF2-C864F3D74A62@sanityinc.com> <87y53niicw.fsf@yandex.ru> <87r49fe1d2.fsf@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1387075518 2015 80.91.229.3 (15 Dec 2013 02:45:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 15 Dec 2013 02:45:18 +0000 (UTC) Cc: 16116@debbugs.gnu.org, Steve Purcell To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Dec 15 03:45:23 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1Vs1hp-0006S2-I7 for geb-bug-gnu-emacs@m.gmane.org; Sun, 15 Dec 2013 03:45:21 +0100 Original-Received: from localhost ([::1]:49273 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vs1hp-0003oZ-1W for geb-bug-gnu-emacs@m.gmane.org; Sat, 14 Dec 2013 21:45:21 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39529) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vs1he-0003oP-VI for bug-gnu-emacs@gnu.org; Sat, 14 Dec 2013 21:45:18 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vs1hX-0004IJ-KS for bug-gnu-emacs@gnu.org; Sat, 14 Dec 2013 21:45:10 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:36521) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vs1hX-0004Gs-H7 for bug-gnu-emacs@gnu.org; Sat, 14 Dec 2013 21:45:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Vs1hW-0001Md-IH for bug-gnu-emacs@gnu.org; Sat, 14 Dec 2013 21:45:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 15 Dec 2013 02:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 16116 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 16116-submit@debbugs.gnu.org id=B16116.13870754845197 (code B ref 16116); Sun, 15 Dec 2013 02:45:02 +0000 Original-Received: (at 16116) by debbugs.gnu.org; 15 Dec 2013 02:44:44 +0000 Original-Received: from localhost ([127.0.0.1]:50540 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vs1hD-0001Lk-Qs for submit@debbugs.gnu.org; Sat, 14 Dec 2013 21:44:44 -0500 Original-Received: from mail-ea0-f169.google.com ([209.85.215.169]:48849) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vs1hB-0001Lc-Ey for 16116@debbugs.gnu.org; Sat, 14 Dec 2013 21:44:41 -0500 Original-Received: by mail-ea0-f169.google.com with SMTP id l9so1331822eaj.14 for <16116@debbugs.gnu.org>; Sat, 14 Dec 2013 18:44:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=P4PjnyVxUYkg3xMx+dGKV4a5uEUnfzFi+/LOWO1FJUw=; b=wxmCsVRVl7xpU/IPQi6F1m/IVx+K3pMPBL8ejajMzn4rmWTBDydM+ew2Amy+kEqcqc tc2m3wSfK/6gNMDr8A6RDWP75pEmuG7OHBwMIjWUolQaci7koc6VnvT32idgmw74a1Yz tIhwQnmpzTclFyeugL6KMH8z7hJ5e9hco4o0hl/an4+nItKmZwQyq17juw9yLIrXabEW tfPKKXkGi2oasugsNNPFTZfMdp11HGuP3aRlyKWVpW27rg71HQ3XutO0AK7gFJRVKBF1 41HHyloYOeHEjWBGfjEJWrdBZgV+YHAw2mo7mfdSdzXjXq0hJFORb3ljvhq8K/Jp9KOJ fF9A== X-Received: by 10.14.251.132 with SMTP id b4mr10075091ees.78.1387075480497; Sat, 14 Dec 2013 18:44:40 -0800 (PST) Original-Received: from [192.168.10.2] ([83.168.26.131]) by mx.google.com with ESMTPSA id o47sm24936735eem.21.2013.12.14.18.44.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 14 Dec 2013 18:44:39 -0800 (PST) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:82000 Archived-At: On 15.12.2013 03:50, Stefan Monnier wrote: >> I believe this argument also works against doing it in the rules >> function, and in favor of adding a defvar. > > I don't think so: setting the var is a one-liner, adding the rule to the > rule-function is also a one-liner. So either way is just as easy for > the major-mode. I mean in terms of code reuse: the rules function is also specific to a major mode. The rule itself doesn't look like it'll take just one line to me, AFAICS it'll have to duplicate most of the code in `smie-indent-close': (`(:before . ,(or `")" `"]" `"}")) (save-excursion (forward-char 1) (condition-case nil (progn (backward-sexp 1) (cons 'column . (smie-indent-virtual))) (scan-error nil)))) If any other major mode wants to do the same, they have to duplicate this, or extract this code to a helper function in smie.el. Using the rules function will also add 2-3 lines to `smie-indent-close'. > By contrast, setting smie-indent-functions buffer-locally, then > removing smie-indent-close from it and adding some other function > requires a lot more code, and a lot more brittle as well (the ordering > in smie-indent-functions is important, the set of functions in there and > their order is not guaranteed to stay unchanged in future versions, the > replacement function needs to be written (delegating to > smie-indent-close seems like it might not work), ... Looks like three lines to me. :) (setq-local smie-indent-functions (copy-sequence smie-indent-functions)) (setcar (memq 'smie-indent-close smie-indent-functions) 'ruby--smie-indent-close) And the replacement function wouldn't be much longer than the added rule.