Denote notes, journal and renaming !386

merged merged by cmc on 2026-11-19 16:31 UTC · krz/orgstar:denote-notes into main

18 files changed, +445 −12

Layout: unified · split

Sources/OrgApp/Dailies.swift +34 −3
@@ -4,6 +4,7 @@ import OrgCore
4/// org-roam-dailies (org-roam 2.3): a file a day in `org-roam-dailies-directory` under 4/// org-roam-dailies (org-roam 2.3): a file a day in `org-roam-dailies-directory` under
5/// `org-roam-directory`, named and started as its default capture template does, 5/// `org-roam-directory`, named and started as its default capture template does,
6/// `%<%Y-%m-%d>.org` with `#+title: %<%Y-%m-%d>`, and an ID like any new org-roam file. 6/// `%<%Y-%m-%d>.org` with `#+title: %<%Y-%m-%d>`, and an ID like any new org-roam file.
7/// With `journal` set, denote-journal's instead: a Denote note a day with the journal keyword.
7public struct Dailies: Sendable, Equatable { 8public struct Dailies: Sendable, Equatable {
8 public struct Failure: Error, Equatable, CustomStringConvertible { 9 public struct Failure: Error, Equatable, CustomStringConvertible {
9 public let description: String 10 public let description: String
@@ -18,17 +19,37 @@ public struct Dailies: Sendable, Equatable {
18 public var head: String 19 public var head: String
19 /// What Capture to Daily adds, an org-capture template. 20 /// What Capture to Daily adds, an org-capture template.
20 public var entry: String 21 public var entry: String
22 /// denote-journal's settings, in place of `file` and `head`.
23 public var journal: Journal?
21 24
22 public init(directory: String, file: String = "%<%Y-%m-%d>.org", head: String = "#+title: %<%Y-%m-%d>\n", entry: String = "* %?") { 25 public struct Journal: Sendable, Equatable {
26 /// `denote-journal-keyword`.
27 public var keyword: String
28 /// `denote-journal-title-format`, a `format-time-string` format.
29 public var title: String
30
31 public init(keyword: String = "journal", title: String = "%A %e %B %Y") {
32 self.keyword = keyword
33 self.title = title
34 }
35 }
36
37 public init(directory: String, file: String = "%<%Y-%m-%d>.org", head: String = "#+title: %<%Y-%m-%d>\n", entry: String = "* %?", journal: Journal? = nil) {
23 self.directory = directory 38 self.directory = directory
24 self.file = file 39 self.file = file
25 self.head = head 40 self.head = head
26 self.entry = entry 41 self.entry = entry
42 self.journal = journal
27 } 43 }
28 44
29 /// The settings' dailies: `org-roam-directory`, by default the first folder, and 45 /// The settings' dailies: `org-roam-directory`, by default the first folder, and
30 /// `org-roam-dailies-directory` in it. Nil without a folder. 46 /// `org-roam-dailies-directory` in it. Nil without a folder.
31 public static func configured(roots: [String], defaults: UserDefaults = .standard) -> Dailies? { 47 public static func configured(roots: [String], defaults: UserDefaults = .standard) -> Dailies? {
48 if OrgPreferences.usesDenote(defaults) {
49 guard let base = DenoteNote.directory(roots: roots, defaults: defaults) else { return nil }
50 return Dailies(directory: OrgAttach.expand(OrgPreferences.denoteJournalDirectory(defaults), in: base), entry: OrgPreferences.dailiesEntry(defaults),
51 journal: Journal(keyword: Denote.keyword(OrgPreferences.denoteJournalKeyword(defaults)), title: OrgPreferences.denoteJournalTitle(defaults)))
52 }
32 let roam = OrgPreferences.roamDirectory(defaults) 53 let roam = OrgPreferences.roamDirectory(defaults)
33 guard let base = roam.isEmpty ? roots.first : OrgAttach.expand(roam, in: roots.first ?? NSHomeDirectory()) else { return nil } 54 guard let base = roam.isEmpty ? roots.first : OrgAttach.expand(roam, in: roots.first ?? NSHomeDirectory()) else { return nil }
34 return Dailies(directory: OrgAttach.expand(OrgPreferences.dailiesDirectory(defaults), in: base), 55 return Dailies(directory: OrgAttach.expand(OrgPreferences.dailiesDirectory(defaults), in: base),
@@ -50,12 +71,21 @@ public struct Dailies: Sendable, Equatable {
50 } 71 }
51 72
52 public func path(for day: Date) -> String { 73 public func path(for day: Date) -> String {
53 OrgAttach.expand(Self.expandTime(file, day).trimmingCharacters(in: .whitespaces), in: directory) 74 if let journal {
75 let date = Denote.identifier(for: day).prefix(8)
76 if let found = files().first(where: { Denote.identifier(ofFile: $0)?.hasPrefix(date) == true }) { return found }
77 let name = Denote.fileName(identifier: Denote.identifier(for: day), title: Self.strftime(journal.title, day), keywords: [journal.keyword])
78 return (directory as NSString).appendingPathComponent(name)
79 }
80 return OrgAttach.expand(Self.expandTime(file, day).trimmingCharacters(in: .whitespaces), in: directory)
54 } 81 }
55 82
56 /// The file's text when it's new: the head, ending in a newline, under a property drawer 83 /// The file's text when it's new: the head, ending in a newline, under a property drawer
57 /// with the ID, as `org-entry-put` puts it at the start. 84 /// with the ID, as `org-entry-put` puts it at the start.
58 public func newText(_ day: Date, id: String) -> String { 85 public func newText(_ day: Date, id: String) -> String {
86 if let journal {
87 return Denote.frontMatter(title: Self.strftime(journal.title, day), date: day, keywords: [journal.keyword], identifier: Denote.identifier(for: day))
88 }
59 var text = Self.expandTime(head, day) 89 var text = Self.expandTime(head, day)
60 if !text.hasSuffix("\n") { text += "\n" } 90 if !text.hasSuffix("\n") { text += "\n" }
61 return OrgAttach.ensuringID(text, at: 0) { id }.text 91 return OrgAttach.ensuringID(text, at: 0) { id }.text
@@ -72,13 +102,14 @@ public struct Dailies: Sendable, Equatable {
72 } 102 }
73 103
74 /// `org-roam-dailies--list-files`: the org files in the folder and below, without hidden, 104 /// `org-roam-dailies--list-files`: the org files in the folder and below, without hidden,
75 /// backup and auto-save files, sorted. 105 /// backup and auto-save files, sorted. For a Denote journal, those with its keyword.
76 public func files() -> [String] { 106 public func files() -> [String] {
77 let paths = (FileManager.default.enumerator(atPath: directory)?.allObjects as? [String]) ?? [] 107 let paths = (FileManager.default.enumerator(atPath: directory)?.allObjects as? [String]) ?? []
78 return paths.compactMap { relative -> String? in 108 return paths.compactMap { relative -> String? in
79 let name = (relative as NSString).lastPathComponent 109 let name = (relative as NSString).lastPathComponent
80 guard (relative as NSString).pathExtension == "org", !relative.split(separator: "/").contains(where: { $0.hasPrefix(".") }), 110 guard (relative as NSString).pathExtension == "org", !relative.split(separator: "/").contains(where: { $0.hasPrefix(".") }),
81 !name.hasPrefix("#"), !name.hasSuffix("~") else { return nil } 111 !name.hasPrefix("#"), !name.hasSuffix("~") else { return nil }
112 if let journal, !Denote.name(ofFile: name).keywords.contains(journal.keyword) { return nil }
82 return (directory as NSString).appendingPathComponent(relative) 113 return (directory as NSString).appendingPathComponent(relative)
83 }.sorted() 114 }.sorted()
84 } 115 }
Sources/OrgApp/DenoteNote.swift added +26
@@ -0,0 +1,26 @@
1import Foundation
2import OrgCore
3
4/// A new Denote note, as `denote` makes it with the default `denote-prompts` (title and
5/// keywords): `IDENTIFIER--title__keywords.org` in `denote-directory`, starting with the
6/// Org front matter.
7public enum DenoteNote {
8 /// `denote-directory`: the setting, else the first folder.
9 public static func directory(roots: [String], defaults: UserDefaults = .standard) -> String? {
10 let denote = OrgPreferences.denoteDirectory(defaults)
11 return denote.isEmpty ? roots.first : OrgAttach.expand(denote, in: roots.first ?? NSHomeDirectory())
12 }
13
14 /// Makes the note's file in `folder`. Fails rather than replace a file that's there.
15 public static func create(title: String, keywords: [String], in folder: String, now: Date = Date()) throws -> (path: String, id: String) {
16 let id = Denote.identifier(for: now)
17 let keywords = Denote.keywords(keywords)
18 let name = Denote.fileName(identifier: id, title: title, keywords: keywords)
19 let path = (folder as NSString).appendingPathComponent(name)
20 try FileManager.default.createDirectory(atPath: folder, withIntermediateDirectories: true)
21 guard !FileManager.default.fileExists(atPath: path) else { throw Dailies.Failure("\(name) is already there") }
22 let text = Denote.frontMatter(title: title, date: now, keywords: keywords, identifier: id)
23 try Data(text.utf8).write(to: URL(fileURLWithPath: path), options: .withoutOverwriting)
24 return (path, id)
25 }
26}
Sources/OrgApp/EmacsImport.swift +8 −1
@@ -416,7 +416,7 @@ public struct EmacsImport: Sendable {
416 416
417 // MARK: - Results 417 // MARK: - Results
418 418
419 static let orgRelated = ["org-", "appt-", "display-line-numbers", "fill-column", "evil-", "doom-font", "doom-variable-pitch-font", "doom-theme", "calendar-week-start-day"] 419 static let orgRelated = ["org-", "denote-", "appt-", "display-line-numbers", "fill-column", "evil-", "doom-font", "doom-variable-pitch-font", "doom-theme", "calendar-week-start-day"]
420 420
421 mutating func build(from scanner: Scanner) { 421 mutating func build(from scanner: Scanner) {
422 var next = 0 422 var next = 0
@@ -557,6 +557,13 @@ public struct EmacsImport: Sendable {
557 add(name, .string(format)) 557 add(name, .string(format))
558 case "org-timer-default-timer": 558 case "org-timer-default-timer":
559 if let text = value.string { add(name, .string(text)) } else if let number = value.integer { add(name, .string(String(number))) } else { note("not a string or number") } 559 if let text = value.string { add(name, .string(text)) } else if let number = value.integer { add(name, .string(String(number))) } else { note("not a string or number") }
560 case "denote-directory", "denote-journal-directory", "denote-journal-keyword":
561 guard let text = value.string else { return note("not a string") }
562 add(name, .string(text))
563 case "denote-journal-title-format":
564 let formats = ["day-date-month-year": "%A %e %B %Y", "day-date-month-year-24h": "%A %e %B %Y %H:%M",
565 "day-date-month-year-12h": "%A %e %B %Y %I:%M %p"]
566 if let format = value.string ?? value.symbol.flatMap({ formats[$0] }) { add(name, .string(format)) } else { note("not a format or a known style") }
560 case "org-roam-directory", "org-roam-dailies-directory": 567 case "org-roam-directory", "org-roam-dailies-directory":
561 guard let dir = value.string else { return note("not a string") } 568 guard let dir = value.string else { return note("not a string") }
562 add(name, .string(dir)) 569 add(name, .string(dir))
Sources/OrgApp/OrgPreferences.swift +9
@@ -172,6 +172,15 @@ public enum OrgPreferences {
172 public static func dailiesFile(_ defaults: UserDefaults = .standard) -> String { string("dailiesFile", defaults).nonEmpty ?? "%<%Y-%m-%d>.org" } 172 public static func dailiesFile(_ defaults: UserDefaults = .standard) -> String { string("dailiesFile", defaults).nonEmpty ?? "%<%Y-%m-%d>.org" }
173 public static func dailiesHead(_ defaults: UserDefaults = .standard) -> String { string("dailiesHead", defaults).nonEmpty ?? "#+title: %<%Y-%m-%d>\n" } 173 public static func dailiesHead(_ defaults: UserDefaults = .standard) -> String { string("dailiesHead", defaults).nonEmpty ?? "#+title: %<%Y-%m-%d>\n" }
174 public static func dailiesEntry(_ defaults: UserDefaults = .standard) -> String { string("dailiesEntry", defaults).nonEmpty ?? "* %?" } 174 public static func dailiesEntry(_ defaults: UserDefaults = .standard) -> String { string("dailiesEntry", defaults).nonEmpty ?? "* %?" }
175 /// Whether the note and daily-note commands follow Denote rather than org-roam.
176 public static func usesDenote(_ defaults: UserDefaults = .standard) -> Bool { string("notesPackage", defaults) == "denote" }
177 /// `denote-directory`; empty for the first folder.
178 public static func denoteDirectory(_ defaults: UserDefaults = .standard) -> String { string("denoteDirectory", defaults) }
179 /// `denote-journal-directory`, relative to `denote-directory` unless absolute.
180 public static func denoteJournalDirectory(_ defaults: UserDefaults = .standard) -> String { string("denoteJournalDirectory", defaults).nonEmpty ?? "journal" }
181 public static func denoteJournalKeyword(_ defaults: UserDefaults = .standard) -> String { string("denoteJournalKeyword", defaults).nonEmpty ?? "journal" }
182 /// `denote-journal-title-format`, a `format-time-string` format.
183 public static func denoteJournalTitle(_ defaults: UserDefaults = .standard) -> String { string("denoteJournalTitle", defaults).nonEmpty ?? "%A %e %B %Y" }
175 /// `org-attach-id-dir`, relative to an org file's folder unless absolute. 184 /// `org-attach-id-dir`, relative to an org file's folder unless absolute.
176 public static func attachIDDir(_ defaults: UserDefaults = .standard) -> String { 185 public static func attachIDDir(_ defaults: UserDefaults = .standard) -> String {
177 let dir = string("attachIDDir", defaults) 186 let dir = string("attachIDDir", defaults)
Sources/OrgApp/RoamActions.swift +49 −4
@@ -3,7 +3,8 @@ import OrgCore
3import OrgIndex 3import OrgIndex
4 4
5/// The `app.dailies.` and `app.node.` commands: org-roam's daily notes, and finding and 5/// The `app.dailies.` and `app.node.` commands: org-roam's daily notes, and finding and
6/// linking ID nodes, with the platform's questions and file opening. 6/// linking ID nodes, or with Denote set, denote-journal's entries and Denote's notes, with
7/// the platform's questions and file opening.
7@MainActor 8@MainActor
8public struct RoamActions { 9public struct RoamActions {
9 public var session: DocumentSession 10 public var session: DocumentSession
@@ -37,6 +38,8 @@ public struct RoamActions {
37 } 38 }
38 39
39 private var dailies: Dailies? { Dailies.configured(roots: roots()) } 40 private var dailies: Dailies? { Dailies.configured(roots: roots()) }
41 private var denote: Bool { OrgPreferences.usesDenote() }
42 private var linkType: String { denote ? "denote:" : "id:" }
40 43
41 private func day(_ offset: Int, from now: Date = Date()) -> Date { 44 private func day(_ offset: Int, from now: Date = Date()) -> Date {
42 Calendar.current.date(byAdding: .day, value: offset, to: now) ?? now 45 Calendar.current.date(byAdding: .day, value: offset, to: now) ?? now
@@ -72,6 +75,8 @@ public struct RoamActions {
72 } catch { 75 } catch {
73 show("\(error)") 76 show("\(error)")
74 } 77 }
78 case "app.node.rename-from-front-matter":
79 renameFromFrontMatter()
75 case "app.node.find": 80 case "app.node.find":
76 chooseNode("Node: ") { choice in 81 chooseNode("Node: ") { choice in
77 switch choice { 82 switch choice {
@@ -82,8 +87,8 @@ public struct RoamActions {
82 case "app.node.insert": 87 case "app.node.insert":
83 chooseNode("Node: ") { choice in 88 chooseNode("Node: ") { choice in
84 switch choice { 89 switch choice {
85 case .existing(let node): insertLink("id:" + node.id, node.title) 90 case .existing(let node): insertLink(linkType + node.id, node.title)
86 case .created(_, let id, let title): insertLink("id:" + id, title) 91 case .created(_, let id, let title): insertLink(linkType + id, title)
87 } 92 }
88 } 93 }
89 default: 94 default:
@@ -146,7 +151,8 @@ public struct RoamActions {
146 } 151 }
147 152
148 /// `org-roam-node-read`: a node by its title, with its file's name when titles repeat. A 153 /// `org-roam-node-read`: a node by its title, with its file's name when titles repeat. A
149 /// title no node has makes a node with it, as org-roam's default capture template does. 154 /// title no node has makes a node with it, as org-roam's default capture template does;
155 /// with Denote, `denote` asks for its keywords and makes the note.
150 private func chooseNode(_ message: String, _ then: @escaping (NodeChoice) -> Void) { 156 private func chooseNode(_ message: String, _ then: @escaping (NodeChoice) -> Void) {
151 let all = nodes() 157 let all = nodes()
152 let counts = Dictionary(all.map { ($0.title, 1) }, uniquingKeysWith: +) 158 let counts = Dictionary(all.map { ($0.title, 1) }, uniquingKeysWith: +)
@@ -158,6 +164,7 @@ public struct RoamActions {
158 if let index = labels.firstIndex(of: answer) { return then(.existing(all[index])) } 164 if let index = labels.firstIndex(of: answer) { return then(.existing(all[index])) }
159 let title = answer.trimmingCharacters(in: .whitespaces) 165 let title = answer.trimmingCharacters(in: .whitespaces)
160 guard !title.isEmpty else { return } 166 guard !title.isEmpty else { return }
167 if denote { return createDenote(title, known: all, then) }
161 guard let folder = RoamNode.directory(roots: roots()) else { return show("No folder for new nodes") } 168 guard let folder = RoamNode.directory(roots: roots()) else { return show("No folder for new nodes") }
162 do { 169 do {
163 let node = try RoamNode.create(title: title, in: folder) 170 let node = try RoamNode.create(title: title, in: folder)
@@ -169,4 +176,42 @@ public struct RoamActions {
169 } 176 }
170 } 177 }
171 } 178 }
179
180 /// `denote`: the keywords, separated by commas or spaces, then the note in
181 /// `denote-directory`. The keywords already in file names are offered.
182 private func createDenote(_ title: String, known: [IndexStore.Node], _ then: @escaping (NodeChoice) -> Void) {
183 let keywords = Denote.keywords(known.flatMap { Denote.name(ofFile: $0.location.path).keywords })
184 ask(Prompt(key: "keywords", message: "New file KEYWORDS: ", choices: keywords, requireMatch: false)) { answer in
185 guard let answer else { return }
186 guard let folder = DenoteNote.directory(roots: roots()) else { return show("No folder for new notes") }
187 do {
188 let note = try DenoteNote.create(title: title, keywords: answer.split(whereSeparator: { $0 == "," || $0.isWhitespace }).map(String.init), in: folder)
189 refresh()
190 show("Created \((note.path as NSString).lastPathComponent)")
191 then(.created(path: note.path, id: note.id, title: title))
192 } catch {
193 show("Can't make the note: \(error)")
194 }
195 }
196 }
197
198 /// `denote-rename-file-using-front-matter`: the open file renamed from its title and
199 /// keywords, keeping its identifier and signature.
200 func renameFromFrontMatter() {
201 guard let path = session.path else { return show("No file is open") }
202 guard let text = session.text(of: path) else { return show("Can't read \((path as NSString).lastPathComponent)") }
203 guard let target = Denote.renamed(path, text: text) else { return show("Not a Denote note: no identifier") }
204 guard target != path else { return show("Nothing to rename") }
205 guard !FileManager.default.fileExists(atPath: target) else { return show("\((target as NSString).lastPathComponent) is already there") }
206 guard session.save(path) else { return show("Can't save \((path as NSString).lastPathComponent)") }
207 do {
208 try FileManager.default.moveItem(atPath: path, toPath: target)
209 session.kill(path)
210 refresh()
211 open(target, 0)
212 show("Renamed to \((target as NSString).lastPathComponent)")
213 } catch {
214 show("Can't rename: \(error.localizedDescription)")
215 }
216 }
172} 217}
Sources/OrgApp/UserConfig.swift +10
@@ -175,6 +175,16 @@ public enum UserConfig {
175 comment: "what a new daily note starts with, under its ID", legacy: ""), 175 comment: "what a new daily note starts with, under its ID", legacy: ""),
176 Setting(section: "", key: "org-roam-dailies-entry", defaultsKey: "dailiesEntry", kind: .string, fallback: .string("* %?"), 176 Setting(section: "", key: "org-roam-dailies-entry", defaultsKey: "dailiesEntry", kind: .string, fallback: .string("* %?"),
177 comment: "the capture template Capture to Daily Note files", legacy: ""), 177 comment: "the capture template Capture to Daily Note files", legacy: ""),
178 Setting(section: "", key: "notes-package", defaultsKey: "notesPackage", kind: .choice([("org-roam", "org-roam"), ("denote", "denote")]),
179 fallback: .string("org-roam"), comment: "whose conventions Find Node, Insert Node Link and the daily-note commands follow: org-roam or denote", legacy: ""),
180 Setting(section: "", key: "denote-directory", defaultsKey: "denoteDirectory", kind: .string, fallback: .string(""),
181 comment: "the folder new Denote notes go in; empty for the first folder", legacy: ""),
182 Setting(section: "", key: "denote-journal-directory", defaultsKey: "denoteJournalDirectory", kind: .string, fallback: .string("journal"),
183 comment: "the folder denote-journal entries are in, relative to denote-directory", legacy: ""),
184 Setting(section: "", key: "denote-journal-keyword", defaultsKey: "denoteJournalKeyword", kind: .string, fallback: .string("journal"),
185 comment: "the keyword journal entries have", legacy: ""),
186 Setting(section: "", key: "denote-journal-title-format", defaultsKey: "denoteJournalTitle", kind: .string, fallback: .string("%A %e %B %Y"),
187 comment: "a journal entry's title; a format-time-string format", legacy: ""),
178 Setting(section: "", key: "auto-fill-mode", defaultsKey: "autoFill", kind: .bool, fallback: .bool(false), 188 Setting(section: "", key: "auto-fill-mode", defaultsKey: "autoFill", kind: .bool, fallback: .bool(false),
179 comment: "typing a space past fill-column breaks the line (View ▸ Auto Fill)", legacy: ""), 189 comment: "typing a space past fill-column breaks the line (View ▸ Auto Fill)", legacy: ""),
180 Setting(section: "", key: "org-timer-format", defaultsKey: "timerFormat", kind: .string, fallback: .string("%s "), 190 Setting(section: "", key: "org-timer-format", defaultsKey: "timerFormat", kind: .string, fallback: .string("%s "),
Sources/OrgApp/WorkspaceModel.swift +3 −3
@@ -381,9 +381,9 @@ public final class WorkspaceModel {
381 } 381 }
382 } 382 }
383 383
384 /// Headings and files with IDs (org-roam's nodes). 384 /// Headings and files with IDs (org-roam's nodes), or Denote's notes.
385 public func nodes(overlay: [String: FileRecord] = [:]) -> [IndexStore.Node] { 385 public func nodes(overlay: [String: FileRecord] = [:], denote: Bool = OrgPreferences.usesDenote()) -> [IndexStore.Node] {
386 (try? index.nodes(overlay: overlay)) ?? [] 386 (try? denote ? index.denoteNodes(overlay: overlay) : index.nodes(overlay: overlay)) ?? []
387 } 387 }
388 388
389 public func search(_ query: String, overlay: [String: FileRecord] = [:]) -> [HeadingLocation] { 389 public func search(_ query: String, overlay: [String: FileRecord] = [:]) -> [HeadingLocation] {
Sources/OrgCore/Links/Denote.swift +123
@@ -24,4 +24,127 @@ public enum Denote {
24 let matches = paths.filter { Self.identifier(ofFile: $0) == identifier } 24 let matches = paths.filter { Self.identifier(ofFile: $0) == identifier }
25 return matches.first { ($0 as NSString).pathExtension == "org" } ?? matches.first 25 return matches.first { ($0 as NSString).pathExtension == "org" } ?? matches.first
26 } 26 }
27
28 // MARK: - Naming new files
29
30 /// `denote-excluded-punctuation-regexp`.
31 static let punctuation = Set("[]{}!@#$%^&*()+'\"?,.|;:~`‘’“”=<>/")
32
33 /// `denote-sluggify-title`: without punctuation, spaces and underscores as one `-`, none
34 /// at either end, lower case.
35 public static func slug(_ title: String) -> String {
36 var out = ""
37 for character in title.lowercased() where !punctuation.contains(character) {
38 if character.isWhitespace || character == "_" || character == "-" {
39 if !out.isEmpty, out.last != "-" { out.append("-") }
40 } else {
41 out.append(character)
42 }
43 }
44 while out.last == "-" { out.removeLast() }
45 return out
46 }
47
48 /// `denote-sluggify-keyword`: one word, lower case, without punctuation or spaces.
49 public static func keyword(_ word: String) -> String {
50 String(word.lowercased().filter { !punctuation.contains($0) && !$0.isWhitespace && $0 != "_" && $0 != "-" })
51 }
52
53 /// Keywords as `denote-keywords-sort` keeps them: sluggified, without empties or repeats,
54 /// sorted.
55 public static func keywords(_ words: [String]) -> [String] {
56 Array(Set(words.map(keyword).filter { !$0.isEmpty })).sorted()
57 }
58
59 /// `%Y%m%dT%H%M%S` in `calendar`'s time zone.
60 public static func identifier(for date: Date, calendar: Calendar = .current) -> String {
61 let c = calendar.dateComponents([.year, .month, .day, .hour, .minute, .second], from: date)
62 return String(format: "%04d%02d%02dT%02d%02d%02d", c.year!, c.month!, c.day!, c.hour!, c.minute!, c.second!)
63 }
64
65 /// `denote-format-file-name` in the default component order: identifier, signature,
66 /// title, keywords.
67 public static func fileName(identifier: String, signature: String? = nil, title: String, keywords: [String], extension ext: String = "org") -> String {
68 var name = identifier
69 if let signature, !signature.isEmpty { name += "==" + signature }
70 let slug = slug(title)
71 if !slug.isEmpty { name += "--" + slug }
72 if !keywords.isEmpty { name += "__" + keywords.joined(separator: "_") }
73 return name + "." + ext
74 }
75
76 /// `denote-org-front-matter`, dated as an inactive Org timestamp.
77 public static func frontMatter(title: String, date: Date, keywords: [String], identifier: String, calendar: Calendar = .current) -> String {
78 let c = calendar.dateComponents([.year, .month, .day, .weekday, .hour, .minute], from: date)
79 let day = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"][c.weekday! - 1]
80 let stamp = String(format: "[%04d-%02d-%02d %@ %02d:%02d]", c.year!, c.month!, c.day!, day, c.hour!, c.minute!)
81 let tags = keywords.isEmpty ? "" : ":" + keywords.joined(separator: ":") + ":"
82 return """
83 #+title: \(title)
84 #+date: \(stamp)
85 #+filetags: \(tags)
86 #+identifier: \(identifier)
87
88
89 """
90 }
91
92 // MARK: - Reading names and front matter
93
94 /// The parts of a Denote file name, in any component order.
95 public struct Name: Sendable, Equatable {
96 public var identifier: String?
97 public var signature: String?
98 public var title: String?
99 public var keywords: [String]
100 public var ext: String
101 }
102
103 public static func name(ofFile path: String) -> Name {
104 let file = (path as NSString).lastPathComponent
105 let ext = (file as NSString).pathExtension
106 let stem = ext.isEmpty ? file : String(file.dropLast(ext.count + 1))
107 var name = Name(identifier: identifier(ofFile: file), keywords: [], ext: ext)
108 for match in stem.matches(of: /(--|__|==)(.+?)(?=--|__|==|@@|$)/) {
109 let value = String(match.2)
110 switch match.1 {
111 case "--": name.title = value
112 case "__": name.keywords = value.split(separator: "_").map(String.init)
113 default: name.signature = value
114 }
115 }
116 return name
117 }
118
119 /// The `#+title`, `#+filetags` and `#+identifier` of a file's front matter.
120 public static func frontMatter(of text: String) -> (title: String?, keywords: [String]?, identifier: String?) {
121 func value(_ key: String) -> String? {
122 for line in text.split(separator: "\n", omittingEmptySubsequences: false).prefix(40) {
123 let trimmed = line.trimmingCharacters(in: .whitespaces)
124 guard trimmed.lowercased().hasPrefix("#+" + key + ":") else { continue }
125 return trimmed.dropFirst(key.count + 3).trimmingCharacters(in: .whitespaces)
126 }
127 return nil
128 }
129 let keywords = value("filetags").map { $0.split(separator: ":").map(String.init).filter { !$0.isEmpty } }
130 return (value("title"), keywords, value("identifier")?.nonEmptyOrNil)
131 }
132
133 /// `denote-rename-file-using-front-matter`: the name the file at `path` takes from its
134 /// front matter, keeping the identifier and signature. Nil when the file has no identifier
135 /// in its name or front matter.
136 public static func renamed(_ path: String, text: String) -> String? {
137 let current = name(ofFile: path)
138 let front = frontMatter(of: text)
139 guard let identifier = current.identifier ?? front.identifier else { return nil }
140 let title = front.title ?? current.title.map { $0.replacingOccurrences(of: "-", with: " ") } ?? ""
141 let keywords = keywords(front.keywords ?? current.keywords)
142 let file = fileName(identifier: identifier, signature: current.signature, title: title, keywords: keywords,
143 extension: current.ext.isEmpty ? "org" : current.ext)
144 return ((path as NSString).deletingLastPathComponent as NSString).appendingPathComponent(file)
145 }
146}
147
148private extension String {
149 var nonEmptyOrNil: String? { isEmpty ? nil : self }
27} 150}
Sources/OrgEditorAppKit/EditorCommands.swift +1
@@ -121,6 +121,7 @@ public enum EditorCommands {
121 EditorCommand(id: "app.dailies.previous", title: "Previous Daily Note", action: .app), 121 EditorCommand(id: "app.dailies.previous", title: "Previous Daily Note", action: .app),
122 EditorCommand(id: "app.node.find", title: "Find Node…", action: .app), 122 EditorCommand(id: "app.node.find", title: "Find Node…", action: .app),
123 EditorCommand(id: "app.node.insert", title: "Insert Node Link…", action: .app), 123 EditorCommand(id: "app.node.insert", title: "Insert Node Link…", action: .app),
124 EditorCommand(id: "app.node.rename-from-front-matter", title: "Rename Note from Front Matter", action: .app),
124 EditorCommand(id: "app.attach.attach", title: "Attach File…", action: .app), 125 EditorCommand(id: "app.attach.attach", title: "Attach File…", action: .app),
125 EditorCommand(id: "app.attach.move", title: "Attach File by Moving…", action: .app), 126 EditorCommand(id: "app.attach.move", title: "Attach File by Moving…", action: .app),
126 EditorCommand(id: "app.attach.link", title: "Attach File as Hard Link…", action: .app), 127 EditorCommand(id: "app.attach.link", title: "Attach File as Hard Link…", action: .app),
Sources/OrgIndex/IndexStore.swift +15
@@ -1,5 +1,6 @@
1import Foundation 1import Foundation
2import GRDB 2import GRDB
3import OrgCore
3 4
4/// What the index knows about a file without reading it. 5/// What the index knows about a file without reading it.
5public struct FileState: Sendable, Equatable { 6public struct FileState: Sendable, Equatable {
@@ -440,6 +441,20 @@ public final class IndexStore: Sendable {
440 return indexed.filter { overlay[$0.location.path] == nil } + live 441 return indexed.filter { overlay[$0.location.path] == nil } + live
441 } 442 }
442 443
444 /// Every Org file with a Denote identifier in its name, as a node with that identifier,
445 /// titled by its `#+TITLE`, else its name; unsaved buffers' titles in place of their files'.
446 public func denoteNodes(overlay: [String: FileRecord] = [:]) throws -> [Node] {
447 func node(_ path: String, _ title: String?, _ hash: String) -> Node? {
448 guard let id = Denote.identifier(ofFile: path) else { return nil }
449 return Node(id: id, title: title ?? ((path as NSString).lastPathComponent as NSString).deletingPathExtension, location: .file(path, contentHash: hash))
450 }
451 let indexed = try database.read { db in
452 try Row.fetchAll(db, sql: "SELECT path, hash, title FROM files WHERE kind = 'org' ORDER BY path").compactMap { node($0["path"], $0["title"], $0["hash"]) }
453 }
454 let live = overlay.values.sorted { $0.path < $1.path }.compactMap { node($0.path, $0.title, $0.hash) }
455 return indexed.filter { overlay[$0.location.path] == nil } + live
456 }
457
443 /// Every link and the heading it's in, or the file for links before its first heading, 458 /// Every link and the heading it's in, or the file for links before its first heading,
444 /// unsaved buffers' in place of their files'. 459 /// unsaved buffers' in place of their files'.
445 public func links(overlay: [String: FileRecord] = [:]) throws -> [(source: HeadingLocation, target: String)] { 460 public func links(overlay: [String: FileRecord] = [:]) throws -> [(source: HeadingLocation, target: String)] {
Sources/OrgstarMobile/EditorScreen.swift +1
@@ -931,6 +931,7 @@ struct CommandPalette: View {
931 ("app.crypt.encrypt-entry", "Encrypt Entry…"), ("app.crypt.open-entry", "Decrypt Entry…"), ("app.crypt.decrypt-entry", "Decrypt Entry in File…"), 931 ("app.crypt.encrypt-entry", "Encrypt Entry…"), ("app.crypt.open-entry", "Decrypt Entry…"), ("app.crypt.decrypt-entry", "Decrypt Entry in File…"),
932 ("app.crypt.encrypt-entries", "Encrypt Tagged Entries…"), ("app.crypt.forget-passphrase", "Forget Encryption Passphrase"), 932 ("app.crypt.encrypt-entries", "Encrypt Tagged Entries…"), ("app.crypt.forget-passphrase", "Forget Encryption Passphrase"),
933 ("app.backlinks", "Show Backlinks"), ("app.node.find", "Find Node…"), ("app.node.insert", "Insert Node Link…"), 933 ("app.backlinks", "Show Backlinks"), ("app.node.find", "Find Node…"), ("app.node.insert", "Insert Node Link…"),
934 ("app.node.rename-from-front-matter", "Rename Note from Front Matter"),
934 ("app.dailies.today", "Go to Today's Daily Note"), ("app.dailies.yesterday", "Go to Yesterday's Daily Note"), 935 ("app.dailies.today", "Go to Today's Daily Note"), ("app.dailies.yesterday", "Go to Yesterday's Daily Note"),
935 ("app.dailies.tomorrow", "Go to Tomorrow's Daily Note"), ("app.dailies.date", "Go to Daily Note for Date…"), 936 ("app.dailies.tomorrow", "Go to Tomorrow's Daily Note"), ("app.dailies.date", "Go to Daily Note for Date…"),
936 ("app.dailies.capture-today", "Capture to Today's Daily Note"), ("app.dailies.capture-yesterday", "Capture to Yesterday's Daily Note"), 937 ("app.dailies.capture-today", "Capture to Today's Daily Note"), ("app.dailies.capture-yesterday", "Capture to Yesterday's Daily Note"),
Sources/OrgstarMobile/MobileEditor.swift +2 −1
@@ -405,7 +405,8 @@ final class MobileEditor: NSObject, DocumentBuffer {
405 "app.clock.goto-recent", "app.clock.default", "app.clock.resolve", "app.toggle-markup": return onAppCommand != nil 405 "app.clock.goto-recent", "app.clock.default", "app.clock.resolve", "app.toggle-markup": return onAppCommand != nil
406 case "app.refile.goto", "app.table-import", "app.crypt.encrypt-entries", "app.crypt.forget-passphrase", "app.attach.attach", "app.attach.url", 406 case "app.refile.goto", "app.table-import", "app.crypt.encrypt-entries", "app.crypt.forget-passphrase", "app.attach.attach", "app.attach.url",
407 "app.attach.new", "app.attach.open", "app.attach.reveal", "app.attach.delete", "app.attach.delete-all", "app.attach.sync", 407 "app.attach.new", "app.attach.open", "app.attach.reveal", "app.attach.delete", "app.attach.delete-all", "app.attach.sync",
408 "app.attach.set-directory", "app.attach.unset-directory", "app.backlinks", "app.node.find", "app.node.insert": return onAppCommand != nil 408 "app.attach.set-directory", "app.attach.unset-directory", "app.backlinks", "app.node.find", "app.node.insert",
409 "app.node.rename-from-front-matter": return onAppCommand != nil
409 case _ where id.hasPrefix("app.dailies."): return onAppCommand != nil 410 case _ where id.hasPrefix("app.dailies."): return onAppCommand != nil
410 case "app.crypt.encrypt-entry": return onAppCommand != nil && OrgCrypt.heading(context.text, at: context.caret) != nil && OrgCrypt.encryptedRange(context.text, at: context.caret) == nil 411 case "app.crypt.encrypt-entry": return onAppCommand != nil && OrgCrypt.heading(context.text, at: context.caret) != nil && OrgCrypt.encryptedRange(context.text, at: context.caret) == nil
411 case "app.crypt.open-entry", "app.crypt.decrypt-entry": return onAppCommand != nil && OrgCrypt.encryptedRange(context.text, at: context.caret) != nil 412 case "app.crypt.open-entry", "app.crypt.decrypt-entry": return onAppCommand != nil && OrgCrypt.encryptedRange(context.text, at: context.caret) != nil
Tests/OrgAppTests/DailiesTests.swift +58
@@ -56,6 +56,53 @@ struct DailiesTests {
56 #expect(try dailies.ensure(Self.day).created == false) 56 #expect(try dailies.ensure(Self.day).created == false)
57 } 57 }
58 58
59 @Test func denoteJournalEntries() throws {
60 let folder = FileManager.default.temporaryDirectory.appendingPathComponent("orgstar-journal-\(UUID().uuidString)").resolvingSymlinksInPath()
61 defer { try? FileManager.default.removeItem(at: folder) }
62 let journal = Dailies(directory: folder.path, journal: Dailies.Journal())
63 let made = try journal.ensure(Self.day)
64 #expect(made.created && (made.path as NSString).lastPathComponent == "20261011T120000--sunday-11-october-2026__journal.org")
65 #expect(try String(contentsOfFile: made.path, encoding: .utf8).hasPrefix("#+title: Sunday 11 October 2026\n#+date: [2026-10-11 Sun 12:00]\n#+filetags: :journal:\n"))
66 // Another time the same day finds the entry.
67 let later = Calendar.current.date(byAdding: .hour, value: 3, to: Self.day)!
68 #expect(try journal.ensure(later) == (made.path, false))
69 try journal.ensure(Calendar.current.date(byAdding: .day, value: -2, to: Self.day)!)
70 try "x".write(to: folder.appendingPathComponent("20261010T080000--not-a-journal__work.org"), atomically: true, encoding: .utf8)
71 #expect(journal.files().map { ($0 as NSString).lastPathComponent } == ["20261009T120000--friday-9-october-2026__journal.org", (made.path as NSString).lastPathComponent])
72 #expect(try (journal.neighbor(of: made.path, by: -1) as NSString).lastPathComponent == "20261009T120000--friday-9-october-2026__journal.org")
73 }
74
75 @Test func newDenoteNote() throws {
76 let folder = FileManager.default.temporaryDirectory.appendingPathComponent("orgstar-denote-\(UUID().uuidString)").path
77 defer { try? FileManager.default.removeItem(atPath: folder) }
78 let note = try DenoteNote.create(title: "Field Notes", keywords: ["Work", "ideas"], in: folder, now: Self.day)
79 #expect((note.path as NSString).lastPathComponent == "20261011T120000--field-notes__ideas_work.org" && note.id == "20261011T120000")
80 #expect(try String(contentsOfFile: note.path, encoding: .utf8).hasPrefix("#+title: Field Notes\n"))
81 #expect(throws: (any Error).self) { try DenoteNote.create(title: "Field Notes", keywords: ["work", "ideas"], in: folder, now: Self.day) }
82 }
83
84 @MainActor
85 @Test func renamesFromFrontMatter() throws {
86 let folder = FileManager.default.temporaryDirectory.appendingPathComponent("orgstar-denote-\(UUID().uuidString)").resolvingSymlinksInPath()
87 defer { try? FileManager.default.removeItem(at: folder) }
88 try FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true)
89 let old = folder.appendingPathComponent("20261011T120000--old__x.org").path
90 try "#+title: Old\n#+filetags: :x:\n".write(toFile: old, atomically: true, encoding: .utf8)
91 let session = DocumentSession(recovery: FileRecoveryStore(directory: folder.appendingPathComponent(".r")))
92 session.open(old)
93 var opened: String?
94 var shown: [String] = []
95 let actions = RoamActions(session: session, roots: { [folder.path] }, nodes: { [] }, show: { shown.append($0) }, ask: { $1(nil) },
96 open: { path, _ in opened = path }, insertLink: { _, _ in }, refresh: {})
97 if case .failed = session.perform(ReplaceText(old: "#+title: Old\n#+filetags: :x:\n", new: "#+title: New Name\n#+filetags: :x:y:\n"), path: old, at: 0, expect: nil) {
98 Issue.record("edit failed"); return
99 }
100 actions.renameFromFrontMatter()
101 let new = folder.appendingPathComponent("20261011T120000--new-name__x_y.org").path
102 #expect(opened == new && !FileManager.default.fileExists(atPath: old), "\(shown)")
103 #expect(try String(contentsOfFile: new, encoding: .utf8) == "#+title: New Name\n#+filetags: :x:y:\n")
104 }
105
59 @MainActor 106 @MainActor
60 @Test func captureFilesTheEntryAtTheEnd() throws { 107 @Test func captureFilesTheEntryAtTheEnd() throws {
61 let folder = FileManager.default.temporaryDirectory.appendingPathComponent("orgstar-daily-\(UUID().uuidString)").resolvingSymlinksInPath() 108 let folder = FileManager.default.temporaryDirectory.appendingPathComponent("orgstar-daily-\(UUID().uuidString)").resolvingSymlinksInPath()
@@ -74,6 +121,17 @@ struct DailiesTests {
74} 121}
75 122
76struct NodeIndexTests { 123struct NodeIndexTests {
124 @Test func denoteNotesAreNodes() throws {
125 let store = try IndexStore()
126 let settings = IndexSettings()
127 try store.write(FileRecord(path: "/n/20261011T120000--a__x.org", root: "/n", kind: .org, bytes: Array("#+title: A note\n".utf8), mtime: 1, settings: settings))
128 try store.write(FileRecord(path: "/n/20261012T120000--untitled.org", root: "/n", kind: .org, bytes: [], mtime: 1, settings: settings))
129 try store.write(FileRecord(path: "/n/plain.org", root: "/n", kind: .org, bytes: Array("#+title: Plain\n".utf8), mtime: 1, settings: settings))
130 let nodes = try store.denoteNodes()
131 #expect(nodes.map(\.id) == ["20261011T120000", "20261012T120000"])
132 #expect(nodes.map(\.title) == ["A note", "20261012T120000--untitled"])
133 }
134
77 @Test func filesAndHeadingsWithIDsAreNodes() throws { 135 @Test func filesAndHeadingsWithIDsAreNodes() throws {
78 let store = try IndexStore() 136 let store = try IndexStore()
79 let settings = IndexSettings() 137 let settings = IndexSettings()
Tests/OrgAppTests/EmacsImportTests.swift +16
@@ -264,6 +264,22 @@ struct EmacsImportTests {
264 #expect(s["org-roam-dailies-entry"] == .string("* %<%H:%M> %?")) 264 #expect(s["org-roam-dailies-entry"] == .string("* %<%H:%M> %?"))
265 } 265 }
266 266
267 @Test func readsDenote() throws {
268 let folder = FileManager.default.temporaryDirectory.appendingPathComponent("orgstar-import-\(UUID().uuidString)")
269 try FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true)
270 defer { try? FileManager.default.removeItem(at: folder) }
271 try #"""
272 (setq denote-directory "~/notes/")
273 (setq denote-journal-directory "~/notes/journal/" denote-journal-keyword "diary")
274 (setq denote-journal-title-format 'day-date-month-year-24h)
275 """#.write(to: folder.appendingPathComponent("init.el"), atomically: true, encoding: .utf8)
276 let s = settings(EmacsImport.scan(EmacsImport.files(in: folder)))
277 #expect(s["denote-directory"] == .string("~/notes/"))
278 #expect(s["denote-journal-directory"] == .string("~/notes/journal/"))
279 #expect(s["denote-journal-keyword"] == .string("diary"))
280 #expect(s["denote-journal-title-format"] == .string("%A %e %B %Y %H:%M"))
281 }
282
267 @Test func readsPublishingProjects() async throws { 283 @Test func readsPublishingProjects() async throws {
268 let folder = FileManager.default.temporaryDirectory.appendingPathComponent("orgstar-import-\(UUID().uuidString)") 284 let folder = FileManager.default.temporaryDirectory.appendingPathComponent("orgstar-import-\(UUID().uuidString)")
269 try FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true) 285 try FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true)
Tests/OrgCoreTests/DenoteTests.swift +38
@@ -1,3 +1,4 @@
1import Foundation
1import Testing 2import Testing
2@testable import OrgCore 3@testable import OrgCore
3 4
@@ -21,4 +22,41 @@ struct DenoteTests {
21 #expect(Denote.file(withIdentifier: "20261119T120000", in: paths) == "/n/20261119T120000--a.org") 22 #expect(Denote.file(withIdentifier: "20261119T120000", in: paths) == "/n/20261119T120000--a.org")
22 #expect(Denote.file(withIdentifier: "20261119T120002", in: paths) == nil) 23 #expect(Denote.file(withIdentifier: "20261119T120002", in: paths) == nil)
23 } 24 }
25
26 /// 2026-11-19 09:05:03, a Thursday, in UTC.
27 static let calendar: Calendar = { var c = Calendar(identifier: .gregorian); c.timeZone = TimeZone(identifier: "UTC")!; return c }()
28 static let date = calendar.date(from: DateComponents(year: 2026, month: 11, day: 19, hour: 9, minute: 5, second: 3))!
29
30 @Test func namesNewFiles() {
31 #expect(Denote.slug("Hello, World: a_test -- Note!") == "hello-world-a-test-note")
32 #expect(Denote.slug(" Café au lait ") == "café-au-lait")
33 #expect(Denote.keywords(["Emacs", "org-mode", "emacs", "", "two words"]) == ["emacs", "orgmode", "twowords"])
34 let id = Denote.identifier(for: Self.date, calendar: Self.calendar)
35 #expect(id == "20261119T090503")
36 #expect(Denote.fileName(identifier: id, title: "A note", keywords: ["b", "a"]) == "20261119T090503--a-note__b_a.org")
37 #expect(Denote.fileName(identifier: id, signature: "1a", title: "", keywords: []) == "20261119T090503==1a.org")
38 #expect(Denote.frontMatter(title: "A note", date: Self.date, keywords: ["a", "b"], identifier: id, calendar: Self.calendar) == """
39 #+title: A note
40 #+date: [2026-11-19 Thu 09:05]
41 #+filetags: :a:b:
42 #+identifier: 20261119T090503
43
44
45 """)
46 }
47
48 @Test func readsNamesInAnyOrder() {
49 #expect(Denote.name(ofFile: "/n/20261119T090503==1a--a-note__kw1_kw2.org")
50 == Denote.Name(identifier: "20261119T090503", signature: "1a", title: "a-note", keywords: ["kw1", "kw2"], ext: "org"))
51 #expect(Denote.name(ofFile: "--a-note__kw@@20261119T090503.pdf")
52 == Denote.Name(identifier: "20261119T090503", signature: nil, title: "a-note", keywords: ["kw"], ext: "pdf"))
53 }
54
55 @Test func renamesFromFrontMatter() {
56 let text = "#+title: New Title\n#+filetags: :Zeta:alpha:\n#+identifier: 20261119T090503\n\nBody\n"
57 #expect(Denote.renamed("/n/20261119T090503==1a--old__x.org", text: text) == "/n/20261119T090503==1a--new-title__alpha_zeta.org")
58 #expect(Denote.renamed("/n/plain.org", text: text) == "/n/20261119T090503--new-title__alpha_zeta.org")
59 #expect(Denote.renamed("/n/plain.org", text: "#+title: x\n") == nil)
60 #expect(Denote.renamed("/n/20261119T090503--old-name__x.org", text: "No front matter\n") == "/n/20261119T090503--old-name__x.org")
61 }
24} 62}
docs/manual/guide/03-keys.org +1
@@ -1070,6 +1070,7 @@ See [[file:09-links.org][Links]].
1070| Capture to Daily Note for Date… (=app.dailies.capture-date=) | =C-c n d v= | — | =SPC n r d D= (N) | =org-roam-dailies-capture-date=. | 1070| Capture to Daily Note for Date… (=app.dailies.capture-date=) | =C-c n d v= | — | =SPC n r d D= (N) | =org-roam-dailies-capture-date=. |
1071| Next Daily Note (=app.dailies.next=) | =C-c n d f= | — | =SPC n r d f= (N) | =org-roam-dailies-goto-next-note=. | 1071| Next Daily Note (=app.dailies.next=) | =C-c n d f= | — | =SPC n r d f= (N) | =org-roam-dailies-goto-next-note=. |
1072| Previous Daily Note (=app.dailies.previous=) | =C-c n d b= | — | =SPC n r d b= (N) | =org-roam-dailies-goto-previous-note=. | 1072| Previous Daily Note (=app.dailies.previous=) | =C-c n d b= | — | =SPC n r d b= (N) | =org-roam-dailies-goto-previous-note=. |
1073| Rename Note from Front Matter (=app.node.rename-from-front-matter=) | — | — | — | =denote-rename-file-using-front-matter=. |
1073 1074
1074** Unbound commands 1075** Unbound commands
1075 1076
docs/manual/guide/09-links.org +43
@@ -127,6 +127,15 @@ under one of your sidebar folders. An =ID= in the property drawer before a file'
127heading names the file, as org-roam's file nodes do, and the link opens the file. A link 127heading names the file, as org-roam's file nodes do, and the link opens the file. A link
128to an ID that isn't indexed shows =No heading has the ID= followed by the ID. 128to an ID that isn't indexed shows =No heading has the ID= followed by the ID.
129 129
130** denote links
131
132=denote:= links name a Denote note by its identifier, as in
133=[[denote:20261119T120000][A note]]=. The note is the indexed file whose name has the
134identifier, at its start or after =@@=; an Org file comes before others with the same
135identifier, such as a PDF. A search after =::=, such as =::#custom-id= or =::*Heading=,
136works as in a =file:= link. Backlinks list =denote:= links to a file, and to a heading when
137the link searches for it.
138
130** Timestamps 139** Timestamps
131 140
132=C-c C-o= (Mac =⌃⌘O=) or =⌘=-click on a timestamp opens the agenda on that day, as 141=C-c C-o= (Mac =⌃⌘O=) or =⌘=-click on a timestamp opens the agenda on that day, as
@@ -326,6 +335,40 @@ what a new note starts with, and what capturing adds; =%<…>= formats the note'
326(=%t=, =%U= and the like) use the note's day. Import from Emacs reads them from the first of 335(=%t=, =%U= and the like) use the note's day. Import from Emacs reads them from the first of
327=org-roam-dailies-capture-templates=. See [[file:13-configuration.org][Configuration]]. 336=org-roam-dailies-capture-templates=. See [[file:13-configuration.org][Configuration]].
328 337
338** Denote
339
340With =notes-package = "denote"= in =config.toml=, the same commands follow Denote:
341
342- Find Node… and Insert Node Link… list the Org files whose names have a Denote
343 identifier, titled by their =#+title:=, and Insert Node Link… inserts
344 =[[denote:…][Title]]=.
345- A title no note has asks for keywords, separated by commas or spaces, offering the
346 keywords in existing file names, then makes the note in =denote-directory= (the first
347 folder unless set), as =denote= does with its default prompts:
348
349 #+BEGIN_SRC org
350 ,#+title: Field Notes
351 ,#+date: [2026-11-19 Thu 12:00]
352 ,#+filetags: :ideas:work:
353 ,#+identifier: 20261119T120000
354 #+END_SRC
355
356 named =20261119T120000--field-notes__ideas_work.org=: the title in lower case without
357 punctuation, words joined by =-=; the keywords sorted, each one word, joined by =_=.
358- The daily-note commands work on denote-journal's entries: notes in
359 =denote-journal-directory= (=journal=, under =denote-directory=) with the
360 =denote-journal-keyword= (=journal=). A day's entry is the one whose identifier has its
361 date; a new one is titled by =denote-journal-title-format= (="%A %e %B %Y"=). Capturing
362 adds =org-roam-dailies-entry= as for org-roam.
363- Rename Note from Front Matter renames the open file from its =#+title:= and
364 =#+filetags:=, keeping its identifier and signature, as
365 =denote-rename-file-using-front-matter= does. Links keep working, as they use the
366 identifier.
367
368Import from Emacs reads =denote-directory=, =denote-journal-directory=,
369=denote-journal-keyword= and =denote-journal-title-format=. Denote notes in Markdown or
370plain text are not supported.
371
329* Inline images 372* Inline images
330 373
331=org-toggle-inline-images= shows image links as images. 374=org-toggle-inline-images= shows image links as images.
docs/manual/guide/13-configuration.org +8
@@ -179,6 +179,7 @@ These settings have no control in the Settings window. Some are in the View menu
179| =org-track-ordered-property-with-tag= | | 179| =org-track-ordered-property-with-tag= | |
180| =org-timer-format=, =org-timer-default-timer= | | 180| =org-timer-format=, =org-timer-default-timer= | |
181| =org-roam-directory=, =org-roam-dailies-directory=, =org-roam-dailies-file=, =org-roam-dailies-head=, =org-roam-dailies-entry= | | 181| =org-roam-directory=, =org-roam-dailies-directory=, =org-roam-dailies-file=, =org-roam-dailies-head=, =org-roam-dailies-entry= | |
182| =notes-package=, =denote-directory=, =denote-journal-directory=, =denote-journal-keyword=, =denote-journal-title-format= | |
182| =org-attach-id-dir=, =org-attach-use-inheritance= | | 183| =org-attach-id-dir=, =org-attach-use-inheritance= | |
183| =org-yank-image-save-method=, =org-yank-dnd-method= | | 184| =org-yank-image-save-method=, =org-yank-dnd-method= | |
184| =org-crypt-tag-matcher= | | 185| =org-crypt-tag-matcher= | |
@@ -238,6 +239,11 @@ A key you remove from the file goes back to its default. A key that isn't in the
238| =org-roam-dailies-file= | string | ="%<%Y-%m-%d>.org"= | A daily note's file name; =%<…>= formats its date. | 239| =org-roam-dailies-file= | string | ="%<%Y-%m-%d>.org"= | A daily note's file name; =%<…>= formats its date. |
239| =org-roam-dailies-head= | string | ="#+title: %<%Y-%m-%d>\n"= | What a new daily note starts with, under its =ID=. | 240| =org-roam-dailies-head= | string | ="#+title: %<%Y-%m-%d>\n"= | What a new daily note starts with, under its =ID=. |
240| =org-roam-dailies-entry= | string | ="* %?"= | The capture template Capture to Daily Note files. See [[file:09-links.org][Links]]. | 241| =org-roam-dailies-entry= | string | ="* %?"= | The capture template Capture to Daily Note files. See [[file:09-links.org][Links]]. |
242| =notes-package= | string | ="org-roam"= | Whose conventions Find Node…, Insert Node Link… and the daily-note commands follow: ="org-roam"= or ="denote"=. |
243| =denote-directory= | string | =""= | The folder new Denote notes go in; empty for the first sidebar folder. Mirrors =denote-directory=. |
244| =denote-journal-directory= | string | ="journal"= | The folder journal entries are in, relative to =denote-directory=. Mirrors =denote-journal-directory=. |
245| =denote-journal-keyword= | string | ="journal"= | The keyword journal entries have. Mirrors =denote-journal-keyword=. |
246| =denote-journal-title-format= | string | ="%A %e %B %Y"= | A new journal entry's title, a =format-time-string= format. |
241| =org-timer-format= | string | ="%s "= | What Insert Timer Value writes, with =%s= for the =h:mm:ss= value. Mirrors =org-timer-format=. | 247| =org-timer-format= | string | ="%s "= | What Insert Timer Value writes, with =%s= for the =h:mm:ss= value. Mirrors =org-timer-format=. |
242| =org-timer-default-timer= | string | ="0"= | The countdown Set Countdown Timer… offers, in minutes or =h:mm:ss=; ="0"= offers none. Mirrors =org-timer-default-timer=. | 248| =org-timer-default-timer= | string | ="0"= | The countdown Set Countdown Timer… offers, in minutes or =h:mm:ss=; ="0"= offers none. Mirrors =org-timer-default-timer=. |
243| =org-attach-id-dir= | string | ="data/"= | The folder ID-based attachment folders go in, relative to the org file's folder unless absolute. See [[file:04-outlines.org][Outlines]]. Mirrors =org-attach-id-dir=. | 249| =org-attach-id-dir= | string | ="data/"= | The folder ID-based attachment folders go in, relative to the org file's folder unless absolute. See [[file:04-outlines.org][Outlines]]. Mirrors =org-attach-id-dir=. |
@@ -617,6 +623,8 @@ Only variables whose names start with =org-=, =appt-=, =display-line-numbers=, =
617| =org-agenda-todo-ignore-scheduled=, =-deadlines=, =-timestamp= | The symbol or number as a string; =org-agenda-todo-ignore-with-date= and =org-agenda-tags-todo-honor-ignore-options= as booleans | 623| =org-agenda-todo-ignore-scheduled=, =-deadlines=, =-timestamp= | The symbol or number as a string; =org-agenda-todo-ignore-with-date= and =org-agenda-tags-todo-honor-ignore-options= as booleans |
618| =org-track-ordered-property-with-tag= | A tag name as given; =t= becomes ="t"=, =nil= ="nil"= | 624| =org-track-ordered-property-with-tag= | A tag name as given; =t= becomes ="t"=, =nil= ="nil"= |
619| =org-roam-directory=, =org-roam-dailies-directory= | The same keys, when the value is a string or a form that makes one | 625| =org-roam-directory=, =org-roam-dailies-directory= | The same keys, when the value is a string or a form that makes one |
626| =denote-directory=, =denote-journal-directory=, =denote-journal-keyword= | The same keys, when the value is a string |
627| =denote-journal-title-format= | The same key; the symbols =day-date-month-year=, =-24h= and =-12h= become their formats |
620| =org-roam-dailies-capture-templates= | =org-roam-dailies-file=, =-head= and =-entry=, from the first template's =(file+head NAME HEAD)= target and template | 628| =org-roam-dailies-capture-templates= | =org-roam-dailies-file=, =-head= and =-entry=, from the first template's =(file+head NAME HEAD)= target and template |
621| =org-timer-format=, =org-timer-default-timer= | The same keys; a number becomes a string | 629| =org-timer-format=, =org-timer-default-timer= | The same keys; a number becomes a string |
622| =org-attach-id-dir= | The same key, when the value is a string or an =expand-file-name= form | 630| =org-attach-id-dir= | The same key, when the value is a string or an =expand-file-name= form |