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: Mon, 16 Dec 2013 01:22:10 +0200 Message-ID: <87k3f5lmxp.fsf@yandex.ru> References: <87sity96he.fsf@yandex.ru> <6B783955-B72E-4876-BCF2-C864F3D74A62@sanityinc.com> <87y53niicw.fsf@yandex.ru> <87r49fe1d2.fsf@yandex.ru> <52AD1793.50901@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1387149797 7620 80.91.229.3 (15 Dec 2013 23:23:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 15 Dec 2013 23:23:17 +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 Mon Dec 16 00:23:18 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 1VsL1o-0003eQ-WB for geb-bug-gnu-emacs@m.gmane.org; Mon, 16 Dec 2013 00:23:17 +0100 Original-Received: from localhost ([::1]:52845 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VsL1o-0008Mf-Fj for geb-bug-gnu-emacs@m.gmane.org; Sun, 15 Dec 2013 18:23:16 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55954) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VsL1g-0008MV-6r for bug-gnu-emacs@gnu.org; Sun, 15 Dec 2013 18:23:13 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VsL1a-0001JU-JT for bug-gnu-emacs@gnu.org; Sun, 15 Dec 2013 18:23:08 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:38276) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VsL1a-0001JP-FB for bug-gnu-emacs@gnu.org; Sun, 15 Dec 2013 18:23:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1VsL1a-0004aZ-1v for bug-gnu-emacs@gnu.org; Sun, 15 Dec 2013 18:23: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 23:23:01 +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.138714974417575 (code B ref 16116); Sun, 15 Dec 2013 23:23:01 +0000 Original-Received: (at 16116) by debbugs.gnu.org; 15 Dec 2013 23:22:24 +0000 Original-Received: from localhost ([127.0.0.1]:52295 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VsL0x-0004ZP-Dr for submit@debbugs.gnu.org; Sun, 15 Dec 2013 18:22:23 -0500 Original-Received: from mail-ea0-f179.google.com ([209.85.215.179]:36598) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VsL0u-0004ZG-TD for 16116@debbugs.gnu.org; Sun, 15 Dec 2013 18:22:21 -0500 Original-Received: by mail-ea0-f179.google.com with SMTP id r15so1902751ead.10 for <16116@debbugs.gnu.org>; Sun, 15 Dec 2013 15:22:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=CnFl7e5ZPr6m/vlRriXYj26eLJtPcar46PHdBsXw4w8=; b=HrBJD4pPwt9QhAh1kLDigzXH7raWuWD0ivKa/0TNgpGWB0NWuqddkqUmuAhw6Xx1Bk wH69pajx2uAjF7lEFPwuA7hG33N6QkwsODN+wG/z1KXSqikzNtnDrsuWR8kK/W40YFA9 OuJj6gUSkxXNmOGw0SB8e+mqaVltUQL7cY15hj5voz7ekD/4IgoeejIMP6IOe0sWwdZo IltPZqUsfvA3LzO/x7e8pigLsTJO+WjgGb278oAxE9k0EjuCOTv7kkXI5kY6cSK45Uu+ aos+PIK1fs+fTMUXMDvEp+6s/SpbGj/UUFfekbc7ixLdmHeRZueVr1rxYFJhE/KGqowS mxOw== X-Received: by 10.15.108.73 with SMTP id cc49mr13683379eeb.93.1387149739998; Sun, 15 Dec 2013 15:22:19 -0800 (PST) Original-Received: from axl ([83.168.26.131]) by mx.google.com with ESMTPSA id v1sm35322329eef.9.2013.12.15.15.22.17 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 15 Dec 2013 15:22:18 -0800 (PST) In-Reply-To: (Stefan Monnier's message of "Sun, 15 Dec 2013 08:00:00 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) 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:82036 Archived-At: --=-=-= Content-Type: text/plain Stefan Monnier writes: > No, the rule should be something like > > (`(:close-all . ,_) t) Ah, ok. How does this look to you? Note that it makes the new behavior the default one, because "close all" sounds more fitting to characterize the current behavior ("closing" all sexps ending on the current line). If that's not what you meant, maybe a different method name is in order. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=smie-close-all.diff === modified file 'lisp/emacs-lisp/smie.el' --- lisp/emacs-lisp/smie.el 2013-12-11 15:59:27 +0000 +++ lisp/emacs-lisp/smie.el 2013-12-15 23:09:35 +0000 @@ -1135,6 +1135,10 @@ - :list-intro, in which case ARG is a token and the function should return non-nil if TOKEN is followed by a list of expressions (not separated by any token) rather than an expression. +- :close-all, in which case ARG is a close-paren token at indentation and + the function should return non-nil if it should be aligned with the opener + of the last close-paren token on the same line, if there are multiple. + Otherwise, it will be aligned with its own opener. When ARG is a token, the function is called with point just before that token. A return value of nil always means to fallback on the default behavior, so the @@ -1316,8 +1320,8 @@ (defun smie-indent--rule (method token ;; FIXME: Too many parameters. &optional after parent base-pos) - "Compute indentation column according to `indent-rule-functions'. -METHOD and TOKEN are passed to `indent-rule-functions'. + "Compute indentation column according to `smie-rules-function'. +METHOD and TOKEN are passed to `smie-rules-function'. AFTER is the position after TOKEN, if known. PARENT is the parent info returned by `smie-backward-sexp', if known. BASE-POS is the position relative to which offsets should be applied." @@ -1330,11 +1334,7 @@ ;; - :after tok, where ;; ; after is set; parent=nil; base-pos=point; (save-excursion - (let ((offset - (let ((smie--parent parent) - (smie--token token) - (smie--after after)) - (funcall smie-rules-function method token)))) + (let ((offset (smie-indent--rule-1 method token after parent))) (cond ((not offset) nil) ((eq (car-safe offset) 'column) (cdr offset)) @@ -1355,6 +1355,12 @@ (smie-indent-virtual) (current-column))))) (t (error "Unknown indentation offset %s" offset)))))) +(defun smie-indent--rule-1 (method token &optional after parent) + (let ((smie--parent parent) + (smie--token token) + (smie--after after)) + (funcall smie-rules-function method token))) + (defun smie-indent-forward-token () "Skip token forward and return it, along with its levels." (let ((tok (funcall smie-forward-token-function))) @@ -1423,8 +1429,13 @@ (save-excursion ;; (forward-comment (point-max)) (when (looking-at "\\s)") - (while (not (zerop (skip-syntax-forward ")"))) - (skip-chars-forward " \t")) + (if (smie-indent--rule-1 :close-all + (buffer-substring-no-properties + (point) (1+ (point))) + (1+ (point))) + (while (not (zerop (skip-syntax-forward ")"))) + (skip-chars-forward " \t")) + (forward-char 1)) (condition-case nil (progn (backward-sexp 1) --=-=-=--