emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Kris Nelson <Kris@KristoferNelson.com>
To: Rens Oliemans <hallo@rensoliemans.nl>,
	"emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: LOGBOOK drawer now being created with blank line afterwards
Date: Thu, 16 May 2024 01:48:04 -0600	[thread overview]
Message-ID: <084bf42e-00f6-48eb-a1ea-01a76cfc999c@KristoferNelson.com> (raw)
In-Reply-To: <87seyjsc58.fsf@rensoliemans.nl>

On 2024-05-15 02:38, Rens Oliemans wrote:
> Thanks for reporting, it seems that this was changed in 
> f63ff074417315fcf93c2ca6cfe8f89fcc6d902f, "Fix subtle differences 
> between overlays and invisible text properties", bisected with Emacs 
> 29.3. 

Thanks, that definitely helps narrow it down! Seems to be a result of 
this specific patch in the org-log-beginning function:

diff --git a/lisp/org.el b/lisp/org.el
index 4c87011..953f2f3 100644
--- a/lisp/org.el 
<https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/lisp/org.el?id=cd83606cfd8a52e7222a0deeeddb3af29e9cbfce>
+++ b/lisp/org.el 
<https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/lisp/org.el?id=f63ff074417315fcf93c2ca6cfe8f89fcc6d902f> 

@@ -10020,13 +10031,19 @@ narrowing."
           (throw 'exit nil))))
         ;; No drawer found.  Create one, if permitted.
         (when create
-         (unless (bolp) (insert "\n"))
-         (let ((beg (point)))
-           (insert ":" drawer ":\n:END:\n")
-           (org-indent-region beg (point))
-           (org-flag-region (line-end-position -1)
-                                (1- (point)) t 'outline))
-         (end-of-line -1)))))
+             ;; Avoid situation when we insert drawer right before
+             ;; first "*".  Otherwise, if the previous heading is
+             ;; folded, we are inserting after visible newline at
+             ;; the end of the fold, thus breaking the fold
+             ;; continuity.
+             (when (org-at-heading-p) (backward-char))
+             (org-fold-core-ignore-modifications
+             (unless (bolp) (insert-and-inherit "\n"))
+           (let ((beg (point)))
+             (insert-and-inherit ":" drawer ":\n:END:\n")
+             (org-indent-region beg (point))
+             (org-fold-region (line-end-position -1) (1- (point)) t (if 
(eq org-fold-core-style 'text-properties) 'drawer 'outline)))))
+       (end-of-line -1))))
        (t
         (org-end-of-meta-data org-log-state-notes-insert-after-drawers)
         (skip-chars-forward " \t\n")

I switched the (when create) section back to the previous state and 
confirmed that when redoing my test scenario no blank line was left 
after the logbook.

In the new code, I attempted just removing the final "\n" from 
(insert-and-inherit ":" drawer ":\n:END:\n") but that resulted in some 
weird behaviour when redoing my tests. I'll keep mucking with this to 
see where I get.

To clarify, would this behaviour change be considered a bug? Or is this 
intentional as a part of that patch, and I just need to figure out how 
to change the behaviour for myself?



  reply	other threads:[~2024-05-16  7:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-14 20:56 LOGBOOK drawer now being created with blank line afterwards Kris Nelson
2024-05-15  8:38 ` Rens Oliemans
2024-05-16  7:48   ` Kris Nelson [this message]
2024-05-16  7:53     ` Ihor Radchenko
2024-05-17 11:22 ` Ihor Radchenko
2024-05-18 18:44   ` Kris Nelson
2024-05-19 11:48     ` Ihor Radchenko

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=084bf42e-00f6-48eb-a1ea-01a76cfc999c@KristoferNelson.com \
    --to=kris@kristofernelson.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=hallo@rensoliemans.nl \
    /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).