Dungeon Master Screen in Emacs

As a bona fide nerd, I would like to combine my love of Dungeons and Dragons with Emacs. Sure, formatting with Org is a life-saver, but I would like to turn the volume to eleven, by hitring a key to have a customized Dungeon Master’s Screen appear.

This screen is a usually a tri-fold cardboard cutout that separates the Dungeon Master from the players (so they don’t take a glimpse at the spoilers in their notes). These screens, when purchased, contain many of the tables and charts needed during play. The best charts are the ones full of details that are un-memorizable but used during normal play. However, two event this year kept my screen tucked on its shelf:

  1. My eyesight doesn’t allow me to actually read the text of the charts
  2. The pandemic has forced all my games to be virtual

But with my notes in Org, why not the tables, charts and other reference material easily displayable?

At first, I thought I would end up writing a fair bit of Lisp to achieve my goal, but after seeing how most features come standard in Emacs, I thought I would share, as not all of these features are well known.

Auto Narrowing

Auto Dice Rolls

Storing the Layout

If you split the frame into multiple windows (remember, that is ancient Emacs terminology), you can say the “state” to a file using:

                                        ; (frameset-to-register ?H)
(setq dm-screen-frame
      (frameset-save (list (selected-frame))))

We can view the contents:

(print (get-register ?H))

To save:

(with-temp-file ".dm-screen"
  (insert (prin1-to-string dm-screen-frame))))

To read:

(setq dm-screen-frame2
      (read
       (with-temp-buffer
         (insert-file-contents ".dm-screen")
         (buffer-string))))

And then show the results:

(frameset-restore dm-screen-frameset2)

Summary

The only thing left to do, is display the “screen” with a keybinding:

(global-set-key (kbd "<f5>") )