Updated: 2023-11-17. Read more below

Nearly everything I write is in Emacs.1
It’s been slightly more than two years, since I made the move to using it as my everyday text editor.
I have a spartan Emacs config, with only a few customisations, that I found by watching David Wilson aka System Crafters’ Emacs From Scratch #1 video and the rest by searching on the web and asking around on the fediverse.

I’ve touched my config only about three times; basically every time I’ve found a new use for emacs.

  1. When I started editing text
  2. When I start using it as my Organiser (Org Mode) and
  3. When I began using it as my Zettelkasten (Org Roam)

Which is to say, I know only the bare bones of how Emacs configuration and Elisp work.

And yet … and yet …
I have this itch that rankles.
You see, every morning I sit at the computer with my cup of coffee, and pull up my tasks and notes and the agenda for the day.
Now I don’t use the agenda much, but the tasks and notes are a must.
So I open the tasks file and maximize my window and then I split my frame and I open the notes file, and then I go back to my tasks and I have it all ready just the way I like it.
Thing is, I’m grumpy in the morning and doing all that grates on me.

There’s gotta be a better way!

So I tried looking around, and came to the conclusion that creating a function, that did all this for me, would be the best thing.
But I know no Elisp.
And right now, I have no time to put into learning it. I did spend close to a day looking at what I could whip up, to no avail.2

So the next best idea I came up with, was recording my actions, doing the file opening, window arranging dance, as a macro and then assigning a keyboard shortcut to it.
That turned out to be iffy.
It’d work fine when I created it, but when I restarted my Emacs daemon (or my system) and then call it again, Emacs would freeze.

My intuition told me that it could be the fact, that a recorded macro3 could not handle opening files and switching buffers.4
Then I realised that I could outsource that part to the command line or my application launcher5 and leave the rest of it to the macro.

So I did just that. I created a Ulauncher shortcut.
It binds the keyword etn to the command:
emacsclient -c --no-wait ~/path/to/tasks.org ~/path/to/my/notes.org
so that Emacs opens both my tasks and notes files as it fires up.

A Ulauncher window, with name, keyword and the actual command to launch emacs

And in Emacs I bound a keyboard macro, to the rest of the recorded macro code that would

  1. Maximise the frame
  2. Split the frame into two windows, with my tasks on top and the notes in the bottom
  3. Have the cursor be ready at the place I needed it to be.
(defalias 'mjbtn
   (kmacro "M-x t o g g l e - f r a m e - m a x i m i z e d <return> 
   C-x 2 C-x o C-x b n o t e s . o r g <return> C-x o M-g g 3 6 <return>"))

;; Assign a keyboard shortcut to the macro above: C-c z
(global-set-key (kbd "C-c z") 'mjbtn)

Et voilà! I have everything, just the way I want it.
And while it might not be fancy, it works without a fuss!

Update: 2023-11-17

One advantage of writing about what you do and putting it out there, is that really kind souls come along and teach you new things!
One of them is @laotang, over on the Fediverse.
Remember when I said, the best solution would be to write an Emacs function that would do what I wanted?
Well, laotang loved my tinkering and then went on to give me just that!
I raise my cup of coffee to you, Sir! You made my day! Thank you, so much!

Here’s the code he suggested.Worked like a charm!

(defun getting-ready ()
  "Getting ready for work."
  (find-file "~/path/to/notes/notes.org")
  (find-file-other-window "~/path/to/tasks/tasks.org"))
(global-set-key (kbd "C-c r") 'getting-ready)

Oh, and if you liked how Org-Roam worked in the past? When it was all just text files?
Well, if you want something like that, check out laotang’s feature-complete6 replica, ORGRR

Feedback on this post? Mail me at feedback@janusworx.com

P.S. Subscribe to my mailing list!
Forward these posts and letters to your friends and get them to subscribe!
P.P.S. Feed my insatiable reading habit.

  1. with the exception of code. ↩︎

  2. Not much. there are lots of primitives and I cannot separate the language from Emacs specific stuff yet ↩︎

  3. rather, my recorded macro ↩︎

  4. Don’t know if this is true or not. This is just me scratching my head. I’m assuming a function that can call buffers and handle switching between them is the ticket. ↩︎

  5. Ulauncher ↩︎

  6. almost ↩︎