[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[emacs-humanities] Form-feed as literary-style scene breaks
From: |
Paul W. Rankin |
Subject: |
[emacs-humanities] Form-feed as literary-style scene breaks |
Date: |
Thu, 14 Jan 2021 18:35:00 +1000 |
User-agent: |
Purely Mail via Roundcube/1.4.7 |
If you've poked around Elisp much you might see a bunch of form-feed
characters: ^L. When you send these to a printer they will actually
trigger a page break, which is cool, but they still look ugly.
There are a couple of minor modes that replace the ^L with a horizontal
line, but I wanted something a tiny bit fancier, akin to a
literary-style scene break, so I put this into my init.el...
(aset standard-display-table ?\^L
(vconcat (make-string 15 ?\s) (make-string 35 ?─)))
See attached screenshot.
What this code does:
From the inner-most parens to the outer... first we make a string of 15
space characters (\s means space) and another of 35 horizontal line
characters. These two strings are concatenated together into a vector,
which is Elisp's general array. (A string is a type of array that holds
only characters.) All characters in Emacs are actually numbers. Emacs
knows what to display in place of the numbers thanks to display tables.
Given that all characters are numbers, the form-feed character ^L is
actually 12 (which you can see by evaluating M-: ?\^L or M-: ? C-q C-l).
So aset means to set the array variable standard-display-table index
position 12 to the vector we just made, i.e. tell Emacs that instead of
displaying ^L for 12, display our string vector instead.
--
Paul W. Rankin
https://bydasein.com
The single best thing you can do for the world is delete your social
media accounts.
screenshot.png
Description: JPEG image
- [emacs-humanities] Form-feed as literary-style scene breaks,
Paul W. Rankin <=