Re: [BUG] org-list-struct-apply-struct overrides src block indentation (was: [BUG] Source block indentation does not work properly for yaml-mode [9.6.6 ( @ /home/user/.emacs.d/elpa/org-9.6.6/)])

2023-07-08 Thread Ihor Radchenko
Sébastien Miquel  writes:

> Ihor Radchenko writes:
>> The cause is the following line in `org-list-struct-apply-struct'
>> [[file:~/Git/org-mode/lisp/org-list.el::indent-line-to  (+ 
>> (org-current-text-indentation) delta)))]]
>>
>> It calls `indent-line-to' that replaces spaces with tabs according to
>> current value of indent-tabs-mode in Org buffer.
>
> There are a few other instances of `indent-line-to` in the code. I
> guess the right fix is to un-obsolete `org-indent-line-to`, use it and
> make a special case if point is in a src block.

Yup. Sounds reasonable. Although we should not use it blindly; just
where necessary. Checking for element at point will create overheads.

> This use case is
> uncommon and not really compatible with `org-src-preserve-indentation`
> though.

May you please elaborate?

> Somewhat more common possibility: say one has a src block at 0
> indentation, and wants to make it part of an org list. Is there any
> proper org way to do this ? I can use `indent-rigidly`, but again,
> this might break an org-src indentation. No easy fix to this beside
> providing a simple org version of `indent-rigidly`.

I recall struggling with it and ending up with adding spaces manually to
the first src line and then using indent-region.

`indent-line-function' technically allows force indent, if
`tab-always-indent' is set to t, but we have  bound to org-cycle,
which will take precedence when at #+begin_src.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [BUG] org-list-struct-apply-struct overrides src block indentation (was: [BUG] Source block indentation does not work properly for yaml-mode [9.6.6 ( @ /home/user/.emacs.d/elpa/org-9.6.6/)])

2023-07-07 Thread Sébastien Miquel



Ihor Radchenko writes:

The cause is the following line in `org-list-struct-apply-struct'
[[file:~/Git/org-mode/lisp/org-list.el::indent-line-to  (+ 
(org-current-text-indentation) delta)))]]

It calls `indent-line-to' that replaces spaces with tabs according to
current value of indent-tabs-mode in Org buffer.


There are a few other instances of `indent-line-to` in the code. I
guess the right fix is to un-obsolete `org-indent-line-to`, use it and
make a special case if point is in a src block. This use case is
uncommon and not really compatible with `org-src-preserve-indentation`
though.

Somewhat more common possibility: say one has a src block at 0
indentation, and wants to make it part of an org list. Is there any
proper org way to do this ? I can use `indent-rigidly`, but again,
this might break an org-src indentation. No easy fix to this beside
providing a simple org version of `indent-rigidly`.

The issues above do not seem too bad. They are uncommon, and an
indent-region call should fix the indentation.

--
Sébastien Miquel



[BUG] org-list-struct-apply-struct overrides src block indentation (was: [BUG] Source block indentation does not work properly for yaml-mode [9.6.6 ( @ /home/user/.emacs.d/elpa/org-9.6.6/)])

2023-07-07 Thread Ihor Radchenko
Using a similar example, another indentation bug has been revealed:

1. emacs -Q
2. Create an Org file with the following contents:

- 1
  - 2
- 3
  - 4
- 5
  #+begin_src yaml
a:
  b:
c:
  d:
  #+end_src

Everything indented using spaces, including "d:" that uses 8 spaces,
which should remain spaces since yaml-mode uses spaces for indentation.

3. M-x whitespace-mode
4. Move point to item 5 and press M- 3 times
5. Observe "d:" indented using two tabs with all the spaces replaced by tabs.

The cause is the following line in `org-list-struct-apply-struct'
[[file:~/Git/org-mode/lisp/org-list.el::indent-line-to (+ 
(org-current-text-indentation) delta)))]]

It calls `indent-line-to' that replaces spaces with tabs according to
current value of indent-tabs-mode in Org buffer.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at