Toggling Keyboard Mapping for Org Roam

Dynamically Changing Keyboard Shortcuts to Match Working States

I previously wrote about . I’ve been using this for the past 10 days, and it’s working great.

However, I noticed one nussance. If I’m focusing on a project, I am usually only using one of those menu items.

For example, when I spent writing up adventure notes for a new Worlds without Number (WWN 📖) game, I only used the “World of Ardu” menu option.

What I wanted was a quick means to temporarily override the keyboard shortcut that invoked the Hydra menu. The override would then filter the org-roam-insert for the specific project.

In other words, when I’m writing notes for my Campaign: New Vistas in the Thel Sector game, I want the search and insert function of org-roam narrowed to only the Thel Sector project. This narrowed scope removes a keystroke, keeps my roam-roam interactions topical, and reinforces one of my goto key combinations when writing.

Some Code

Elisp function to toggle what Cmd+i invokes.

See the relevant Github file for more context.

(defun jnf-toggle-roam-project-filter (project)
  "Prompt for a PROJECT, then toggle the `s-i' kbd
  to filter for that project."
  (interactive (list
                (completing-read
                 "Project: " '((":all" 1)
                               ("ardu" 2)
                               ("hesburgh-libraries" 3)
                               ("permanent-bibliographies" 4)
                               ("permanent-cards" 5)
                               ("samvera" 6)
                               ("thel-sector" 7)))))
  (if (string= project ":all")
      (global-set-key (kbd "s-i")
        'jnf-org-subject-menu/body)
      (global-set-key (kbd "s-i")
        (intern (concat
                   "org-roam-insert--filter-with--"
                   project)))))

Emacs Gives You the Tools to Help You Out

This solution helps me move from general writing situations into project specific writing modes. It also hightlights the dynamism of Emacs (Emacs 📖).

While I’m writing code, prose, notes, or documentation, if I think of something that might help me out, I take a quick note. Later, I sit with the problem a bit.

I think through if it’s something I want, and how it would might be useful. I then work out a possible approach and write up some Elisp: dialect of Lisp used in GNU Emacs (elisp 📖) to help out.

The goal of these tweaks is to help keep me in a flow state. And Emacs provides ample means for tweaking and helping me operate closer to my thoughts.