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

From: Noam Postavsky <[email-masked]>
Date: Sun, 24 Sep 2017 13:42:12 -0400

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.