Subject: bug#28475: 25.3; python double-indents multi-line function argument blocks

From: Ross Donaldson <[email-masked]>
Date: Thu, 12 Oct 2017 14:11:49 -0700

ARG -- apologies! I somehow missed this as it came in. Thank you very much for the feedback; I'll make those changes and submit a new patch soon.

Noam Postavsky writes:

> Ross Donaldson <[email-masked]> writes:
>
>> From 83a622ec32a64ae30e68de18a84cc32fc6a811d9 Mon Sep 17 00:00:00 2001
>> From: Ross Donaldson <[email-masked]>
>> Date: Sun, 24 Sep 2017 09:42:23 -0700
>> Subject: [PATCH] Rather than scaling certain python blocks by a
>> constant, scale by a defcustom
>>
>> This provides customization of the number of indent levels in
>> multi-line `def` blocks in python; it also corrects a nearby (but
>> unrelated) incorrect symbol quote.
>
> You're missing the ChangeLog style entry here, see CONTRIBUTE under
> "Commit messages" for details.  Also, an imperative style usually reads
> more concisely ("Provide customization..." rather than "This
> provides...").
>
> I think a NEWS entry would be appropriate as well.
>
>> -  :safe' booleanp)
>> +  :safe 'booleanp)
>
> It's better not to mix up your change with unrelated whitespace fixes.
>
>>  (defcustom python-indent-trigger-commands
>>    '(indent-for-tab-command yas-expand yas/expand)
>> @@ -746,6 +746,12 @@ It makes underscores and dots word constituent chars.")
>>    :type '(repeat symbol)
>>    :group 'python)
>>
>> +(defcustom python-indent-def-block-scale 2
>> +  "Multiplier applied to indentation inside multi-line def blocks."
>> +  :version "26.0"
>
> This should rather be "26.1", as released Emacs versions always end in ".1".
>
>> +  :type 'integer
>> +  :safe (lambda (i) (and (integerp i) (< 0 i))))
>
> I would probably go with 'natnump here.  This does also allow 0 which is
> probably not generally wanted, but still "safe", I think.
>
>>          (`(,(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)))))))
>> +         (+ (current-indentation) (* python-indent-offset python-indent-def-block-scale)))))))
>
> A line break here would keep the line to within a reasonable width
> (generally we try to stay in 80 columns).
>
> Thanks for working on this.