Subject: Re: bug#36056: 26.2; Python Documentation String Indent In Auto Fill Mode

From: "Basil L. Contovounesios" <[email-masked]>
Date: Mon, 03 Jun 2019 01:57:45 +0100

ricercar <[email-masked]> writes:

> There is some peculiar behavior when using auto-fill-mode editing Python
> code. For example if I start typing the following:
>
> def some_function(keyword_argument0, keyword_argument1,
>                   keyword_argument2='foobar'):
>     """
>     Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
>
>
> and press Enter, it will look like this:
>
> def some_function(keyword_argument0, keyword_argument1,
>                   keyword_argument2='foobar'):
>     """
>     Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
>                   eiusmod tempor incididunt ut labore et dolore magna
>                   aliqua.
>
> That is, the subsequent lines of the documentation string are indented
> as to match the indentation of the second line of the list of keyword
> arguments, rather than four columns as I would expect.

I'm not familiar with this part of Emacs or python.el, and I don't know
what else this may break, but from stepping through do-auto-fill I
discovered the following setting gives the desired auto-fill behaviour:

  (add-hook 'python-mode-hook
            (lambda ()
              (setq-local fill-indent-according-to-mode t)))

HTH,

-- 
Basil