From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#28475: 25.3; python double-indents multi-line function argument blocks Date: Sun, 24 Sep 2017 08:26:22 -0400 Message-ID: <87tvzsmgep.fsf@users.sourceforge.net> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1506256039 10660 195.159.176.226 (24 Sep 2017 12:27:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 24 Sep 2017 12:27:19 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.60 (gnu/linux) Cc: 28475@debbugs.gnu.org To: Ross Donaldson Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Sep 24 14:27:15 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dw604-0002CX-NG for geb-bug-gnu-emacs@m.gmane.org; Sun, 24 Sep 2017 14:27:08 +0200 Original-Received: from localhost ([::1]:38005 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dw60C-00043f-0E for geb-bug-gnu-emacs@m.gmane.org; Sun, 24 Sep 2017 08:27:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37942) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dw603-000421-0h for bug-gnu-emacs@gnu.org; Sun, 24 Sep 2017 08:27:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dw5zy-0000cr-1c for bug-gnu-emacs@gnu.org; Sun, 24 Sep 2017 08:27:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:46604) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dw5zx-0000cf-U0 for bug-gnu-emacs@gnu.org; Sun, 24 Sep 2017 08:27:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dw5zx-0008A4-OH for bug-gnu-emacs@gnu.org; Sun, 24 Sep 2017 08:27:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 24 Sep 2017 12:27:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28475 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 28475-submit@debbugs.gnu.org id=B28475.150625599231329 (code B ref 28475); Sun, 24 Sep 2017 12:27:01 +0000 Original-Received: (at 28475) by debbugs.gnu.org; 24 Sep 2017 12:26:32 +0000 Original-Received: from localhost ([127.0.0.1]:55284 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dw5zU-00089F-IS for submit@debbugs.gnu.org; Sun, 24 Sep 2017 08:26:32 -0400 Original-Received: from mail-io0-f177.google.com ([209.85.223.177]:54461) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dw5zS-000892-Hd for 28475@debbugs.gnu.org; Sun, 24 Sep 2017 08:26:30 -0400 Original-Received: by mail-io0-f177.google.com with SMTP id h66so7687486ioh.11 for <28475@debbugs.gnu.org>; Sun, 24 Sep 2017 05:26:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=YzMPo9rv2ucvmTwesfz68lQNBljp7hQl7Yyf7AiklYw=; b=qxeMCbjqMSr9DVnS3f6pgGpUjz4gu0rl+N0UDtu6KFadqGoHOxYFI16Ro+3fz5pNHE yW8sw4S6mwcUTIrASPhflRwUEloAb8ds9FRPNJJ5En3OdCAChgOc1gcYDhRUT3VlxIDy 0KzDjMdOxoLiBmS0Ec7m3QjT+tVwpUmh2PaqHSI3FrykmXuVfSWOKJ+ajrL8I9nZyXnY DCnF9/e0kXjveSlN9+IeW45j4J+M/umytZIQVIP4EiRMULtW/OJBxeethpyvzng2Vx+R CKNnP0j267Oo9pVcYEqIdk1GSF4NBHqmoDT8vgs7kKImSabodRTjuBBKawuMTvkEX360 D2ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=YzMPo9rv2ucvmTwesfz68lQNBljp7hQl7Yyf7AiklYw=; b=pL+Alvv5ZyjjyokUm/PlOxSR3PkpEEbY3lQtGTfIRuSSuk6TOWsO8Yotvj+5BidPUk 8WfVkMsaL6CHrYGZHP91AE/N2zbVpGX8fy0x8JsGJvGZS9RlkQyd4eMg80GM69SlfKAE eI/ye+TVslAqT6dR2xAFtuc9McT1bL3801dQCCsplZCnzLqDiMfHvTJIjquUHZ/eOpvN 7+JR1dUAEuxz8AlpgHLfG72dnGLlJBXF6eC8AE/28syq3KZvikXfi/TtJN2owzl4pV5N Pe3WEjy1adNqXO3m5pKmjeuGUW1l07wuQam93iHNkbb7s7GVciMiK+bh0SP0b87X3YWv He0w== X-Gm-Message-State: AHPjjUgWKAFSW7x61iLkMhEy+9e/O6TpnOMMSgISvMSfhqfba4enYP3c QxsZpTknOtZSVckwJvBbZ0XsKw== X-Google-Smtp-Source: AOwi7QCmmoqBaXsgaKzMXF2fDbIZQDsbhF8YvVyZzEQ6qXaZOiLH6dyj30CYTTrvt8LufwDLeUw8eQ== X-Received: by 10.107.9.90 with SMTP id j87mr6117827ioi.111.1506255984375; Sun, 24 Sep 2017 05:26:24 -0700 (PDT) Original-Received: from zebian ([45.2.119.34]) by smtp.googlemail.com with ESMTPSA id o71sm1911825itb.15.2017.09.24.05.26.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 24 Sep 2017 05:26:23 -0700 (PDT) In-Reply-To: (Ross Donaldson's message of "Sat, 16 Sep 2017 11:42:18 -0700") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.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" Xref: news.gmane.org gmane.emacs.bugs:137335 Archived-At: Ross Donaldson writes: > python-mode double-indents the arguments to function definitions. > > To reproduce: > 1. emacs -Q > 2. Enter the following: It seems your email client dropped the whitespace, but I guess you meant # This is fine: def foo(arg): print('hello') # This is indented double: def foo( bar, baz ): print('hello') # It should be: def foo( bar, baz ): print('hello') # Only seems to be true for `def`s so far, eg: baz = list( 'good' ) > This is caused by the function `python-indent--calculate-indentation`, > line ~1023 of `python.el`. Frustratingly, the behavior is hardcoded, > and apparently intentional, as we see at the end of the function: > > ``` > (`(,(or :inside-paren-newline-start-from-block) . ,start) > ;; Add two indentation levels to make the suite stand out. > (goto-char start) > (+ (current-indentation) (* python-indent-offset 2))) > ``` > > This is problematic. Python's holy grail of style, PEP-8, does not > specify how this indentation should be done. However, many companies > which write python -- like my employer -- create internal style guides > to fill in gaps left by PEP-8. So far, in my career, they *all* > indicate a single indent to be appropriate in this context. > > I'd like to propose two solutions; I don't know which will suit best: > > 1. Stop doubling indentation > 2. Make the indent scaling integer a variable, so that this behavior can be changed. I think the latter will be best, in case some people want the current indentation still. > A final complication for me is that, at least on `master` of the > Github emacs-mirror (https://github.com/emacs-mirror/emacs), this > function still uses `prog-widen` and `prog-first-column`, which have > been removed from emacs. I'm not sure how to correctly patch this > function to remove them. I think it's rather that `prog-widen' and `prog-first-column' have been *added* to Emacs. > So! With a little guidance on `prog-widen`/`prog-first-column`, I'm > happy to create and submit a patch, or I can leave this in y'all's > capable hands. If you can build from the git checkout write your patch against the emacs-26 branch then you should be able to use the prog-FOO functions. Otherwise, just write it against 25.3, it should be easy enough to update the patch afterwards, if needed. Have you assigned copyright to Emacs? If the patch ends up more than about 15 lines we won't be able to accept it until you do. I guess just adding and using the new custom variable should fit within that limit though.