Typing a priority by hand is slow and easy to get wrong. A /priority slash command sets urgent, high, medium or low on the task you're on, or removes it.

Setup

  1. Open your CONFIG page, or any page you keep code on.
  2. Add a space-lua code block (three backticks followed by space-lua) and paste this code inside it:
slashCommand.define {
  name = "priority",
  description = "Set or clear a task's priority",
  run = function()
    local choice = editor.filterBox("Priority:", {
      {name = "urgent", value = "urgent"},
      {name = "high", value = "high"},
      {name = "medium", value = "medium"},
      {name = "low", value = "low"},
      {name = "none", value = "none", description = "Remove the priority"}
    })
    if not choice then return end
    local line = editor.getCurrentLine()
    local text = string.gsub(line.text, "%s*%[priority:[^%]]*%]", "")
    if choice.name ~= "none" then
      text = text .. " [priority: " .. choice.name .. "]"
    end
    editor.replaceRange(line.from, line.to, text)
  end
}
  1. Run the command System: Reload.

Use

  • Put the cursor on a task line, type /priority and pick a level.
  • The command adds [priority: high] (or the level you picked) to the end of the line, replacing any priority already there.
  • Pick none to remove it.
  • Queries can then filter on it, for example where t.priority == "urgent".
  • To use other levels, change the names in the list.