Commit eb700e6739
eb700e67391c27d460f7c452d97d4020e4f4f021
parent: ab3da01d50
Verified · cmc
cmc <hello@cleberg.net> · 2026-10-11 08:07 UTC
org-archive-location
config.toml's org-archive-location is the archive location for entries without an ARCHIVE property or #+ARCHIVE:, as in Org. Emacs import carries it over.
Closes #20
Layout: unified · split
Sources/OrgApp/EmacsImport.swift
+3
| @@ -479,6 +479,9 @@ public struct EmacsImport: Sendable { |
| 479 | 479 | "org-startup-indented", "org-hide-leading-stars", "org-startup-align-all-tables", "org-startup-truncated", |
| 480 | 480 | "org-enforce-todo-dependencies", "org-enforce-todo-checkbox-dependencies": |
| 481 | 481 | add(name, .bool(truthy)) |
| 482 | case "org-archive-location": |
| 483 | guard let location = value.string, location.contains("::") else { return note("not a file::heading location") } |
| 484 | add(name, .string(location)) |
| 482 | 485 | case "org-track-ordered-property-with-tag": |
| 483 | 486 | if let tag = value.string { add(name, .string(tag)) } else { add(name, .string(truthy ? "t" : "nil")) } |
| 484 | 487 | case "org-agenda-dim-blocked-tasks": |
Sources/OrgApp/OrgPreferences.swift
+1
| @@ -35,6 +35,7 @@ public enum OrgPreferences { |
| 35 | 35 | options.electricPair = bool("electricPair", defaults) |
| 36 | 36 | options.enforceTodoDependencies = bool("enforceTodoDependencies", defaults) |
| 37 | 37 | options.enforceTodoCheckboxDependencies = bool("enforceTodoCheckboxDependencies", defaults) |
| 38 | options.archiveLocation = string("archiveLocation", defaults).nonEmpty |
| 38 | 39 | options.trackOrderedPropertyWithTag = switch string("trackOrderedTag", defaults) { |
| 39 | 40 | case "", "nil": nil |
| 40 | 41 | case "t": "ORDERED" |
Sources/OrgApp/UserConfig.swift
+2
| @@ -121,6 +121,8 @@ public enum UserConfig { |
| 121 | 121 | comment: "an entry can't be done before its TODO children, or under an ORDERED parent before its earlier siblings", legacy: ""), |
| 122 | 122 | Setting(section: "", key: "org-enforce-todo-checkbox-dependencies", defaultsKey: "enforceTodoCheckboxDependencies", kind: .bool, fallback: .bool(false), |
| 123 | 123 | comment: "an entry can't be done while it has unchecked boxes", legacy: ""), |
| 124 | Setting(section: "", key: "org-archive-location", defaultsKey: "archiveLocation", kind: .string, fallback: .string("%s_archive::"), |
| 125 | comment: "where Archive Subtree moves an entry without an ARCHIVE property or #+ARCHIVE: file::heading, %s the file's name", legacy: ""), |
| 124 | 126 | Setting(section: "", key: "org-track-ordered-property-with-tag", defaultsKey: "trackOrderedTag", kind: .string, fallback: .string("nil"), |
| 125 | 127 | comment: "nil, t (the tag ORDERED) or a tag that Toggle ORDERED Property toggles too", legacy: ""), |
| 126 | 128 | Setting(section: "", key: "org-startup-indented", defaultsKey: "startupIndented", kind: .bool, fallback: .bool(true), |
Sources/OrgCore/Commands/Archive.swift
+2 −3
| @@ -1,7 +1,6 @@ |
| 1 | 1 | import Foundation |
| 2 | 2 | |
| 3 | | // Archiving (`org-archive-subtree`, Org 9.8.7) with the defaults: location "%s_archive::", |
| 4 | | // context info time, file, olpath, category, todo and itags, inherited tags added only within |
| 3 | // Archiving (`org-archive-subtree`, Org 9.8.7) with `org-archive-location` and the defaults: context info time, file, olpath, category, todo and itags, inherited tags added only within |
| 5 | 4 | // the same file, no marking DONE, the archive file's header for a new file. |
| 6 | 5 | |
| 7 | 6 | extension EmacsBuffer { |
| @@ -191,7 +190,7 @@ public enum Archive { |
| 191 | 190 | public static func destination(_ context: EditContext, sourcePath: String) -> Result<Destination, ArchiveError> { |
| 192 | 191 | let buffer = EmacsBuffer(context.text, point: context.caret, settings: context.tree.settings) |
| 193 | 192 | guard !buffer.beforeFirstHeading else { return .failure(.message("Before first headline")) } |
| 194 | | let spec = buffer.inheritedProperty("ARCHIVE")?.value ?? buffer.keyword("ARCHIVE") ?? "%s_archive::" |
| 193 | let spec = buffer.inheritedProperty("ARCHIVE")?.value ?? buffer.keyword("ARCHIVE") ?? context.options.archiveLocation ?? "%s_archive::" |
| 195 | 194 | guard let separator = spec.range(of: "::") else { return .failure(.message("Invalid archive location: \"\(spec)\"")) } |
| 196 | 195 | let name = (sourcePath as NSString).lastPathComponent |
| 197 | 196 | let fileFormat = String(spec[..<separator.lowerBound]) |
Sources/OrgCore/Commands/Command.swift
+3
| @@ -27,6 +27,9 @@ public struct EditingOptions: Sendable, Equatable, Codable { |
| 27 | 27 | public var enforceTodoDependencies = false |
| 28 | 28 | /// `org-enforce-todo-checkbox-dependencies`: an entry can't become done with unchecked boxes. |
| 29 | 29 | public var enforceTodoCheckboxDependencies = false |
| 30 | /// `org-archive-location`, for entries without an `ARCHIVE` property or `#+ARCHIVE:`; nil |
| 31 | /// for Org's default, `%s_archive::`. |
| 32 | public var archiveLocation: String? |
| 30 | 33 | /// `org-track-ordered-property-with-tag`: the tag toggling `ORDERED` toggles too; nil for none. |
| 31 | 34 | public var trackOrderedPropertyWithTag: String? |
| 32 | 35 | /// `org-use-speed-commands`: single keys at the start of a heading line run commands. |
Tests/OrgAppTests/EmacsImportTests.swift
+3 −1
| @@ -42,6 +42,7 @@ struct EmacsImportTests { |
| 42 | 42 | org-deadline-warning-days 7 |
| 43 | 43 | org-agenda-start-on-weekday 0 |
| 44 | 44 | org-track-ordered-property-with-tag t |
| 45 | org-archive-location "archive/%s::" |
| 45 | 46 | org-agenda-start-day "-3d" |
| 46 | 47 | org-clock-idle-time 15 |
| 47 | 48 | org-clock-history-length 10 |
| @@ -86,6 +87,7 @@ struct EmacsImportTests { |
| 86 | 87 | #expect(s["org-deadline-warning-days"] == .integer(7)) |
| 87 | 88 | #expect(s["org-agenda-start-on-weekday"] == .string("0")) |
| 88 | 89 | #expect(s["org-track-ordered-property-with-tag"] == .string("t")) |
| 90 | #expect(s["org-archive-location"] == .string("archive/%s::")) |
| 89 | 91 | #expect(s["org-agenda-start-day"] == .string("-3d")) |
| 90 | 92 | #expect(s["org-clock-idle-time"] == .integer(15)) |
| 91 | 93 | #expect(s["org-clock-history-length"] == .integer(10)) |
| @@ -177,7 +179,7 @@ struct EmacsImportTests { |
| 177 | 179 | let keymap = folder.appendingPathComponent("keymap.toml") |
| 178 | 180 | #expect(KeymapLoader.load(.doom, userFile: keymap).problems.isEmpty) |
| 179 | 181 | #expect(KeymapLoader.load(.doom, userFile: keymap).keymap.keyLabels(for: "app.agenda", modes: ["normal"]).contains("C-c a")) |
| 180 | | #expect(summary.hasPrefix("Imported 22 settings, 3 capture templates, 3 key bindings."), "\(summary)") |
| 182 | #expect(summary.hasPrefix("Imported 23 settings, 3 capture templates, 3 key bindings."), "\(summary)") |
| 181 | 183 | #expect(defaults.string(forKey: "themeFont") == "JetBrains Mono") |
| 182 | 184 | #expect(defaults.integer(forKey: "themeFontSize") == 14) |
| 183 | 185 | |
Tests/OrgAppTests/OrgPreferencesTests.swift
+3
| @@ -14,6 +14,7 @@ struct OrgPreferencesTests { |
| 14 | 14 | #expect(OrgPreferences.orgSettings(defaults).deadlineWarningDays == 14) |
| 15 | 15 | #expect(OrgPreferences.agendaStartOnWeekday(defaults) == 1) |
| 16 | 16 | #expect(OrgPreferences.options(defaults).trackOrderedPropertyWithTag == nil) |
| 17 | #expect(OrgPreferences.options(defaults).archiveLocation == "%s_archive::") |
| 17 | 18 | #expect(OrgPreferences.agendaOptions(AgendaOptions(), defaults).deadlineWarningDays == 14) |
| 18 | 19 | #expect(OrgPreferences.reminders(defaults) && OrgPreferences.reminderLead(defaults) == 12) |
| 19 | 20 | let fallbacks = OrgPreferences.options(defaults) |
| @@ -30,6 +31,7 @@ struct OrgPreferencesTests { |
| 30 | 31 | org-deadline-warning-days = 5 |
| 31 | 32 | org-agenda-start-on-weekday = "nil" |
| 32 | 33 | org-track-ordered-property-with-tag = "t" |
| 34 | org-archive-location = "~/org/archive.org::* %s" |
| 33 | 35 | org-M-RET-may-split-line = true |
| 34 | 36 | org-hide-emphasis-markers = false |
| 35 | 37 | org-pretty-entities = false |
| @@ -45,6 +47,7 @@ struct OrgPreferencesTests { |
| 45 | 47 | #expect(OrgPreferences.orgSettings(defaults).deadlineWarningDays == 5) |
| 46 | 48 | #expect(OrgPreferences.agendaStartOnWeekday(defaults) == nil) |
| 47 | 49 | #expect(OrgPreferences.options(defaults).trackOrderedPropertyWithTag == "ORDERED") |
| 50 | #expect(OrgPreferences.options(defaults).archiveLocation == "~/org/archive.org::* %s") |
| 48 | 51 | #expect(OrgPreferences.agendaOptions(AgendaOptions(), defaults).deadlineWarningDays == 5) |
| 49 | 52 | #expect(!OrgPreferences.reminders(defaults) && OrgPreferences.reminderLead(defaults) == 30) |
| 50 | 53 | #expect(UserConfig.apply("org-agenda-start-on-weekday = \"0\"", to: defaults).isEmpty) |
Tests/OrgCoreTests/ArchiveTests.swift
+10
| @@ -21,6 +21,16 @@ struct ArchiveTests { |
| 21 | 21 | #expect(keyword == Archive.Destination(path: "/n/done.org", heading: "* a.org", isSameFile: false)) |
| 22 | 22 | let local = try Archive.destination(context("* a\n:PROPERTIES:\n:ARCHIVE: ::* Old\n:END:\n", 0), sourcePath: "/n/a.org").get() |
| 23 | 23 | #expect(local.isSameFile && local.heading == "* Old") |
| 24 | // org-archive-location, under the keyword and the property. |
| 25 | var options = EditingOptions.org |
| 26 | options.archiveLocation = "old/%s::* From %s" |
| 27 | func optioned(_ text: String, _ caret: Int) -> EditContext { |
| 28 | EditContext(revision: 0, text: text, tree: OrgParser.parse(text), selection: [caret..<caret], now: Self.now, calendar: Self.utc, options: options) |
| 29 | } |
| 30 | let global = try Archive.destination(optioned("* a\n", 0), sourcePath: "/n/a.org").get() |
| 31 | #expect(global == Archive.Destination(path: "/n/old/a.org", heading: "* From a.org", isSameFile: false)) |
| 32 | let overridden = try Archive.destination(optioned("#+ARCHIVE: done.org::\n* a\n", 22), sourcePath: "/n/a.org").get() |
| 33 | #expect(overridden.path == "/n/done.org" && overridden.heading == nil) |
| 24 | 34 | } |
| 25 | 35 | |
| 26 | 36 | @Test func archivesToANewFile() throws { |
docs/manual/guide/04-outlines.org
+4 −5
| @@ -771,7 +771,8 @@ Archive Subtree (=org-archive-subtree=, =C-c C-x C-s= or =C-c $=, Mac =⌃⌘A=, |
| 771 | 771 | =SPC m A= or =SPC m s A=) moves the subtree at the caret to an archive. |
| 772 | 772 | |
| 773 | 773 | The archive location is read from, in order: the =ARCHIVE= property of the entry or an |
| 774 | | ancestor, a =#+ARCHIVE:= line in the file, and Org's default =%s_archive::=. A location |
| 774 | ancestor, a =#+ARCHIVE:= line in the file, and =org-archive-location= in =config.toml= |
| 775 | (Org's default =%s_archive::=). A location |
| 775 | 776 | is =file::heading=, where =%s= stands for the current file's name: |
| 776 | 777 | |
| 777 | 778 | | Location | Where the subtree goes | |
| @@ -794,8 +795,7 @@ changed. |
| 794 | 795 | |
| 795 | 796 | If the archive file is open, the subtree goes into its buffer. Otherwise orgstar writes |
| 796 | 797 | the archive file first and removes the subtree from the source only after that |
| 797 | | succeeds. Org's option =org-archive-location= in Emacs is not read; use the =ARCHIVE= |
| 798 | | property or =#+ARCHIVE:=. Archiving from the agenda is covered in [[file:07-agenda.org][Agenda]]. |
| 798 | succeeds. Archiving from the agenda is covered in [[file:07-agenda.org][Agenda]]. |
| 799 | 799 | |
| 800 | 800 | ** The ARCHIVE tag |
| 801 | 801 | |
| @@ -887,5 +887,4 @@ These Org structure features are not in orgstar: |
| 887 | 887 | - The =ORDERED= property, radio lists and timer list items in the list commands. |
| 888 | 888 | - =S-<left>= and =S-<right>= to cycle bullets on an item; use =C-c -=. |
| 889 | 889 | - =org-drag-element= (=M-<up>= and =M-<down>= on paragraphs). |
| 890 | | - Custom =org-structure-template-alist=, =org-refile-targets= and |
| 891 | | =org-archive-location=. |
| 890 | - Custom =org-structure-template-alist= and =org-refile-targets=. |
docs/manual/guide/13-configuration.org
+2
| @@ -155,6 +155,7 @@ These settings have no control in the Settings window. Some are in the View menu |
| 155 | 155 | | =tab-bar= | View ▸ Show Tab Bar | |
| 156 | 156 | | =show-markup= | View ▸ Show Markup (=⇧⌘M=) | |
| 157 | 157 | | =ignored-folders= | | |
| 158 | | =org-archive-location= | | |
| 158 | 159 | | =org-track-ordered-property-with-tag= | | |
| 159 | 160 | | =org-agenda-start-on-weekday= | | |
| 160 | 161 | | =org-deadline-warning-days= | | |
| @@ -189,6 +190,7 @@ A key you remove from the file goes back to its default. A key that isn't in the |
| 189 | 190 | | =org-log-into-drawer= | string | =""= | The drawer state notes go in. ="LOGBOOK"= is Emacs's =t=; =""= puts them under the heading. Mirrors =org-log-into-drawer=. | |
| 190 | 191 | | =org-enforce-todo-dependencies= | boolean | =false= | An entry can't become done while a descendant has an active TODO keyword, or under an =ORDERED= parent while an earlier sibling has one. Mirrors =org-enforce-todo-dependencies=. | |
| 191 | 192 | | =org-enforce-todo-checkbox-dependencies= | boolean | =false= | An entry can't become done while its text has an unchecked checkbox. Mirrors =org-enforce-todo-checkbox-dependencies=. | |
| 193 | | =org-archive-location= | string | ="%s_archive::"= | Where Archive Subtree moves an entry that has no =ARCHIVE= property and whose file has no =#+ARCHIVE:=, as =file::heading=; =%s= is the file's name. Mirrors =org-archive-location=. | |
| 192 | 194 | | =org-track-ordered-property-with-tag= | string | ="nil"= | A tag that Toggle ORDERED Property adds and removes with the property: ="t"= for the tag =ORDERED=, or a tag name. Mirrors =org-track-ordered-property-with-tag=. | |
| 193 | 195 | | =org-startup-indented= | boolean | =true= | Indent bodies under their headings, as =org-indent-mode=. =#+STARTUP: indent= / =noindent= override it. Mirrors =org-startup-indented=. | |
| 194 | 196 | | =org-hide-leading-stars= | boolean | =false= | Show only a heading's last star, without indentation. =#+STARTUP: hidestars= / =showstars= override it. Mirrors =org-hide-leading-stars=. | |
docs/manual/guide/14-ios.org
+1
| @@ -348,6 +348,7 @@ These settings from =config.toml= apply on iOS: |
| 348 | 348 | - =[theme]= (=font=, =font-size=, =line-spacing=, =heading-size-step=, =theme-file= and colours), =[theme.light]=, =[theme.dark]=, =[theme.todo]=, =[theme.category]= |
| 349 | 349 | - =org-log-done=, =org-log-reschedule=, =org-log-redeadline=, =org-log-into-drawer= |
| 350 | 350 | - =org-enforce-todo-dependencies=, =org-enforce-todo-checkbox-dependencies=, =org-track-ordered-property-with-tag=, =org-agenda-dim-blocked-tasks= |
| 351 | - =org-archive-location= |
| 351 | 352 | - =org-use-speed-commands=, with a hardware keyboard |
| 352 | 353 | - =electric-pair-mode=, =spell-check= |
| 353 | 354 | - =org-agenda-span=, =org-agenda-start-day=, =org-agenda-start-on-weekday=, =org-deadline-warning-days=, =agenda-include-subfolders=, =org-agenda-show-all-dates=, =org-agenda-skip-scheduled-if-done=, =org-agenda-skip-deadline-if-done=, =org-agenda-search-view-always-boolean=, =org-agenda-search-view-force-full-words= |