Indicating which blocks are loaded in webpage literate elisp

The need for indicating what source is run

My literate elisp webpage has a problem. It does not tell the reader what source code is loaded at startup, and what source code is vestigial, and only there to remind me that I configured a package but didn’t like it. I’d like the webpage to show this to the user.

How to display to the user

I solved this by dynamically converting emacs-lisp blocks to plaintext blocks at org-export time. This way, the emacs lisp code will look like:

(print "This code will not be run!")

if it is skipped, and

(print "This code is run in my config!")

if it is loaded by the literate-elisp library.

The solution

Replacing header blocks that look like #+begin_src emacs-lisp :load no with header blocks that look like #+begin_src plaintext will achieve this in the rouge syntax highlighting system. I can do this (somewhat) hackily with some very simple regular expressions over the pure org source before export.

(defun my/org-export-filter-src-blocks (backend)
  (when (eq backend 'jekyll)
    (goto-char (point-min))
    (while (re-search-forward "^#\\+begin_src\\s-+emacs-lisp\\(.*:load\\s-+no.*\\)$" nil t)
      (replace-match "#+begin_src plaintext"))))

(add-hook 'org-export-before-processing-hook 'my/org-export-filter-src-blocks)

See where the code is run in the workflow code for automated export of the tangled config.

See the literate elisp webpage

Another TODO down




Enjoy Reading This Article?

Here are some more articles you might like to read next:

  • Unison Sync in Emacs
  • Studying Eigenvalues of Rotation Group Matrices
  • Why we can interpret softmax scores as probabilities
  • Hosting my CV with github actions
  • Company Announcement about LLM Project