emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Kris Nelson <Kris@KristoferNelson.com>
To: Ihor Radchenko <yantar92@posteo.net>,
	Rens Oliemans <hallo@rensoliemans.nl>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: LOGBOOK drawer now being created with blank line afterwards
Date: Sat, 18 May 2024 12:44:07 -0600	[thread overview]
Message-ID: <31465f70-3985-4e0e-aae7-d0fe59e4c69e@KristoferNelson.com> (raw)
In-Reply-To: <874jawadjs.fsf@localhost>

[-- 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


  reply	other threads:[~2024-05-18 18:45 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
2024-05-16  7:53     ` Ihor Radchenko
2024-05-17 11:22 ` Ihor Radchenko
2024-05-18 18:44   ` Kris Nelson [this message]
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=31465f70-3985-4e0e-aae7-d0fe59e4c69e@KristoferNelson.com \
    --to=kris@kristofernelson.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=hallo@rensoliemans.nl \
    --cc=yantar92@posteo.net \
    /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).