author: Chenzhu-Xie name: Library/xczphysics/CONFIG/Add_Fields_for_Obj/Last_Opened-Page/Picker tags: meta/library

pageDecoration.prefix: "🤏📃👀 "

  1. click history #community #silverbullet
  • 我也没搞清楚 [ 所触发的 排序规则...不是 上述顺序 中的 任何一个。

Implementation

command.define {
  name = "Page Picker: Last Opened",
  key = "Ctrl-p",
  priority = 1,
  run = function()
    local VisitHistory = queryVisitHistory()
    if not VisitHistory or #VisitHistory == 0 then
      editor.flashNotification("No Visit History found.")
      return
    end
    
    local sel = editor.filterBox("🤏 Pick", VisitHistory, "order by _.lastOpened desc", "📃👀 a Page")
    if not sel then return end
    editor.navigate(sel.name)
    editor.invokeCommand("Navigate: Center Cursor")
  end
}

local function queryVisitHistory()
  return query[[
    -- from editor.getRecentlyOpenedPages "page"
    from editor.getRecentlyOpenedPages()
    where _.lastOpened
    select {name=_.ref, description=os.date("%Y-%m-%d %H:%M:%S", _.lastOpened/1000)} 
    order by _.lastOpened desc
](` 所触发的 排序规则...不是 上述顺序 中的 任何一个。

# Implementation

```space-lua
command.define {
  name = "Page Picker: Last Opened",
  key = "Ctrl-p",
  priority = 1,
  run = function()
    local VisitHistory = queryVisitHistory()
    if not VisitHistory or #VisitHistory == 0 then
      editor.flashNotification("No Visit History found.")
      return
    end
    
    local sel = editor.filterBox("🤏 Pick", VisitHistory, "order by _.lastOpened desc", "📃👀 a Page")
    if not sel then return end
    editor.navigate(sel.name)
    editor.invokeCommand("Navigate: Center Cursor")
  end
}

local function queryVisitHistory()
  return query[[
    -- from editor.getRecentlyOpenedPages "page"
    from editor.getRecentlyOpenedPages()
    where _.lastOpened
    select {name=_.ref, description=os.date("%Y-%m-%d %H:%M:%S", _.lastOpened/1000)} 
    order by _.lastOpened desc
)
end

Update Ctrl+p's Original KeyBind

command.update {
  name = "Share: Page",
  key = "Shift-Alt-s",
  mac = "Shift-Alt-s",
  priority = 2,
}