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.
This commit is contained in:
Daniel Borchmann 2025-11-22 11:57:56 +01:00
parent e30dd26212
commit a7d0b70a8b
No known key found for this signature in database
GPG Key ID: 50EA937BF472ADD1

View File

@ -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)