GNU bug report logs - #79883
Allow locally overriding how a form is indented

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; Reported by: Jonas Bernoulli <jonas@HIDDEN>; dated Tue, 25 Nov 2025 20:23:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

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


Received: (at 79883) by debbugs.gnu.org; 26 Nov 2025 10:48:43 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Nov 26 05:48:43 2025
Received: from localhost ([127.0.0.1]:51474 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vOD4l-0007cP-4c
	for submit <at> debbugs.gnu.org; Wed, 26 Nov 2025 05:48:43 -0500
Received: from sendmail.purelymail.com ([34.202.193.197]:48180)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <spwhitton@HIDDEN>)
 id 1vOD4i-0007cC-BX
 for 79883 <at> debbugs.gnu.org; Wed, 26 Nov 2025 05:48:42 -0500
DKIM-Signature: a=rsa-sha256;
 b=YB65DOpv6SLsJVPqN9F7zRGI3U6trin3B8FWjr8RueeOCG77pkkNDcAbGB8e79uAnj2WevhFgun8+yjhyRX3nz2b151CQB3gfcd1O9/YAWeqjg4kEX/R6u2paImNfgkBAm25oxQ8gmFtrSIHZ9cvjZGGQliz7458GlofTq2tqSg8CrFjuKlU455OkmVs3AHRLfLmoo1SWPG8iusSFnLK836Ah4JK7dbMcbYNN5qPeNYoaGVXrZ1qo6mdKhPpATuJwwZugfZNXJCY8yIfgF1pmsVR0XXd4FM0WBfEDjOuVv2K9MaKQ46zGQamH/xlFWBNVCu4ktbXUj7S8wZTn0j2PQ==;
 s=purelymail2; d=spwhitton.name; v=1;
 bh=LWyZw9jEdZrM9oUSBQ7DtEhN4zjjhsGqn6tHs6c+0hg=;
 h=Received:Received:From:To:Subject:Date; 
DKIM-Signature: a=rsa-sha256;
 b=Hw4oJbAVATNVKDSd2GDkkpkQV5EJq5Pgu8BwMId9bk7O6/+bi7xF6WLfxLKMU20h+4PxGXOr1pdUKA8h7pWFE9n2PkTHUobpYl0Sy5Gqzay18QVKrk2b+xDi9lId5VmaKzEX56BTPHwvvZ4e/o0EkJkMfqwyhIl7UvYALxJuNWlEclj9TRFcX0ZoPcqIFrvWEJh8RXDRoKyFTY7MpNyTfKy5zej4lLhXURKeLJtj3Am00fUOwZXdHYocPZY3RMaNc1KukkZ1vaDm5B+M3bIf/dpxURS7YHr5mt32wdGN7WtI6zjD4jwlVTrBddlnpJtDZurXVGYMLI7o+TXiyVVBsg==;
 s=purelymail2; d=purelymail.com; v=1;
 bh=LWyZw9jEdZrM9oUSBQ7DtEhN4zjjhsGqn6tHs6c+0hg=;
 h=Feedback-ID:Received:Received:From:To:Subject:Date; 
Feedback-ID: 20115:3760:null:purelymail
X-Pm-Original-To: 79883 <at> debbugs.gnu.org
Received: by smtp.purelymail.com (Purelymail SMTP) with ESMTPSA id -1779243905; 
 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384);
 Wed, 26 Nov 2025 10:48:29 +0000 (UTC)
Received: by zephyr.silentflame.com (Postfix, from userid 1000)
 id AA369940809; Wed, 26 Nov 2025 10:48:27 +0000 (GMT)
From: Sean Whitton <spwhitton@HIDDEN>
To: 79883 <at> debbugs.gnu.org
Subject: Re: bug#79883: Allow locally overriding how a form is indented
In-Reply-To: <87h5ukini3.fsf@HIDDEN>
References: <87h5ukini3.fsf@HIDDEN>
Date: Wed, 26 Nov 2025 10:48:27 +0000
Message-ID: <87bjkpdq84.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 79883
Cc: Jonas Bernoulli <jonas@HIDDEN>
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: -1.0 (-)

Hello,

On Sun 23 Nov 2025 at 07:59pm +01, Jonas Bernoulli wrote:

> Hello,
>
> The following patch makes it possible to change how certain forms
> are indented in a file, using a buffer-local variable, like so:
>
> ;; Local Variables:
> ;; lisp-indent-local-overrides: ((interactive . 0) (cond . 0))
> ;; End:
>
> IMO that's how these two forms should be indented, but it's unlikely
> everyone would agree.  Even if everyone agreed, changing this globally
> would have the drawback that a lot of existing code would suddenly be
> indented wrongly.  Letting maintainers change the indentation for these
> and/or other forms in individual files would not have the same issue.

A feature like this makes sense to me.  Can you write up the docs?

Thanks.

-- 
Sean Whitton




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#79883; Package emacs. Full text available.

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


