From cb5d20b54349dabea25241072feca4822ae0e77d Mon Sep 17 00:00:00 2001 From: Max Nikulin Date: Sun, 10 Mar 2024 11:22:15 +0700 Subject: [PATCH 3/3] org.el: Avoid `find-file-no-select' during MathML generation * lisp/org.el (org-create-math-formula): Bypass `find-file-hook' during reading MathML files. At least in Emacs-28 calling `find-file-noselect' for a file in a directory under git control when git is not installed causes failures: Lisp error: (file-missing "Searching for program" "No such file or directory" "git") `org-create-math-formula' uses document `default-directory' for temporary files for conversion process input and output. I have faced an issue with Org mode unit tests running in a minimal container with no git installed. --- lisp/org.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index a00d50c51..caf1bfa67 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -16215,14 +16215,15 @@ (defun org-create-math-formula (latex-frag &optional mathml-file) (setq shell-command-output (shell-command-to-string cmd)) (setq mathml (when (file-readable-p tmp-out-file) - (with-current-buffer (find-file-noselect tmp-out-file t) + (with-temp-buffer + (insert-file-contents tmp-out-file) (goto-char (point-min)) (when (re-search-forward (format "]*?%s[^>]*?>\\(.\\|\n\\)*" (regexp-quote "xmlns=\"http://www.w3.org/1998/Math/MathML\"")) nil t) - (prog1 (match-string 0) (kill-buffer)))))) + (match-string 0))))) (cond (mathml (setq mathml -- 2.39.2