🧹 An Emacs minor mode to automatically tidy org-mode property drawers
Emacs Lisp
139
53 commits
updated Dec 12, 2024
#+title: org-tidy #+author: Xuqing Jia 🧹 An Emacs minor mode to automatically tidy org-mode property drawers. * Why? Org-mode's property drawer is a very useful feature. We can store properties associated with an entry in property drawer. I use org-roam every day. And org-roam node is an entry with ID property. But if I create many nodes in a single file, there will be a lot of property drawers. This is really annoying. Even after they are folded, there are still lines like ~:PROPERTIES: ...~ , which makes the whole buffer hard to read. At first I googled for some tricks to hide property drawers completely. And I found there are many people like me who are bothered by this problem. Of course there are solutions. But these solutions involve a lot of code. So I made this package. * Screenshots @@html:<div align="center">@@ @@html:<img src='https://raw.githubusercontent.com/jxq0/org-tidy/main/screenshot.png'>@@ @@html:</div>@@ After org-tidy mode is turned on, these property drawers are hidden. And the symbol ♯ is appended after the headline. You can also customize how property drawers will be hidden. * Usage ** Manual #+begin_src emacs-lisp (require 'org-tidy) (add-hook 'org-mode-hook #'org-tidy-mode) #+end_src ** use-package #+begin_src emacs-lisp (use-package org-tidy :ensure t :hook (org-mode . org-tidy-mode)) #+end_src ** How to edit property drawers in org-tidy-mode? If you need to edit only one drawer temporarily, you can simply ~M-x org-tidy-untidy-buffer~. When you save the buffer, it will be tidied again. If you need to edit a lot of drawers, you can ~M-x org-tidy-toggle~. Then the buffer will not be tidied on save, until ~M-x org-tidy-toggle~ again. * Customize - ~org-tidy-top-property-style~ How to display the property at the beginning of buffer. ~keep~ will do nothing. ~invisible~ will hide it. - ~org-tidy-properties-style~ How to display other property drawers. - ~fringe~ will hide the property drawer and show a indicator in the left fringe - ~inline~ will hide the property drawer and append a symbol (default to ♯) at the end of previous line - ~invisible~ will just hide the property drawer - ~org-tidy-properties-inline-symbol~ The inline symbol. - ~org-tidy-property-drawer-flag~ Whether to tidy property drawers. - ~org-tidy-property-drawer-property-whitelist~ The whitelist of properties. If set, only property drawers which contain property in this list *will* be tidied. - ~org-tidy-property-drawer-property-blacklist~ Blacklist of properties. If set, property drawers which contain property in this list *will not* be tidied. - ~org-tidy-general-drawer-flag~ Non-nil means should tidy general drawers. - ~org-tidy-general-drawer-name-whitelist~ Whitelist of drawer names. If set, only general drawers whose name is in this list *will* be tidied. - ~org-tidy-general-drawer-name-blacklist~ Blacklist of drawer names. If set, general drawers whose name is in this list *will not* be tidied.
Not written in Markdown, so it's shown here as plain text — view it formatted on GitHub.
Emacs Lisp
100.0%
🧹 An Emacs minor mode to automatically tidy org-mode property drawers
Emacs Lisp
139
53 commits
updated Dec 12, 2024
#+title: org-tidy #+author: Xuqing Jia 🧹 An Emacs minor mode to automatically tidy org-mode property drawers. * Why? Org-mode's property drawer is a very useful feature. We can store properties associated with an entry in property drawer. I use org-roam every day. And org-roam node is an entry with ID property. But if I create many nodes in a single file, there will be a lot of property drawers. This is really annoying. Even after they are folded, there are still lines like ~:PROPERTIES: ...~ , which makes the whole buffer hard to read. At first I googled for some tricks to hide property drawers completely. And I found there are many people like me who are bothered by this problem. Of course there are solutions. But these solutions involve a lot of code. So I made this package. * Screenshots @@html:<div align="center">@@ @@html:<img src='https://raw.githubusercontent.com/jxq0/org-tidy/main/screenshot.png'>@@ @@html:</div>@@ After org-tidy mode is turned on, these property drawers are hidden. And the symbol ♯ is appended after the headline. You can also customize how property drawers will be hidden. * Usage ** Manual #+begin_src emacs-lisp (require 'org-tidy) (add-hook 'org-mode-hook #'org-tidy-mode) #+end_src ** use-package #+begin_src emacs-lisp (use-package org-tidy :ensure t :hook (org-mode . org-tidy-mode)) #+end_src ** How to edit property drawers in org-tidy-mode? If you need to edit only one drawer temporarily, you can simply ~M-x org-tidy-untidy-buffer~. When you save the buffer, it will be tidied again. If you need to edit a lot of drawers, you can ~M-x org-tidy-toggle~. Then the buffer will not be tidied on save, until ~M-x org-tidy-toggle~ again. * Customize - ~org-tidy-top-property-style~ How to display the property at the beginning of buffer. ~keep~ will do nothing. ~invisible~ will hide it. - ~org-tidy-properties-style~ How to display other property drawers. - ~fringe~ will hide the property drawer and show a indicator in the left fringe - ~inline~ will hide the property drawer and append a symbol (default to ♯) at the end of previous line - ~invisible~ will just hide the property drawer - ~org-tidy-properties-inline-symbol~ The inline symbol. - ~org-tidy-property-drawer-flag~ Whether to tidy property drawers. - ~org-tidy-property-drawer-property-whitelist~ The whitelist of properties. If set, only property drawers which contain property in this list *will* be tidied. - ~org-tidy-property-drawer-property-blacklist~ Blacklist of properties. If set, property drawers which contain property in this list *will not* be tidied. - ~org-tidy-general-drawer-flag~ Non-nil means should tidy general drawers. - ~org-tidy-general-drawer-name-whitelist~ Whitelist of drawer names. If set, only general drawers whose name is in this list *will* be tidied. - ~org-tidy-general-drawer-name-blacklist~ Blacklist of drawer names. If set, general drawers whose name is in this list *will not* be tidied.
Not written in Markdown, so it's shown here as plain text — view it formatted on GitHub.
Emacs Lisp
100.0%