Skip to content

Instantly share code, notes, and snippets.

(add-hook 'after-save-hook
(lambda ()
(org-map-entries
(lambda ()
(let ((name (nth 4 (org-heading-components))))
(when (and
;; export only top-level entries
(= 1 (nth 0 (org-heading-components)))
;; subtree export, body only
(org-html-export-as-html nil t nil t))

Pattern Matching

The problem

I’d like to be able to write functions using pattern-matching, something like so:

(defun factorial (n)
  (pattern-case n
    (0 1)
    (n (* n (factorial (1- n))))))