2023-10-17 Writing pages offline, some of the time

I'm trying to get into the habit of writing my pages offline, on the laptop. I use Emacs to do it. Markdown Mode has a keybinding to follow links, `C-c C-o`. The problem is that I usually don't follow links to HTML pages elsewhere when I'm writing. I want to follow links to Markdown pages.

I use Emacs

The link itself just names the page. It looks like this: `[some text](page%20name)`. When I follow the link in Emacs while writing, I want it to open the file `page name.md` – reverse the percent encoding and append the `.md` suffix. Then again, when following the links to some other file (images and the like), I want those to open. Still, the percent encoding has to be reversed.

So this is what I use:

(advice-add 'markdown-link-url :filter-return #'asc:markdown-link-url)

(defun asc:markdown-link-url (url)
  "Add .md to URL if that makes sense."
  (let* ((filename (url-unhex-string url))
         (markdown (concat filename ".md")))
    (cond ((file-exists-p filename)
           filename)
          ((file-exists-p markdown)
           markdown)
          (t url))))

Another thing I do while writing is I use a Makefile with some targets:

Makefile

To be honest, I added the snapshot target just now. I continue to be afraid of overwriting my local copy or the remote copy with something that I don't want to and then having no way to get it back. Let's hope this is good enough. Plus my irregular offline backups, of course.

This is my alternative for keeping the wiki in a version control system.

I keep thinking about adding an Emacs command to add links to "index.md" and all the hashtag pages (e.g. "Emacs.md" and "Oddµ", in this case). Or may it should be part of Oddmu? Or maybe I should just keep doing it by hand.

​#Emacs ​#Oddµ