From: "John Wiegley" <johnw@gnu.org>
To: emacs-orgmode@gnu.org
Subject: Archiving always adds a newline before entries
Date: Mon, 26 Aug 2024 18:22:46 -0700 [thread overview]
Message-ID: <m2r0aakbdl.fsf@gnu.org> (raw)
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
next reply other threads:[~2024-08-27 1:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-27 1:22 John Wiegley [this message]
2024-09-22 16:03 ` Archiving always adds a newline before entries 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=m2r0aakbdl.fsf@gnu.org \
--to=johnw@gnu.org \
--cc=emacs-orgmode@gnu.org \
/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).