all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ross Donaldson <gastove@gmail.com>
To: Noam Postavsky <npostavs@users.sourceforge.net>
Cc: 28475@debbugs.gnu.org
Subject: bug#28475: 25.3; python double-indents multi-line function argument blocks
Date: Sun, 24 Sep 2017 16:25:48 +0000	[thread overview]
Message-ID: <CAC+S337PtwN=ookZhrz+v0nvFRHbRtiNOvdnCZxNo0kskAfj2g@mail.gmail.com> (raw)
In-Reply-To: <87tvzsmgep.fsf@users.sourceforge.net>

[-- Attachment #1: Type: text/plain, Size: 3530 bytes --]

First: apologies for the whitespace cleanup, but yes, you correctly figured
out what the bug report was intended to be. Thanks!

I was thrown off by the `prog-FOO` commands because of this message in the
ChangeLog:

```
2016-03-27  Dmitry Gutov  <dgutov@yandex.ru>

Remove prog-indentation-context

* lisp/progmodes/prog-mode.el: (prog-indentation-context)
(prog-first-column, prog-widen): Remove, as discussed in
http://lists.gnu.org/archive/html/emacs-devel/2016-03/msg01425.html.
```

But I see you are correct, and only `prog-indentation-context` was removed.

I haven't assigned copyright to Emacs yet; I'd be happy to, and also, I
suspect this patch will be quite short. I'll send it over soon.

On Sun, Sep 24, 2017 at 5:26 AM Noam Postavsky <
npostavs@users.sourceforge.net> wrote:

> Ross Donaldson <gastove@gmail.com> 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.
>

[-- Attachment #2: Type: text/html, Size: 4869 bytes --]

  reply	other threads:[~2017-09-24 16:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-16 18:42 bug#28475: 25.3; python double-indents multi-line function argument blocks Ross Donaldson
2017-09-24 12:26 ` Noam Postavsky
2017-09-24 16:25   ` Ross Donaldson [this message]
2017-09-24 16:42     ` Noam Postavsky
2017-09-24 17:02       ` Ross Donaldson
2017-09-24 17:42         ` Noam Postavsky
2017-10-12 21:11           ` Ross Donaldson
2017-11-07  1:10             ` Noam Postavsky
2017-12-25 20:54               ` Ross Donaldson
2018-01-01 16:17                 ` Noam Postavsky
2018-01-02 17:55                   ` Ross Donaldson
2017-09-26  0:50       ` 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='CAC+S337PtwN=ookZhrz+v0nvFRHbRtiNOvdnCZxNo0kskAfj2g@mail.gmail.com' \
    --to=gastove@gmail.com \
    --cc=28475@debbugs.gnu.org \
    --cc=npostavs@users.sourceforge.net \
    /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.