From a7d0b70a8bf04501af2a47b7b7fa234bea7158f2 Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Sat, 22 Nov 2025 11:57:56 +0100 Subject: [PATCH] Fix line splitting in item to headline conversion The previous attempt did remove too much leading whitespace from the body, so that identation removal did not work. The current attempt tries to remedy this by being a bit more low-level. --- site-lisp/db-org.el | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/site-lisp/db-org.el b/site-lisp/db-org.el index c05afe7..009b15d 100644 --- a/site-lisp/db-org.el +++ b/site-lisp/db-org.el @@ -414,8 +414,15 @@ history of the buffer." ;; Generate headline and store it somewhere (let* ((body (buffer-substring-no-properties (org-element-contents-begin last-seen-item) (org-element-end last-seen-item))) - (first-line-of-body (seq-take-while #'(lambda (x) (not (= x ?\n))) body)) - (rest-of-body (string-trim (seq-drop-while #'(lambda (x) (not (= x ?\n))) body)))) + first-line-of-body + rest-of-body) + + (if-let ((first-linebreak (cl-position ?\n body))) + (setq first-line-of-body (substring body 0 first-linebreak) + rest-of-body (seq-drop-while #'(lambda (x) (= x ?\n)) + (substring body (1+ first-linebreak)))) + (setq first-line-of-body body + rest-of-body "")) ;; Remove old entry first (delete-region (org-element-begin last-seen-item)