From: "Sébastien Miquel" <sebastien.miquel@posteo.eu>
To: Bastien <bzg@gnu.org>
Cc: emacs-orgmode@gnu.org
Subject: Re: begin_src Indentation in org 9.4.4, 9.4.5
Date: Mon, 17 May 2021 09:02:47 +0000 [thread overview]
Message-ID: <6da18e3f-08a1-1ab6-93c7-6243c685a55f@posteo.eu> (raw)
In-Reply-To: <87zgwwfc7f.fsf@gnu.org>
Hi Bastien,
The commit `bfda3cc7df31fa79222efb4c190618c3c85a3d04` breaks automatic
(electric) indentation in src blocks for all configurations.
Here's what happens with the original issue.
When you press `RET` after the first ~hello hi~, the result is that
the first line is indented by two spaces, and the second (where the
point is) isn't.
- since ~electric-indent-mode~ is on, ~org-return~ is called with
`indent` set to `t`.
- Since ~org-src-tab-acts-natively~ is `t`, indentation is done by
calling `tab` in a src edit buffer, which by itself, does nothing.
- The observed indentation comes from ~org-src--contents-for-write-back~.
Since ~org-src--content-indentation~ is 2 and
~org-src--preserve-indentation~
is ~nil~, this functions further indents each *non blank* line by 2.
At this point, the first line is indented, cursor is at bol. Note
that you cannot indent your current empty line with `tab`. You can
either indent it manually, or call ~org-edit-special~.
When you write your second line, then press `RET`,
~org-src--contents-for-write-back~ will add an additional two spaces,
producing the reported result.
I think a reasonable fix is to have ~org-src--contents-for-write-back~
also indent blank lines. To do this, you need only remove following
line from its definition.
: (unless (eolp) ;ignore blank lines
With this done and `bfda3cc7df31fa79222efb4c190618c3c85a3d04`
reverted, the original issue is fixed, and the behaviour is better:
when you press `RET` to enter a newline in a src block, it is
automatically indented.
The downside is that, unless ~org-src--preserve-indentation~ is `t`,
when editing a src block, every empty line will be indented with
spaces (according to ~org-edit-src-content-indentation~ + the
indentation of the #+begin_src line). I think this is reasonable, but
perhaps some might disagree.
Regards,
--
Sébastien Miquel
next prev parent reply other threads:[~2021-05-17 9:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-07 21:01 begin_src Indentation in org 9.4.4, 9.4.5 Nathaniel W Griswold
2021-05-07 21:03 ` Nathaniel W Griswold
2021-05-07 22:14 ` Nathaniel W Griswold
2021-05-08 2:22 ` Ihor Radchenko
2021-05-15 11:50 ` Bastien
2021-05-15 11:51 ` Nathaniel W Griswold
2021-05-17 9:02 ` Sébastien Miquel [this message]
2021-05-18 6:37 ` Bastien
2021-05-18 13:43 ` Sébastien Miquel
2021-05-18 14:08 ` Bastien
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=6da18e3f-08a1-1ab6-93c7-6243c685a55f@posteo.eu \
--to=sebastien.miquel@posteo.eu \
--cc=bzg@gnu.org \
--cc=emacs-orgmode@gnu.org \
/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.