emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [BUG] Source block indentation does not work properly for yaml-mode


From: Sébastien Miquel
Subject: Re: [BUG] Source block indentation does not work properly for yaml-mode [9.6.6 ( @ /home/user/.emacs.d/elpa/org-9.6.6/)]
Date: Sat, 17 Jun 2023 19:11:01 +0000

Hi Ihor, wolf,

Ihor Radchenko writes:
Confirmed.
This is caused by `org-src--contents-for-write-back' not adjusting
blank line indentation in some cases.

I don't think that's the issue. In fact, applying your diff didn't
seem to solve the issue on my end.

Generally, if you edit the given yaml in a =C-c C-'= buffer and go
back to the org buffer with the default configuration, spaces will be
converted to tabs, because =indent-tabs-mode= is =t= in the org buffer.

I don't think there's much that we can do about it. We could try to
read the value of =indent-tabs-mode= in the native buffer and preserve
it in the org buffer, but then the org buffer would have mixed
indentation all over, and that's exactly what the current code tries to
avoid.

To fix the original issue, you can set =indent-tabs-mode= to =nil= in
your org files, or possibly set =org-preserve-indentation= to =t=
(untested).

I feel that the whole approach we use now with preserve-fl, use-tabs?,
and preserve-blank-line is overcomplicated. Maybe someone can explain
why we need all these special cases? The code does not reveal a whole lot.

 - =use-tabs?= seems pretty straightforward, its purpose is to respect
   the value of =indent-tabs-mode= in the org buffer.
 - =preserve-fl= is an isolated issue, and only concerns LaTeX
   fragments. I will attach a test with the issue it solves with
   multiline LaTeX fragments. I think LaTeX fragments are particular
   because in the org buffer they do not need to start at the
   beginning of a line.
 - The =preserve-blank-line= part (committed by me) is quite abstruse.
   Its name does not make any sense !

   Originally, we did not try to reindent blank lines when writing
   back to the org buffer. I changed it so that when using
   =org-return=, the newline would get correctly indented, I think.
   Then I changed it again so that only the current blank line might
   get indented, see
   : https://list.orgmode.org/725763.1632663635@apollo2.minshall.org/T/
   The variable =preserve-blank-line= decides whether we should indent
   the current blank line (if it is empty, we should maybe not).


Here are three patches attached.
 1. Two tests : about editing LaTeX fragments, and preserving empty
    lines.
 2. Renaming of =preserve-blank-line=, for clarity.
 3. Two more tests testing the behaviour of =org-return= and
    indentation, with the default configuration. When writing these, I
    found the behaviour was buggy in one case, and modified
    =org-indent-line= to fix it.

Does that look alright to you ?

Regards,
--
Sébastien Miquel

Attachment: 0001-test-org-src.el-Add-two-tests.patch
Description: Text Data

Attachment: 0001-org-src.el-Rename-internal-variable-for-clarity.patch
Description: Text Data

Attachment: 0001-org.el-org-indent-line-Fix-to-the-indentation-inside.patch
Description: Text Data


reply via email to

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