Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rougier/book-mode
A clean interface for org files (Emacs)
https://github.com/rougier/book-mode
Last synced: about 1 month ago
JSON representation
A clean interface for org files (Emacs)
- Host: GitHub
- URL: https://github.com/rougier/book-mode
- Owner: rougier
- License: gpl-3.0
- Created: 2022-10-01T14:47:26.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-01-09T20:25:51.000Z (8 months ago)
- Last Synced: 2024-05-02T01:12:33.712Z (5 months ago)
- Language: Emacs Lisp
- Size: 14 MB
- Stars: 272
- Watchers: 10
- Forks: 7
- Open Issues: 4
-
Metadata Files:
- Readme: README.org
- License: LICENSE.txt
Awesome Lists containing this project
README
#+attr_org: :width 600
[[./book-mode.png]]*Book mode* - /Nicolas Rougier - January 9, 2023/ (*WIP*)
Book mode is an attempt at offering an interface for reading org-mode files with a clean layout. It is based on the use of large margins, headline and mode-line, with leading stars and bullets in the left margin using right alignment and different symbols. All decorations are part of the header-line (including upper left colored part and right upper glyph) and messages are displayed in the mode-line.
*See also* inside article directory for a more advanced and experimental example.
* Section
Using font lock keywords, we can have outer indent by moving leading stars into the left margin such that text is always aligned. This could be extended to org-num-mode but it would require a bigger margin and dedicated regex. This is applied for level 1, 2 and 3 while level 4 has a special transformation to make it appear like a paragraph (see below).
** Subsection
Using the same trick, we can also move list bullets in the margin and use a nicer glyph ("•" instead of "-"):
- Item 1
- Item 2Not everyone like to have bullets in the margin though.
*** Subsubsection
The hl-line has been extended to margins such that it goes from side to side and plays nicely with leading stars and bullets.
**** Paragraph
This is actually a fourth level heading with a special keyword that suppress the (first) line jump. This results in the first paragraph to immediately follows the heading (like a paragraph in LaTeX).#+begin_src emacs-lisp :results none
(when (derived-mode-p 'org-mode)
(add-to-list 'font-lock-extra-managed-props 'display)
;;(setq left-margin 5)
;;(setq left-margin-width left-margin)
;;(set-window-margins (selected-window) left-margin 0)
(let ((margin-format (format "%%%ds" left-margin-width)))
(font-lock-add-keywords nil
`(
("^\\(\\- \\)\\(.*\\)$"
1 '(face nano-default display ((margin left-margin)
,(propertize (format margin-format "• ")
'face '(:inherit nano-default :weight light)) append)))("^\\(\\*\\{1\\} \\)\\(.*\\)$"
1 '(face nano-faded display ((margin left-margin)
,(propertize (format margin-format "# ")
'face '(:inherit nano-faded :weight light)) append))
2 '(face bold append))("^\\(\\*\\{2\\} \\)\\(.*\\)$"
1 '(face nano-faded display ((margin left-margin)
,(propertize (format margin-format "## ")
'face '(:inherit nano-faded :weight light)) append))
2 '(face bold append))("^\\(\\*\\{3\\} \\)\\(.*\\)$"
1 '(face nano-faded display ((margin left-margin)
,(propertize (format margin-format "### ")
'face '(:inherit nano-faded :weight light)) append))
2 '(face bold append))("^\\*\\{4\\} .*?\\(\n\\)"
1 '(face nil display " - "))("^\\(\\*\\{4\\} \\)\\(.*?\\)$"
1 '(face nano-faded display ((margin left-margin)
,(propertize (format margin-format "§ ")
'face '(:inherit nano-faded :weight light)) append))
2 '(face bold append)))))(font-lock-fontify-buffer)
;; (visual-line-mode)
)#+end_src