emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [Bug] incorrect indent of next heading after org-paste-subtree


From: Ihor Radchenko
Subject: Re: [Bug] incorrect indent of next heading after org-paste-subtree
Date: Mon, 02 May 2022 12:00:36 +0800

Max Nikulin <manikulin@gmail.com> writes:

>> I am unable to reproduce on the latest Org.
>
> Thank you, Ihor. I have checked it once more for current main HEAD 
> 2bd34edb64. I can reproduce it using the provided steps in Emacs-26, but 
> not in Emacs-27.
>
> Unless there is a reason to suspect something weird underneath, the 
> issue should be considered with rather low priority. Anyway, I have 
> added trailing newline to generated content and mostly use org-capture 
> with org-protocol for communication between applications.

Thanks for the extra info!
I managed to reproduce using Emacs 26 and it is a real problem with some
edge case in org-indent. The problem is masked by
combine-after-change-calls that is used since Emacs 27 but replaced by a
placeholer in Emacs 26.

The fix is attached. Let me know if it also works on your side.

Best,
Ihor

>From 5dd89d7b36bee94804c7ab631780a4bd020c49cb Mon Sep 17 00:00:00 2001
Message-Id: 
<5dd89d7b36bee94804c7ab631780a4bd020c49cb.1651463875.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Mon, 2 May 2022 11:56:15 +0800
Subject: [PATCH] org-indent: Fix edge case when edited region ends at headline
 leading stars

* lisp/org-indent.el (org-indent-refresh-maybe): Extend affected
region to the whole line after END.

Fixes https://orgmode.org/list/t4lpos$l3p$1@ciao.gmane.io
---
 lisp/org-indent.el | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lisp/org-indent.el b/lisp/org-indent.el
index 4cca0c35d..7469aba97 100644
--- a/lisp/org-indent.el
+++ b/lisp/org-indent.el
@@ -409,7 +409,13 @@ (defun org-indent-refresh-maybe (beg end _)
                 (goto-char beg)
                 (beginning-of-line)
                 (re-search-forward
-                 (org-with-limited-levels org-outline-regexp-bol) end t)))
+                 (org-with-limited-levels org-outline-regexp-bol)
+                  (save-excursion
+                    (goto-char end)
+                    ;; Extend to headline if END is within its
+                    ;; headline stars.
+                    (line-end-position))
+                  t)))
           (let ((end (save-excursion
                        (goto-char end)
                        (org-with-limited-levels (outline-next-heading))
-- 
2.35.1


reply via email to

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