Skip to content

Latest commit

 

History

History
2208 lines (1725 loc) · 95.2 KB

api-reference.org

File metadata and controls

2208 lines (1725 loc) · 95.2 KB

Vulpea API Reference

This reference covers the programmatic API for building tools with Vulpea.

The vulpea-note Struct

All query functions return vulpea-note structs:

(vulpea-note-id note)            ; UUID string
(vulpea-note-path note)          ; Absolute file path
(vulpea-note-level note)         ; 0 = file-level, 1+ = heading
(vulpea-note-title note)         ; Note title
(vulpea-note-primary-title note) ; Original title when selected via an alias, else nil
(vulpea-note-aliases note)       ; List of alias strings
(vulpea-note-tags note)          ; List of tag strings
(vulpea-note-links note)         ; List of plists (:dest :type :pos :description)
(vulpea-note-meta note)          ; Alist of metadata (document order)
(vulpea-note-properties note)    ; Alist of org properties
(vulpea-note-todo note)          ; TODO state string or nil
(vulpea-note-priority note)      ; Priority character or nil
(vulpea-note-scheduled note)     ; Scheduled timestamp or nil
(vulpea-note-deadline note)      ; Deadline timestamp or nil
(vulpea-note-closed note)        ; Closed timestamp or nil
(vulpea-note-category note)      ; Resolved org category, never nil
(vulpea-note-outline-path note)  ; List of parent headings
(vulpea-note-attach-dir note)    ; Attachment directory or nil
(vulpea-note-file-title note)    ; Title of file containing note
(vulpea-note-created-at note)    ; Creation date "YYYY-MM-DD" or nil
(vulpea-note-modified-at note)   ; File mtime "YYYY-MM-DD HH:MM:SS"
(vulpea-note-title-source note)  ; Where the title came from, or nil
(vulpea-note-category-source note) ; Where the category came from, or nil

vulpea-note-created-at is the note’s creation date, derived from its CREATED property and normalized to a YYYY-MM-DD string (the same source used by the vulpea-db-query-by-created-* queries), or nil when the note has no CREATED property. vulpea-note-modified-at is the file’s own modification time (mtime), formatted as a YYYY-MM-DD HH:MM:SS string and captured at the last sync. All notes in a file share it (a heading-level note carries its file’s mtime), and a file edited but not yet re-synced keeps its previous value until the next sync. vulpea-db-query-stale-notes filters notes by this same mtime, read from the files table.

vulpea-note-closed is the note’s completion timestamp. It is read from the CLOSED: planning line when present; otherwise, for a note currently in a done state, it falls back to the most recent State "DONE" entry in the note’s :LOGBOOK: drawer. This covers the common workflow where state-change logging (org-log-done) records completion in the logbook rather than on a CLOSED: planning line. The fallback keys on State "DONE" specifically, so a cancelled task is left with a nil closed.

vulpea-note-category is the note’s category, resolved at extraction time with org’s own precedence: the note’s own CATEGORY drawer property, then ancestor heading drawers, then the file-level drawer, then the last #+CATEGORY keyword in the file, then a buffer-local org-category (set globally, via dir-locals, or file-local variables - reaching extraction depends on the parse method, see vulpea-db-parse-method), and finally the file’s base name. Every note therefore has a category, exactly the value org agenda displays and filters by. Note that this is a computed value, not the literal CATEGORY property: vulpea-note-properties contains only what is written in the drawer.

