Monday, November 2, 2026

Emacs Bookmark -- Just a Bitmap in the Fringe

You can set up a capture template that creates a new Org heading. If you define jump-to-captured to be non-nil, org-capture will jump to that new heading. It will also create a bookmark named org-capture-last-stored at that line.

Bookmarks can help you find your way back to a line of code or a line in an essay, and you don't have to be using Org. Before you navigate away to look something up, invoke bookmark-set ( C-x r m ) to save your place. This will place a character-sized image in the left fringe at the line. Invoke bookmark-jump ( C-x r b ) to return to your work.

If you have nothing better to do, you can change the shape of the bookmark.1 First, design it with define-fringe-bitmap. Then set the variable bookmark-fringe-mark to your new bitmap using customize.

The Lisp expression in the following source block defines a Z-shaped pattern that's 8 pixels wide and 8 pixels tall and names it bookmark-zeit. Figure 1 shows the default bookmark and this new bookmark for comparison.

(define-fringe-bitmap 'bookmark-zeit
[#b11111111
 #b01111111
 #b00001111
 #b00011100
 #b00111000
 #b11110000
 #b11111110
 #b11111111])
Figure 1 -- Above, default bookmark; below, custom, Z-shaped bookmark

The pattern can be a different size, but I'd recommend making it the same width as the fringe, which is 8 pixels by default. But you could make it taller. Figure 2 shows a Z-shaped pattern that's 12 pixels tall; note how well it stands out!


Figure 2 -- A Z-shaped bookmark 12 pixels tall

Recently I wrote about how to make the active window stand out. Originally, I thought to change the color of the left fringe to something much brighter. Now it occurs to me that one might leverage the bookmark system to fill the fringe with a pattern that's 64 pixels tall. Unfortunately it seems Emacs renders only the first 16 rows. In this case, adding eight 16-pixel-tall bookmarks on successive lines can fill up a 64-pixel vertical portion of the fringe. This is shown in Figure 3.

(define-fringe-bitmap 'bookmark-16
[#b01111110
 #b01111110
 #b01111110
 #b00011000
 #b00011000
 #b01111110
 #b01111110
 #b01111110
 #b01111110
 #b01111110
 #b01111110
 #b00011000
 #b00011000
 #b01111110
 #b01111110
 #b01111110])

Figure 3 -- Eight 16-pixel-tall bookmarks on consective lines

One important caveat to all this is that this re-defining of bookmarks affects all bookmarks everywhere, not just the latest one or the next one. At least that's true of Emacs version 30. Who knows, maybe we'll see a fringe-decor package eventually. As if there's isn't enough to play with now ....


1 But if you do have better things to do and want to change fringe bitmaps, you could check out the packages fringe-helper or modern-fringes on melpa.

No comments:

Post a Comment

Thank you for taking time to comment. Please note that comments may be deleted if they:

* Contain link(s) to a domain outside USA or Canada or to a commercial enterprise.
* Include non-English words or characters.
* Are irrelevant to the subject matter of the post.

For posts older than 14 days, comments are moderated and require approval.