emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [BUG] defaults make it hard to edit Elisp blocks in org buffers


From: Ihor Radchenko
Subject: Re: [BUG] defaults make it hard to edit Elisp blocks in org buffers
Date: Thu, 18 Jan 2024 12:35:32 +0000

Sébastien Miquel <sebastien.miquel@posteo.eu> writes:

> The issue is that when you press return, you insert a newline, with no
> indentation, then call =org-indent-line= which edits the block in a
> native buffer. This is supposed to remove any common indentation, but
> there is now none. Then it reinserts the code in the org-buffer,
> adding a new common indentation to the block.

Exactly.
Confirmed.

> If I recall correctly, in order to fix this, in =org-indent-line=,
> before calling =TAB= in the native buffer, one should check the
> current line indentation and if it is less than =block-content-ind=,
> start by adding this much indentation to the current line.
>
> This could be a bit fragile, and in particular it assumes that the
> rest of the block has this =block-content-ind=, which might not be the
> case. One could possibly at least check that the first line of the
> block does have this much indentation. If it doesn't, just do
> whatever.

What about a simpler approach - indent the line at point to block's
expected indentation (if it is not yet there) and then rely upon the
code block's major mode to do the right thing?

Even when we are in a situation when the user did not just press C-j or
<RET>, things should still work with the described approach.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
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

[Prev in Thread] Current Thread [Next in Thread]