[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Unindentation fixup for code blocks
From: |
Ihor Radchenko |
Subject: |
Re: [PATCH] Unindentation fixup for code blocks |
Date: |
Wed, 10 Jan 2024 12:28:07 +0000 |
Psionic K <psionik@positron.solutions> writes:
> When cleaning up hard indentation, I found my source blocks remaining
> indented.
>
> The way that org-do-remove-indentation is sensitive to invisible text.
> This occurs for source blocks whenever using org-modern-mode, where it
> makes the source blocks align left.
Thanks for the patch!
Would you also be able to create a reproducer, so that we can replicate
the problem and write a test?
> By swapping out the arithmetic and expressions that relied on
> current-column, the behavior is fixed.
>
> There are several behaviors I only just found, so I don't expect a lot
> of precision in my fix, but the patch I came up with follows:
>
> From 858077f0d2a7f4cd8699948229c2965f0c6bb0a1 Mon Sep 17 00:00:00 2001
> From: Psionik K <73710933+psionic-k@users.noreply.github.com>
> Date: Wed, 10 Jan 2024 18:05:53 +0900
> Subject: [PATCH] when removing indentation, take into account invisible text
It looks like you did not send the patch with git send-email (this email
patch does not apply with git). It might be easier if you simply attach
the patch to email.
> One behavioral difference is that the point is no longer moved
> forward. Therefore, arithmetic is used instead of (current-column)
> based math. (current-column) is inaccurate when moving the point
> through invisible text.
If you can, please add changelog entries to the commit message. See
https://orgmode.org/worg/org-contribute.html#org77afce2
> - (progn (move-to-column n t)
> - (point)))))
> + (+ (line-beginning-position) n))))
This math is not accurate when tabs are present.
--
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>