shelper9527 · 2022-08-30 13:28
e.g, i would like to have a tool to format the org mode buffer with some customization like empty lines between headlines, table alignment, code block alignment, etc.
I've searched for such tool a while and there are ways like below but none of that works automatically like you format your other source code, like black for python...,
(setq org-blank-before-new-entry '((heading . t) (plain-list-item . auto)))
edumerco · 2022-08-30 22:08
I'm not sure I understand... You mean font, sizes and colors, adding spaces or what?
Usually this is done from the face configuration (and it has a UI from customize-face).
Or maybe it's other thing that escaped me... ;)
shelper9527 · 2022-08-31 01:24
I mean things like how you format source code, e.g., adding spacing, empty lines, etc.
Font and color and size they are properties that are not editable characters,
dpoggio · 2022-08-31 02:45
Org is not formatted like source code AFAIK. You may like empty lines, then you have Capture Templates. How much more do you “format” in your Org files? And why would you prefer that format to be hard characters instead of properties?
shelper9527 · 2022-08-31 14:03
couple of examples:
1. i got org file from somewhere else, and i want it to be my style in terms of empty lines, indentation of src blocks, etc.
2. I copied an org file block from somewhere which does not match my style.
I would like to have some thing like `format on save` so that for cases above, i just presss `C-x C-s` to save file and it got reformatted as i want.
chrisdbarrett · 2022-08-31 22:23
I spiked out a headline formatter a while back for my own config. It's here: [https://github.com/chrisbarrett/nursery/tree/main/lisp/org-format.el](https://github.com/chrisbarrett/nursery/tree/main/lisp/org-format.el)
It just headine and property drawer spacing, but might give you some ideas.
publicvoit · 2022-09-05 11:07
FYI: For source code, this is usually done via a [linter](https://en.wikipedia.org/wiki/Lint_(software)). You might want to search for that.