Matthew Kennard

19 May 2022

Raycast and Org mode

I’ve transitioned recently from Alfred to Raycast. I have created a few scripts, one of which adds a new task to my todo list in Org mode. I don’t spend all of my day in Emacs so its handy to be able to create tasks with little friction when I’m in Xcode, Android Studio or PhpStorm.

There are two parts to this.

First, there is a small Emacs function:

(defun add-to-refile (text)
  (save-window-excursion
    (find-file (concat org-directory "/refile.org"))
    (goto-char (point-max))
    (insert "\n")
    (insert text)
    (save-buffer)))

Then there is the Raycast script (they’ve got some good documentation on how to extend Raycast):

#!/bin/bash

# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Create Org TODO
# @raycast.mode silent

# Optional parameters:
# @raycast.icon 🪄
# @raycast.argument1 { "type": "text", "placeholder": "The task to get done" }
# @raycast.packageName Task Management

# Documentation:
# @raycast.description Create a new todo in refile.org
# @raycast.author Matthew Kennard
# @raycast.authorURL https://micro.kennard.uk

emacsclient -e "(add-to-refile  \"* TODO $1\nSCHEDULED: <`date "+%Y-%m-%d %a"`>\")"
echo "Created TODO"

The result:

CleanShot 2022 05 19 at 17 06 32

I probably need to make this a little more robust, but its been working well so far.