emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: Max Nikulin <manikulin@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [Bug] incorrect indent of next heading after org-paste-subtree
Date: Mon, 02 May 2022 12:00:36 +0800	[thread overview]
Message-ID: <87a6c0vb17.fsf@localhost> (raw)
In-Reply-To: <t4lpos$l3p$1@ciao.gmane.io>

[-- Attachment #1: Type: text/plain, Size: 861 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-indent-Fix-edge-case-when-edited-region-ends-at-.patch --]
[-- Type: text/x-patch, Size: 1325 bytes --]

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	other threads:[~2022-05-02  4:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-30 11:42 [Bug] incorrect indent of next heading after org-paste-subtree Max Nikulin
2022-05-01  2:31 ` Ihor Radchenko
2022-05-01 11:09   ` Max Nikulin
2022-05-02  4:00     ` Ihor Radchenko [this message]
2022-05-02  7:29       ` Max Nikulin
2022-05-02 23:32       ` Samuel Wales
2022-05-03  1:21         ` Ihor Radchenko
2022-07-17  8:52       ` Ihor Radchenko
2022-05-02  1:54 ` Samuel Wales

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

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a6c0vb17.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=manikulin@gmail.com \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).