vulpea-note-title-source records where the title came from: the symbol keyword (a #+title keyword), heading (heading text) or filename (fallback to the file base name). The title itself is always a non-nil string; the source tells you whether it was written down or derived. Nil means unknown - a hand-constructed note - not untitled. Two predicates build on it: vulpea-note-title-explicit-p is non-nil when the title was written down (keyword or heading), and vulpea-note-titled-p is the opt-in completion filter that drops only notes whose title is known to be filename-derived (see the User Guide on untitled micro-notes).

vulpea-note-category-source does the same for the category: property (a CATEGORY drawer property, the note’s own, an ancestor’s or the file-level one), keyword (the #+CATEGORY keyword), variable (org-category, set globally or through dir-locals) or filename (the file base name fallback). The category itself is always what org shows; the source says whether anyone chose it. Nil means unknown, not uncategorized. vulpea-note-category-explicit-p is non-nil for property, keyword and variable. Note that under the single-temp-buffer parse method dir-locals never apply, so a category set only in .dir-locals.el resolves to the file name there and is recorded as filename; the source is truthful about what extraction saw.

Getting Notes

By ID

The fastest way to get a single note:

(vulpea-db-get-by-id "5093fc4e-8c63-4e60-a1da-83fc7ecd5db7")
;; => #s(vulpea-note :id "5093fc4e..." :title "My Note" ...)
;; => nil if not found

Multiple by IDs

(vulpea-db-query-by-ids '("id-1" "id-2" "id-3"))
;; => list of vulpea-note structs (missing IDs are omitted)

File Path for ID

(vulpea-db-get-file-by-id "note-id")
;; => "/path/to/note.org" or nil

By Title Search

Find notes whose title contains a pattern:

(vulpea-db-search-by-title "meeting")
;; => list of notes with "meeting" in title

;; (vulpea-db-search-by-title PATTERN &optional CASE-SENSITIVE)

By default the match is a case-insensitive SQL LIKE, so % and _ in PATTERN are wildcards. With CASE-SENSITIVE it is a GLOB match, where * and ? are.

Query Functions

All query functions return lists of vulpea-note structs.

By Tags

;; Notes with ANY of these tags
(vulpea-db-query-by-tags-some '("project" "task"))

;; Notes with ALL of these tags
(vulpea-db-query-by-tags-every '("project" "active"))

;; Notes WITHOUT any of these tags
(vulpea-db-query-by-tags-none '("archive" "deprecated"))

By Links

;; Notes linking to ANY of these IDs (backlinks)
(vulpea-db-query-by-links-some '("target-note-id"))

;; Filter by link type
(vulpea-db-query-by-links-some '("note-id") "id")

;; Notes linking to ALL of these IDs
(vulpea-db-query-by-links-every '("id-1" "id-2"))

By Attachments

;; Get all attachment destinations with their attach-dirs for notes in a file
(vulpea-db-query-attachments-by-path "/path/to/file.org")
;; => (("image.png" . "/data/note1/") ("document.pdf" . "/data/note2/") ...)

This is an optimized query that retrieves all attachment link destinations along with their attachment directories in a single database query, avoiding N+1 queries when processing multiple notes in a file. Each result is a cons cell (DEST . ATTACH-DIR) where DEST is the attachment file name and ATTACH-DIR is the attachment directory of the note containing the link.

By Metadata

;; Notes with a specific metadata key
(vulpea-db-query-by-meta-key "status")

;; Notes where key equals value (matched as the string written in the note)
(vulpea-db-query-by-meta "status" "active")

;; Notes where key carries ANY of these values
(vulpea-db-query-by-meta-some "status" '("active" "waiting"))

;; Notes where key carries ALL of these values
(vulpea-db-query-by-meta-every "grape" '("merlot" "cabernet"))

By Properties

Every key in a property drawer is indexed, at file level and on headings alike. Keys are stored upcased.

;; Notes that have a property key
(vulpea-db-query-by-property-key "ISBN")

;; Notes where key equals value
(vulpea-db-query-by-property "AUTHOR" "Ursula K. Le Guin")

For a note in hand, vulpea-note-properties returns the same drawer as an alist. To match property values while selecting a note in vulpea-find, see Customizing Selection Display.

By Category

;; Notes whose resolved category matches (indexed lookup)
(vulpea-db-query-by-category "journal")

Matches the computed category (see vulpea-note-category), so notes that merely inherit a category from an ancestor, a #+CATEGORY keyword, or the file name are found too.

To offer categories as completion candidates, ask for the ones that were actually written down or configured:

(vulpea-db-query-categories)
;; => ("journal" "people" "wine")

File-name fallbacks are left out: every note has one, nobody chose it, and on a collection with dated file names it would drown the real categories (see vulpea-note-category-source).

By File Paths

;; Notes from specific files
(vulpea-db-query-by-file-paths '("/path/to/a.org" "/path/to/b.org"))

;; With level filter
(vulpea-db-query-by-file-paths '("/path/to/a.org") 0)

By Level

;; File-level notes only
(vulpea-db-query-by-level 0)

;; First-level headings only
(vulpea-db-query-by-level 1)

Custom Predicate

For complex queries:

(vulpea-db-query
 (lambda (note)
   (and (member "project" (vulpea-note-tags note))
        (string-prefix-p "2025" (vulpea-note-title note)))))

Get All Tags

(vulpea-db-query-tags)
;; => ("project" "task" "meeting" ...)

Get All Categories

(vulpea-db-query-categories)
;; => ("journal" "people" "wine")

Only categories with an explicit source (drawer property, #+CATEGORY keyword or org-category); file-name fallbacks are skipped. See By Category.

Diagnostics

Dead Links

Find broken ID links that point to non-existent notes:

(vulpea-db-query-dead-links)
;; => ((#s(vulpea-note ...) . "nonexistent-id") ...)

Returns list of cons cells (SOURCE-NOTE . BROKEN-TARGET-ID). Only checks links of type “id”.

Orphan Notes

Find notes with no incoming ID links (nothing links to them):

(vulpea-db-query-orphan-notes)
;; => (#s(vulpea-note ...) ...)

Isolated Notes

Find notes with no incoming or outgoing ID links (completely disconnected):

(vulpea-db-query-isolated-notes)
;; => (#s(vulpea-note ...) ...)

This is stricter than vulpea-db-query-orphan-notes — a note that links out but has no incoming links is an orphan but not isolated.

Title Collisions

Find notes that share the same title:

;; All notes
(vulpea-db-query-title-collisions)
;; => (("Wine" . (#s(vulpea-note ...) #s(vulpea-note ...)))
;;     ("Beer" . (#s(vulpea-note ...) #s(vulpea-note ...))))

;; File-level notes only
(vulpea-db-query-title-collisions 0)

Returns list of (TITLE . NOTES) groups where each group has two or more notes with the same title. Optional LEVEL argument restricts to notes at a specific heading level (0 for file-level).

Stale Notes

Find notes whose file has not been modified within the last N days:

;; notes untouched for more than 90 days
(vulpea-db-query-stale-notes 90)
;; => (#s(vulpea-note ...) ...)

Uses the modification time recorded in the files table during sync. All notes in a stale file are returned (a heading-level note shares its file’s mtime), ordered oldest file first. Useful for surfacing notes that may need review or archiving.

Link Queries

Query links directly from the database. All functions return plists with :source, :dest, :type, :pos and :description keys.

;; All links
(vulpea-db-query-links)
;; => ((:source "id1" :dest "id2" :type "id" :pos 100 :description "Title") ...)

;; Links of a specific type
(vulpea-db-query-links-by-type "id")
(vulpea-db-query-links-by-type "https")

;; Outgoing links from a note
(vulpea-db-query-links-from "note-id")

;; Incoming links (backlinks) to a note
(vulpea-db-query-links-to "note-id")

To display or sort by a backlink count for many notes, do not call vulpea-db-query-links-to per note - that is one query each. Use vulpea-db-query-backlink-counts, which computes every count with a single grouped query and returns a hash table from destination to count:

;; Backlink counts for all notes (one query)
(let ((counts (vulpea-db-query-backlink-counts)))
  (gethash (vulpea-note-id note) counts 0))

;; Count only id: links (ignore file:, https:, ... destinations)
(vulpea-db-query-backlink-counts "id")

;; Count several link types at once, e.g. when denote: links carry the
;; note graph alongside id: links
(vulpea-db-query-backlink-counts '("id" "denote"))

Destinations with no incoming links are absent from the table, so read it with a default of 0.

Unlinked Mentions

An unlinked mention is a place where a note’s title or alias appears as plain text in another note, without an id: link pointing to it. vulpea-note-unlinked-mentions-async finds the notes that mention a given note this way.

It uses ripgrep (rg) to search the files under vulpea-db-sync-directories, so rg must be installed (vulpea-doctor reports its availability). The scan is potentially expensive, so the function is asynchronous and promise-style: it calls exactly one of resolve or reject.

(vulpea-note-unlinked-mentions-async
 note
 ;; resolve: list of plists, each with :note (the mentioning note),
 ;; :path, :line, and :context (the matching line)
 (lambda (mentions)
   (dolist (m mentions)
     (message "%s mentions it: %s"
              (vulpea-note-title (plist-get m :note))
              (plist-get m :context))))
 ;; reject: called with an error string (e.g. rg missing)
 (lambda (err) (message "unlinked mentions failed: %s" err)))

Occurrences already inside an Org link, and hits in the note’s own file, are excluded. The (note resolve reject) shape is a ready-made loader for reactive UIs - for example a vui-use-async widget can use (apply-partially #'vulpea-note-unlinked-mentions-async note) directly.

The dual direction - which existing notes does this buffer mention without linking? - is vulpea-buffer-unlinked-mentions-async. It searches the current buffer’s live content (so unsaved edits count) for the titles and aliases of the candidate notes, and resolves with the candidate note(s) each match could link to. The buffer is snapshotted to a temporary file for ripgrep, so the call returns at once; a buffer visiting an encrypted note (any extension other than .org) goes over a pipe instead and the call blocks while the text is sent.

This search looks for every title and alias of the collection at once, so its cost is set by their number. Case is erased in Emacs on both sides and ripgrep is handed plain strings, the one thing it matches quickly in bulk: about 0.07s with 10,000 titles and 0.8s with 100,000 (ripgrep 15.1 on an M1 Pro), whatever the size of the buffer. When one title starts another (Wine and Wine Tasting), the longest one that fits is the mention.

(vulpea-buffer-unlinked-mentions-async
 ;; resolve: list of plists, each with :note (a note this buffer could
 ;; link to), :line, :context (the matching line), and :matched (the
 ;; text that matched)
 (lambda (mentions)
   (dolist (m mentions)
     (message "line %d could link to %s"
              (plist-get m :line)
              (vulpea-note-title (plist-get m :note)))))
 ;; reject: called with an error string (e.g. rg missing)
 (lambda (err) (message "unlinked mentions failed: %s" err)))

Which notes are searched for is controlled by vulpea-mentions-note-filter, a predicate on a vulpea-note. It defaults to file-level notes only (vulpea-mentions-file-level-note-p), which keeps heading-level notes - often dates or common single words - from producing noisy suggestions. Both directions share the same exclusions (an occurrence inside an Org link or on an Org metadata line is never a mention) and both return the ripgrep process, so a caller can wait on or cancel the scan. A link counts whether it fits on one line or wraps across several, as it does after filling a paragraph.

A title is a mention only where it is prose. In * Setup notes :emacs:work: the word is a tag, in * DONE Ship it a todo keyword, in SCHEDULED: <2024-01-15 Mon> part of a timestamp, and a link written in its place would break the tag, the keyword or the date. Neither search reports these, nor a title in a plain URL, in ~code~ or ==verbatim==, in a source or example block, in a comment, a target, a macro or a footnote label. In a heading only the title counts, and quote, verse and other blocks of text are prose like any paragraph. Generated content is left out as well, a dynamic block or the #+RESULTS: of a source block, since it is rewritten on the next update, and so is the line Org logs on a state change (- State "DONE" from "TODO" [...]).

The Org parser decides what is prose, so the answer follows your todo keywords, those a file declares with #+TODO: included. It is asked last, about the occurrences nothing else has turned down. The incoming search reads each file that still has one, which costs under 1ms for a 5 KB note with three such lines (Emacs 31 on an M1 Pro); the outgoing search reads a copy of the buffer, all of it even when the buffer is narrowed, since what a line is depends on the lines around it.

With vulpea-mentions-exclude-linked on (the default) a note that already links to the target is not listed among its incoming mentions, and notes a buffer already links to are not suggested for it. For the incoming search a file links to the target when the database has a link from one of its notes, or when its text has a link to the target that the Org parser confirms. The second half is for links no note owns: in a file without a file-level id, text that no heading with an id encloses (the lines above the first heading, for one) belongs to no note, so a link written there never reaches the database. Link text in a comment or a code block is no link, and a link in generated content does not count, as the database leaves it out too.

vulpea-mentions-link turns a mention into a link. It takes a buffer, a line and the note to link to, and replaces every mention of that note on the line with an id: link that keeps the text as written:

;; MENTION comes from either search.  For an incoming mention BUFFER
;; visits its :path (widened) and NOTE is the searched note; for an
;; outgoing one BUFFER is the searched buffer and NOTE its :note
(vulpea-mentions-link buffer
                      (plist-get mention :line)
                      note
                      (plist-get mention :context))
;; => number of mentions linked

It reads the line with the code the searches read it with, so it links what they count as a mention and nothing else: C++, the Emacs of Emacs's and 金阁寺 inside 又名金阁寺 become links, a tag or a timestamp does not. One difference is on purpose: where one title starts another, the outgoing search lists only the longest one that fits (Emacs Lisp, not Emacs), while the link function asked to link Emacs links it there too. Pass the :context of the mention and nothing is linked unless the line still reads the same, so a line that moved since the search never gets the link put on its neighbor. It returns 0 then, as it does when the line has no mention of the note or the buffer is not in Org mode.

The line is counted from the start of the accessible portion of the buffer, which is how the outgoing search numbers lines. The incoming search numbers the lines of the file, so widen the buffer before linking one of its mentions. The buffer is edited and not saved. That matters for incoming mentions: the search reads files, so a mention stays listed until its buffer is saved.

Incoming mentions can be silenced per note. The property named by vulpea-mentions-per-note-ignore-property-key holds a whitespace separated list of note ids, and mentions coming from those notes are dropped for the note carrying the property. An id silences the whole file it lives in, in both directions, so it does not matter whether a file-level id or a heading id was written there. vulpea-mentions-ignore-from and vulpea-mentions-unignore-from maintain that list, so the drawer never has to be edited by hand. Both are called as (FN NOTE-OR-ID FROM-NOTE-OR-ID): mentions of the first note coming from the second are silenced or shown again. Ignoring resolves the silenced note to the file-level note that a mention is attributed to (or the first note in the file when there is none) and writes that id; unignoring removes every id of the silenced file, so an entry is gone no matter which id of the file was written there. Both save the file and sync the database before returning - the list is read from the database, so an unsaved drawer would leave the mention on screen. vulpea-mentions-ignored-notes is the read side: it resolves each listed id the same way and returns the notes, one per file, dropping ids that no longer belong to any note. This is what an ignore list in a UI shows next to the mentions.

Matching is script-aware. Titles in scripts that separate words with spaces (Latin, Cyrillic, …) match only as standalone words: art does not match inside smart. Titles in scripts without word separators (Han, Kana, Thai, …) match as substrings: 金阁寺 is found inside 又名金阁寺, since there is no word boundary between two Han characters to respect. A mixed title like Emacs入门 keeps the boundary only on its Latin edge, and a Latin title glued into CJK prose counts too: Emacs is found inside 我爱用Emacs写作. These rules are enforced in Emacs; ripgrep only pre-filters. For the incoming search the pre-filter strategy is controlled by vulpea-mentions-word-boundaries: auto (the default) decides per term edge, t demands strict boundaries everywhere (the historical behavior - it misses titles next to an underscore, and it can also be slower, since a Unicode \b over non-ASCII text forces ripgrep off its fast literal path), and nil drops boundaries from the ripgrep pre-filter entirely: it finds what auto finds, and its cost is that every glued occurrence of every Latin title travels to the Emacs re-check just to be rejected there. The outgoing search does not read the option: its pre-filter never carries boundaries, so it finds what nil finds. Which scripts count as spaceless lives in vulpea-mentions-spaceless-scripts. The minimum searchable length (vulpea-mentions-min-term-length, default 3) measures display width, so a 2-character CJK title like 北京 (width

  1. is searched for while a 2-letter Latin one is not.

One practical caveat for CJK notes: keep them soft-wrapped (visual-line-mode with word-wrap-by-category set to t) rather than hard-filled. auto-fill-mode and M-q insert real newlines between CJK characters, and a title split across a line break is invisible to any line-based search, mentions included.

Statistics

(vulpea-db-count-notes)               ; Total notes
(vulpea-db-count-file-level-notes)    ; File-level only
(vulpea-db-count-heading-level-notes) ; Heading-level only

Reading Metadata

Single Value

;; Default: returns string
(vulpea-note-meta-get note "country")
;; => "France"

;; As number
(vulpea-note-meta-get note "rating" 'number)
;; => 95

;; As symbol
(vulpea-note-meta-get note "status" 'symbol)
;; => 'active

;; As link (extracts ID or URL)
(vulpea-note-meta-get note "url" 'link)
;; => "https://example.com"

;; As note (resolves id: link to vulpea-note)
(vulpea-note-meta-get note "region" 'note)
;; => #s(vulpea-note :id "region-id" :title "Bordeaux" ...)

;; As date or datetime (parses a plain org timestamp, active or
;; inactive; nil when the value is not one)
(vulpea-note-meta-get note "published" 'date)
;; => #s(vulpea-timestamp ...) - see vulpea-timestamp-time,
;;    vulpea-timestamp-with-time, vulpea-timestamp-active

Multiple Values

When a key has multiple entries:

- grape :: Cabernet Sauvignon
- grape :: Merlot
(vulpea-note-meta-get-list note "grape")
;; => ("Cabernet Sauvignon" "Merlot")

(vulpea-note-meta-get-list note "ratings" 'number)
;; => (95 92 88)

Order

vulpea-note-meta returns keys in document order, and the values of a key in the order they appear; a key written several times keeps the position of its first occurrence. So iterating the alist (rendering it, or writing it back into a note) follows document order, with the values of a repeated key grouped at its first occurrence rather than spread out the way the note spells them.

- grape :: Riesling
- year :: 2019
- grape :: Sylvaner
(vulpea-note-meta note)
;; => (("grape" "Riesling" "Sylvaner") ("year" "2019"))

Access Patterns

There are multiple ways to read metadata, each with different trade-offs:

FunctionSourceSpeedAlways Fresh?
vulpea-note-meta-getNote struct (from DB)FastNo (needs sync)
vulpea-meta-getFile on diskSlowerYes
vulpea-buffer-meta-get!Pre-parsed metadataFastestAs fresh as the parse you hand it

Prefer =vulpea-note-meta-get= for most cases - it reads from the note struct which is populated from the database:

(vulpea-note-meta-get note "status")

Use =vulpea-meta-get= when you need to read directly from the file (always fresh, but slower):

(vulpea-meta-get note-or-id "status")

Use bang functions when reading multiple values from the same note via file access. Parse once and reuse:

;; Inefficient: parses file 3 times
(vulpea-meta-get note "a")
(vulpea-meta-get note "b")
(vulpea-meta-get note "c")

;; Efficient: parses file once
(let ((meta (vulpea-meta note)))
  (vulpea-buffer-meta-get! meta "a")
  (vulpea-buffer-meta-get! meta "b")
  (vulpea-buffer-meta-get! meta "c"))

Creating Notes

File-level notes

;; Simple
(vulpea-create "My Note")
;; => #s(vulpea-note ...)

;; With options
(vulpea-create "Project Note"
               nil                              ; file-name (nil = use template)
               :tags '("project" "work")
               :properties '(("STATUS" . "active"))
               :meta '(("client" . "Acme Corp"))
               :head "#+created: %<[%Y-%m-%d]>"
               :body "* Tasks\n\n* Notes\n")

Returns the created vulpea-note. Signals an error if a file already exists at the target path (to prevent accidental overwrites).

Heading-level notes

Use :parent to create a heading inside an existing note’s file:

;; Create a heading under an existing note
(let ((parent (vulpea-db-get-by-id "parent-id")))
  (vulpea-create "Sub-heading"
                 nil
                 :parent parent
                 :tags '("journal")
                 :properties '(("CREATED" . "[2025-01-15]"))))

;; Insert as first child
(vulpea-create "First Item" nil
               :parent parent-note
               :after nil)

;; Insert after a specific sibling
(vulpea-create "After Sibling" nil
               :parent parent-note
               :after "sibling-note-id")

The heading level is computed automatically as parent-level + 1. The parent’s file must exist. Returns the created vulpea-note.

Parameters

ParameterDescriptionDefault
titleNote title (required)
file-nameFile path relative to default directoryfrom template
:idUUID for the noteauto-generated
:tagsList of tags
:headContent after #+title:
:bodyNote body content
:propertiesAlist for property drawer
:metaAlist for metadata
:contextCustom variables for template expansion
:parentvulpea-note to create heading undernil (file-level)
:afterInsertion position among siblings'last

:after accepts:

  • 'last — append as last child (default)
  • nil — insert as first child
  • string — insert after the sibling with that note ID

Visiting Notes

;; By ID
(vulpea-visit "note-id")

;; By note struct
(vulpea-visit note)

;; In other window
(vulpea-visit note t)

Buffer Functions

These operate on the current buffer (must be an org file).

Title

(vulpea-buffer-title-get)              ; Get title
(vulpea-buffer-title-set "New Title")  ; Set title

Tags

(vulpea-buffer-tags-get)               ; Get tags
(vulpea-buffer-tags-set "a" "b")       ; Set tags
(vulpea-buffer-tags-add "new-tag")     ; Add tag (interactive)
(vulpea-buffer-tags-remove "old-tag")  ; Remove tag (interactive)

Aliases

(vulpea-buffer-alias-get)              ; Get aliases
(vulpea-buffer-alias-set "A" "B")      ; Set aliases (replaces all)
(vulpea-buffer-alias-add "Alias")      ; Add alias
(vulpea-buffer-alias-remove "Alias")   ; Remove alias

Metadata

;; Set metadata (in current buffer)
(vulpea-buffer-meta-set "key" "value")
(vulpea-buffer-meta-set "rating" "95")

;; Add one more value to a key, keeping the existing ones
(vulpea-buffer-meta-add "grapes" "Gamay")

;; Set multiple properties efficiently (parses buffer once)
(vulpea-buffer-meta-set-batch
 '(("status" . "active")
   ("priority" . 1)
   ("tags" . ("a" "b" "c"))))

;; Sort metadata keys in a specific order
(vulpea-buffer-meta-sort '("status" "priority" "tags"))
;; Keys not in the list are appended at the end

;; File-level version (by note or ID)
(vulpea-meta-set-batch note
 '(("status" . "done")
   ("reviewed" . t)))

When setting multiple metadata properties, prefer vulpea-meta-set-batch over multiple vulpea-meta-set calls - it’s faster since it only parses the file once: about 6x for 20 properties and 18x for 50 (see bench/README.md). The result is the same: existing keys are rewritten in place, new keys go to the top of the list in alist order.

vulpea-buffer-meta-set replaces every occurrence of the key, re-formatting the values on the way. To grow a multi-value key use vulpea-buffer-meta-add instead: the existing items are left byte-for-byte as written (nothing passes through vulpea-buffer-meta-format again) and the new value is inserted right after the last of them. When the key is absent it behaves like set with append.

To observe metadata mutations without advising the buffer API, add a function to the abnormal hook vulpea-buffer-meta-change-functions. It runs whenever metadata changes through vulpea-buffer-meta-set, vulpea-buffer-meta-add, vulpea-buffer-meta-set-batch, vulpea-buffer-meta-remove or vulpea-buffer-meta-clean:

;; Log every metadata change during a batch operation
(defun my/log-meta-change (prop old new)
  ;; OLD and NEW are lists of string values; adding a property gives
  ;; an empty OLD, removing one gives an empty NEW.
  (message "%s: %S -> %S" prop old new))

(add-hook 'vulpea-buffer-meta-change-functions #'my/log-meta-change)

Each handler is called with PROP, OLD and NEW. The hook fires once per affected property and only for real changes; it reports the outermost operation only, so the nested removal performed by vulpea-buffer-meta-set and the clean/set churn of vulpea-buffer-meta-sort do not produce extra events (a pure reorder fires nothing). OLD and NEW are computed only while the hook is non-nil, so an empty hook adds no overhead.

Heading-Level Metadata

Both file-level and heading-level notes can have their own metadata. The metadata API automatically scopes operations to the correct level based on the note’s level attribute.

For file-level notes (level = 0), metadata is the first description list before any headings:

:PROPERTIES:
:ID:       file-id
:END:
#+title: My Note

- status :: active
- count :: 42

Content here...

* Some Heading
:PROPERTIES:
:ID:       heading-id
:END:

- status :: done

Heading content...

For heading-level notes (level > 0), metadata is the first description list within that heading’s subtree:

;; Get the file-level note
(let ((file-note (vulpea-db-get-by-id "file-id")))
  (vulpea-meta-get file-note "status"))
;; => "active"

;; Get the heading-level note
(let ((heading-note (vulpea-db-get-by-id "heading-id")))
  (vulpea-meta-get heading-note "status"))
;; => "done"

;; Each note has its own metadata scope
(vulpea-meta-set file-note "status" "review")    ; Only affects file-level
(vulpea-meta-set heading-note "status" "pending") ; Only affects heading

This scoping applies to all vulpea-meta-* and vulpea-buffer-meta-* functions.

Tags

Per-Note Tag Operations

Get or modify tags for a specific note (works with both file-level and heading-level notes):

;; Get tags for a note
(vulpea-tags note-or-id)
;; => ("project" "active")

;; Add tags
(vulpea-tags-add note-or-id "new-tag")
(vulpea-tags-add note-or-id "tag1" "tag2" "tag3")

;; Remove tags
(vulpea-tags-remove note-or-id "old-tag")
(vulpea-tags-remove note-or-id "tag1" "tag2")

;; Set tags (replaces all existing tags)
(vulpea-tags-set note-or-id "only" "these" "tags")

For file-level notes (level = 0), these modify #+filetags. For heading-level notes (level > 0), they modify org heading tags.

Batch Tag Operations

Operate on multiple notes efficiently using vulpea-utils-process-notes:

;; Add a tag to multiple notes
(vulpea-tags-batch-add notes "archived")
;; => count of notes processed

;; Remove a tag from multiple notes
(vulpea-tags-batch-remove notes "active")
;; => count of notes processed

;; Rename a tag across all notes
(vulpea-tags-batch-rename "old-tag" "new-tag")
;; => count of notes modified

;; Interactive: M-x vulpea-tags-batch-rename
;; - Prompts for old tag (with completion from existing tags)
;; - Prompts for new tag name
;; - Shows count of modified notes

The rename function queries for all notes with the old tag, removes it, and adds the new tag. When called interactively via M-x vulpea-tags-batch-rename, it provides completion for existing tags.

Batch Metadata Operations

Operate on metadata across multiple notes:

;; Set a metadata property on multiple notes
(vulpea-meta-batch-set notes "status" "archived")
;; => count of notes processed

;; Set a list value
(vulpea-meta-batch-set notes "tags" '("a" "b" "c"))

;; Remove a metadata property from multiple notes
(vulpea-meta-batch-remove notes "deprecated-key")
;; => count of notes processed

Tag Hierarchy

If you use Org’s tag groups (org-tag-alist with :startgrouptag / :grouptags / :endgrouptag, see Info node (org)Tag Hierarchy), vulpea-tags-expand turns a list of tags into that list plus the transitive members of any groups among them:

;; with group GTD = {Control, Persp}, and Control = {TODO, WAITING}
(vulpea-tags-expand '("GTD"))
;; => ("GTD" "Control" "Persp" "TODO" "WAITING")

Combine it with the tag query functions to match a parent tag and all its descendants:

;; notes tagged GTD or any tag under it
(vulpea-db-query-by-tags-some (vulpea-tags-expand '("GTD")))

;; notes tagged with none of GTD's hierarchy
(vulpea-db-query-by-tags-none (vulpea-tags-expand '("GTD")))

Expansion is meaningful for -some and -none (any member matches). It is intentionally not applied to vulpea-db-query-by-tags-every, where “has all of” a group’s members is a different question.

Title Propagation

When you rename a note’s title, incoming links still show the old title as their description. Vulpea provides tools to propagate title changes to link descriptions and optionally rename the file.

vulpea-propagate-title-change

Interactive command to propagate a title change across the knowledge base:

;; Interactive usage
M-x vulpea-propagate-title-change

;; With prefix argument for dry-run preview
C-u M-x vulpea-propagate-title-change

;; Programmatic usage
(vulpea-propagate-title-change note-or-id)

The command:

  1. Identifies the note (from current buffer or prompts)
  2. Prompts for the old title if not detected by vulpea-title-change-detection-mode
  3. Offers to rename the file based on the new title slug
  4. Categorizes incoming links:
    • Exact matches: description equals old title or alias (case-insensitive) → can auto-update
    • Partial matches: description contains old title → manual review needed
  5. For exact matches, offers: [!] Update all, [r] Review individually, [s] Skip, [q] Quit
  6. For partial matches, offers to open files for manual editing

With C-u prefix (dry-run), shows a preview buffer without making changes.

vulpea-rename-file

Rename a note’s file based on a new title:

(vulpea-rename-file note-or-id "New Title")
;; => new file path

;; Renames: old_title.org → new_title.org (using slug)
;; Updates database
;; Signals error if target file exists

Only works for file-level notes (level = 0).

vulpea-move-file

Move a note’s file to another directory, keeping its file name:

(vulpea-move-file note-or-id "~/vault/projects/")
;; => new file path

;; Moves: notes/my_note.org → projects/my_note.org
;; Updates database and org-id location
;; Leaves links alone (they are ids, not paths)

This is the counterpart to vulpea-rename-file: renaming derives a new file name from a title and keeps the directory, moving keeps the file name and changes the directory.

Signals a user-error when the note cannot be found, when it is a heading-level note, when its file is gone from disk, when the directory does not exist or is not writable, when the note already lives there, or when a file of the same name is already in the target directory.

Moving outside vulpea-db-sync-directories is refused as well (unless no sync directories are configured): the note would keep working until the next full scan and then silently drop out of the database.

When a buffer visits the note, it is saved and replaced by a buffer visiting the new location, with point kept.

Called interactively, the note is the one the current buffer visits. This is always the file-level note, never a heading inside it, so it works with point anywhere in the file. Completion for the target offers directories that already hold notes, but is not restricted to them: a directory that exists but is still empty can be typed in and confirmed.

vulpea-split-heading

Extract a heading-level note’s subtree into a file-level note:

(vulpea-split-heading note-or-id)
;; => the created vulpea-note

;; Optionally choose where it lands (defaults to the source directory)
(vulpea-split-heading note-or-id "~/vault/people/")

The heading becomes the file: its text becomes the #+title, its own and inherited tags become #+filetags, its property drawer moves to the file level and its meta moves with it. The id is preserved, so links into the heading keep working with no rewriting.

Children follow and are promoted so the shallowest lands at level 1. A child with an id of its own stays a heading note and keeps that id, it is not split recursively.

Inherited tags are materialized into the new file, since a file has nothing left to inherit from and dropping them would remove the note from queries that used to find it. This follows org-use-tag-inheritance. Category is carried over the same way, unless it was the source file-name fallback.

The subtree is removed from the source file. The new file is written first, so a failure partway leaves the source intact.

With a non-nil third argument (interactively, a prefix argument) the heading is replaced by a link to the new note rather than removed:

(vulpea-split-heading note-or-id nil t)
;; source keeps: * [[id:...][Title]]

The stub sits at the level the heading had, carries no id of its own so it does not become a note, and is described by the note’s title rather than the raw heading, since a raw heading may itself hold a link.

Content is moved verbatim. Unlike vulpea-create, nothing is expanded as a template, so a body containing %(...) or ${...} is written as written, and vulpea-create-default-template is not consulted: the note already exists.

Signals a user-error when the note cannot be found, when it is already a file-level note, when its file is gone from disk or no longer holds the heading, when the title has no file name to slug (punctuation only, say), when the heading carries a todo keyword, a priority, planning information, a logbook or a COMMENT keyword (a file-level note cannot hold any of them), when the directory does not exist, is not writable or lies outside vulpea-db-sync-directories, or when a file of that name already exists there.

Called interactively with point inside a heading, that heading is the target whether or not the database knows it yet: a missing :ID: is created, the buffer saved and the file indexed first. The refusals above are checked before any of that, so a heading that cannot split is left untouched. A file outside vulpea-db-sync-directories (when any are configured) is refused up front. A stale database claim on the id from another file is settled by re-indexing it (or forgetting a file that is gone), so a cut-and-pasted subtree splits fine once its old file is saved; an id genuinely alive in two files is refused, as is a heading excluded from indexing - both discovered by indexing, so found after the save. Away from a heading - another buffer, or a file’s preamble - the heading is picked from the database.

vulpea-merge

Fold one file-level note into another:

(vulpea-merge source-or-id target-or-id)
;; => the target vulpea-note, as it is after the merge

The source’s body is appended to the target under a heading carrying the source’s title, with the source’s own headings demoted to sit under it. This is the inverse of vulpea-split-heading, so splitting that heading back out undoes the merge.

Tags are unioned. Meta is merged key by key, keeping both values where they differ and dropping exact duplicates. The source’s title and all of its aliases become aliases of the target, so every name it answered to still resolves.

Links into the source are re-pointed at the target with their descriptions untouched, so nothing dangles and a link that read the old note’s name still reads it. Plain id: links count as links here, the same as bracketed ones. The source file is then deleted.

Both notes must be file-level. Merging heading-level notes is a different operation on each side and is refused.

Signals a user-error when either note cannot be found, either is a heading-level note, they are the same note, either file is missing, the target is not writable, or the source’s title would not read as itself once it becomes a heading (a title like “TODO list” is read as a todo keyword, one ending in :word: as tags).

vulpea-title-change-detection-mode

Minor mode that detects title changes on save:

;; Enable for current buffer
(vulpea-title-change-detection-mode +1)

;; Enable for all org files
(add-hook 'org-mode-hook #'vulpea-title-change-detection-mode)

When enabled:

  • Captures the title before each save
  • After save, if title changed, shows a message: “Title changed from "Old" to "New". Run M-x vulpea-propagate-title-change to update.”

This mode only notifies - it doesn’t automatically update anything.

Modifying Notes Programmatically

With Async Sync

For modifications where immediate database update isn’t needed:

(vulpea-utils-with-note note
  (vulpea-buffer-meta-set "status" "reviewed")
  (save-buffer))
;; Database updates asynchronously via file watcher

With Immediate Sync

When you need to query updated data right away:

(vulpea-utils-with-note-sync note
  (vulpea-buffer-meta-set "status" "done"))
;; Database is already updated here
(vulpea-note-meta-get (vulpea-db-get-by-id id) "status")
;; => "done"

Tracking What Changed

When a script rewrites metadata across many notes - say a periodic job that refreshes wine prices from shop data - you often want an audit trail of exactly what moved. vulpea-buffer-meta-change-functions makes this a few lines: collect the changes during the run, then print them. Because the hook reports the property’s OLD and NEW values, no diffing of your own is needed.

;; A tiny change log built on the metadata-change hook.
(defvar my/meta-changes nil
  "Hash of note id -> list of (PROP OLD NEW).")

(defun my/meta-record (prop old new)
  "Collect a change of PROP from OLD to NEW under the note at point."
  (when-let* ((id (save-excursion (goto-char (point-min)) (org-id-get))))
    (push (list prop old new) (gethash id my/meta-changes))))

(defun my/meta-log-start ()
  (setq my/meta-changes (make-hash-table :test 'equal))
  (add-hook 'vulpea-buffer-meta-change-functions #'my/meta-record))

(defun my/meta-log-stop ()
  (remove-hook 'vulpea-buffer-meta-change-functions #'my/meta-record))

(defun my/meta-log-report ()
  (maphash
   (lambda (id changes)
     (message "* %s" (vulpea-note-title (vulpea-db-get-by-id id)))
     (dolist (it (reverse changes))
       (message "  %s: %S -> %S" (nth 0 it) (nth 1 it) (nth 2 it))))
   my/meta-changes))

Wrap the batch update between start and stop, then report:

(my/meta-log-start)
(unwind-protect
    (dolist (note (vulpea-db-query-by-tags-every '("wine" "cellar")))
      (when-let* ((price (my/shop-price-for note)))   ; your data source
        (vulpea-utils-with-note note
          (vulpea-buffer-meta-set "price" price)
          (save-buffer))))
  (my/meta-log-stop))

(my/meta-log-report)
;; * Château Test 2019
;;   price: ("18.50") -> ("21.00")

Only notes whose price actually changed appear: a no-op vulpea-buffer-meta-set (same value) fires nothing.

Selection Interface

Select Note

;; Basic selection
(vulpea-select "Select note")
;; => selected vulpea-note or nil

;; With filter
(vulpea-select "Select project"
               :filter-fn (lambda (note)
                            (member "project" (vulpea-note-tags note))))

;; With initial input
(vulpea-select "Select" :initial-prompt "meeting")

;; With alias expansion (allows selecting by alias)
(vulpea-select "Select" :expand-aliases t)
;; When alias is selected, returned note has:
;; - title = the selected alias
;; - primary-title = the original title

Select from List

(vulpea-select-from "Choose" notes)
;; => selected note from provided list

;; With alias expansion
(vulpea-select-from "Choose" notes :expand-aliases t)
;; Each note with aliases appears multiple times in completion

Select Multiple from List

(vulpea-select-multiple-from "Choose" notes)
;; => list of selected notes (each note can only be selected once)

;; With options
(vulpea-select-multiple-from "Choose" notes
                             :require-match t
                             :expand-aliases t)

Customizing Selection Display

Control how notes are displayed in completion with vulpea-select-describe-fn:

;; Default: just the title
(setq vulpea-select-describe-fn #'vulpea-note-title)

;; Show outline path (parent headings) before title
;; Example: "Projects → Work → Task"
(setq vulpea-select-describe-fn #'vulpea-select-describe-outline)

;; Show file title and outline path before title
;; Example: "My Notes → Projects → Task"
(setq vulpea-select-describe-fn #'vulpea-select-describe-outline-full)

The outline variants are useful when using headings as notes (vulpea-db-index-heading-level) to disambiguate notes with identical titles.

A candidate is rendered as describe-fn output followed by annotate-fn output, so the two divide the row between them. vulpea-select-describe-fn produces the main, searchable part of the candidate (matched by completion); vulpea-select-annotate-fn produces a trailing annotation, shown in the completions-annotations face by default. The default annotator appends the primary title (when a note is matched through an alias) and #tag list:

;; Default annotation: "(primary title) #tag1 #tag2"
(setq vulpea-select-annotate-fn #'vulpea-select-annotate)

;; No annotation at all
(setq vulpea-select-annotate-fn nil)

By default the annotation is part of the candidate string, so typing #tag or an alias narrows the selection - that matchability is why it is the default. Set vulpea-select-annotate-matchable to nil to serve the same annotate-fn output through the standard annotation-function (completion metadata) instead. The annotation then behaves like any other minibuffer annotation: it is display-only, so typed text no longer matches it (unless your completion style makes it match, e.g. orderless style dispatchers), marginalia recognizes it as the builtin annotator for the vulpea-note category (so you can register additional annotators and cycle them with marginalia-cycle), and display modes that hide annotations to save space (such as vertico-multiform-grid) actually hide it.

The same mechanism makes any note field matchable. Selection does not search the database: it matches against the candidate string, so a value that is indexed but absent from the string cannot narrow the list. To find notes by a property value, append the values you care about to the annotation (keys are upcased):

(defun my-vulpea-annotate (note)
  (let ((props (vulpea-note-properties note)))
    (concat (vulpea-select-annotate note)
            (mapconcat (lambda (key)
                         (if-let* ((value (cdr (assoc key props))))
                             (concat " " value)
                           ""))
                       '("AUTHOR" "ISBN")
                       ""))))

(setq vulpea-select-annotate-fn #'my-vulpea-annotate)

Name the keys explicitly rather than appending the whole drawer: ID and CREATED are on every note and only add noise and false matches.

Both functions take a vulpea-note and return a string, so you can assemble any layout from the note’s slots. Combining fields from the note alone is straightforward. Some layouts, though, want data that is expensive to compute per candidate - a backlink count is the classic example. For those, use the shared context hook.

Shared context for the whole selection

vulpea-select-dyncontext-fn is called once per selection with the list of notes being presented and returns any value you like - the “dynamic context”. Vulpea passes that value as a second argument to your describe and annotate functions, so they can read precomputed shared data instead of recomputing it for every candidate.

The second argument is only passed to functions that accept it (checked via `func-arity’), so existing one-argument describe/annotate functions keep working unchanged - adopting the context is opt-in per function.

For example, a fixed-width row with directory, hierarchy, tags and a backlink count, where the counts are built with a single query per selection:

(defun my-vulpea-describe (note counts)
  "Describe NOTE, reading its backlink count from the shared COUNTS table."
  (let* ((dir (file-name-nondirectory
               (directory-file-name
                (file-name-directory (vulpea-note-path note)))))
         (hierarchy (string-join
                     (delq nil (cons (vulpea-note-file-title note)
                                     (vulpea-note-outline-path note)))
                     " → "))
         (tags (mapconcat (lambda (x) (concat "#" x))
                          (vulpea-note-tags note) " "))
         (backlinks (gethash (vulpea-note-id note) counts 0)))
    (concat
     (truncate-string-to-width dir 15 nil ?\s) " "
     (truncate-string-to-width hierarchy 60 nil ?\s) " "
     (propertize (truncate-string-to-width tags 30 nil ?\s) 'face 'org-tag) " "
     (format "%6d" backlinks))))

;; Build the shared backlink-count table once per selection. "id" counts
;; only id: links (the real backlinks); it is effectively optional, since
;; only id: links have a note ID as their destination. Omit it to count
;; every link type.
(setq vulpea-select-dyncontext-fn
      (lambda (_notes) (vulpea-db-query-backlink-counts "id"))
      vulpea-select-describe-fn #'my-vulpea-describe
      vulpea-select-annotate-fn nil)

This is a plain setq - no command wrapper, no manual hook binding - and it applies to every selection command (vulpea-find, vulpea-insert, custom vulpea-select calls). Because vulpea-select-dyncontext-fn runs once per selection, the counts are always fresh, and because the table is shared the per-candidate describe-fn never touches the database. The context is computed across all notes on every open, so while it is set vulpea-find and vulpea-insert skip the candidate cache (see Candidate Cache).

Do not query the database inside describe-fn itself: it runs once for every candidate, so a query there means a query per candidate. The whole point of vulpea-select-dyncontext-fn is to move that work out to a single call.

Be aware of the cost even when done right: the work happens when the finder opens - one grouped query over the whole links table, plus describe-fn running once per candidate. On a large collection this adds a noticeable delay before the finder appears. It is open-time cost, not per-keystroke lag (candidate strings are precomputed), but it grows with the number of notes, so keep describe-fn cheap and only pull in extra data like backlink counts when you actually want them on screen.

To order candidates rather than display them differently, set a display-sort-function through completion-category-overrides - the displayed text does not affect candidate order on its own. See Sorting Candidates.

Completion Category

All selection commands (vulpea-select, vulpea-select-from, and therefore vulpea-find / vulpea-insert) report a completion category of vulpea-note to the minibuffer. Completion frameworks and their extensions use this category to recognize candidates as notes:

  • marginalia can annotate candidates via an annotator registered for the vulpea-note category.
  • embark can offer note-specific actions - embark-vulpea keys its keymap on this category and reads the note id from the vulpea-note-id text property carried by each candidate.
  • consult integrations such as consult-vulpea use the same vulpea-note category.

The category is additive - plain completing-read and frameworks that ignore it are unaffected.

A frontend that replaces selection by advising vulpea-select-from keeps receiving every vulpea-find and vulpea-insert call: the candidate cache (see Candidate Cache) steps aside while that advice is present. To use the cache too, advise vulpea-select-from-cache (arguments PROMPT &key REQUIRE-MATCH INITIAL-PROMPT, returns a vulpea-note, with a nil id for input that matches no note), complete over (vulpea-select-cache-candidates), preview with vulpea-select-candidate-path and resolve the pick with vulpea-select-candidate-note.

Candidate Text Properties

Each candidate string is self-describing: besides the note id (the vulpea-note-id property read by embark-vulpea), it carries the whole vulpea-note and the value produced by vulpea-select-dyncontext-fn. Candidates of vulpea-find and vulpea-insert served from the candidate cache (see Candidate Cache) are the exception: keeping every note in memory is what the cache avoids, so they carry the id only, and vulpea-select-candidate-note reads the note from the database when asked. Two accessors read them back:

(vulpea-select-candidate-note candidate)    ;; => the vulpea-note, or nil
(vulpea-select-candidate-path candidate)    ;; => its file path, or nil
(vulpea-select-candidate-context candidate) ;; => the dyncontext value, or nil

vulpea-select-candidate-path never reads the database for a cached candidate, so it is the one to use for work done per displayed candidate, such as previewing the note’s file.

Both return nil when the string is not a candidate - for example the free-form input a user types to name a new note - so code consuming mixed strings needs no special casing. Use the accessors rather than get-text-property: the property names are an implementation detail, the accessors are the supported surface.

This matters wherever your code receives only strings: a display-sort-function (below), an embark action, an annotator registered for the category.

Annotations served through annotation-function (vulpea-select-annotate-matchable set to nil) are kept on cached candidates, so showing them reads nothing. For any other lookup on cached candidates, the first few in a selection read one note each; past that, all notes are read at once and reused until the prompt closes. So a sort function that asks for the note of every candidate costs one full read of the notes table per vulpea-find, most of what the cache saves. If that is your setup and the delay bothers you, sort on something the candidate string already shows, or turn the cache off.

Sorting Candidates

Vulpea does not order candidates itself. Ordering is expressed where Emacs already looks for it: completion-category-overrides, keyed on the vulpea-note category. A display-sort-function set there receives candidate strings, and vulpea-select-candidate-note turns each one back into its note, so any note field can be a sort key:

(defun my-sort-by-created (candidates)
  "Sort note CANDIDATES by creation date, newest first."
  (seq-sort-by
   (lambda (c)
     (or (vulpea-note-created-at (vulpea-select-candidate-note c)) ""))
   #'string>
   candidates))

;; Apply to every vulpea selection:
(setf (alist-get 'vulpea-note completion-category-overrides)
      '((display-sort-function . my-sort-by-created)))

To sort only in a specific command - say, recent backlinks first in vulpea-find-backlink while vulpea-find keeps its default order - bind the override around that command instead of setting it globally:

(defun my-sorted-backlinks (orig-fun &rest args)
  "Show backlinks sorted by creation date, newest first."
  (let ((completion-category-overrides
         '((vulpea-note (display-sort-function . my-sort-by-created)))))
    (apply orig-fun args)))

(advice-add 'vulpea-find-backlink :around #'my-sorted-backlinks)

Notes on sort keys:

  • vulpea-note-created-at comes from the CREATED property and is nil when a note does not carry it; fall back (the (or ... "") above) or key on vulpea-note-modified-at, which is always set.
  • The sort function runs again on every input change, over the candidates that survive filtering. Keep the key cheap - reading a slot from the note is fine, querying the database is not.

vulpea-find

Interactive command for note selection and navigation:

;; Basic usage (interactive)
(vulpea-find)

;; With custom candidates source
;; The function receives the filter (nil when none is set) and applies it
(vulpea-find :candidates-fn (lambda (filter-fn)
                              (seq-filter (or filter-fn #'identity)
                                          (vulpea-db-query-by-tags-some '("project")))))

;; With filter
(vulpea-find :filter-fn (lambda (note)
                          (member "active" (vulpea-note-tags note))))

;; Open in other window
(vulpea-find :other-window t)

;; Require exact match (no creating new notes)
(vulpea-find :require-match t)

;; Custom note creation ("capture on empty"): called with the typed
;; title and capture properties, returns the note to visit (or nil)
(vulpea-find :create-fn (lambda (title &optional _props)
                          (vulpea-create title nil :tags '("inbox"))))

vulpea-insert

Interactive command for inserting a link to a note:

;; Basic usage (interactive)
(vulpea-insert)

;; With custom candidates source
(vulpea-insert :candidates-fn (lambda (filter-fn)
                                (seq-filter (or filter-fn #'identity)
                                            (vulpea-db-query-by-tags-some '("person")))))

;; With filter
(vulpea-insert :filter-fn (lambda (note)
                            (= 0 (vulpea-note-level note))))

;; With custom note creation: the function returns the note,
;; vulpea-insert takes care of the link
(vulpea-insert :note-fn (lambda (title props)
                          (vulpea-create title nil :tags '("new"))))

Both functions support :candidates-fn to customize the source of candidates, and :filter-fn to filter candidates. Global defaults can be configured via vulpea-find-default-candidates-source / vulpea-insert-default-candidates-source and vulpea-find-default-filter / vulpea-insert-default-filter.

Both also support :create-fn to control how a new note is created when the user selects a non-existent note. It is called with two arguments - the typed title and capture properties (currently always nil) - which makes “capture on empty” workflows easy: route to org-capture or a custom command to turn a fruitless search straight into note creation. For vulpea-find, :create-fn should return the vulpea-note to visit (or nil to skip visiting), and a global default can be set via vulpea-find-default-create-fn. For vulpea-insert, :create-fn owns the whole flow - it must create the note and insert the link itself - and its global default is vulpea-insert-default-create-fn.

vulpea-insert additionally supports :note-fn (global default: vulpea-insert-default-note-fn), which brings the vulpea-find contract to link insertion: called with the same two arguments, it only creates and returns the vulpea-note (or nil to skip), and vulpea-insert replaces the selected region, inserts the link with a proper description and runs vulpea-insert-handle-functions itself. Prefer it over :create-fn unless you need to control the link insertion. An explicit argument beats both defaults, vulpea-insert-default-note-fn beats vulpea-insert-default-create-fn when only the defaults are set, and passing both :note-fn and :create-fn is an error.

Ids double as interactive handles in both commands. Every candidate carries its note id as an invisible, matchable suffix (vulpea-select-match-ids, default on), so typing or pasting an id narrows completion to that note, which you then select like any other candidate - vulpea-find visits it, vulpea-insert links it. The vulpea-insert link description comes from vulpea-insert-default-description-fn (the note title by default; a region still wins) - override it to derive the description from the id or anything else. See Selecting by Id in the user guide.

Synchronization

Immediate Update

;; Update specific file (synchronous)
(vulpea-db-update-file "/path/to/note.org")

;; Update via sync system (async if autosync enabled; always
;; re-reads the file, bypassing the unchanged-content check)
(vulpea-db-sync-update-file "/path/to/note.org")

Batch Operations

;; Update directory
(vulpea-db-sync-update-directory "~/org/")

;; Full scan
(vulpea-db-sync-full-scan)

;; Force re-index
(vulpea-db-sync-full-scan 'force)

Waiting for an Up-to-date Database

With vulpea-db-autosync-mode on, scans and file changes are indexed from timers, process output and the extraction worker, so vulpea-db-sync-full-scan returns before the work is done, and a script in a fresh emacs --batch reads the database as the last session left it. Code that must see every change on disk before it queries calls:

;; Index new, changed and deleted files, plus anything queued
;; (forced re-indexes included), in this session; returns when done
(vulpea-db-sync-catch-up)

It waits for what the extraction worker holds, indexes the sync queue, scans every existing sync directory with the usual change detection (an unchanged file costs a stat) and indexes what that scan queued. It works the same with the mode on or off. Unlike vulpea-db-sync-full-scan it keeps the rows of files outside vulpea-db-sync-directories, so notes a script indexed by hand stay put. A database that stays locked is a user-error.

Directory List

Change vulpea-db-sync-directories without toggling vulpea-db-autosync-mode (which would rescan everything). Both are also interactive commands.

;; Append a directory to the list; with autosync enabled, start
;; watching it and index its files with the usual change detection.
;; The first entry - the fallback for notes created outside any
;; corpus - is never displaced.
(vulpea-db-sync-add-directory "~/work-notes/")

;; Stop watching a directory: drop its pending updates and delete
;; its rows from the database, unless another entry still covers
;; them. Without autosync only the variable changes.
(vulpea-db-sync-remove-directory "~/work-notes/")

Utility Functions

;; Report vulpea version (M-x vulpea-version interactively).
;; Returns "git describe" output from a checkout, package version
;; (with commit for MELPA snapshots) when installed, or the
;; `vulpea-version' constant as a fallback.
(vulpea-version)
;; => "v2.2.0" or "v2.2.0-15-g2938416" or "20260610.1234 (commit 2938416)"

;; Diagnose the setup (M-x vulpea-doctor interactively).
;; Returns a report string covering versions, configuration,
;; database and sync state, external tool availability, and
;; detected issues. Read-only - modifies nothing. Include the
;; report in bug reports.
(vulpea-doctor)

;; Convert title to URL-friendly slug
(vulpea-title-to-slug "My Note Title")
;; => "my_note_title"

;; Make org link to note
(vulpea-utils-link-make-string note)
;; => "[[id:abc123][Note Title]]"

(vulpea-utils-link-make-string note "Custom Description")
;; => "[[id:abc123][Custom Description]]"

;; Expand note into multiple notes based on aliases
(vulpea-note-expand-aliases note)
;; Returns a list of notes:
;; - First element: original note (unchanged)
;; - Additional elements: copies with each alias as title
;;   and original title as primary-title
;;
;; Example with note having title "Full Name" and aliases ("Alias1" "Alias2"):
;; => (note-with-title="Full Name"
;;     note-with-title="Alias1" primary-title="Full Name"
;;     note-with-title="Alias2" primary-title="Full Name")

Database Access

For advanced use cases, direct database access:

;; Get database connection
(vulpea-db)

;; Run raw SQL
(emacsql (vulpea-db)
         [:select * :from notes :where (= id $s1)]
         "note-id")

→ See Plugin Guide for custom tables and extractors.

Schemas

A schema describes the structured expectations for a class of notes: a predicate selecting which notes it applies to, and a list of field specs declaring the metadata those notes should carry.

(vulpea-schema-define 'wine
  :predicate (lambda (note) (member "wine" (vulpea-note-tags note)))
  :fields
  '((:key "producer" :type note   :required t)
    (:key "name"     :type string :required t)
    (:key "colour"   :type symbol :required t :one-of (red white rose))
    (:key "grapes"   :type note   :multiple t)
    (:key "vintage"  :type number)
    ;; required only for sparkling wines
    (:key "carbonation method" :type symbol
          :required (lambda (note)
                      (eq (vulpea-note-meta-get note "carbonation" 'symbol)
                          'sparkling)))))

Field spec keys:

KeyMeaning
:keymetadata key string (required)
:typestring (default), number, symbol, note, link, date, or datetime
:requiredt=/=nil, or a function (note) → boolean
:one-ofa list of allowed values, or a function (note) → list
:multiplenon-nil when the field holds a list of values
:target-tagsfor a note field, tags its target must all carry
:target-tags-anyfor a note field, tags its target must carry at least one of
:activefor a date field, whether prompts write an active timestamp (default t)
:defaultdefault value, or a function (note) → value
:validateoptional function (value note) → t or an error string

The :type vocabulary matches vulpea-note-meta-get, so values are read the same way everywhere. Use a function for :required or :one-of when the rule depends on another field (e.g. allowed sweetness levels that vary by carbonation). To read a sibling field inside such a function, call vulpea-note-meta-get directly so you control the value type.

A date field holds a plain org timestamp without a time part (<2026-08-05 Wed>), a datetime field one with a time part (<2026-08-05 Wed 14:30>); anything else - today, a bare 2026-08-05, an impossible date - is a wrong-type violation. Both accept active (<...>) and inactive ([...]) brackets, and the value reads as a vulpea-timestamp struct that remembers which one it was, so re-serializing reproduces the original (the day name is recomputed from the date rather than trusted). The authoring commands prompt for these fields with org-read-date, calendar and all, and write an active timestamp - set :active nil on the field to have them write inactive ones instead. The knob only shapes what prompts write: validation accepts both forms either way, and an existing value keeps its brackets. Ranges, repeaters, and warning periods are not accepted. A :validate function on a date field receives the vulpea-timestamp, so range checks are plain time comparisons:

(:key "published" :type date
      :validate (lambda (ts _note)
                  (if (time-less-p (vulpea-timestamp-time ts) (current-time))
                      t
                    "published must be in the past")))

A field can declare a :default: a literal value, or a function of the note for anything dynamic - an id-derived slug, a value computed from sibling fields, whatever a lambda can reach. The guided flow (vulpea-schema-insert-fields) writes defaulted fields silently instead of prompting (edit after, or use vulpea-schema-insert-field, which always prompts with the default prefilled); the skeleton flow writes them as placeholders. For a date / datetime field a string default is org-read-date input, relative to today - +3d, +1w, +3d 14:00 - or an absolute 2026-12-31, and honors the field’s :active; any other string shape is an error, because org-read-date would quietly resolve it to today, the worst possible behavior for a silently written value. A function default returning nil declines, falling back to the prompt. Defaults never affect validation.

;; everything in the inbox must be processed within 30 days
(vulpea-schema-define 'inbox
  :predicate (lambda (note) (member "inbox" (vulpea-note-tags note)))
  :fields
  '((:key "until" :type date :default "+30d" :required t)))

For a note field, :target-tags additionally constrains the target: the linked note must carry every listed tag, otherwise validation reports an invalid-target violation. For example, (:key "account" :type note :target-tags ("adobe")) only accepts links to notes tagged adobe. The check applies per value, so it also covers each link in a :multiple field. (Restricting a target by another schema - :target-schema - is planned but not yet implemented.)

:target-tags-any is the same restriction with any-of semantics: the target has to carry at least one of the listed tags. Declared together the two compose, so the target must carry every :target-tags tag and at least one :target-tags-any tag:

;; the owner is a person, and on one of the two teams
'(:key "owner" :type note
       :target-tags ("person")
       :target-tags-any ("team-a" "team-b"))

Both keys also narrow the note selection in the authoring commands, so you can only pick a target that validates.

Registry and helpers:

FunctionDescription
vulpea-schema-defineDefine and register a schema
vulpea-schema-getRetrieve a schema by name
vulpea-schema-listList registered schema names
vulpea-schema-unregisterRemove a schema from the registry
vulpea-schema-applies-pDoes a schema’s predicate match a note
vulpea-schema-field-valueRead a field’s value with its type

Per note, not per file

A schema is not tied to a file. Its predicate runs against every note, and a note is any org node with an ID - a whole file or a single heading - so one file can hold many independently validated notes. A swimming.org where each session is its own heading is a good example:

#+title: Swimming

* 2026-06-28 Morning laps :swim:
:PROPERTIES:
:ID: 3f2a6d1c-0b7e-4a2f-9c14-6d5e8a1b2c3d
:END:
- distance :: 1500
- style :: freestyle
- pool :: 25m

* 2026-06-30 Intervals :swim:
:PROPERTIES:
:ID: 7c9b0e42-1a3d-4f56-8b90-2e4c6a8d0f11
:END:
- distance :: 2000
- style :: medley
- pool :: 50m
(vulpea-schema-define 'swim
  :predicate (lambda (note) (member "swim" (vulpea-note-tags note)))
  :fields
  '((:key "distance" :type number :required t)
    (:key "style"    :type symbol :required t
          :one-of (freestyle backstroke breaststroke butterfly medley))
    (:key "pool"     :type string)))

;; validates every swim session heading, wherever it lives
(vulpea-schema-validate-all 'swim)

The :swim tag on each heading is what the predicate keys off, so only the sessions are checked - not the file-level Swimming note that contains them. (The tag can also come from #+filetags:, which heading-level notes inherit; tagging the headings directly is what keeps the container note out.)

Composition

A schema can inherit fields from others with :include, which takes a schema name (a symbol or vulpea-schema object) or a list of them:

(vulpea-schema-define 'base-account
  :predicate (lambda (note) (member "account" (vulpea-note-tags note)))
  :fields '((:key "username" :required t)
            (:key "domain"   :required t)))

(vulpea-schema-define 'adobe-account
  :include 'base-account
  :predicate (lambda (note) (member "adobe" (vulpea-note-tags note)))
  :fields '((:key "cloud-tier" :type symbol :one-of (free pro enterprise))))

Included schemas contribute their fields first (multiple includes are merged left to right), then the schema’s own :fields. When the same :key appears more than once the later definition wins, so a schema’s own field overrides an inherited one, and an overridden field keeps the position of its first appearance. Inheritance is transitive: including a schema that itself includes others pulls in the whole chain. Includes are resolved when the schema is defined, so an included schema must already be registered, and re-defining it later does not retroactively update schemas that included it. The predicate is not inherited - each schema declares its own. The merged field list is what validation and vulpea-schema-field-value operate on, so inherited fields behave exactly like native ones.

:predicate itself is optional. A schema defined without one is abstract: it applies to no note and exists to be included - the way to keep a registry of fields shared between schemas:

(vulpea-schema-define 'common
  :fields '((:key "status" :one-of (todo done))
            (:key "duration" :type number)))

(vulpea-schema-define 'book
  :predicate (lambda (note) (member "book" (vulpea-note-tags note)))
  :include 'common
  :fields '((:key "status" :one-of (unread read))))

Two schemas can share a key yet differ in detail, since the later definition wins (here book narrows status to its own values while inheriting duration untouched). Change a shared field once, in the mixin, and every schema that includes it picks the change up on its next definition - remember the eager resolve above: define mixins first, and re-evaluate the including schemas after changing a mixin. Test for abstractness with vulpea-schema-abstract-p. An abstract schema is skipped by everything predicate-driven (vulpea-schema-applicable, vulpea-schema-validate-all, collection health coverage), can still be validated against directly, and is offered by vulpea-schema-insert-fields when no schema applies to the buffer, so inserting a mixin’s fields by hand works.

Validation

Validate notes against a schema, getting back a list of vulpea-violation structs:

;; one note
(vulpea-schema-validate note 'wine)

;; an arbitrary list of notes (your own subset)
(vulpea-schema-validate-notes my-notes 'wine)

;; every note the schema's predicate matches
(vulpea-schema-validate-all 'wine)

vulpea-schema-validate and vulpea-schema-validate-notes check exactly the notes given - the predicate is a selector, not a guard. Only vulpea-schema-validate-all consults the predicate (to choose which notes to pull in). To validate just the matching notes in a list of your own, filter with vulpea-schema-applies-p first.

Each violation carries note-id, note-title, schema, field, type, message, and the offending value. The type is one of:

TypeMeaning
missing-requireda required field has no value
wrong-typea value does not match the field’s declared type
invalid-referencea note field links to a non-existent note
invalid-targeta note target fails its tag restrictions
disallowed-valuea value is not in the field’s :one-of set
invalid-valuea value is rejected by the field’s :validate fn
FunctionDescription
vulpea-schema-validateViolations for one note
vulpea-schema-validate-notesViolations for a list of notes
vulpea-schema-validate-allViolations for all notes a schema matches

Authoring

Where validation checks a note after the fact, authoring helps you write a conforming one. vulpea-schema-insert-fields is an interactive command that inserts the fields of an applicable schema into the note at point - the heading’s subtree when point is inside one, otherwise the file-level metadata:

;; M-x vulpea-schema-insert-fields
;;   - picks the schema applicable to the buffer (prompts when several
;;     apply, or over all schemas when none do)
;;   - prompts for each field the note does not already have, required
;;     ones first, offering :one-of values as completion and a note
;;     selection for `note' fields
;;   - a :multiple field collects several values by prompting again
;;     after every answer: note and :one-of selection repeat (C-g or
;;     empty input to stop, and each pick leaves the candidate pool),
;;     free-form fields read strings until a blank answer
;;   - inserts the answers as metadata, one "- key :: value" line per
;;     value
;;
;; With a prefix argument it skips prompting and inserts empty
;; placeholders instead:
;;   C-u M-x vulpea-schema-insert-fields

Existing fields are never overwritten, and a note value is stored as a proper id: link. Because it operates on the schema’s merged fields, inherited fields (:include) are offered too. When the target has no :ID: yet, one is created right before the fields are written (both here and in vulpea-schema-insert-field), so the authored note is immediately real: without an id the fields would be invisible to the database, collections and vulpea-select until you run org-id-get-create yourself. The id is ensured even when there is no field to write - a schema with no fields, or a note already carrying them all - since invoking the command is signal enough that the target is meant to be a note; only skipping every prompt leaves an id-less target untouched.

For a single field there is vulpea-schema-insert-field (singular): it prompts for one of the schema’s fields - the ones the note does not carry yet come first - and then for its value, the same way the guided flow does. Use it to add an optional field that was skipped earlier, or one more value to a :multiple field: a :multiple field keeps its existing values and the answer is appended after them (an empty skeleton placeholder is filled rather than kept), while any other field is replaced when already present. An empty answer writes nothing. On a schema with no fields it skips the prompts but still ensures the id, same as the guided flow.

Two headless primitives back the commands and are useful on their own - for example to build a “what’s missing” view:

FunctionDescription
vulpea-schema-applicableNames of schemas whose predicate matches a note
vulpea-schema-missing-fieldsA schema’s fields a note lacks, required ones first
vulpea-schema-insert-fieldsInteractive: insert an applicable schema’s fields
vulpea-schema-insert-fieldInteractive: insert or extend one field
vulpea-schema-fix-violationPrompt to fix one violation in the current buffer

Once a note’s violations are known, vulpea-schema-fix-violation applies a one-shot fix for a single vulpea-violation in the current buffer: it prompts for a corrected value the same way - :one-of completion, and note selection that honours a field’s target-tag restrictions - then writes it, replacing the offending value or inserting a missing field. It is the headless building block UIs use to offer one-key fixes (for example the schema health widget in vulpea-ui).

Validation at sync

Validation can also run automatically as notes are written to the database. vulpea-db-schema-validation-action controls what happens when a note that an applicable schema matches fails validation while it is indexed (on save, external sync, or a full scan):

ValueEffect
silentindex the note, say nothing
warningindex the note, emit a non-blocking warning (the default)
errorkeep the violating note out of the database, and warn

Because files are the source of truth, none of these touch the file. error simply leaves the note absent from the database until it is fixed and re-synced (a later edit changes the file and re-indexes it). The check is a no-op unless schemas are registered and one applies, so it costs nothing when unused.

Two pieces back it and are reusable on their own:

  • vulpea-schema-note-violations validates a note against every schema vulpea-schema-applicable returns, concatenating the violations. It is the per-note counterpart to vulpea-schema-validate-all and the shared entry point for surfacing one note’s violations (sync warnings, in-buffer linting, health widgets).
  • vulpea-db-note-index-filter-functions is an abnormal hook run for each note on its way into the database, whether it was extracted synchronously or by the worker. A handler receives the vulpea-note about to be indexed and returns non-nil to allow it or nil to skip it; a note is indexed only when every handler allows it. This is the general extension point the validation action builds on. The note carries the fields needed to reason about it without touching the database - id, path, level (0 for file-level notes), outline path, title and title source, tags, aliases, meta, links, properties, category and file title - so a handler can decide by where a note sits as well as by what it holds:
    ;; keep the container heading, drop everything under it
    (add-hook 'vulpea-db-note-index-filter-functions
              (lambda (note)
                (not (member "Meetings" (vulpea-note-outline-path note)))))
        

    Three things to keep in mind. Handlers run in the main process, so while any is registered vulpea-db-async-extraction set to full degrades to extract-only. They run after extraction, so they keep rows out of the database but do not save parsing work. And they run before extractor plugins, so a field an extractor rewrites may be stored with a different value than the handler saw.

In-buffer linting

vulpea-schema-flymake-mode is a buffer-local minor mode (off by default) that flags schema violations with flymake while you edit a note:

;; turn it on in the current buffer
(vulpea-schema-flymake-mode)

;; or enable it for note buffers from a hook
(add-hook 'org-mode-hook #'vulpea-schema-flymake-mode)

Every note in the buffer (file-level and heading-level) is validated against each schema vulpea-schema-applicable returns, and each violation is shown as a warning on the offending field’s metadata line, or on the note’s heading line for a missing required field. It reuses vulpea-schema-note-violations, so it is the live, in-buffer counterpart to the sync-time vulpea-db-schema-validation-action.

Collection health

Where vulpea-schema-note-violations answers “is this note healthy?”, vulpea-schema-collection-health answers it for the whole collection at once - the data source a schema dashboard renders:

(vulpea-schema-collection-health)
;; => one `vulpea-schema-health' per registered schema

It takes a list of notes (defaulting to all notes in the database) and returns one vulpea-schema-health per registered schema, in registration order. Each reports:

SlotMeaning
schemathe schema name
coveredhow many notes the schema’s predicate matches
invalidhow many of those have at least one violation
invalid-notesthe invalid notes as (note . violations) pairs
includesschema names this one inherits fields from
included-byschema names that inherit fields from this one

Schemas that match no notes are still reported with zero counts, so the result is a faithful map of every registered schema. includes comes from vulpea-schema-includes (the names a schema now retains from its :include); included-by is its inverse, computed across every schema. The whole scan is one query plus an in-memory pass, linear in the number of notes; the schema benchmark in bench/README.md measures it.

In vulpea-ui

Everything above is headless; vulpea-ui is where schemas get a UI, so in practice you rarely call these functions by hand:

  • The sidebar schema health widget shows the current note’s violations (vulpea-schema-note-violations) and offers one-key quick-fixes (vulpea-schema-fix-violation).
  • The schema dashboard (M-x vulpea-ui-schema-dashboard) renders vulpea-schema-collection-health across the whole collection: every schema with its covered and invalid counts and its :include relationships, expanding each invalid note to its violations to fix or jump to them.

(vulpea-schema-flymake-mode above is vulpea’s own and needs no UI package - it flags the same violations inline as you edit.)

Quick Reference Tables

Core Functions

FunctionDescription
vulpea-findInteractive note selection and navigation
vulpea-find-backlinkFind notes linking to current note
vulpea-insertInsert link to a note
vulpea-createCreate file-level or heading-level note
vulpea-visitVisit note by ID or struct

Query Functions

FunctionDescription
vulpea-db-queryQuery with predicate
vulpea-db-get-by-idGet single note by ID
vulpea-db-query-by-idsGet multiple notes by IDs
vulpea-db-get-file-by-idGet file path for note ID
vulpea-db-search-by-titleSearch by title pattern (LIKE)
vulpea-db-query-by-tags-someNotes with ANY tags
vulpea-db-query-by-tags-everyNotes with ALL tags
vulpea-db-query-by-tags-noneNotes WITHOUT tags
vulpea-db-query-by-links-someNotes linking to ANY IDs
vulpea-db-query-by-links-everyNotes linking to ALL IDs
vulpea-db-query-attachments-by-pathAttachment (dest . attach-dir) pairs
vulpea-db-query-by-metaNotes with metadata key=value
vulpea-db-query-by-meta-someNotes with metadata key=ANY values
vulpea-db-query-by-meta-everyNotes with metadata key=ALL values
vulpea-db-query-by-meta-keyNotes having metadata key
vulpea-db-query-by-propertyNotes with property key=value
vulpea-db-query-by-property-keyNotes having property key
vulpea-db-query-by-file-pathsNotes from specific files
vulpea-db-query-by-levelNotes at specific level
vulpea-db-query-tagsGet all unique tags
vulpea-db-query-categoriesExplicit categories, file names skipped
vulpea-db-query-dead-linksFind broken ID links
vulpea-db-query-orphan-notesNotes with no incoming ID links
vulpea-db-query-isolated-notesNotes with no connections at all
vulpea-db-query-title-collisionsNotes sharing the same title
vulpea-db-query-stale-notesNotes in files unmodified for N days
vulpea-db-query-linksAll links as plists
vulpea-db-query-links-by-typeLinks filtered by type
vulpea-db-query-links-fromOutgoing links from a note
vulpea-db-query-links-toIncoming links (backlinks) to a note

Tag Functions

FunctionDescription
vulpea-tagsGet tags for a note
vulpea-tags-addAdd tags to a note
vulpea-tags-removeRemove tags from a note
vulpea-tags-setSet tags for a note (replace all)
vulpea-tags-batch-addAdd a tag to multiple notes
vulpea-tags-batch-removeRemove a tag from multiple notes
vulpea-tags-batch-renameRename a tag across all notes (interactive)
vulpea-meta-batch-setSet metadata property on notes
vulpea-meta-batch-removeRemove metadata property from notes

Buffer Functions

FunctionDescription
vulpea-buffer-title-getGet buffer title
vulpea-buffer-title-setSet buffer title
vulpea-buffer-tags-getGet buffer tags
vulpea-buffer-tags-setSet buffer tags
vulpea-buffer-tags-addAdd tag interactively
vulpea-buffer-tags-removeRemove tag interactively
vulpea-buffer-alias-getGet aliases
vulpea-buffer-alias-setSet aliases (replace all)
vulpea-buffer-alias-addAdd alias
vulpea-buffer-alias-removeRemove alias
vulpea-buffer-meta-setSet metadata value
vulpea-buffer-meta-addAdd value, keep existing
vulpea-buffer-meta-set-batchSet multiple meta values
vulpea-buffer-meta-sortSort metadata keys

Sync Functions

FunctionDescription
vulpea-db-autosync-modeToggle auto-sync
vulpea-db-update-fileImmediate sync update
vulpea-db-sync-update-fileRe-read file (async if enabled)
vulpea-db-sync-update-directoryUpdate directory
vulpea-db-sync-full-scanScan all directories
vulpea-db-sync-catch-upScan and wait until up to date
vulpea-db-sync-add-directoryAdd sync directory at runtime
vulpea-db-sync-remove-directoryRemove sync directory

Next Steps