Attached find a patch for bug#80454 with Arash's improvements factored in.
>From f71188ec36165ceccd67d31f6e7ec52acbea522c Mon Sep 17 00:00:00 2001
From: Jim Diamond <[email protected]>
Date: Sun, 1 Mar 2026 19:04:59 -0400
Subject: [PATCH] Fix indentation for macros with arguments in ConTeXt

* context.el (ConteXt-find-indent): add a specific case to handle
macro definitions with arguments where the open brace is on the
next line, otherwise the indentation is wildly incorrect.  (Bug#80454)
---
 context.el | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/context.el b/context.el
index 25cbeb34..25a7f3c6 100644
--- a/context.el
+++ b/context.el
@@ -1412,6 +1412,25 @@ else.  There might be text before point."
                                        (ConTeXt-environment-start-name)
                                        ConTeXt-text)))) ; other environments?
          (+ indent (current-column) ConTeXt-indent-basic))
+        ;; This code correctly indents the initial brace of a macro with
+        ;; arguments when the brace is on the following line.
+        ;; JD note: It is unclear to me what the code in the 't' case below
+        ;; is trying to accomplish; modifying it to not incorrectly indent
+        ;; an open brace following the \def line of a macro with argument(s)
+        ;; seems likely to break something else (also for \define).
+        ;; Therefore handle \def and \define with this specific case.
+        ;; Note that \def might be preceded by various combinations of
+        ;; the following modifiers (LMTX):
+        ((or (looking-at-p
+              (concat "\\(?:\\\\"
+                      (regexp-opt '("enforced" "expandafter" "frozen"
+                                    "global" "instance" "immutable"
+                                    "mutable" "noaligned" "noexpand"
+                                    "overloaded" "permanent" "protected"
+                                    "tolerant" "untraced"))
+                      "\\)*\\\\def\\\\"))
+             (looking-at-p "\\\\define[[\\]"))
+           (current-column))
         (t
          (let ((col (current-column)))
            (if (not (and char (eq (char-syntax char) ?\()))
-- 
2.46.4

_______________________________________________
bug-auctex mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-auctex

Reply via email to