Sources/OrgApp/AgendaFiles.swift
16 lines · 782 bytes
1import Foundation
2import OrgConfig
3
4extension WorkspaceModel {
5 /// `(org-agenda-files)`: `list` resolved, or when it is empty the org files at the top of
6 /// each folder (or below it, with `includeSubfolders`), by path, as Emacs lists a
7 /// directory.
8 public func agendaFilePaths(list: [String] = OrgPreferences.agendaFiles(), includeSubfolders: Bool = OrgPreferences.agendaSubfolders()) -> [String] {
9 if !list.isEmpty { return AgendaFiles.resolve(list, base: rootPaths.first) }
10 return files
11 // Dotfiles stay out, as `org-agenda-file-regexp` leaves them out.
12 .filter { $0.kind == .org && !$0.name.hasPrefix(".") && (includeSubfolders || !$0.relativePath.contains("/")) }
13 .map(\.path)
14 .sorted()
15 }
16}