Steinar Bang <s...@dod.no> writes:

>> As for Org mode, may you try another version of the patch (attached)?
>
> No change in behaviour with the patch compared to org-mode HEAD.
>
> I rebuilt org-mode with "make autoloads" and started a fresh emacs.
>
> When I open:
>  emacs ~/git/bang-bompom/README.org
> and then press TAB on the top item, the error occurs.
>
> The README above can be found here:
>  https://github.com/steinarb/bang-bompom/blob/master/README.org

What about the attached?
>From 4d27f5ca930e38a72e44e15368c84db985adbcd4 Mon Sep 17 00:00:00 2001
Message-ID: <4d27f5ca930e38a72e44e15368c84db985adbcd4.1742110532.git.yanta...@posteo.net>
From: Ihor Radchenko <yanta...@posteo.net>
Date: Wed, 12 Mar 2025 18:45:11 +0100
Subject: [PATCH v3] org-mode: Be more aggressive setting tab-width to 8

* lisp/org.el (org--set-tab-width): New helper to set `tab-width'.
(org-mode): Override file-local and directory-local settings for
`tab-width', if any.  With non-standard `tab-width', parser cannot
work properly.

Reported-by: Steinar Bang <s...@dod.no>
Link: https://orgmode.org/list/87msdrw5qt....@dod.no
---
 lisp/org.el | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index bc61a7c462..24c33d9cc0 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -4970,6 +4970,10 @@ (defvar org-mode-tags-syntax-table
     st)
   "Syntax table including \"@\" and \"_\" as word constituents.")
 
+(defun org--set-tab-width (&rest _)
+  "Set `tab-width' to be 8."
+  (setq-local tab-width 8))
+
 ;;;###autoload
 (define-derived-mode org-mode outline-mode "Org"
   "Outline-based notes management and organizer, alias
@@ -4992,7 +4996,16 @@ (define-derived-mode org-mode outline-mode "Org"
   (setq-local org-mode-loading t)
   ;; Force tab width - indentation is significant in lists, so we need
   ;; to make sure that it is consistent across configurations.
-  (setq-local tab-width 8)
+  (org--set-tab-width)
+  ;; Really force it, even if dir-locals or file-locals set it - we
+  ;; need tab-width = 8 as a part of Org syntax.
+  (add-hook 'hack-local-variables-hook
+            #'org--set-tab-width 90 'local)
+  ;; In Emacs <30, editorconfig-mode uses advices, so we cannot rely
+  ;; upon `hack-local-variables-hook' to run after editorconfig
+  ;; tab-width settings are applied.
+  (add-hook 'editorconfig-after-apply-functions
+            #'org--set-tab-width 90 'local)
   (org-load-modules-maybe)
   (when org-agenda-file-menu-enabled
     (org-install-agenda-files-menu))
-- 
2.47.1

-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

Reply via email to