[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#36884: Default python mode with electric-indent-mode sometimes inden

From: Jarosław Rzeszótko
Subject: bug#36884: Default python mode with electric-indent-mode sometimes indents empty lines
Date: Fri, 2 Aug 2019 07:08:21 +0200

Perhaps this behavior exists because there can also be a situation like this:

def test():
[cursor, on empty line in middle of indented block]

where what electric indent does after pressing RET (creates new line aligned to the print statements) makes sense. I think it is mostly irritating though, and editors I tested, Vim and Sublime Text, do not automatically indent in any of the situations I mentioned.

FWIW this works as a workaround for me:

(setq electric-indent-functions
      '((lambda (inserted-char)
          (when (eq major-mode 'python-mode)
            ;; Do not auto-indent after inserting any empty line
            (when (save-excursion
                    (looking-at "^\s*$"))


On Fri, Aug 2, 2019 at 3:26 AM Noam Postavsky <address@hidden> wrote:
Andreas Röhler <address@hidden> writes:

> AFAIU electric-indent-mode doesn't run a timer, cursor position alone
> would not trigger it.

electric-indent-mode works from post-self-insert-hook.  Not sure how
cursor position and timers are related.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]