Received: (at submit) by debbugs.gnu.org; 25 Nov 2025 20:22:58 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Nov 25 15:22:57 2025
Received: from localhost ([127.0.0.1]:41938 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vNzYs-0001Dj-MC
	for submit <at> debbugs.gnu.org; Tue, 25 Nov 2025 15:22:57 -0500
Received: from lists.gnu.org ([2001:470:142::17]:42554)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <jonas@HIDDEN>) id 1vNFJ3-0007FT-9f
 for submit <at> debbugs.gnu.org; Sun, 23 Nov 2025 13:59:30 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <jonas@HIDDEN>) id 1vNFIx-0002VU-Nx
 for bug-gnu-emacs@HIDDEN; Sun, 23 Nov 2025 13:59:23 -0500
Received: from mail.hostpark.net ([212.243.197.30])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <jonas@HIDDEN>) id 1vNFIv-0003ci-46
 for bug-gnu-emacs@HIDDEN; Sun, 23 Nov 2025 13:59:23 -0500
Received: from localhost (localhost [127.0.0.1])
 by mail.hostpark.net (Postfix) with ESMTP id 4C1DE162CE
 for <bug-gnu-emacs@HIDDEN>; Sun, 23 Nov 2025 19:59:17 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=bernoul.li; h=
 content-type:content-type:mime-version:message-id:date:date
 :subject:subject:from:from; s=sel2011a; t=1763924357; bh=tNhhyev
 3N0CBoaDW5dUXsl+i/iBQbRqPeUd7a+r+OoY=; b=DhCpjFPaUjbLoexadb1SfpY
 4UmAurJ+xgqgGNJbVkUNbCCgi/VWeuL8abydtWJByDbZFkshcO8F81jbTaD6tOLJ
 QCBScCgx7xgT6hipW2MpeAz2UptpTSycibmtXZ3lVllyVxvlpK/we8socsCDx6Nl
 U8x1fbNHEOwGuDTzNBEU=
X-Virus-Scanned: by Hostpark/NetZone Mailprotection at hostpark.net
Received: from mail.hostpark.net ([127.0.0.1])
 by localhost (mail0.hostpark.net [127.0.0.1]) (amavis, port 10224) with ESMTP
 id GPTbxVPiQhMW for <bug-gnu-emacs@HIDDEN>;
 Sun, 23 Nov 2025 19:59:17 +0100 (CET)
Received: from customer (localhost [127.0.0.1])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange secp256r1 server-signature RSA-PSS (2048 bits) server-digest
 SHA256) (No client certificate requested)
 by mail.hostpark.net (Postfix) with ESMTPSA id F06F8162C2
 for <bug-gnu-emacs@HIDDEN>; Sun, 23 Nov 2025 19:59:16 +0100 (CET)
From: Jonas Bernoulli <jonas@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: Allow locally overriding how a form is indented
Date: Sun, 23 Nov 2025 19:59:16 +0100
Message-ID: <87h5ukini3.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
Received-SPF: pass client-ip=212.243.197.30; envelope-from=jonas@HIDDEN;
 helo=mail.hostpark.net
X-Spam_score_int: -27
X-Spam_score: -2.8
X-Spam_bar: --
X-Spam_report: (-2.8 / 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,
 RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01,
 RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001,
 SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.9 (/)
X-Debbugs-Envelope-To: submit
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: -0.1 (/)

Hello,

The following patch makes it possible to change how certain forms
are indented in a file, using a buffer-local variable, like so:

;; Local Variables:
;; lisp-indent-local-overrides: ((interactive . 0) (cond . 0))
;; End:

IMO that's how these two forms should be indented, but it's unlikely
everyone would agree.  Even if everyone agreed, changing this globally
would have the drawback that a lot of existing code would suddenly be
indented wrongly.  Letting maintainers change the indentation for these
and/or other forms in individual files would not have the same issue.

diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -1203,6 +1203,17 @@ lisp--local-defform-body-p
                          t)
                    (= local-definitions-starting-point (point))))))))))
 
+(defvar-local lisp-indent-local-overrides nil)
+
+(put 'lisp-indent-local-overrides 'safe-local-variable
+     (lambda (value)
+       (and (listp value)
+            (all (lambda (elt)
+                   (and (symbolp (car elt))
+                        (or (eq (cdr elt) 'defun)
+                            (integerp (cdr elt)))))
+                 value))))
+
 (defun lisp-indent-function (indent-point state)
   "This function is the normal value of the variable `lisp-indent-function'.
 The function `calculate-lisp-indent' calls this to determine
@@ -1252,12 +1263,12 @@ lisp-indent-function
           ;; inside the innermost containing sexp.
           (backward-prefix-chars)
           (current-column))
-      (let ((function (buffer-substring (point)
-                                       (progn (forward-sexp 1) (point))))
-           method)
-       (setq method (or (function-get (intern-soft function)
-                                       'lisp-indent-function 'macro)
-                        (get (intern-soft function) 'lisp-indent-hook)))
+      (let* ((function (intern-soft
+                        (buffer-substring (point)
+                                          (progn (forward-sexp 1) (point)))))
+             (method (or (alist-get function lisp-indent-local-overrides)
+                         (function-get function 'lisp-indent-function 'macro)
+                         (get function 'lisp-indent-hook))))
        (cond ((or (eq method 'defun)
                    ;; Check whether we are in flet-like form.
                    (lisp--local-defform-body-p state))

     Cheers,
     Jonas




Acknowledgement sent to Jonas Bernoulli <jonas@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#79883; 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: Wed, 26 Nov 2025 11:00:02 UTC

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