* Archiving always adds a newline before entries
@ 2024-08-27 1:22 John Wiegley
2024-09-22 16:03 ` Ihor Radchenko
0 siblings, 1 reply; 2+ messages in thread
From: John Wiegley @ 2024-08-27 1:22 UTC (permalink / raw)
To: emacs-orgmode
I like to avoid blank lines between Org-mode entries, but have found that when
archiving (and not use datetrees), that this is not supported by Org-mode
out-of-the-box. Mainly it’s due to these lines:
(if (and heading (not (and datetree-date (not datetree-subheading-p))))
…
;; No specific heading, just go to end of file, or to the
;; beginning, depending on `org-archive-reversed-order'.
(if org-archive-reversed-order
…
(goto-char (point-max))
;; Subtree narrowing can let the buffer end on
;; a headline. `org-paste-subtree' then deletes it.
;; To prevent this, make sure visible part of buffer
;; always terminates on a new line, while limiting
;; number of blank lines in a date tree.
---> (unless (and datetree-date (bolp)) (insert "\n"))))
;; Paste
(org-paste-subtree (org-get-valid-level level (and heading 1)))
The line indicated above always appends a newline at the end of the buffer,
so that the pasted tree appears after this newline. It would be nice if this
followed the configuration of ‘org-blank-before-new-entry’, for example.
Meanwhile, I corrected the behavior with advice. Not ideal, since it affects
all cases of pasting subtrees, but it works well enough:
(advice-add 'org-paste-subtree :before #'(lambda (_) (delete-blank-lines)))
--
John Wiegley GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com 60E1 46C4 BD1A 7AC1 4BA2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Archiving always adds a newline before entries
2024-08-27 1:22 Archiving always adds a newline before entries John Wiegley
@ 2024-09-22 16:03 ` Ihor Radchenko
0 siblings, 0 replies; 2+ messages in thread
From: Ihor Radchenko @ 2024-09-22 16:03 UTC (permalink / raw)
To: John Wiegley; +Cc: emacs-orgmode
"John Wiegley" <johnw@gnu.org> writes:
> I like to avoid blank lines between Org-mode entries, but have found that when
> archiving (and not use datetrees), that this is not supported by Org-mode
> out-of-the-box. Mainly it’s due to these lines:
> ...
> ;; Subtree narrowing can let the buffer end on
> ;; a headline. `org-paste-subtree' then deletes it.
> ;; To prevent this, make sure visible part of buffer
> ;; always terminates on a new line, while limiting
> ;; number of blank lines in a date tree.
> ---> (unless (and datetree-date (bolp)) (insert "\n"))))
> ;; Paste
> (org-paste-subtree (org-get-valid-level level (and heading 1)))
>
> The line indicated above always appends a newline at the end of the buffer,
> so that the pasted tree appears after this newline. It would be nice if this
> followed the configuration of ‘org-blank-before-new-entry’, for example.
+1
Ideally, we should use something more Elisp-friendly compared to
interactive context-dependent `org-paste-subtree'.
In the current state, things are way too fragile to touch them without
risking unexpected breakage in various corner cases.
It would be nice to factor out context-sensitive handling in
`org-paste-subtree' into some kind of API function. Then, we can use
that function more safely in other places like org-archive.
--
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] 2+ messages in thread
end of thread, other threads:[~2024-09-22 16:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-27 1:22 Archiving always adds a newline before entries John Wiegley
2024-09-22 16:03 ` 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).