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

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: minor; Reported by: Lojze Gačnik <lojze.gacnik@HIDDEN>; dated Fri, 26 Aug 2022 23:26:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Severity set to 'minor' from 'normal' Request was from Stefan Kangas <stefankangas@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 26 Aug 2022 23:25:10 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Aug 26 19:25:10 2022
Received: from localhost ([127.0.0.1]:54796 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oRihK-0007GY-86
	for submit <at> debbugs.gnu.org; Fri, 26 Aug 2022 19:25:10 -0400
Received: from lists.gnu.org ([209.51.188.17]:57300)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <megalojze@HIDDEN>) id 1oRiHx-0006cl-1K
 for submit <at> debbugs.gnu.org; Fri, 26 Aug 2022 18:58:57 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:53880)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <megalojze@HIDDEN>)
 id 1oRiHw-00048j-Om
 for bug-gnu-emacs@HIDDEN; Fri, 26 Aug 2022 18:58:56 -0400
Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]:44553)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <megalojze@HIDDEN>)
 id 1oRiHv-0005ep-68
 for bug-gnu-emacs@HIDDEN; Fri, 26 Aug 2022 18:58:56 -0400
Received: by mail-ej1-x630.google.com with SMTP id kk26so5660610ejc.11
 for <bug-gnu-emacs@HIDDEN>; Fri, 26 Aug 2022 15:58:54 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=to:subject:message-id:date:from:mime-version:from:to:cc;
 bh=D7ygUO0GQfrOx9Wt7XCQiyoW0jEu9odFnVdx9dbekZ8=;
 b=SoIJXkZqrZpyv1SCyjxo9y2LZ28kWuI9dDM5oYpK6wJOFuuGBdivyNVpmBELzvRbHc
 jr1x+47qTXCQ7wAJy8g1Q41OFYxc4dw2xiXkvHmABItF1ZkyWcGcmuRjsVh4iaLyCzCe
 ELyIz3R2PdlHqSaWyJsuybfG4GISHN8r4+1I7mIYxrsai92ljj4VNPWV8c01dsqpWQTx
 mLSIjmuKWAn50+5D5GbG+UO5cs7l8xXQQf0rbbaRjCRzCmOaU5iciLvej6DwmcmymDwf
 hSAZ8EjdJD9x/uKQ2Cn0aCmmPvCcr50w+270SyT597nImqKclmkBjReByIwGsCTtmThL
 Ax/A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=to:subject:message-id:date:from:mime-version:x-gm-message-state
 :from:to:cc;
 bh=D7ygUO0GQfrOx9Wt7XCQiyoW0jEu9odFnVdx9dbekZ8=;
 b=O13QVZTz+HUOyxMy4mNvS7SB/Ro4mYjE3hEqZvaHEu14q9dI7zov36mz//wVUYcmzY
 81ifEeLNGmJhWpj2Kew8jmqXnYicR1fI6YHBmqgDholGabmGLk7Xdww9ca6cEGIoNsiX
 W7IIpeKlr0V2G9ts4ApZoh9RDUDOlzxVhDLf9tJUP1bszXtUDdckBGA5alX0fI/Js3KO
 noPtyQwhoxKEGOiymQcDtMJfdltOs1zmdUPgQq934VGSkOP0se2kW3D3kCxV9lZrz0pD
 wTfroE/9f0zw695jgpmSlnTUwhWOrExr87EbTXrPtD5jWxVe1wKPtIaKHdNj3t6ryNfL
 VKUw==
X-Gm-Message-State: ACgBeo2juNIG9PbWfRM5lnkfT45IPsPOuuP1cv/raNOfGFmjKI6w7/Gj
 cyvi7r74dEEUEPOT78grBF2VqZWo67ypTQ/plEiCgMCUrMU=
X-Google-Smtp-Source: AA6agR5yf/AWpz9iitHEy0anfjLejmb2/uldDgAU2FvvNis3Vy62Pcx105bkGVDVbdUMMyfAHcNcdGMAo82Waq1evu4=
X-Received: by 2002:a17:907:2cea:b0:73d:a431:6b6c with SMTP id
 hz10-20020a1709072cea00b0073da4316b6cmr6849211ejc.423.1661554733041; Fri, 26
 Aug 2022 15:58:53 -0700 (PDT)
MIME-Version: 1.0
From: =?UTF-8?Q?Lojze_Ga=C4=8Dnik?= <lojze.gacnik@HIDDEN>
Date: Fri, 26 Aug 2022 22:58:41 +0000
Message-ID: <CAGm=J2O=iaDNEAYW2TQOXMKQrcXLokRB4_8iHFMrEAFpAeqoBA@HIDDEN>
Subject: indent-according-to-mode indents incorrectly if previous line is blank
To: bug-gnu-emacs@HIDDEN
Content-Type: text/plain; charset="UTF-8"
Received-SPF: pass client-ip=2a00:1450:4864:20::630;
 envelope-from=megalojze@HIDDEN; helo=mail-ej1-x630.google.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Fri, 26 Aug 2022 19:25:09 -0400
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

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)




Acknowledgement sent to Lojze Gačnik <lojze.gacnik@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#57441; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Thu, 13 Oct 2022 14:00:02 UTC

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