emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Dávid Jakab" <djakab314@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Bug: org-edit-special indents inline latex [9.5 (nil @ /home/david/.emacs.d/.local/straight/build-27.2/org-mode/)]
Date: Wed, 28 Apr 2021 15:37:54 +0200	[thread overview]
Message-ID: <0f961d3b-a4ef-fbbf-ab16-7ff1af8b2070@gmail.com> (raw)

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


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 @ 

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* (...
           (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.

             reply	other threads:[~2021-04-28 13:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-28 13:37 Dávid Jakab [this message]
2021-08-28 13:11 ` Bug: org-edit-special indents inline latex [9.5 (nil @ /home/david/.emacs.d/.local/straight/build-27.2/org-mode/)] Ihor Radchenko
2021-08-31 15:13   ` [PATCH] " Sébastien Miquel
2021-09-27 11:01     ` Bastien
2021-09-29 21:01       ` Dávid Jakab
2021-09-30 12:07       ` Sébastien Miquel
2021-09-30 13:50         ` Ihor Radchenko
2021-09-30 15:42         ` Bastien
2022-07-04 14:48   ` Sébastien Miquel
2022-07-07  9:05     ` Ihor Radchenko
2022-07-04 12:35 ` Sébastien Miquel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0f961d3b-a4ef-fbbf-ab16-7ff1af8b2070@gmail.com \
    --to=djakab314@gmail.com \
    --cc=emacs-orgmode@gnu.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).