Fancy Outline Bullets

We improve upon the outline bullets presented in the previous post Managing code with Outlines.

My Headings Editing my config
/img/outline-bullets-fancy.png /img/outline-bullets-config.png

This solution:

  1. Allows for face application to the bullet. The default faces outline-1/2/3...
  2. only apply to the text, not the bullet.
  3. Adds spaces for higher level bullets. So not every outline-level needs to
  4. have its text start at the same column.
  5. Works for any number of outline levels.
  6. Generalized - uses outline regexes, all that is required to add the bullets
  7. to a mode is adding to its hook.

The package can be found at:

(require 'dash)
(require 'outshine)
(require 's)

(provide 'pretty-outlines)

;;; Config

(defvar pretty-outline-bullets-bullet-list '("" "" "" "")
  "An implemention of `org-bullets-bullet-list' for outlines")

;;; Outline-bullets

(defun pretty-outline--add-font-locks (FONT-LOCK-ALIST)
  "Put text property for FONT-LOCK-ALIST for var-width replacements."
   nil (--map (-let (((rgx uni-point) it))
             `(,rgx (0 (progn
                          (match-beginning 1) (match-end 1)

(defun pretty-outline--bullets-rgx-at-level (LEVEL)
  "Calculate regex or outline-bullets at LEVEL."
  (concat "\\(^"
          (->> LEVEL
             (s-replace "*" "\\*"))
          "\\) "))

(defun pretty-outline--propertize-bullet (LEVEL BULLET)
  "Add LEVEL-dependent face to BULLET."
  (with-face BULLET
             (pcase LEVEL
               (0 '(:inherit outline-1 :underline nil))
               (1 '(:inherit outline-2 :underline nil))
               (2 '(:inherit outline-3 :underline nil))
               (3 '(:inherit outline-4 :underline nil))
               (_ nil))))

(defun pretty-outline-add-bullets ()
  "Use with `add-hook' to enable pretty-outline-bullets-bullet-list for mode."
     (pretty-outline--bullets-rgx-at-level (+ 1 it-index))
      (s-repeat it-index " ")
      (pretty-outline--propertize-bullet it-index it)))
    (-take 8 (-cycle pretty-outline-bullets-bullet-list)))))

(add-hook 'emacs-lisp-mode-hook 'pretty-outline-add-bullets)
(add-hook 'hy-mode-hook 'pretty-outline-add-bullets)
(add-hook 'python-mode-hook 'pretty-outline-add-bullets)
comments powered by Disqus