Overwriting Library/Std etc space-lua

I’ve noticed Library/Std/… “pages” appearing (although discoverability very limited by Page picker scrolls to selection every time sync occurs issue, particularly as the pages don’t exist in the server filesystem). Say for example in Library/Std/Page Templates there is:

command.define {
  name = "Quick Note",
  key = "Alt-Shift-n",
  run = function()
    local pageName = "Inbox/" .. os.date("%Y-%m-%d/%H-%M-%S")
    editor.navigate(pageName)
  end
}

So how would I (e.g.) overwrite the Quick Note function with my own command?

Thanks

Nick

1 Like

I’m open to better ways to do this, but the approach I’d go for is to simply override the default implementation. I just pushed this to the v2 branch (so be sure to pull the latest version), but I just set a priority of 10 for most of the Std library space lua scripts (I also documented load order now: Space Lua order).

This means that if you define your own version of a command (in a space lua script that doesn’t set the priority) it would load later, which effectively overrides it if you use the same name.

So what you can do is simply copy & paste the command.define you got there, not specify a load priority, and supply your own implementation. I just tested this on the new build, and it works for me.