GNU bug report logs - #57441
indent-according-to-mode indents incorrectly if previous line is blank

Previous Next

Package: emacs;

Reported by: Lojze Gačnik <lojze.gacnik <at> gmail.com>

Date: Fri, 26 Aug 2022 23:26:01 UTC

Severity: minor

Full log


View this message in rfc822 format

From: Lojze Gačnik <lojze.gacnik <at> gmail.com>
To: 57441 <at> debbugs.gnu.org
Subject: bug#57441: indent-according-to-mode indents incorrectly if previous line is blank
Date: Fri, 26 Aug 2022 22:58:41 +0000
The documentation of indent-according-to-mode claims that, if
indent-line-function is set to indent-relative-first-indent-point, it
will indent the line the same as the previous non-blank line.

But this is not the case - it only works if the immediately preceding
line is non-blank. If line 1 is indented 4 spaces, and line 2 is
blank, then indent-according-to-mode on line 3 will indent 0 spaces,
instead of the expected 4.

Calling indent-according-to-line on line 2, or calling
indent-relative-first-indent-point directly on line 2 or 3, behaves
correctly.

I reproduced this issue on emacs 29.0.50, using the following init.el file:

(electric-indent-mode -1)
(defun my/plain-indent ()
  (setq indent-line-function 'indent-relative-first-indent-point))
; Have to set it in a hook, otherwise it gets overrriden.
(add-hook 'prog-mode-hook 'my/plain-indent)
(add-hook 'text-mode-hook 'my/plain-indent)




This bug report was last modified 2 years and 306 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.