fix(org-latex): inhibit-modification-hooks in auto-tabularx to prevent recursion

The insert call in my/org-auto-tabularx triggered buffer-change hooks (e.g.
org-element-cache) during LaTeX export, causing infinite recursion and
'max-lisp-eval-depth exceeded'. HTML export was unaffected (hook only runs
for latex backend). Fix: wrap body in (let ((inhibit-modification-hooks t))).
This commit is contained in:
2026-02-23 14:44:32 +01:00
parent 26ac9082dd
commit 457b9d3d4c

View File

@@ -339,8 +339,10 @@ Bound to cmd+v in org-mode and markdown-mode."
;; Automatically insert #+ATTR_LATEX tabularx before tables on LaTeX export ;; Automatically insert #+ATTR_LATEX tabularx before tables on LaTeX export
(defun my/org-auto-tabularx (backend) (defun my/org-auto-tabularx (backend)
"Insert #+ATTR_LATEX tabularx before each table when exporting to LaTeX." "Insert #+ATTR_LATEX tabularx before each table when exporting to LaTeX.
Uses inhibit-modification-hooks to prevent recursive hook calls during insert."
(when (org-export-derived-backend-p backend 'latex) (when (org-export-derived-backend-p backend 'latex)
(let ((inhibit-modification-hooks t))
(save-excursion (save-excursion
(goto-char (point-min)) (goto-char (point-min))
(while (not (eobp)) (while (not (eobp))
@@ -362,7 +364,8 @@ Bound to cmd+v in org-mode and markdown-mode."
(insert attr))))) (insert attr)))))
(forward-line)) (forward-line))
(t (t
(forward-line)))))))) (forward-line)))))))))
)
(add-hook 'org-export-before-processing-hook #'my/org-auto-tabularx) (add-hook 'org-export-before-processing-hook #'my/org-auto-tabularx)