Skip to main content

Baty.net

A blog about everything by Jack Baty đź‘‹

Category: Software

Publishing portions of my Org-roam database

I’m trying something new.

I’ve become a pretty heavy user of Org-roam for personal notes. I put nearly everything there now; technical notes, contact information, project notes, vendor info, etc. These notes are all nicely linked and backlinked and live in my main ~/org directory so I can easily find things right within Emacs.

A portion of these notes might be useful to other people. So I’m exporting the shareable notes from Org-roam as Hugo-compatible Markdown files. This turned out to be surprisingly easy. You can see the results at https://notes.baty.net and the details of how it works makes a good example.

Aligning comments in Emacs

I want my per-line code comments to line up nicely, so I’ll often add a bunch of spaces by hand to make things just so. I realized that, being Emacs, there must be an easier way to handle this. Of course there is.

Two minutes of searching revealed a short bit of lisp that does the job nicely:

;; Align comments in marked region
;; Via https://stackoverflow.com/a/20278032
(defun jab/align-comments (beginning end)
  "Align comments within marked region."
  (interactive "*r")
  (let (indent-tabs-mode align-to-tab-stop)
    (align-regexp beginning end (concat "\\(\\s-*\\)"
                                        (regexp-quote comment-start)))))

Here’s an example of what I was working on, with horribly un-aligned comments.

Configuring the org-download save directory

When I drag and drop an image into Emacs, I want the attached file to end up in ./img/YYYY/. This is how I tried configuring org-download in my setup (I use Doom Emacs):

(setq org-download-method 'directory
        org-download-image-dir (concat "img/"  (format-time-string "%Y") "/")
        org-download-image-org-width 600
        org-download-heading-lvl 1)

For some reason, org-download-method was being reset from 'directory to 'attach after loading, and this broke things. I thought maybe I needed to set the variables after org-download was loaded, so I did this:

Plain text can’t save you if you lose the files

Derek Sivers suggests, in a much-linked-to post, that all your stuff should be in plain text files, and I (almost) agree with him.

Most of my notes are in some form of plain text format, but not for the reasons Sivers lists. My notes are in plain text because I prefer editors that use plain text by default. I suggest you use the tools and formats that are most useful to you now. If that’s plain text, then great.

Weight logging with Tinderbox

I kept a “daybook” using Tinderbox for years. I drifted away from Tinderbox for a few years after I became infatuated with Linux or iOS or other “cross-platform” systems. Right now, I’m back with a vengeance.

While rebuilding my Daybook, I wanted to make logging my weight easier. It’s not like it was difficult, but I wanted to tweak it.

Tinderbox is an outliner, so my weight entries are collected under a “Weight Log” node. It looked like this (I obviously wasn’t consistent with tracking last year).