* LOGBOOK drawer now being created with blank line afterwards
@ 2024-05-14 20:56 Kris Nelson
2024-05-15 8:38 ` Rens Oliemans
2024-05-17 11:22 ` Ihor Radchenko
0 siblings, 2 replies; 7+ messages in thread
From: Kris Nelson @ 2024-05-14 20:56 UTC (permalink / raw)
To: emacs-orgmode@gnu.org
Hi,
I've noticed after upgrading to the latest Org version (9.6.30), when the LOGBOOK drawer is automatically generated during a TODO state change it inserts a blank line after the end of the drawer. This did not occur on the Org version I was using previously (9.5.5).
I'm not sure if this is an intended change or a bug. If it is intended, would there be a way to disable that behaviour (org-blank-before-new-entry does not seem to apply here)?
To clarify, given the following sample org file:
====================
-*- mode: org; org-log-into-drawer: t -*-
#+SEQ_TODO: TODO(t!) | DONE(d!)
* With Org 9.5.5
** Example project
*** Action 1
*** Action 2
* With Org 9.6.30
** Example project
*** Action 1
*** Action 2
====================
I get the following results when toggling the TODO state on the "Example project" heading with org-todo:
====================
* With Org 9.5.5
** TODO Example project
:LOGBOOK:
- State "TODO" from [2024-05-14 Tue 12:24]
:END:
*** Action 1
*** Action 2
* With Org 9.6.30
** TODO Example project
:LOGBOOK:
- State "TODO" from [2024-05-14 Tue 12:38]
:END:
*** Action 1
*** Action 2
====================
I'm currently reviewing the org source to try and see where the new line is coming from in the process flow, but I'm a bit of a novice in regards to elisp, so I haven't figured that out yet.
I also tried searching the mailing list archive, but didn't see anything related.
Thanks,
Kris
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: LOGBOOK drawer now being created with blank line afterwards
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
2024-05-17 11:22 ` Ihor Radchenko
1 sibling, 1 reply; 7+ messages in thread
From: Rens Oliemans @ 2024-05-15 8:38 UTC (permalink / raw)
To: Kris Nelson, emacs-orgmode@gnu.org
Kris Nelson <kris@kristofernelson.com> writes:
> I'm currently reviewing the org source to try and see where the new line is coming from in the process flow, but I'm a bit of a novice in regards to elisp, so I haven't figured that out yet.
>
> I also tried searching the mailing list archive, but didn't see anything related.
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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: LOGBOOK drawer now being created with blank line afterwards
2024-05-15 8:38 ` Rens Oliemans
@ 2024-05-16 7:48 ` Kris Nelson
2024-05-16 7:53 ` Ihor Radchenko
0 siblings, 1 reply; 7+ messages in thread
From: Kris Nelson @ 2024-05-16 7:48 UTC (permalink / raw)
To: Rens Oliemans, emacs-orgmode@gnu.org
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?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: LOGBOOK drawer now being created with blank line afterwards
2024-05-16 7:48 ` Kris Nelson
@ 2024-05-16 7:53 ` Ihor Radchenko
0 siblings, 0 replies; 7+ messages in thread
From: Ihor Radchenko @ 2024-05-16 7:53 UTC (permalink / raw)
To: Kris Nelson; +Cc: Rens Oliemans, emacs-orgmode@gnu.org
Kris Nelson <Kris@KristoferNelson.com> writes:
> 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?
As you see from the comment, creating a new blank line was not the
intention. So, what you see is a bug.
--
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>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: LOGBOOK drawer now being created with blank line afterwards
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-17 11:22 ` Ihor Radchenko
2024-05-18 18:44 ` Kris Nelson
1 sibling, 1 reply; 7+ messages in thread
From: Ihor Radchenko @ 2024-05-17 11:22 UTC (permalink / raw)
To: Kris Nelson, Rens Oliemans; +Cc: emacs-orgmode@gnu.org
Kris Nelson <kris@kristofernelson.com> writes:
> I've noticed after upgrading to the latest Org version (9.6.30), when the LOGBOOK drawer is automatically generated during a TODO state change it inserts a blank line after the end of the drawer. This did not occur on the Org version I was using previously (9.5.5).
Fixed, on main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=288c7069c
Thanks Kris for reporting, and thanks Rens for hunting down the cause!
--
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>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: LOGBOOK drawer now being created with blank line afterwards
2024-05-17 11:22 ` Ihor Radchenko
@ 2024-05-18 18:44 ` Kris Nelson
2024-05-19 11:48 ` Ihor Radchenko
0 siblings, 1 reply; 7+ messages in thread
From: Kris Nelson @ 2024-05-18 18:44 UTC (permalink / raw)
To: Ihor Radchenko, Rens Oliemans; +Cc: emacs-orgmode@gnu.org
[-- Attachment #1: Type: text/plain, Size: 1073 bytes --]
On 2024-05-17 05:22, Ihor Radchenko wrote:
> Fixed, on main.
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=288c7069c
>
> Thanks Kris for reporting, and thanks Rens for hunting down the cause!
Thanks for the prompt fix, Ihor! I tested it out and confirmed I'm not
seeing a blank space after the LOGBOOK anymore.
However, I did notice that it now errors out when creating the LOGBOOK
on a heading which is at the end of the buffer. The error is:
Error in post-command-hook (org-add-log-note): (end-of-buffer)
I did some debugging and found that the error was coming from the
(forward-char) call in the following line:
(if (eolp) (forward-char) (insert "\n"))
I've taken a crack at fixing this, which seems to work correctly from
all my tests. See attached for the patch file.
The basic reasoning behind the included changes is:
- Keep point at the end of the LOGBOOK entry (right after :END:) instead
of needing it to be on the line after.
- Adjust the values for folding the drawer and moving the point after
folding based on the logic above.
[-- Attachment #2: 0001-org-log-beginning-Fix-error-creating-LOGBOOK-drawer-.patch --]
[-- Type: text/x-patch, Size: 1472 bytes --]
From 2c53fa24e2a7abfa73e070145365d89ad1197b8a Mon Sep 17 00:00:00 2001
From: Kris Nelson <Kris@KristoferNelson.com>
Date: Sat, 18 May 2024 12:16:06 -0600
Subject: [PATCH] org-log-beginning: Fix error creating LOGBOOK drawer at end
of buffer
* lisp/org.el (org-log-beginning): Fix regression after 288c7069c where
"Error in post-command-hook (org-add-log-note): (end-of-buffer)"
is displayed after creating the LOGBOOK drawer on a heading which is
at the end of the buffer.
Reported-by: Kris Nelson <kris@kristofernelson.com>
Link: https://orgmode.org/list/766237934.317726.1715720181047@office.mailbox.org
---
lisp/org.el | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lisp/org.el b/lisp/org.el
index 4342ddd73..5e9f479fb 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -10676,10 +10676,10 @@ narrowing."
(unless (bolp) (insert-and-inherit "\n"))
(let ((beg (point)))
(insert-and-inherit ":" drawer ":\n:END:")
- (if (eolp) (forward-char) (insert "\n"))
+ (unless (eolp) (insert-and-inherit "\n") (backward-char))
(org-indent-region beg (point))
- (org-fold-region (line-end-position -1) (1- (point)) t 'drawer))))
- (end-of-line -1))))
+ (org-fold-region (line-end-position 0) (point) t 'drawer))))
+ (end-of-line 0))))
(t
(org-end-of-meta-data org-log-state-notes-insert-after-drawers)
(let ((endpos (point)))
--
2.45.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: LOGBOOK drawer now being created with blank line afterwards
2024-05-18 18:44 ` Kris Nelson
@ 2024-05-19 11:48 ` Ihor Radchenko
0 siblings, 0 replies; 7+ messages in thread
From: Ihor Radchenko @ 2024-05-19 11:48 UTC (permalink / raw)
To: Kris Nelson; +Cc: Rens Oliemans, emacs-orgmode@gnu.org
Kris Nelson <Kris@KristoferNelson.com> writes:
> On 2024-05-17 05:22, Ihor Radchenko wrote:
>> Fixed, on main.
>> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=288c7069c
>>
>> Thanks Kris for reporting, and thanks Rens for hunting down the cause!
> Thanks for the prompt fix, Ihor! I tested it out and confirmed I'm not
> seeing a blank space after the LOGBOOK anymore.
>
> However, I did notice that it now errors out when creating the LOGBOOK
> on a heading which is at the end of the buffer. The error is:
>
> Error in post-command-hook (org-add-log-note): (end-of-buffer)
> ...
> From 2c53fa24e2a7abfa73e070145365d89ad1197b8a Mon Sep 17 00:00:00 2001
> From: Kris Nelson <Kris@KristoferNelson.com>
> Date: Sat, 18 May 2024 12:16:06 -0600
> Subject: [PATCH] org-log-beginning: Fix error creating LOGBOOK drawer at end
> of buffer
Thanks!
Applied, onto main, adding TINYCHANGE cookie as you do not seem to have
FSF copyright assignment.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=c0b66bf9c
You are now added as an Org mode contributor:
https://git.sr.ht/~bzg/worg/commit/20d4f3f3
--
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>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-05-19 11:47 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
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).