Beautify Org mode

May 16, 2019
4 minute read
emacs org

In the last months I collected some packages and settings to add eye candy to Org buffers mostly with the help of Unicode tricks. I like to result and want to share as it may be useful for others as well. Here are the settings I built with some explanations. Like the rest of my Emacs config this uses use-package.

The default fontset setting ensures that all unicode symbols and the like can be displayed. It’s also the basis for some of the eye-candy later. I check first if the Symbola font is present.

(when (member "Symbola" (font-family-list))
  (set-fontset-font "fontset-default" nil
                    (font-spec :size 20 :name "Symbola")))

I also specify Symbola as the font for all unicode characters

(when (member "Symbola" (font-family-list))
  (set-fontset-font t 'unicode "Symbola" nil 'prepend))

I use utf8-encoding everywhere and set it explicitly rather than relying on Emacs defaults

(prefer-coding-system       'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(setq default-buffer-file-coding-system 'utf-8)

And now on to the Org mode specific settings.

I want indentation

(setq org-startup-indented t
      org-src-tab-acts-natively t)

I like visual-pitch-mode and visual-line-mode for org files

(add-hook 'org-mode-hook
          (lambda ()
            (variable-pitch-mode 1)

To start the look of the Org mode buffers let’s first use some general settings:

I feel this makes for a cleaner look of the buffer.

(setq org-hide-emphasis-markers t
      org-fontify-done-headline t
      org-hide-leading-stars t
      org-pretty-entities t
      org-odd-levels-only t)

The next is a setting to automatically change list bullets. I work quite a lot with bulleted list and I think it emphasises the structure better.

(setq org-list-demote-modify-bullet
      (quote (("+" . "-")
              ("-" . "+")
              ("*" . "-")
              ("1." . "-")
              ("1)" . "-")
              ("A)" . "-")
              ("B)" . "-")
              ("a)" . "-")
              ("b)" . "-")
              ("A." . "-")
              ("B." . "-")
              ("a." . "-")
              ("b." . "-"))))

Here is the first package to convert stars into nice looking bullets. Since I only use odd-levels I added a specific one for all even levels to show the odd levels as intended.

(use-package org-bullets
  (org-bullets-bullet-list '("◉" "☯" "○" "☯" "✸" "☯" "✿" "☯" "✜" "☯" "◆" "☯" "▶"))
  (org-ellipsis "⤵")
  :hook (org-mode . org-bullets-mode))

From I collected the setting to show bullets instead of a dash in bulleted lists.

(font-lock-add-keywords 'org-mode
                        '(("^ *\\([-]\\) "
                           (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•"))))))
(font-lock-add-keywords 'org-mode
                        '(("^ *\\([+]\\) "
                           (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "◦"))))))

The next setting prettifies src blocks. Inspired by a comment in i use markdown rather than org-mode for my notes : emacs I looked at the now builtin mode prettify-symbols-mode. The configuration follows the example given in New in Emacs 25.1: Have prettify-symbols-mode reveal the symbol at point · En…. This approach can also be used to provides some kind of ligatures.

(setq-default prettify-symbols-alist '(("#+BEGIN_SRC" . "†")
                                       ("#+END_SRC" . "†")
                                       ("#+begin_src" . "†")
                                       ("#+end_src" . "†")
                                       (">=" . "≥")
                                       ("=>" . "⇨")))
(setq prettify-symbols-unprettify-at-point 'right-edge)
(add-hook 'org-mode-hook 'prettify-symbols-mode)

Even though I prefer variable-pitch I want fixed-pitch for src blocks.

 '(variable-pitch ((t (:family "Source Sans Pro" :height 120 :weight light))))
 '(fixed-pitch ((t ( :family "Consolas" :slant normal :weight normal :height 0.9 :width normal)))))

 '(org-block                 ((t (:inherit fixed-pitch))))
 '(org-document-info-keyword ((t (:inherit (shadow fixed-pitch)))))
 '(org-property-value        ((t (:inherit fixed-pitch))) t)
 '(org-special-keyword       ((t (:inherit (font-lock-comment-face fixed-pitch)))))
 '(org-tag                   ((t (:inherit (shadow fixed-pitch) :weight bold))))
 '(org-verbatim              ((t (:inherit (shadow fixed-pitch))))))

pretty-tags is a package to replace the tags by unicode symbols. The name needs to be exactly as in the buffer for this to work.

(use-package org-pretty-tags
  :demand t
   (setq org-pretty-tags-surrogate-strings
          (("TOPIC" . "☆")
           ("PROJEKT" . "💡")
           ("SERVICE" . "✍")
           ("Blog" . "✍")
           ("music" . "♬")
           ("security" . "🔥"))))

There’s also a package to show fancy priorities instead of the standard ones.

(use-package org-fancy-priorities
  :demand t
  :defines org-fancy-priorities-list
  :hook (org-mode . org-fancy-priorities-mode)
  (unless (char-displayable-p ?❗)
    (setq org-fancy-priorities-list '("HIGH" "MID" "LOW" "OPTIONAL"))))

I like to display an outline numbering as overlays on Org mode headlines. The numbering matches how it would appear when exporting the org file. This file is in the org-mode git repo but not (yet?) part of official orgmode

(use-package org-num
  :load-path "lisp/"
  :after org
  :hook (org-mode . org-num-mode))
Share on:

Building a static website with Emacs and Hugo

September 30, 2018
4 minute read
software emacs hugo

Org mode dependency on htmlize

September 21, 2018
1 minute read
emacs org
comments powered by Disqus