emacs orgmode do not insert line between headers?
Asked Answered
F

2

15

In emacs org-mode, when I make a new sub-heading,(org-insert-subheading), sometimes it adds a blank line, sometimes it doesn't based on some pattern in text above.

Can I force emacs to never insert a line break?

I.e,

* Heading 1
** Heading 2  #no line breaks.
Forensics answered 5/2, 2015 at 18:33 Comment(0)
I
6

I think this is controlled by the variable org-blank-before-new-entry. As per the Org documentation:

Should org-insert-heading leave a blank line before new heading/item? The value is an alist, with heading and plain-list-item as CAR, and a boolean flag as CDR. The cdr may also be the symbol `auto', in which case Org will look at the surrounding headings/items and try to make an intelligent decision whether to insert a blank line or not.

For plain lists, if org-list-empty-line-terminates-plain-lists is set, the setting here is ignored and no empty line is inserted to avoid breaking the list structure.

The default value is '((heading . auto) (plain-list-item . auto)), so it normally will insert a newline before a heading (the auto part in the heading). You can specify Never when you customize the variable, and it will not insert a newline.

Irra answered 5/2, 2015 at 19:16 Comment(0)
G
12

This is controlled by the variable org-blank-before-new-entry:

Should `org-insert-heading' leave a blank line before new heading/item?
The value is an alist, with `heading' and `plain-list-item' as CAR, and a boolean flag as CDR. The cdr may also be the symbol `auto', in which case Org will look at the surrounding headings/items and try to make an intelligent decision whether to insert a blank line or not.

On my version of emacs, the default for both items is auto. To never insert blank lines, set both to nil:

(setf org-blank-before-new-entry '((heading . nil) (plain-list-item . nil)))
Gillis answered 5/2, 2015 at 19:14 Comment(2)
I found this does not work (it seems to interpret nil as auto), but (setf org-blank-before-new-entry '((heading . never) (plain-list-item . never))) does. My version: "GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.24, cairo version 1.16.0) of 2021-03-27, modified by Debian"Wordbook
Can this approach remove newline in between TODOs as well?Gymnosophist
I
6

I think this is controlled by the variable org-blank-before-new-entry. As per the Org documentation:

Should org-insert-heading leave a blank line before new heading/item? The value is an alist, with heading and plain-list-item as CAR, and a boolean flag as CDR. The cdr may also be the symbol `auto', in which case Org will look at the surrounding headings/items and try to make an intelligent decision whether to insert a blank line or not.

For plain lists, if org-list-empty-line-terminates-plain-lists is set, the setting here is ignored and no empty line is inserted to avoid breaking the list structure.

The default value is '((heading . auto) (plain-list-item . auto)), so it normally will insert a newline before a heading (the auto part in the heading). You can specify Never when you customize the variable, and it will not insert a newline.

Irra answered 5/2, 2015 at 19:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.