Giter VIP home page Giter VIP logo

book-mode's Introduction

./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 2

Not 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).

(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)
  )

book-mode's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

book-mode's Issues

force box to nil in the mode-line face

using book-mode, i got some weird box around book-mode--message and current line/total line.
I don't know why there are displayed, by the way forcing box to nil in book-mode mask them :

(face-remap-add-relative 'mode-line
                           :foreground (face-foreground 'default)
                           :background (face-background 'default)
                           :height (face-attribute 'default :height)
			   :box nil)
  
  (face-remap-add-relative 'mode-line-inactive
                           :foreground (face-foreground 'default)
                           :background (face-background 'default)
                           :height (face-attribute 'default :height)
			   :box nil)

Mode-line face conflict with nano-theme

Step to reproduce, in dark mode:

  1. open a .el file (which default to book-mode) . Mode line face is as wanted, empty.
  2. then open an info file (eg: elisp manual) which is opened in info mode
    Then modeline of the book-mode window as a nano-faded background.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.