Remember to cover the basics, that is, what you expected to happen and
what in fact did happen. You don't know how to make a good report? See
https://orgmode.org/manual/Feedback.html#Feedback
Your bug report will be posted to the Org mailing list.
------------------------------------------------------------------------
Emacs : GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.27, cairo version 1.17.4)
of 2021-03-26
Package: Org mode version 9.5 (nil @
/home/david/.emacs.d/.local/straight/build-27.2/org-mode/)
When using org-edit-special to edit inline latex, i.e., equations
between \( and \), in an org-mode buffer, a number of
spaces may get inserted before \( after the latex editing minibuffer is
closed. It seems like the number of extra spaces
defaults to the indentation of the line in which the inline math is
located. This behavior makes complete sense for code
blocks and latex environments, but I can't see a use case in which it
should be applied to inline math. It looks like
the option to edit inline math with org-edit-special was added only
recently, so this could be a bug that noone
noticed yet.
I looked at the code that does things and it seems the variable that
controls the indentation of the parts edited in the
minibuffer is a buffer-local variable org-src--preserve-indentation.
Setting a default value to it has no effect because
it gets overwritten internally in the function org-src--edit-element.
There is a variable with a similar name
org-src-preserve-indentation that is supposed to set by the user, but it
has no effect specifically in the case of latex
fragments because org-src--edit-element contains the code:
(let* (...
(preserve-ind
(and (memq type '(example-block src-block))
(or (org-element-property :preserve-indent datum)
org-src-preserve-indentation))) ...)
...
(setq org-src--preserve-indentation preserve-ind)
So the user is only allowed to turn off org-edit-special messing with
the indentation if he is an an example-block or
src-block. I hacked in a fix modifying org-src--edit-element by
replacing (memq type '(example-block src-block)) with
(memq type '(example-block src-block latex-fragment)) and setting
org-src-preserve-indentation. This seems to have
solved the issue, but I believe the function shouldn't even be trying to
indent inline math in the first place.