From: Ihor Radchenko <yantar92@posteo.net>
To: sebastien.miquel@posteo.eu
Cc: emacs-orgmode@gnu.org
Subject: Re: [BUG] defaults make it hard to edit Elisp blocks in org buffers
Date: Thu, 18 Jan 2024 12:35:32 +0000 [thread overview]
Message-ID: <878r4makff.fsf@localhost> (raw)
In-Reply-To: <a87204af-4839-40de-bb64-b901f9399c70@posteo.eu>
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>
next prev parent reply other threads:[~2024-01-18 12:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-17 18:34 [BUG] defaults make it hard to edit Elisp blocks in org buffers gerard.vermeulen
2024-01-17 20:04 ` Sébastien Miquel
2024-01-18 12:35 ` Ihor Radchenko [this message]
2024-01-18 16:45 ` Sébastien Miquel
2024-01-18 18:11 ` gerard.vermeulen
2024-01-18 18:19 ` Ihor Radchenko
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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878r4makff.fsf@localhost \
--to=yantar92@posteo.net \
--cc=emacs-orgmode@gnu.org \
--cc=sebastien.miquel@posteo.eu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* 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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.