Incremental search, relative line numbers, auto-fill !291
28 files changed, +888 −31
Layout: unified · split
Sources/OrgApp/EmacsImport.swift +8 −2
| @@ -212,6 +212,12 @@ public struct EmacsImport: Sendable { | |||
| 212 | case "progn", "when", "unless", "if", "let", "let*", "with-no-warnings": | 212 | case "progn", "when", "unless", "if", "let", "let*", "with-no-warnings": |
| 213 | let skip = ["let", "let*", "when", "unless", "if"].contains(head) ? 1 : 0 | 213 | let skip = ["let", "let*", "when", "unless", "if"].contains(head) ? 1 : 0 |
| 214 | body(args.dropFirst(skip), deferred: deferred) | 214 | body(args.dropFirst(skip), deferred: deferred) |
| 215 | case "add-hook": | ||
| 216 | // `auto-fill-mode` turned on for Org or text buffers. | ||
| 217 | if args.count >= 2, let hook = unquote(args[0])?.symbol, ["org-mode-hook", "text-mode-hook"].contains(hook), | ||
| 218 | let function = unquote(args[1])?.symbol, ["auto-fill-mode", "turn-on-auto-fill"].contains(function) { | ||
| 219 | assign("auto-fill-mode", .symbol("t"), source, priority: priority, deferred: deferred) | ||
| 220 | } | ||
| 215 | case "defun", "defun!", "add-hook!": | 221 | case "defun", "defun!", "add-hook!": |
| 216 | // Doom sets org's defaults in the functions its module runs when org loads. | 222 | // Doom sets org's defaults in the functions its module runs when org loads. |
| 217 | if doom, head == "defun" { body(args.dropFirst(2), deferred: true) } | 223 | if doom, head == "defun" { body(args.dropFirst(2), deferred: true) } |
| @@ -495,7 +501,7 @@ public struct EmacsImport: Sendable { | |||
| 495 | add(name, .integer(n)) | 501 | add(name, .integer(n)) |
| 496 | case "org-insert-heading-respect-content", "org-list-allow-alphabetical", "org-hide-emphasis-markers", "org-pretty-entities", | 502 | case "org-insert-heading-respect-content", "org-list-allow-alphabetical", "org-hide-emphasis-markers", "org-pretty-entities", |
| 497 | "org-cycle-hide-drawer-startup", "org-cycle-hide-block-startup", "org-use-speed-commands", "org-startup-with-inline-images", "org-startup-with-latex-preview", | 503 | "org-cycle-hide-drawer-startup", "org-cycle-hide-block-startup", "org-use-speed-commands", "org-startup-with-inline-images", "org-startup-with-latex-preview", |
| 498 | "org-startup-indented", "org-hide-leading-stars", "org-startup-align-all-tables", "org-startup-truncated", | 504 | "org-startup-indented", "org-hide-leading-stars", "org-startup-align-all-tables", "org-startup-truncated", "auto-fill-mode", |
| 499 | "org-enforce-todo-dependencies", "org-enforce-todo-checkbox-dependencies", | 505 | "org-enforce-todo-dependencies", "org-enforce-todo-checkbox-dependencies", |
| 500 | "org-agenda-todo-ignore-with-date", "org-agenda-tags-todo-honor-ignore-options", "org-clock-out-remove-zero-time-clocks", | 506 | "org-agenda-todo-ignore-with-date", "org-agenda-tags-todo-honor-ignore-options", "org-clock-out-remove-zero-time-clocks", |
| 501 | "org-agenda-sort-notime-is-late", "org-agenda-sort-noeffort-is-high", "org-agenda-use-time-grid", "org-agenda-show-current-time-in-grid": | 507 | "org-agenda-sort-notime-is-late", "org-agenda-sort-noeffort-is-high", "org-agenda-use-time-grid", "org-agenda-show-current-time-in-grid": |
| @@ -638,7 +644,7 @@ public struct EmacsImport: Sendable { | |||
| 638 | case "org-log-into-drawer": | 644 | case "org-log-into-drawer": |
| 639 | if let s = value.string { add(name, .string(s)) } else { add(name, .string(truthy ? "LOGBOOK" : "")) } | 645 | if let s = value.string { add(name, .string(s)) } else { add(name, .string(truthy ? "LOGBOOK" : "")) } |
| 640 | case "display-line-numbers-type": | 646 | case "display-line-numbers-type": |
| 641 | add(name, .bool(truthy), truthy && value.symbol != "t" ? "display-line-numbers-type = true (orgstar numbers lines absolutely)" : nil) | 647 | if let type = value.symbol, ["relative", "visual"].contains(type) { add(name, .string(type)) } else { add(name, .bool(truthy)) } |
| 642 | case "org-agenda-span": | 648 | case "org-agenda-span": |
| 643 | let days: Int? = value.integer ?? ["day": 1, "week": 7, "fortnight": 14, "month": 30, "year": 365][value.symbol ?? ""] | 649 | let days: Int? = value.integer ?? ["day": 1, "week": 7, "fortnight": 14, "month": 30, "year": 365][value.symbol ?? ""] |
| 644 | guard let days else { return note("unknown span \(value.description)") } | 650 | guard let days else { return note("unknown span \(value.description)") } |
Sources/OrgApp/OrgPreferences.swift +1
| @@ -35,6 +35,7 @@ public enum OrgPreferences { | |||
| 35 | spellCheck: bool("spellCheck", defaults) | 35 | spellCheck: bool("spellCheck", defaults) |
| 36 | ) | 36 | ) |
| 37 | options.electricPair = bool("electricPair", defaults) | 37 | options.electricPair = bool("electricPair", defaults) |
| 38 | options.autoFill = bool("autoFill", defaults) | ||
| 38 | options.startupWithLatexPreview = bool("startupWithLatexPreview", defaults) | 39 | options.startupWithLatexPreview = bool("startupWithLatexPreview", defaults) |
| 39 | options.remoteInlineImages = string("remoteInlineImages", defaults) | 40 | options.remoteInlineImages = string("remoteInlineImages", defaults) |
| 40 | options.enforceTodoDependencies = bool("enforceTodoDependencies", defaults) | 41 | options.enforceTodoDependencies = bool("enforceTodoDependencies", defaults) |
Sources/OrgApp/UserConfig.swift +17 −2
| @@ -76,6 +76,9 @@ public enum UserConfig { | |||
| 76 | case integerChoice([(name: String, stored: Int)]) | 76 | case integerChoice([(name: String, stored: Int)]) |
| 77 | /// `org-agenda-start-day`: `"-3d"` in the file, -3 stored. | 77 | /// `org-agenda-start-day`: `"-3d"` in the file, -3 stored. |
| 78 | case dayOffset | 78 | case dayOffset |
| 79 | /// `display-line-numbers-type`: `true`, `false`, `"relative"` or `"visual"`, stored as | ||
| 80 | /// a switch and, in `lineNumbersType`, the kind. | ||
| 81 | case lineNumbers | ||
| 79 | } | 82 | } |
| 80 | 83 | ||
| 81 | public let section: String | 84 | public let section: String |
| @@ -157,6 +160,8 @@ public enum UserConfig { | |||
| 157 | comment: "what a new daily note starts with, under its ID", legacy: ""), | 160 | comment: "what a new daily note starts with, under its ID", legacy: ""), |
| 158 | Setting(section: "", key: "org-roam-dailies-entry", defaultsKey: "dailiesEntry", kind: .string, fallback: .string("* %?"), | 161 | Setting(section: "", key: "org-roam-dailies-entry", defaultsKey: "dailiesEntry", kind: .string, fallback: .string("* %?"), |
| 159 | comment: "the capture template Capture to Daily Note files", legacy: ""), | 162 | comment: "the capture template Capture to Daily Note files", legacy: ""), |
| 163 | Setting(section: "", key: "auto-fill-mode", defaultsKey: "autoFill", kind: .bool, fallback: .bool(false), | ||
| 164 | comment: "typing a space past fill-column breaks the line (View ▸ Auto Fill)", legacy: ""), | ||
| 160 | Setting(section: "", key: "org-timer-format", defaultsKey: "timerFormat", kind: .string, fallback: .string("%s "), | 165 | Setting(section: "", key: "org-timer-format", defaultsKey: "timerFormat", kind: .string, fallback: .string("%s "), |
| 161 | comment: "how Insert Timer Value writes the timer; %s is h:mm:ss", legacy: ""), | 166 | comment: "how Insert Timer Value writes the timer; %s is h:mm:ss", legacy: ""), |
| 162 | Setting(section: "", key: "org-timer-default-timer", defaultsKey: "timerDefault", kind: .string, fallback: .string("0"), | 167 | Setting(section: "", key: "org-timer-default-timer", defaultsKey: "timerDefault", kind: .string, fallback: .string("0"), |
| @@ -177,8 +182,8 @@ public enum UserConfig { | |||
| 177 | comment: "fold drawers when a file opens; #+STARTUP: nohidedrawers overrides", legacy: ""), | 182 | comment: "fold drawers when a file opens; #+STARTUP: nohidedrawers overrides", legacy: ""), |
| 178 | Setting(section: "", key: "org-cycle-hide-block-startup", defaultsKey: "hideBlockStartup", kind: .bool, fallback: .bool(false), | 183 | Setting(section: "", key: "org-cycle-hide-block-startup", defaultsKey: "hideBlockStartup", kind: .bool, fallback: .bool(false), |
| 179 | comment: "fold blocks when a file opens; #+STARTUP: hideblocks overrides", legacy: ""), | 184 | comment: "fold blocks when a file opens; #+STARTUP: hideblocks overrides", legacy: ""), |
| 180 | Setting(section: "", key: "display-line-numbers-type", defaultsKey: "showLineNumbers", kind: .bool, fallback: .bool(true), | 185 | Setting(section: "", key: "display-line-numbers-type", defaultsKey: "showLineNumbers", kind: .lineNumbers, fallback: .bool(true), |
| 181 | comment: "line numbers (View ▸ Show Line Numbers)", legacy: "editor.line-numbers"), | 186 | comment: "line numbers: true, false, \"relative\" or \"visual\" (View ▸ Line Numbers)", legacy: "editor.line-numbers"), |
| 182 | Setting(section: "", key: "org-agenda-span", defaultsKey: "agendaSpan", kind: .integer, fallback: .integer(10), | 187 | Setting(section: "", key: "org-agenda-span", defaultsKey: "agendaSpan", kind: .integer, fallback: .integer(10), |
| 183 | comment: "days the agenda shows", legacy: "agenda.span"), | 188 | comment: "days the agenda shows", legacy: "agenda.span"), |
| 184 | Setting(section: "", key: "org-agenda-start-day", defaultsKey: "agendaStartOffset", kind: .dayOffset, fallback: .string("+0d"), | 189 | Setting(section: "", key: "org-agenda-start-day", defaultsKey: "agendaStartOffset", kind: .dayOffset, fallback: .string("+0d"), |
| @@ -341,6 +346,10 @@ public enum UserConfig { | |||
| 341 | case .dayOffset: | 346 | case .dayOffset: |
| 342 | let days = defaults.integer(forKey: setting.defaultsKey) | 347 | let days = defaults.integer(forKey: setting.defaultsKey) |
| 343 | return .string((days < 0 ? "" : "+") + "\(days)d") | 348 | return .string((days < 0 ? "" : "+") + "\(days)d") |
| 349 | case .lineNumbers: | ||
| 350 | guard defaults.bool(forKey: setting.defaultsKey) else { return .bool(false) } | ||
| 351 | let type = defaults.string(forKey: "lineNumbersType") ?? "" | ||
| 352 | return ["relative", "visual"].contains(type) ? .string(type) : .bool(true) | ||
| 344 | } | 353 | } |
| 345 | } | 354 | } |
| 346 | 355 | ||
| @@ -348,6 +357,12 @@ public enum UserConfig { | |||
| 348 | static func store(_ value: TOML.Value, _ setting: Setting, in defaults: UserDefaults) -> String? { | 357 | static func store(_ value: TOML.Value, _ setting: Setting, in defaults: UserDefaults) -> String? { |
| 349 | let key = setting.defaultsKey | 358 | let key = setting.defaultsKey |
| 350 | switch (setting.kind, value) { | 359 | switch (setting.kind, value) { |
| 360 | case (.lineNumbers, .bool(let b)): | ||
| 361 | defaults.set(b, forKey: key) | ||
| 362 | defaults.set("t", forKey: "lineNumbersType") | ||
| 363 | case (.lineNumbers, .string(let s)) where ["relative", "visual", "t", "nil"].contains(s): | ||
| 364 | defaults.set(s != "nil", forKey: key) | ||
| 365 | defaults.set(s == "nil" ? "t" : s, forKey: "lineNumbersType") | ||
| 351 | case (.bool, .bool(let b)): defaults.set(b, forKey: key) | 366 | case (.bool, .bool(let b)): defaults.set(b, forKey: key) |
| 352 | case (.integer, .integer(let i)): defaults.set(i, forKey: key) | 367 | case (.integer, .integer(let i)): defaults.set(i, forKey: key) |
| 353 | case (.string, .string(let s)): defaults.set(s, forKey: key) | 368 | case (.string, .string(let s)): defaults.set(s, forKey: key) |
Sources/OrgCore/Commands/Command.swift +2
| @@ -84,6 +84,8 @@ public struct EditingOptions: Sendable, Equatable, Codable { | |||
| 84 | public var subSuperscriptsNeedBraces: Bool | 84 | public var subSuperscriptsNeedBraces: Bool |
| 85 | /// The running org-timer, which the app keeps; nil when there is none. | 85 | /// The running org-timer, which the app keeps; nil when there is none. |
| 86 | public var timer: OrgTimer? | 86 | public var timer: OrgTimer? |
| 87 | /// `auto-fill-mode`: typing a space past `fill-column` breaks the line. | ||
| 88 | public var autoFill = false | ||
| 87 | /// `org-timer-format`. | 89 | /// `org-timer-format`. |
| 88 | public var timerFormat = "%s " | 90 | public var timerFormat = "%s " |
| 89 | /// `org-timer-default-timer`. | 91 | /// `org-timer-default-timer`. |
Sources/OrgCore/Commands/Fill.swift +88
| @@ -105,6 +105,7 @@ extension EmacsBuffer { | |||
| 105 | guard let element = element(at: lineBegin) else { return nil } | 105 | guard let element = element(at: lineBegin) else { return nil } |
| 106 | switch element.kind { | 106 | switch element.kind { |
| 107 | case .comment: | 107 | case .comment: |
| 108 | point = lineBegin | ||
| 108 | let indent = substring(lineBegin, lineBegin + (looking("[ \\t]*", setsMatch: false).map { $0[0]!.count } ?? 0)) | 109 | let indent = substring(lineBegin, lineBegin + (looking("[ \\t]*", setsMatch: false).map { $0[0]!.count } ?? 0)) |
| 109 | return indent + "# " | 110 | return indent + "# " |
| 110 | case .item, .plainList: | 111 | case .item, .plainList: |
| @@ -591,3 +592,90 @@ public struct FillRegion: OrgCommand { | |||
| 591 | } | 592 | } |
| 592 | } | 593 | } |
| 593 | } | 594 | } |
| 595 | |||
| 596 | // `auto-fill-mode` in Org: `org-auto-fill-function`, which runs `do-auto-fill` with | ||
| 597 | // `org-adaptive-fill-function`'s prefix and breaks lines with `org-comment-line-break-function`. | ||
| 598 | extension EmacsBuffer { | ||
| 599 | /// After typing a space, point after it: the line broken before `fill-column` as often as it | ||
| 600 | /// takes, each new line starting with the fill prefix. | ||
| 601 | func autoFill() { | ||
| 602 | let fillColumn = options.fillColumn | ||
| 603 | guard currentColumn > fillColumn, let prefix = orgAdaptiveFillPrefix() else { return } | ||
| 604 | var giveUp = false | ||
| 605 | while !giveUp, currentColumn > fillColumn { | ||
| 606 | let fillPoint = saveExcursion { () -> Int in | ||
| 607 | beginningOfLine() | ||
| 608 | moveToColumn(cellWidth(prefix)) | ||
| 609 | let afterPrefix = point | ||
| 610 | moveToColumn(fillColumn + 1) | ||
| 611 | moveToBreakPoint(afterPrefix) | ||
| 612 | return point | ||
| 613 | } | ||
| 614 | let useless = saveExcursion { () -> Bool in | ||
| 615 | point = fillPoint | ||
| 616 | if bolp || lookingAt(" *$") != nil { return true } | ||
| 617 | // Right after a comment starter, which would only start another comment. | ||
| 618 | let limit = point | ||
| 619 | beginningOfLine() | ||
| 620 | return searchForward("^[ \\t]*#(?: |$)", bound: limit, caseInsensitive: false).map { $0[0]!.upperBound == limit } ?? false | ||
| 621 | } | ||
| 622 | if useless { break } | ||
| 623 | let previousColumn = currentColumn | ||
| 624 | let atFillPoint = saveExcursion { () -> Bool in | ||
| 625 | skipBackward(Self.blanks) | ||
| 626 | return point == fillPoint | ||
| 627 | } | ||
| 628 | if atFillPoint { | ||
| 629 | commentLineBreak() | ||
| 630 | } else { | ||
| 631 | saveExcursion { | ||
| 632 | point = fillPoint | ||
| 633 | commentLineBreak() | ||
| 634 | } | ||
| 635 | } | ||
| 636 | if currentColumn >= previousColumn { giveUp = true } | ||
| 637 | } | ||
| 638 | } | ||
| 639 | |||
| 640 | /// `org-comment-line-break-function` with SOFT: a newline at point, the space around it | ||
| 641 | /// gone, and the next line started with the fill prefix. | ||
| 642 | func commentLineBreak() { | ||
| 643 | let prefix = orgAdaptiveFillPrefix() | ||
| 644 | insert("\n") | ||
| 645 | saveExcursion { | ||
| 646 | point -= 1 | ||
| 647 | deleteBlanksAround() | ||
| 648 | } | ||
| 649 | deleteBlanksAround() | ||
| 650 | if let prefix { insert(prefix) } | ||
| 651 | } | ||
| 652 | |||
| 653 | /// `delete-horizontal-space`. | ||
| 654 | private func deleteBlanksAround() { | ||
| 655 | var start = point | ||
| 656 | while start > 0, let c = character(at: start - 1), c == 32 || c == 9 { start -= 1 } | ||
| 657 | var end = point | ||
| 658 | while let c = character(at: end), c == 32 || c == 9 { end += 1 } | ||
| 659 | deleteRegion(start, end) | ||
| 660 | point = start | ||
| 661 | } | ||
| 662 | } | ||
| 663 | |||
| 664 | /// SPC with `auto-fill-mode`: the space typed, then the line filled as Org's auto-fill does. | ||
| 665 | public struct AutoFillSpace: OrgCommand { | ||
| 666 | public init() {} | ||
| 667 | public var id: String { "org.auto-fill-space" } | ||
| 668 | public var title: String { "Type Space and Auto-Fill" } | ||
| 669 | public func applies(in context: EditContext) -> Bool { true } | ||
| 670 | public func run(in context: EditContext) -> CommandStep { | ||
| 671 | let selection = context.selection.first ?? context.caret..<context.caret | ||
| 672 | let typed = TextEdit(range: selection, replacement: " ").apply(to: context.text) | ||
| 673 | let caret = selection.lowerBound + 1 | ||
| 674 | let inserted = EditContext(revision: context.revision, text: typed, tree: OrgParser.parse(typed, defaults: context.tree.settings), | ||
| 675 | selection: [caret..<caret], now: context.now, calendar: context.calendar, options: context.options) | ||
| 676 | let filled = commitBuffer(inserted) { $0.autoFill() } | ||
| 677 | guard case .commit(let result) = filled else { return filled } | ||
| 678 | let text = result.edits.sorted { $0.range.lowerBound > $1.range.lowerBound }.reduce(typed) { $1.apply(to: $0) } | ||
| 679 | return .commit(EditResult(baseRevision: context.revision, edits: TextEdit.between(context.text, text), selection: result.selection)) | ||
| 680 | } | ||
| 681 | } | ||
Sources/OrgCore/Keymap/ISearch.swift added +168
| @@ -0,0 +1,168 @@ | |||
| 1 | import Foundation | ||
| 2 | |||
| 3 | /// Incremental search (isearch.el, Emacs 31.1) with its defaults: `isearch-lax-whitespace` | ||
| 4 | /// with `search-whitespace-regexp` `[ \t]+`, `search-upper-case` `not-yanks` (an upper-case | ||
| 5 | /// letter makes the search case-sensitive) and `isearch-wrap-pause` `t`. The editor feeds it | ||
| 6 | /// keys; it says where point and the match are and what the echo area shows. | ||
| 7 | public struct ISearch: Sendable, Equatable { | ||
| 8 | public struct State: Sendable, Equatable { | ||
| 9 | public var string: String | ||
| 10 | public var forward: Bool | ||
| 11 | /// Point: the match's end going forward, its start going back. | ||
| 12 | public var point: Int | ||
| 13 | public var match: Range<Int>? | ||
| 14 | public var failing: Bool | ||
| 15 | public var wrapped: Bool | ||
| 16 | /// Wrapped and gone past where the search began. | ||
| 17 | public var overwrapped: Bool | ||
| 18 | } | ||
| 19 | |||
| 20 | /// Where the search began, to go back to on C-g. | ||
| 21 | public let origin: Int | ||
| 22 | public private(set) var state: State | ||
| 23 | /// The states before, for DEL (`isearch-cmds`). | ||
| 24 | private var history: [State] = [] | ||
| 25 | /// What a repeat with nothing typed searches for: the previous search. | ||
| 26 | public let previous: String? | ||
| 27 | /// `isearch-forward-regexp`: the string is an ICU regular expression. | ||
| 28 | public let regexp: Bool | ||
| 29 | /// `isearch-barrier`: a backward match may not end past it; where the search began, or | ||
| 30 | /// where it last changed direction. | ||
| 31 | private var barrier: Int | ||
| 32 | |||
| 33 | public init(origin: Int, forward: Bool, previous: String? = nil, regexp: Bool = false) { | ||
| 34 | self.origin = origin | ||
| 35 | self.previous = previous | ||
| 36 | self.regexp = regexp | ||
| 37 | barrier = origin | ||
| 38 | state = State(string: "", forward: forward, point: origin, match: nil, failing: false, wrapped: false, overwrapped: false) | ||
| 39 | } | ||
| 40 | |||
| 41 | public var string: String { state.string } | ||
| 42 | public var point: Int { state.point } | ||
| 43 | public var match: Range<Int>? { state.failing ? nil : state.match } | ||
| 44 | |||
| 45 | /// `isearch-message-prefix`. | ||
| 46 | public var message: String { | ||
| 47 | var prefix = "" | ||
| 48 | if state.failing { prefix += "Failing " } | ||
| 49 | if state.overwrapped { prefix += "overwrapped " } else if state.wrapped { prefix += "wrapped " } | ||
| 50 | prefix += regexp ? "regexp I-search" : "I-search" | ||
| 51 | if !state.forward { prefix += " backward" } | ||
| 52 | prefix = prefix.prefix(1).uppercased() + prefix.dropFirst() | ||
| 53 | return prefix + ": " + state.string | ||
| 54 | } | ||
| 55 | |||
| 56 | /// The search string as a regular expression: spaces match runs of spaces and tabs; with | ||
| 57 | /// `regexp`, as it is. An invalid one is nil, and fails. | ||
| 58 | public static func pattern(_ string: String, regexp: Bool = false) -> NSRegularExpression? { | ||
| 59 | if regexp { return try? NSRegularExpression(pattern: string, options: string.contains { $0.isUppercase } ? [] : [.caseInsensitive]) } | ||
| 60 | let parts = string.split(separator: " ", omittingEmptySubsequences: false).map { NSRegularExpression.escapedPattern(for: String($0)) } | ||
| 61 | let caseSensitive = string.contains { $0.isUppercase } | ||
| 62 | return try? NSRegularExpression(pattern: parts.joined(separator: "[ \\t]+"), options: caseSensitive ? [] : [.caseInsensitive]) | ||
| 63 | } | ||
| 64 | |||
| 65 | /// The first match starting at or after `from` going forward; going back, the last one | ||
| 66 | /// ending at or before `from`. | ||
| 67 | static func find(_ string: String, in text: String, from: Int, forward: Bool, regexp: Bool = false) -> Range<Int>? { | ||
| 68 | guard !string.isEmpty, let regex = pattern(string, regexp: regexp) else { return nil } | ||
| 69 | let length = (text as NSString).length | ||
| 70 | if forward { | ||
| 71 | guard from <= length, let m = regex.firstMatch(in: text, range: NSRange(location: from, length: length - from)) else { return nil } | ||
| 72 | return m.range.location..<NSMaxRange(m.range) | ||
| 73 | } | ||
| 74 | // `re-search-backward`: the match starting nearest before `from`, ending by it. | ||
| 75 | var start = min(from, length) | ||
| 76 | while start >= 0 { | ||
| 77 | if let m = regex.firstMatch(in: text, options: .anchored, range: NSRange(location: start, length: min(from, length) - start)), m.range.length > 0 { | ||
| 78 | return m.range.location..<NSMaxRange(m.range) | ||
| 79 | } | ||
| 80 | start -= 1 | ||
| 81 | } | ||
| 82 | return nil | ||
| 83 | } | ||
| 84 | |||
| 85 | private mutating func found(_ range: Range<Int>?) { | ||
| 86 | if let range { | ||
| 87 | state.match = range | ||
| 88 | state.point = state.forward ? range.upperBound : range.lowerBound | ||
| 89 | state.failing = false | ||
| 90 | if state.wrapped, state.forward ? range.lowerBound >= origin : range.upperBound <= origin { state.overwrapped = true } | ||
| 91 | } else { | ||
| 92 | state.failing = true | ||
| 93 | } | ||
| 94 | } | ||
| 95 | |||
| 96 | /// A character typed: the search goes on with it, from the current match's start (its end | ||
| 97 | /// going back), so the match grows in place when it can. | ||
| 98 | public mutating func add(_ characters: String, in text: String) { | ||
| 99 | history.append(state) | ||
| 100 | state.string += characters | ||
| 101 | if state.failing { return } | ||
| 102 | if state.forward { | ||
| 103 | found(Self.find(state.string, in: text, from: state.match?.lowerBound ?? state.point, forward: true, regexp: regexp)) | ||
| 104 | } else { | ||
| 105 | // `looking-at` at point first, as long as the match ends by the origin; otherwise | ||
| 106 | // back from just past the current match's end. | ||
| 107 | let start = state.point | ||
| 108 | let limit = min(origin, barrier) | ||
| 109 | if let regex = Self.pattern(state.string, regexp: regexp), start <= (text as NSString).length, | ||
| 110 | let m = regex.firstMatch(in: text, options: .anchored, range: NSRange(location: start, length: (text as NSString).length - start)), m.range.length > 0, | ||
| 111 | NSMaxRange(m.range) <= limit { | ||
| 112 | found(m.range.location..<NSMaxRange(m.range)) | ||
| 113 | } else { | ||
| 114 | let from = state.match.map { min(limit, $0.upperBound + 1) } ?? state.point | ||
| 115 | found(Self.find(state.string, in: text, from: from, forward: false, regexp: regexp)) | ||
| 116 | } | ||
| 117 | } | ||
| 118 | } | ||
| 119 | |||
| 120 | /// C-s and C-r (`isearch-repeat`): the next match, the previous search when nothing is | ||
| 121 | /// typed yet, the other end of the match when the direction changes, and the other end of | ||
| 122 | /// the buffer after a failing search. | ||
| 123 | public mutating func again(forward: Bool, in text: String) { | ||
| 124 | history.append(state) | ||
| 125 | if state.string.isEmpty { | ||
| 126 | state.forward = forward | ||
| 127 | guard let previous, !previous.isEmpty else { return } | ||
| 128 | state.string = previous | ||
| 129 | found(Self.find(previous, in: text, from: state.point, forward: forward, regexp: regexp)) | ||
| 130 | return | ||
| 131 | } | ||
| 132 | if forward != state.forward { | ||
| 133 | state.forward = forward | ||
| 134 | barrier = state.point | ||
| 135 | guard let match = state.match else { return } | ||
| 136 | found(Self.find(state.string, in: text, from: forward ? match.lowerBound : match.upperBound, forward: forward, regexp: regexp)) | ||
| 137 | return | ||
| 138 | } | ||
| 139 | if state.failing { | ||
| 140 | state.wrapped = true | ||
| 141 | found(Self.find(state.string, in: text, from: forward ? 0 : (text as NSString).length, forward: forward, regexp: regexp)) | ||
| 142 | return | ||
| 143 | } | ||
| 144 | let from = state.point | ||
| 145 | var next = Self.find(state.string, in: text, from: from, forward: forward, regexp: regexp) | ||
| 146 | // An empty match at point would find itself again. | ||
| 147 | if let range = next, range.isEmpty { next = Self.find(state.string, in: text, from: forward ? from + 1 : from - 1, forward: forward, regexp: regexp) } | ||
| 148 | if next == nil { | ||
| 149 | state.failing = true | ||
| 150 | } else { | ||
| 151 | found(next) | ||
| 152 | } | ||
| 153 | } | ||
| 154 | |||
| 155 | /// DEL (`isearch-delete-char`): back to the state before the last key. | ||
| 156 | public mutating func delete() { | ||
| 157 | guard let last = history.popLast() else { return } | ||
| 158 | state = last | ||
| 159 | } | ||
| 160 | |||
| 161 | /// C-g (`isearch-abort`): with a failing search, the part that fails comes off and the | ||
| 162 | /// search goes on (true); otherwise the search is over, point back where it began (false). | ||
| 163 | public mutating func abort() -> Bool { | ||
| 164 | guard state.failing else { return false } | ||
| 165 | while state.failing, let last = history.popLast() { state = last } | ||
| 166 | return true | ||
| 167 | } | ||
| 168 | } | ||
Sources/OrgCore/Keymap/PresetEmacs.swift +8 −2
| @@ -87,10 +87,16 @@ extension KeymapPreset { | |||
| 87 | command = "edit.transpose-chars" | 87 | command = "edit.transpose-chars" |
| 88 | [[bind]] | 88 | [[bind]] |
| 89 | keys = "C-s" | 89 | keys = "C-s" |
| 90 | command = "edit.find" | 90 | command = "edit.isearch-forward" |
| 91 | [[bind]] | 91 | [[bind]] |
| 92 | keys = "C-r" | 92 | keys = "C-r" |
| 93 | command = "edit.find" | 93 | command = "edit.isearch-backward" |
| 94 | [[bind]] | ||
| 95 | keys = "C-M-s" | ||
| 96 | command = "edit.isearch-forward-regexp" | ||
| 97 | [[bind]] | ||
| 98 | keys = "C-M-r" | ||
| 99 | command = "edit.isearch-backward-regexp" | ||
| 94 | [[bind]] | 100 | [[bind]] |
| 95 | keys = "M-%" | 101 | keys = "M-%" |
| 96 | command = "edit.replace" | 102 | command = "edit.replace" |
Sources/OrgEditorAppKit/EditorCommands.swift +5
| @@ -49,6 +49,7 @@ public enum EditorCommands { | |||
| 49 | EditorCommand(id: "editor.complete", title: "Complete at Point", action: .view), | 49 | EditorCommand(id: "editor.complete", title: "Complete at Point", action: .view), |
| 50 | EditorCommand(id: "editor.toggle-spell-check", title: "Check Spelling While Typing", action: .view), | 50 | EditorCommand(id: "editor.toggle-spell-check", title: "Check Spelling While Typing", action: .view), |
| 51 | EditorCommand(id: "editor.toggle-truncate-lines", title: "Truncate or Wrap Long Lines", action: .view), | 51 | EditorCommand(id: "editor.toggle-truncate-lines", title: "Truncate or Wrap Long Lines", action: .view), |
| 52 | EditorCommand(id: "editor.toggle-auto-fill", title: "Turn Auto Fill On or Off", action: .view), | ||
| 52 | EditorCommand(id: "org.table.toggle-column-width", title: "Shrink or Expand Table Column", action: .view), | 53 | EditorCommand(id: "org.table.toggle-column-width", title: "Shrink or Expand Table Column", action: .view), |
| 53 | EditorCommand(id: "org.table.shrink", title: "Shrink Table Columns with Widths", action: .view), | 54 | EditorCommand(id: "org.table.shrink", title: "Shrink Table Columns with Widths", action: .view), |
| 54 | EditorCommand(id: "org.table.expand", title: "Expand Table Columns", action: .view), | 55 | EditorCommand(id: "org.table.expand", title: "Expand Table Columns", action: .view), |
| @@ -186,6 +187,10 @@ public enum EditorCommands { | |||
| 186 | edit("undo", "Undo", "undo:"), | 187 | edit("undo", "Undo", "undo:"), |
| 187 | edit("transpose-chars", "Transpose Characters", "transpose:"), | 188 | edit("transpose-chars", "Transpose Characters", "transpose:"), |
| 188 | EditorCommand(id: "edit.find", title: "Find", action: .find(.showFindInterface)), | 189 | EditorCommand(id: "edit.find", title: "Find", action: .find(.showFindInterface)), |
| 190 | EditorCommand(id: "edit.isearch-forward", title: "Incremental Search", action: .view), | ||
| 191 | EditorCommand(id: "edit.isearch-backward", title: "Incremental Search Backward", action: .view), | ||
| 192 | EditorCommand(id: "edit.isearch-forward-regexp", title: "Incremental Regexp Search", action: .view), | ||
| 193 | EditorCommand(id: "edit.isearch-backward-regexp", title: "Incremental Regexp Search Backward", action: .view), | ||
| 189 | EditorCommand(id: "edit.replace", title: "Find and Replace", action: .find(.showReplaceInterface)), | 194 | EditorCommand(id: "edit.replace", title: "Find and Replace", action: .find(.showReplaceInterface)), |
| 190 | EditorCommand(id: "edit.find-next", title: "Find Next", action: .find(.nextMatch)), | 195 | EditorCommand(id: "edit.find-next", title: "Find Next", action: .find(.nextMatch)), |
| 191 | EditorCommand(id: "edit.find-previous", title: "Find Previous", action: .find(.previousMatch)), | 196 | EditorCommand(id: "edit.find-previous", title: "Find Previous", action: .find(.previousMatch)), |
Sources/OrgEditorAppKit/Keys.swift +3
| @@ -51,6 +51,9 @@ final class OrgTextView: NSTextView { | |||
| 51 | var showsLineNumbers = false { | 51 | var showsLineNumbers = false { |
| 52 | didSet { if showsLineNumbers != oldValue { updateGutter() } } | 52 | didSet { if showsLineNumbers != oldValue { updateGutter() } } |
| 53 | } | 53 | } |
| 54 | var lineNumbersType = LineNumbersType.absolute { | ||
| 55 | didSet { if lineNumbersType != oldValue { needsDisplay = true } } | ||
| 56 | } | ||
| 54 | 57 | ||
| 55 | override func drawBackground(in rect: NSRect) { | 58 | override func drawBackground(in rect: NSRect) { |
| 56 | super.drawBackground(in: rect) | 59 | super.drawBackground(in: rect) |
Sources/OrgEditorAppKit/LineNumbers.swift +46 −6
| @@ -1,6 +1,11 @@ | |||
| 1 | #if os(macOS) | 1 | #if os(macOS) |
| 2 | import AppKit | 2 | import AppKit |
| 3 | 3 | ||
| 4 | /// `display-line-numbers-type`: `t`, `relative` or `visual`. | ||
| 5 | public enum LineNumbersType: String, Sendable { | ||
| 6 | case absolute = "t", relative, visual | ||
| 7 | } | ||
| 8 | |||
| 4 | /// Line numbers in a margin left of the text, as `display-line-numbers-mode` shows them: one | 9 | /// Line numbers in a margin left of the text, as `display-line-numbers-mode` shows them: one |
| 5 | /// per line of the file (folded lines skipped, wrapped lines numbered once), the caret's line | 10 | /// per line of the file (folded lines skipped, wrapped lines numbered once), the caret's line |
| 6 | /// bright. Drawn by the text view itself: an `NSRulerView` stops TextKit 2 from drawing text. | 11 | /// bright. Drawn by the text view itself: an `NSRulerView` stops TextKit 2 from drawing text. |
| @@ -24,26 +29,61 @@ extension OrgTextView { | |||
| 24 | let gutter = textContainerInset.width | 29 | let gutter = textContainerInset.width |
| 25 | guard rect.minX < gutter else { return } | 30 | guard rect.minX < gutter else { return } |
| 26 | let text = string as NSString | 31 | let text = string as NSString |
| 27 | let caretLine = text.lineRange(for: NSRange(location: min(selectedRange().location, text.length), length: 0)).location | 32 | let caret = min(selectedRange().location, text.length) |
| 33 | let caretLine = text.lineRange(for: NSRange(location: caret, length: 0)).location | ||
| 34 | let caretNumber = lineIndex?.line(of: caretLine) ?? 1 | ||
| 28 | let origin = textContainerOrigin | 35 | let origin = textContainerOrigin |
| 29 | let documentStart = content.documentRange.location | 36 | let documentStart = content.documentRange.location |
| 30 | guard let start = layout.textLayoutFragment(for: CGPoint(x: 0, y: max(0, rect.minY - origin.y)))?.rangeInElement.location | 37 | guard let start = layout.textLayoutFragment(for: CGPoint(x: 0, y: max(0, rect.minY - origin.y)))?.rangeInElement.location |
| 31 | ?? layout.textViewportLayoutController.viewportRange?.location else { return } | 38 | ?? layout.textViewportLayoutController.viewportRange?.location else { return } |
| 32 | 39 | ||
| 40 | // The screen lines to number: each paragraph's first, or every one for visual numbers. | ||
| 41 | struct Row { var y: CGFloat; var height: CGFloat; var line: Int; var hasCaret: Bool } | ||
| 42 | var rows: [Row] = [] | ||
| 33 | layout.enumerateTextLayoutFragments(from: start, options: []) { fragment in | 43 | layout.enumerateTextLayoutFragments(from: start, options: []) { fragment in |
| 34 | let frame = fragment.layoutFragmentFrame | 44 | let frame = fragment.layoutFragmentFrame |
| 35 | if frame.minY + origin.y > rect.maxY { return false } | 45 | if frame.minY + origin.y > rect.maxY { return false } |
| 36 | let offset = content.offset(from: documentStart, to: fragment.rangeInElement.location) | 46 | let offset = content.offset(from: documentStart, to: fragment.rangeInElement.location) |
| 37 | guard offset <= text.length else { return false } | 47 | guard offset <= text.length else { return false } |
| 38 | let line = lineIndex?.line(of: offset) ?? 1 | 48 | let line = lineIndex?.line(of: offset) ?? 1 |
| 39 | let label = NSAttributedString(string: "\(line)", attributes: [ | 49 | let lines = lineNumbersType == .visual ? fragment.textLineFragments : Array(fragment.textLineFragments.prefix(1)) |
| 50 | if lines.isEmpty { | ||
| 51 | rows.append(Row(y: frame.minY + origin.y, height: frame.height, line: line, hasCaret: offset == caretLine)) | ||
| 52 | } | ||
| 53 | for (index, lineFragment) in lines.enumerated() { | ||
| 54 | let range = lineFragment.characterRange | ||
| 55 | let begin = offset + range.location | ||
| 56 | let last = index == fragment.textLineFragments.count - 1 | ||
| 57 | let hasCaret = lineNumbersType == .visual | ||
| 58 | ? caret >= begin && (caret < begin + range.length || (last && caret <= begin + range.length)) | ||
| 59 | : offset == caretLine | ||
| 60 | rows.append(Row(y: frame.minY + origin.y + lineFragment.typographicBounds.minY, height: lineFragment.typographicBounds.height, | ||
| 61 | line: line, hasCaret: hasCaret)) | ||
| 62 | } | ||
| 63 | return true | ||
| 64 | } | ||
| 65 | let caretRow = rows.firstIndex { $0.hasCaret } | ||
| 66 | for (index, row) in rows.enumerated() { | ||
| 67 | let number: Int | ||
| 68 | switch lineNumbersType { | ||
| 69 | case .absolute: number = row.line | ||
| 70 | // The caret's line keeps its own number, as `display-line-numbers-current-absolute` has it. | ||
| 71 | case .relative: number = row.hasCaret ? row.line : abs(row.line - caretNumber) | ||
| 72 | case .visual: | ||
| 73 | if row.hasCaret { | ||
| 74 | number = row.line | ||
| 75 | } else if let caretRow { | ||
| 76 | number = abs(index - caretRow) | ||
| 77 | } else { | ||
| 78 | number = abs(row.line - caretNumber) | ||
| 79 | } | ||
| 80 | } | ||
| 81 | let label = NSAttributedString(string: "\(number)", attributes: [ | ||
| 40 | .font: lineNumberFont, | 82 | .font: lineNumberFont, |
| 41 | .foregroundColor: offset == caretLine ? currentLineNumberColor : lineNumberColor, | 83 | .foregroundColor: row.hasCaret ? currentLineNumberColor : lineNumberColor, |
| 42 | ]) | 84 | ]) |
| 43 | let lineHeight = fragment.textLineFragments.first?.typographicBounds.height ?? frame.height | ||
| 44 | let size = label.size() | 85 | let size = label.size() |
| 45 | label.draw(at: NSPoint(x: gutter - size.width - 8, y: frame.minY + origin.y + (lineHeight - size.height) / 2)) | 86 | label.draw(at: NSPoint(x: gutter - size.width - 8, y: row.y + (row.height - size.height) / 2)) |
| 46 | return true | ||
| 47 | } | 87 | } |
| 48 | } | 88 | } |
| 49 | } | 89 | } |
Sources/OrgEditorAppKit/Modal.swift +4 −2
| @@ -85,8 +85,8 @@ extension OrgEditor { | |||
| 85 | func feedVim(_ keys: [KeyChord]) -> Bool { | 85 | func feedVim(_ keys: [KeyChord]) -> Bool { |
| 86 | for (index, key) in keys.enumerated() { | 86 | for (index, key) in keys.enumerated() { |
| 87 | if vim.mode == .insert, vim.passesThrough(key) { | 87 | if vim.mode == .insert, vim.passesThrough(key) { |
| 88 | if keys.count == 1 { return electricPair(key) } | 88 | if keys.count == 1 { return electricPair(key) || autoFill(key) } |
| 89 | if !electricPair(key) { insertTyped(key) } | 89 | if !electricPair(key), !autoFill(key) { insertTyped(key) } |
| 90 | continue | 90 | continue |
| 91 | } | 91 | } |
| 92 | let leaving = key == KeyChord("ESC") || key == KeyChord("[", .control) || key == KeyChord("g", .control) | 92 | let leaving = key == KeyChord("ESC") || key == KeyChord("[", .control) || key == KeyChord("g", .control) |
| @@ -331,6 +331,8 @@ extension OrgEditor { | |||
| 331 | /// `/`, `?` and `:` read their argument in the echo area; `history` (`q:`) offers the | 331 | /// `/`, `?` and `:` read their argument in the echo area; `history` (`q:`) offers the |
| 332 | /// earlier ones to pick and edit. | 332 | /// earlier ones to pick and edit. |
| 333 | private func prompt(_ kind: String, history: Bool = false) { | 333 | private func prompt(_ kind: String, history: Bool = false) { |
| 334 | // `/` and `?` search as you type. | ||
| 335 | if !history, kind == "/" || kind == "?" { return startISearch(forward: kind == "/", vim: true) } | ||
| 334 | let earlier = Array((Self.promptHistory[kind] ?? []).reversed()) | 336 | let earlier = Array((Self.promptHistory[kind] ?? []).reversed()) |
| 335 | let request = history ? Prompt(key: kind, message: kind, choices: earlier, requireMatch: false) : Prompt(key: kind, message: kind) | 337 | let request = history ? Prompt(key: kind, message: kind, choices: earlier, requireMatch: false) : Prompt(key: kind, message: kind) |
| 336 | onPrompt?(request) { [weak self] answer in | 338 | onPrompt?(request) { [weak self] answer in |
Sources/OrgEditorAppKit/OrgEditor+ISearch.swift added +108
| @@ -0,0 +1,108 @@ | |||
| 1 | #if os(macOS) | ||
| 2 | import AppKit | ||
| 3 | import OrgCore | ||
| 4 | |||
| 5 | // Incremental search: C-s and C-r in the Emacs preset, `/` and `?` in the Doom preset. While | ||
| 6 | // it runs, keys go to the search; the match is selected and the other matches highlighted. | ||
| 7 | extension OrgEditor { | ||
| 8 | /// Starts searching from the caret. `vim`: `/` or `?`, which end with Vim's search, so `n` | ||
| 9 | /// and `N` repeat it. | ||
| 10 | func startISearch(forward: Bool, vim: Bool = false, regexp: Bool = false) { | ||
| 11 | isearch = ISearch(origin: textView.selectedRange().location, forward: forward, previous: Self.lastISearch, regexp: regexp || vim) | ||
| 12 | isearchVim = vim | ||
| 13 | showISearch() | ||
| 14 | } | ||
| 15 | |||
| 16 | /// A key while searching: true when the search took it, false when the search ended | ||
| 17 | /// and the key should run as usual. | ||
| 18 | func isearchKey(_ chord: KeyChord) -> Bool { | ||
| 19 | guard var search = isearch else { return false } | ||
| 20 | let text = document.text | ||
| 21 | switch (chord.key, chord.modifiers) { | ||
| 22 | case ("s", [.control]) where !isearchVim, ("s", [.control, .meta]) where !isearchVim: | ||
| 23 | search.again(forward: true, in: text) | ||
| 24 | case ("r", [.control]) where !isearchVim, ("r", [.control, .meta]) where !isearchVim: | ||
| 25 | search.again(forward: false, in: text) | ||
| 26 | case ("DEL", []): | ||
| 27 | if isearchVim, search.string.isEmpty { | ||
| 28 | endISearch(caret: search.origin) | ||
| 29 | return true | ||
| 30 | } | ||
| 31 | search.delete() | ||
| 32 | case ("g", [.control]): | ||
| 33 | if search.abort() { | ||
| 34 | isearch = search | ||
| 35 | showISearch() | ||
| 36 | } else { | ||
| 37 | endISearch(caret: search.origin) | ||
| 38 | onMessage?("Quit") | ||
| 39 | } | ||
| 40 | return true | ||
| 41 | case ("ESC", []) where isearchVim: | ||
| 42 | endISearch(caret: search.origin) | ||
| 43 | return true | ||
| 44 | case ("RET", []): | ||
| 45 | finishISearch(search) | ||
| 46 | return true | ||
| 47 | case ("SPC", []): | ||
| 48 | search.add(" ", in: text) | ||
| 49 | case (let key, let modifiers) where key.count == 1 && (modifiers.isEmpty || modifiers == [.shift]): | ||
| 50 | search.add(key, in: text) | ||
| 51 | default: | ||
| 52 | // Any other key ends the search where it is, then runs. | ||
| 53 | finishISearch(search) | ||
| 54 | return false | ||
| 55 | } | ||
| 56 | isearch = search | ||
| 57 | showISearch() | ||
| 58 | return true | ||
| 59 | } | ||
| 60 | |||
| 61 | private func finishISearch(_ search: ISearch) { | ||
| 62 | if !search.string.isEmpty { Self.lastISearch = search.string } | ||
| 63 | if isearchVim, !search.string.isEmpty { | ||
| 64 | endISearch(caret: search.origin) | ||
| 65 | let context = Vim.Context(text: document.text, caret: search.origin) | ||
| 66 | apply(vim.search(search.string, forward: search.state.forward, context)) | ||
| 67 | updateCursor() | ||
| 68 | } else { | ||
| 69 | endISearch(caret: search.point) | ||
| 70 | } | ||
| 71 | } | ||
| 72 | |||
| 73 | private func endISearch(caret: Int) { | ||
| 74 | isearch = nil | ||
| 75 | setISearchHighlights([]) | ||
| 76 | setCaret(caret) | ||
| 77 | } | ||
| 78 | |||
| 79 | /// The match selected, the others highlighted, and the prompt in the echo area. | ||
| 80 | private func showISearch() { | ||
| 81 | guard let search = isearch else { return } | ||
| 82 | if let match = search.match { | ||
| 83 | // Folded text around the match opens, as `isearch-open-invisible` opens it. | ||
| 84 | reveal(match.lowerBound) | ||
| 85 | textView.setSelectedRange(NSRange(location: match.lowerBound, length: match.count)) | ||
| 86 | textView.scrollRangeToVisible(NSRange(location: match.lowerBound, length: match.count)) | ||
| 87 | } else { | ||
| 88 | textView.setSelectedRange(NSRange(location: search.point, length: 0)) | ||
| 89 | } | ||
| 90 | var others: [Range<Int>] = [] | ||
| 91 | if !search.string.isEmpty, let regex = ISearch.pattern(search.string, regexp: search.regexp) { | ||
| 92 | for m in regex.matches(in: document.text, range: NSRange(location: 0, length: utf16Length)).prefix(1000) where m.range.length > 0 { | ||
| 93 | let range = m.range.location..<NSMaxRange(m.range) | ||
| 94 | if range != search.match { others.append(range) } | ||
| 95 | } | ||
| 96 | } | ||
| 97 | setISearchHighlights(others) | ||
| 98 | onMessage?(isearchVim ? (search.state.forward ? "/" : "?") + search.string : search.message) | ||
| 99 | } | ||
| 100 | |||
| 101 | private func setISearchHighlights(_ ranges: [Range<Int>]) { | ||
| 102 | let old = highlights | ||
| 103 | highlights = ranges | ||
| 104 | for range in old + ranges where range.upperBound <= utf16Length { restyleOutsideEditing(range) } | ||
| 105 | redrawViews() | ||
| 106 | } | ||
| 107 | } | ||
| 108 | #endif | ||
Sources/OrgEditorAppKit/OrgEditor.swift +34 −2
| @@ -207,6 +207,7 @@ public final class OrgEditor: NSObject { | |||
| 207 | configure(view, frame: frame, editable: active.isEditable) | 207 | configure(view, frame: frame, editable: active.isEditable) |
| 208 | view.lineIndex = lines | 208 | view.lineIndex = lines |
| 209 | view.showsLineNumbers = showLineNumbers | 209 | view.showsLineNumbers = showLineNumbers |
| 210 | view.lineNumbersType = lineNumbersType | ||
| 210 | view.isContinuousSpellCheckingEnabled = active.isContinuousSpellCheckingEnabled | 211 | view.isContinuousSpellCheckingEnabled = active.isContinuousSpellCheckingEnabled |
| 211 | view.blockCursor = active.blockCursor | 212 | view.blockCursor = active.blockCursor |
| 212 | applyThemeToView() | 213 | applyThemeToView() |
| @@ -323,6 +324,7 @@ public final class OrgEditor: NSObject { | |||
| 323 | scroll.hasVerticalScroller = true | 324 | scroll.hasVerticalScroller = true |
| 324 | scroll.documentView = textView | 325 | scroll.documentView = textView |
| 325 | (textView as? OrgTextView)?.showsLineNumbers = showLineNumbers | 326 | (textView as? OrgTextView)?.showsLineNumbers = showLineNumbers |
| 327 | (textView as? OrgTextView)?.lineNumbersType = lineNumbersType | ||
| 326 | textView.minSize = NSSize(width: 0, height: scroll.contentSize.height) | 328 | textView.minSize = NSSize(width: 0, height: scroll.contentSize.height) |
| 327 | textView.maxSize = NSSize(width: CGFloat.greatestFiniteMagnitude, height: CGFloat.greatestFiniteMagnitude) | 329 | textView.maxSize = NSSize(width: CGFloat.greatestFiniteMagnitude, height: CGFloat.greatestFiniteMagnitude) |
| 328 | return scroll | 330 | return scroll |
| @@ -384,6 +386,9 @@ public final class OrgEditor: NSObject { | |||
| 384 | didSet { if showMarkup != oldValue { restyleEverything() } } | 386 | didSet { if showMarkup != oldValue { restyleEverything() } } |
| 385 | } | 387 | } |
| 386 | /// Line numbers in a ruler beside the text. | 388 | /// Line numbers in a ruler beside the text. |
| 389 | public var lineNumbersType = LineNumbersType.absolute { | ||
| 390 | didSet { for view in orgTextViews { view.lineNumbersType = lineNumbersType } } | ||
| 391 | } | ||
| 387 | public var showLineNumbers = true { | 392 | public var showLineNumbers = true { |
| 388 | didSet { for view in orgTextViews { view.showsLineNumbers = showLineNumbers } } | 393 | didSet { for view in orgTextViews { view.showsLineNumbers = showLineNumbers } } |
| 389 | } | 394 | } |
| @@ -429,6 +434,11 @@ public final class OrgEditor: NSObject { | |||
| 429 | var replayingMacro = 0 | 434 | var replayingMacro = 0 |
| 430 | /// A region is active: movement extends the selection, as after C-SPC in Emacs. | 435 | /// A region is active: movement extends the selection, as after C-SPC in Emacs. |
| 431 | private(set) var markActive = false | 436 | private(set) var markActive = false |
| 437 | /// An incremental search in progress, and whether Vim's `/` or `?` started it. | ||
| 438 | var isearch: ISearch? | ||
| 439 | var isearchVim = false | ||
| 440 | /// The last search string, for C-s C-s. | ||
| 441 | static var lastISearch: String? | ||
| 432 | 442 | ||
| 433 | public func context(now: Date = Date(), answers: [String: String] = [:]) -> EditContext { | 443 | public func context(now: Date = Date(), answers: [String: String] = [:]) -> EditContext { |
| 434 | let selected = textView.selectedRange() | 444 | let selected = textView.selectedRange() |
| @@ -443,6 +453,7 @@ public final class OrgEditor: NSObject { | |||
| 443 | /// Offers a key press to the keymap. False lets the text system have it. | 453 | /// Offers a key press to the keymap. False lets the text system have it. |
| 444 | func handleKey(_ event: NSEvent) -> Bool { | 454 | func handleKey(_ event: NSEvent) -> Bool { |
| 445 | guard let chord = KeyEvents.chord(for: event, optionAsMeta: optionAsMeta) else { return modal && vim.mode != .insert } | 455 | guard let chord = KeyEvents.chord(for: event, optionAsMeta: optionAsMeta) else { return modal && vim.mode != .insert } |
| 456 | if isearch != nil, isearchKey(chord) { return true } | ||
| 446 | if let handled = completionKey(chord) { return handled } | 457 | if let handled = completionKey(chord) { return handled } |
| 447 | if modal { return handleModal(chord) } | 458 | if modal { return handleModal(chord) } |
| 448 | switch dispatcher.feed(chord) { | 459 | switch dispatcher.feed(chord) { |
| @@ -462,7 +473,7 @@ public final class OrgEditor: NSObject { | |||
| 462 | onMessage?("\(KeySequence.format(keys)) is undefined") | 473 | onMessage?("\(KeySequence.format(keys)) is undefined") |
| 463 | return true | 474 | return true |
| 464 | case .unbound: | 475 | case .unbound: |
| 465 | return electricPair(chord) | 476 | return electricPair(chord) || autoFill(chord) |
| 466 | case .complete(let keys, let candidates): | 477 | case .complete(let keys, let candidates): |
| 467 | if keys.count > 1 { onKeysPending?(nil, []) } | 478 | if keys.count > 1 { onKeysPending?(nil, []) } |
| 468 | let context = context() | 479 | let context = context() |
| @@ -471,10 +482,26 @@ public final class OrgEditor: NSObject { | |||
| 471 | run(binding.command) | 482 | run(binding.command) |
| 472 | return true | 483 | return true |
| 473 | } | 484 | } |
| 474 | return keys.count == 1 && electricPair(chord) | 485 | return keys.count == 1 && (electricPair(chord) || autoFill(chord)) |
| 475 | } | 486 | } |
| 476 | } | 487 | } |
| 477 | 488 | ||
| 489 | /// `auto-fill-mode` for this buffer: the settings' unless toggled here. | ||
| 490 | public var autoFillOverride: Bool? | ||
| 491 | var autoFills: Bool { isOrg && (autoFillOverride ?? options.autoFill) } | ||
| 492 | |||
| 493 | /// SPC with `auto-fill-mode`: true when it typed the space and filled the line. | ||
| 494 | func autoFill(_ key: KeyChord) -> Bool { | ||
| 495 | guard autoFills, key.key == "SPC", key.modifiers.isEmpty, !textView.hasMarkedText() else { return false } | ||
| 496 | _ = perform(AutoFillSpace()) | ||
| 497 | return true | ||
| 498 | } | ||
| 499 | |||
| 500 | func toggleAutoFill() { | ||
| 501 | autoFillOverride = !autoFills | ||
| 502 | onMessage?(autoFills ? "Auto-Fill mode enabled in current buffer" : "Auto-Fill mode disabled in current buffer") | ||
| 503 | } | ||
| 504 | |||
| 478 | /// `electric-pair-mode` for a key the keymap leaves to the text system: true when it | 505 | /// `electric-pair-mode` for a key the keymap leaves to the text system: true when it |
| 479 | /// typed the key itself. | 506 | /// typed the key itself. |
| 480 | func electricPair(_ key: KeyChord) -> Bool { | 507 | func electricPair(_ key: KeyChord) -> Bool { |
| @@ -537,6 +564,11 @@ public final class OrgEditor: NSObject { | |||
| 537 | case "editor.toggle-spell-check": toggleSpellCheck() | 564 | case "editor.toggle-spell-check": toggleSpellCheck() |
| 538 | case "editor.complete": completeAtPoint() | 565 | case "editor.complete": completeAtPoint() |
| 539 | case "editor.toggle-truncate-lines": toggleTruncateLines() | 566 | case "editor.toggle-truncate-lines": toggleTruncateLines() |
| 567 | case "editor.toggle-auto-fill": toggleAutoFill() | ||
| 568 | case "edit.isearch-forward": startISearch(forward: true) | ||
| 569 | case "edit.isearch-backward": startISearch(forward: false) | ||
| 570 | case "edit.isearch-forward-regexp": startISearch(forward: true, regexp: true) | ||
| 571 | case "edit.isearch-backward-regexp": startISearch(forward: false, regexp: true) | ||
| 540 | default: tableColumnWidth(id) | 572 | default: tableColumnWidth(id) |
| 541 | } | 573 | } |
| 542 | case .edit(let selector, let extending): | 574 | case .edit(let selector, let extending): |
Sources/Orgstar/ContentView.swift +3 −1
| @@ -84,6 +84,7 @@ struct ContentView: View { | |||
| 84 | @AppStorage("inspectorShown") private var inspectorShown = false | 84 | @AppStorage("inspectorShown") private var inspectorShown = false |
| 85 | @AppStorage("showMarkup") private var showMarkup = false | 85 | @AppStorage("showMarkup") private var showMarkup = false |
| 86 | @AppStorage("showLineNumbers") private var showLineNumbers = true | 86 | @AppStorage("showLineNumbers") private var showLineNumbers = true |
| 87 | @AppStorage("lineNumbersType") private var lineNumbersType = "t" | ||
| 87 | @AppStorage("showHiddenFiles") private var showHiddenFiles = true | 88 | @AppStorage("showHiddenFiles") private var showHiddenFiles = true |
| 88 | @AppStorage("ignoredFolders") private var ignoredFolders = ScanRules.defaultIgnoredFolders.sorted().joined(separator: " ") | 89 | @AppStorage("ignoredFolders") private var ignoredFolders = ScanRules.defaultIgnoredFolders.sorted().joined(separator: " ") |
| 89 | @AppStorage("themeFont") private var themeFont = "" | 90 | @AppStorage("themeFont") private var themeFont = "" |
| @@ -108,7 +109,8 @@ struct ContentView: View { | |||
| 108 | @State private var window: WindowModel? | 109 | @State private var window: WindowModel? |
| 109 | 110 | ||
| 110 | private var editorSettings: EditorSettings { | 111 | private var editorSettings: EditorSettings { |
| 111 | EditorSettings(keymap: keymap, modal: preset.isModal, optionAsMeta: OptionAsMeta(rawValue: optionAsMeta), options: options, showMarkup: showMarkup, showLineNumbers: showLineNumbers, theme: theme) | 112 | EditorSettings(keymap: keymap, modal: preset.isModal, optionAsMeta: OptionAsMeta(rawValue: optionAsMeta), options: options, showMarkup: showMarkup, showLineNumbers: showLineNumbers, |
| 113 | lineNumbersType: LineNumbersType(rawValue: lineNumbersType) ?? .absolute, theme: theme) | ||
| 112 | } | 114 | } |
| 113 | 115 | ||
| 114 | /// The pane that had the focus when a sheet opened, to act on when it closes. | 116 | /// The pane that had the focus when a sheet opened, to act on when it closes. |
Sources/Orgstar/OrgstarApp.swift +7
| @@ -428,6 +428,7 @@ struct OrgstarApp: App { | |||
| 428 | .keyboardShortcut("i", modifiers: [.command, .option]) | 428 | .keyboardShortcut("i", modifiers: [.command, .option]) |
| 429 | MarkupToggle() | 429 | MarkupToggle() |
| 430 | Button("Truncate or Wrap Long Lines") { commands.run("editor.toggle-truncate-lines") } | 430 | Button("Truncate or Wrap Long Lines") { commands.run("editor.toggle-truncate-lines") } |
| 431 | Button("Turn Auto Fill On or Off") { commands.run("editor.toggle-auto-fill") } | ||
| 431 | } | 432 | } |
| 432 | CommandGroup(after: .pasteboard) { | 433 | CommandGroup(after: .pasteboard) { |
| 433 | Divider() | 434 | Divider() |
| @@ -501,12 +502,18 @@ struct MarkupToggle: View { | |||
| 501 | @AppStorage("showTabBar") private var showTabBar = false | 502 | @AppStorage("showTabBar") private var showTabBar = false |
| 502 | @AppStorage("showMarkup") private var showMarkup = false | 503 | @AppStorage("showMarkup") private var showMarkup = false |
| 503 | @AppStorage("showLineNumbers") private var showLineNumbers = true | 504 | @AppStorage("showLineNumbers") private var showLineNumbers = true |
| 505 | @AppStorage("lineNumbersType") private var lineNumbersType = "t" | ||
| 504 | 506 | ||
| 505 | var body: some View { | 507 | var body: some View { |
| 506 | Toggle("Show Markup", isOn: $showMarkup) | 508 | Toggle("Show Markup", isOn: $showMarkup) |
| 507 | .keyboardShortcut("m", modifiers: [.command, .shift]) | 509 | .keyboardShortcut("m", modifiers: [.command, .shift]) |
| 508 | Toggle("Show Line Numbers", isOn: $showLineNumbers) | 510 | Toggle("Show Line Numbers", isOn: $showLineNumbers) |
| 509 | .keyboardShortcut("l", modifiers: [.command, .shift]) | 511 | .keyboardShortcut("l", modifiers: [.command, .shift]) |
| 512 | Picker("Line Numbers", selection: $lineNumbersType) { | ||
| 513 | Text("Absolute").tag("t") | ||
| 514 | Text("Relative").tag("relative") | ||
| 515 | Text("Visual").tag("visual") | ||
| 516 | } | ||
| 510 | Toggle("Show Tab Bar", isOn: $showTabBar) | 517 | Toggle("Show Tab Bar", isOn: $showTabBar) |
| 511 | } | 518 | } |
| 512 | } | 519 | } |
Sources/Orgstar/PaneView.swift +2
| @@ -14,6 +14,7 @@ struct EditorSettings: Equatable { | |||
| 14 | var options = EditingOptions.org | 14 | var options = EditingOptions.org |
| 15 | var showMarkup = false | 15 | var showMarkup = false |
| 16 | var showLineNumbers = true | 16 | var showLineNumbers = true |
| 17 | var lineNumbersType = LineNumbersType.absolute | ||
| 17 | var theme = ThemeSpec.default | 18 | var theme = ThemeSpec.default |
| 18 | } | 19 | } |
| 19 | 20 | ||
| @@ -69,6 +70,7 @@ struct PaneView: NSViewRepresentable { | |||
| 69 | if editor.options != options { editor.options = options } | 70 | if editor.options != options { editor.options = options } |
| 70 | editor.showMarkup = settings.showMarkup | 71 | editor.showMarkup = settings.showMarkup |
| 71 | editor.showLineNumbers = settings.showLineNumbers | 72 | editor.showLineNumbers = settings.showLineNumbers |
| 73 | editor.lineNumbersType = settings.lineNumbersType | ||
| 72 | editor.themeSpec = settings.theme | 74 | editor.themeSpec = settings.theme |
| 73 | } | 75 | } |
| 74 | container.window?.isDocumentEdited = !session.dirtyPaths.isEmpty | 76 | container.window?.isDocumentEdited = !session.dirtyPaths.isEmpty |
Sources/OrgstarMobile/EditorScreen.swift +2 −1
| @@ -784,7 +784,8 @@ struct CommandPalette: View { | |||
| 784 | ("app.clock.default", "Mark as Default Clock Task"), ("app.clock.resolve", "Resolve Open Clocks…"), | 784 | ("app.clock.default", "Mark as Default Clock Task"), ("app.clock.resolve", "Resolve Open Clocks…"), |
| 785 | ("app.refile", "Refile…"), ("app.refile.copy", "Copy to Refile Target…"), ("app.refile.goto", "Go to Refile Target…"), | 785 | ("app.refile", "Refile…"), ("app.refile.copy", "Copy to Refile Target…"), ("app.refile.goto", "Go to Refile Target…"), |
| 786 | ("app.toggle-markup", "Show or Hide Markup"), | 786 | ("app.toggle-markup", "Show or Hide Markup"), |
| 787 | ("org.toggle-inline-images", "Show or Hide Inline Images"), ("org.latex-preview", "Show or Hide LaTeX Previews"), ("editor.toggle-truncate-lines", "Truncate or Wrap Long Lines"), | 787 | ("org.toggle-inline-images", "Show or Hide Inline Images"), ("org.latex-preview", "Show or Hide LaTeX Previews"), ("editor.toggle-truncate-lines", "Truncate or Wrap Long Lines"), ("editor.toggle-auto-fill", "Turn Auto Fill On or Off"), |
| 788 | ("edit.isearch-forward", "Incremental Search"), ("edit.isearch-backward", "Incremental Search Backward"), | ||
| 788 | ("org.table.toggle-column-width", "Shrink or Expand Table Column"), ("org.table.shrink", "Shrink Table Columns with Widths"), | 789 | ("org.table.toggle-column-width", "Shrink or Expand Table Column"), ("org.table.shrink", "Shrink Table Columns with Widths"), |
| 789 | ("org.table.expand", "Expand Table Columns"), | 790 | ("org.table.expand", "Expand Table Columns"), |
| 790 | ("app.table-import", "Import Table from File…"), ("app.table-export", "Export Table to File…"), ("app.plot", "Plot Table"), | 791 | ("app.table-import", "Import Table from File…"), ("app.table-export", "Export Table to File…"), ("app.plot", "Plot Table"), |
Sources/OrgstarMobile/MobileEditor+ISearch.swift added +81
| @@ -0,0 +1,81 @@ | |||
| 1 | #if os(iOS) | ||
| 2 | import OrgCore | ||
| 3 | import UIKit | ||
| 4 | |||
| 5 | // Incremental search: C-s and C-r with a hardware keyboard in the Emacs preset, or from | ||
| 6 | // Commands. While it runs, typed keys go to the search and the match is selected. | ||
| 7 | extension MobileEditor { | ||
| 8 | func startISearch(forward: Bool, regexp: Bool = false) { | ||
| 9 | isearch = ISearch(origin: textView.selectedRange.location, forward: forward, previous: Self.lastISearch, regexp: regexp) | ||
| 10 | showISearch() | ||
| 11 | } | ||
| 12 | |||
| 13 | /// A key while searching: true when the search took it, false when the search ended and | ||
| 14 | /// the key should run as usual. | ||
| 15 | func isearchKey(_ chord: KeyChord) -> Bool { | ||
| 16 | guard var search = isearch else { return false } | ||
| 17 | let text = document.text | ||
| 18 | switch (chord.key, chord.modifiers) { | ||
| 19 | case ("s", [.control]), ("s", [.control, .meta]): search.again(forward: true, in: text) | ||
| 20 | case ("r", [.control]), ("r", [.control, .meta]): search.again(forward: false, in: text) | ||
| 21 | case ("DEL", []): search.delete() | ||
| 22 | case ("g", [.control]): | ||
| 23 | if search.abort() { | ||
| 24 | isearch = search | ||
| 25 | showISearch() | ||
| 26 | } else { | ||
| 27 | endISearch(caret: search.origin) | ||
| 28 | onMessage?("Quit") | ||
| 29 | } | ||
| 30 | return true | ||
| 31 | case ("RET", []): | ||
| 32 | finishISearch(search) | ||
| 33 | return true | ||
| 34 | case ("SPC", []): search.add(" ", in: text) | ||
| 35 | case (let key, let modifiers) where key.count == 1 && (modifiers.isEmpty || modifiers == [.shift]): | ||
| 36 | search.add(key, in: text) | ||
| 37 | default: | ||
| 38 | finishISearch(search) | ||
| 39 | return false | ||
| 40 | } | ||
| 41 | isearch = search | ||
| 42 | showISearch() | ||
| 43 | return true | ||
| 44 | } | ||
| 45 | |||
| 46 | /// Text from the on-screen keyboard while searching: it goes into the search string. | ||
| 47 | func isearchTyped(_ typed: String) { | ||
| 48 | guard var search = isearch else { return } | ||
| 49 | if typed == "\n" { return finishISearch(search) } | ||
| 50 | if typed.isEmpty { | ||
| 51 | search.delete() | ||
| 52 | } else { | ||
| 53 | search.add(typed, in: document.text) | ||
| 54 | } | ||
| 55 | isearch = search | ||
| 56 | showISearch() | ||
| 57 | } | ||
| 58 | |||
| 59 | func finishISearch(_ search: ISearch) { | ||
| 60 | if !search.string.isEmpty { Self.lastISearch = search.string } | ||
| 61 | endISearch(caret: search.point) | ||
| 62 | } | ||
| 63 | |||
| 64 | private func endISearch(caret: Int) { | ||
| 65 | isearch = nil | ||
| 66 | textView.selectedRange = NSRange(location: caret, length: 0) | ||
| 67 | } | ||
| 68 | |||
| 69 | private func showISearch() { | ||
| 70 | guard let search = isearch else { return } | ||
| 71 | if let match = search.match { | ||
| 72 | reveal(match.lowerBound) | ||
| 73 | textView.selectedRange = NSRange(location: match.lowerBound, length: match.count) | ||
| 74 | textView.scrollRangeToVisible(textView.selectedRange) | ||
| 75 | } else { | ||
| 76 | textView.selectedRange = NSRange(location: search.point, length: 0) | ||
| 77 | } | ||
| 78 | onMessage?(search.message) | ||
| 79 | } | ||
| 80 | } | ||
| 81 | #endif | ||
Sources/OrgstarMobile/MobileEditor.swift +27 −2
| @@ -41,6 +41,12 @@ final class MobileEditor: NSObject, DocumentBuffer { | |||
| 41 | var showMarkup = true { | 41 | var showMarkup = true { |
| 42 | didSet { if showMarkup != oldValue { restyleAll() } } | 42 | didSet { if showMarkup != oldValue { restyleAll() } } |
| 43 | } | 43 | } |
| 44 | /// An incremental search in progress, and the last search string, for C-s C-s. | ||
| 45 | var isearch: ISearch? | ||
| 46 | static var lastISearch: String? | ||
| 47 | /// `auto-fill-mode` for this buffer: the settings' unless toggled here. | ||
| 48 | var autoFillOverride: Bool? | ||
| 49 | var autoFills: Bool { autoFillOverride ?? options.autoFill } | ||
| 44 | var keymap = KeymapPreset.emacs.keymap { | 50 | var keymap = KeymapPreset.emacs.keymap { |
| 45 | didSet { dispatcher = KeyDispatcher(keymap: keymap) } | 51 | didSet { dispatcher = KeyDispatcher(keymap: keymap) } |
| 46 | } | 52 | } |
| @@ -277,6 +283,13 @@ final class MobileEditor: NSObject, DocumentBuffer { | |||
| 277 | case "editor.toggle-truncate-lines": | 283 | case "editor.toggle-truncate-lines": |
| 278 | truncatesLines.toggle() | 284 | truncatesLines.toggle() |
| 279 | onMessage?(truncatesLines ? "Truncate long lines enabled" : "Truncate long lines disabled") | 285 | onMessage?(truncatesLines ? "Truncate long lines enabled" : "Truncate long lines disabled") |
| 286 | case "edit.isearch-forward": startISearch(forward: true) | ||
| 287 | case "edit.isearch-backward": startISearch(forward: false) | ||
| 288 | case "edit.isearch-forward-regexp": startISearch(forward: true, regexp: true) | ||
| 289 | case "edit.isearch-backward-regexp": startISearch(forward: false, regexp: true) | ||
| 290 | case "editor.toggle-auto-fill": | ||
| 291 | autoFillOverride = !autoFills | ||
| 292 | onMessage?(autoFills ? "Auto-Fill mode enabled in current buffer" : "Auto-Fill mode disabled in current buffer") | ||
| 280 | case "edit.undo": textView.undoManager?.undo() | 293 | case "edit.undo": textView.undoManager?.undo() |
| 281 | case "edit.redo": textView.undoManager?.redo() | 294 | case "edit.redo": textView.undoManager?.redo() |
| 282 | case "org.table.toggle-column-width", "org.table.shrink", "org.table.expand": tableColumnWidth(id) | 295 | case "org.table.toggle-column-width", "org.table.shrink", "org.table.expand": tableColumnWidth(id) |
| @@ -299,7 +312,9 @@ final class MobileEditor: NSObject, DocumentBuffer { | |||
| 299 | switch id { | 312 | switch id { |
| 300 | case "org.cycle": | 313 | case "org.cycle": |
| 301 | return Presentation.heading(containing: context.caret, in: context.tree) != nil || Wrappers.toggleable(at: context.caret, in: context.tree) != nil | 314 | return Presentation.heading(containing: context.caret, in: context.tree) != nil || Wrappers.toggleable(at: context.caret, in: context.tree) != nil |
| 302 | case "org.cycle-global", "edit.undo", "edit.redo", "org.toggle-inline-images", "org.latex-preview", "editor.toggle-truncate-lines": return true | 315 | case "org.cycle-global", "edit.undo", "edit.redo", "org.toggle-inline-images", "org.latex-preview", "editor.toggle-truncate-lines", |
| 316 | "editor.toggle-auto-fill", "edit.isearch-forward", "edit.isearch-backward", | ||
| 317 | "edit.isearch-forward-regexp", "edit.isearch-backward-regexp": return true | ||
| 303 | case "app.clock.in", "app.clock.out", "app.clock.cancel", "app.clock.goto", "app.clock.in-recent", "app.clock.in-last", | 318 | case "app.clock.in", "app.clock.out", "app.clock.cancel", "app.clock.goto", "app.clock.in-recent", "app.clock.in-last", |
| 304 | "app.clock.goto-recent", "app.clock.default", "app.clock.resolve", "app.toggle-markup": return onAppCommand != nil | 319 | "app.clock.goto-recent", "app.clock.default", "app.clock.resolve", "app.toggle-markup": return onAppCommand != nil |
| 305 | case "app.refile.goto", "app.table-import", "app.crypt.encrypt-entries", "app.crypt.forget-passphrase", "app.attach.attach", "app.attach.url", | 320 | case "app.refile.goto", "app.table-import", "app.crypt.encrypt-entries", "app.crypt.forget-passphrase", "app.attach.attach", "app.attach.url", |
| @@ -350,6 +365,7 @@ final class MobileEditor: NSObject, DocumentBuffer { | |||
| 350 | /// and editing keys (C-a, C-e, C-k...) are the text system's. | 365 | /// and editing keys (C-a, C-e, C-k...) are the text system's. |
| 351 | func handleKey(_ key: UIKey) -> Bool { | 366 | func handleKey(_ key: UIKey) -> Bool { |
| 352 | guard let chord = Self.chord(key), !chord.modifiers.contains(.command) else { return false } | 367 | guard let chord = Self.chord(key), !chord.modifiers.contains(.command) else { return false } |
| 368 | if isearch != nil, isearchKey(chord) { return true } | ||
| 353 | if modal { return handleModal(chord) } | 369 | if modal { return handleModal(chord) } |
| 354 | // Option alone types characters unless it begins a binding. | 370 | // Option alone types characters unless it begins a binding. |
| 355 | if chord.modifiers == [.meta], dispatcher.pending.isEmpty, | 371 | if chord.modifiers == [.meta], dispatcher.pending.isEmpty, |
| @@ -469,9 +485,18 @@ extension MobileEditor: UITextViewDelegate { | |||
| 469 | selectionChanged() | 485 | selectionChanged() |
| 470 | } | 486 | } |
| 471 | 487 | ||
| 472 | /// `electric-pair-mode` for typed brackets and quotes, DEL and RET, from either keyboard. | 488 | /// `electric-pair-mode` for typed brackets and quotes, DEL and RET, and `auto-fill-mode` |
| 489 | /// for a typed space, from either keyboard. | ||
| 473 | func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { | 490 | func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { |
| 491 | if isearch != nil, !applyingEdits { | ||
| 492 | isearchTyped(text) | ||
| 493 | return false | ||
| 494 | } | ||
| 474 | if !applyingEdits { typedOutsideInsert() } | 495 | if !applyingEdits { typedOutsideInsert() } |
| 496 | if autoFills, !applyingEdits, textView.markedTextRange == nil, text == " ", range == textView.selectedRange { | ||
| 497 | _ = perform(AutoFillSpace()) | ||
| 498 | return false | ||
| 499 | } | ||
| 475 | guard options.electricPair, !applyingEdits, textView.markedTextRange == nil else { return true } | 500 | guard options.electricPair, !applyingEdits, textView.markedTextRange == nil else { return true } |
| 476 | let selected = textView.selectedRange | 501 | let selected = textView.selectedRange |
| 477 | let key: String | 502 | let key: String |
Tests/OrgAppTests/UserConfigTests.swift +13
| @@ -13,6 +13,19 @@ struct UserConfigTests { | |||
| 13 | return defaults | 13 | return defaults |
| 14 | } | 14 | } |
| 15 | 15 | ||
| 16 | @Test func lineNumbersTypes() throws { | ||
| 17 | let d = defaults() | ||
| 18 | let setting = try #require(UserConfig.settings.first { $0.key == "display-line-numbers-type" }) | ||
| 19 | #expect(UserConfig.store(.string("relative"), setting, in: d) == nil) | ||
| 20 | #expect(d.bool(forKey: "showLineNumbers") && d.string(forKey: "lineNumbersType") == "relative") | ||
| 21 | #expect(UserConfig.value(setting, in: d) == .string("relative")) | ||
| 22 | #expect(UserConfig.store(.bool(true), setting, in: d) == nil) | ||
| 23 | #expect(UserConfig.value(setting, in: d) == .bool(true)) | ||
| 24 | #expect(UserConfig.store(.bool(false), setting, in: d) == nil) | ||
| 25 | #expect(UserConfig.value(setting, in: d) == .bool(false)) | ||
| 26 | #expect(UserConfig.store(.string("sideways"), setting, in: d) != nil) | ||
| 27 | } | ||
| 28 | |||
| 16 | @Test func templateRoundTrips() { | 29 | @Test func templateRoundTrips() { |
| 17 | let source = defaults() | 30 | let source = defaults() |
| 18 | source.set("doom", forKey: "keymap") | 31 | source.set("doom", forKey: "keymap") |
Tests/OrgCoreTests/AutoFillTests.swift added +68
| @@ -0,0 +1,68 @@ | |||
| 1 | import Foundation | ||
| 2 | import Testing | ||
| 3 | @testable import OrgCore | ||
| 4 | |||
| 5 | /// Typing a space with `auto-fill-mode` on, against Emacs's `self-insert-command`. | ||
| 6 | struct AutoFillTests { | ||
| 7 | static let texts = [ | ||
| 8 | "one two three four five six", | ||
| 9 | "* Heading\nSome words that run well past the fill column here", | ||
| 10 | "- an item with several words that need wrapping", | ||
| 11 | " 1. numbered item text that is long enough to wrap twice over", | ||
| 12 | "# a comment line that goes on and on past the column", | ||
| 13 | "#+begin_quote\nquoted text that is long enough to need a break\n#+end_quote", | ||
| 14 | "#+begin_src sh\necho one two three four five six seven eight\n#+end_src", | ||
| 15 | "| a table row with words that never wraps at all |", | ||
| 16 | "* A heading that is long enough to pass the fill column", | ||
| 17 | "short", | ||
| 18 | "averyveryveryverylongwordwithoutanyspaces then", | ||
| 19 | "text with a [[https://example.com/a/long/link][link description]] in it", | ||
| 20 | "- [ ] a checkbox item whose words run past the column", | ||
| 21 | " indented paragraph words that keep going past fill", | ||
| 22 | ] | ||
| 23 | |||
| 24 | @Test(.enabled(if: ProcessInfo.processInfo.environment["ORGSTAR_SKIP_ORACLE"] == nil)) | ||
| 25 | func typingASpaceMatchesEmacs() throws { | ||
| 26 | var options = EditingOptions.org | ||
| 27 | options.fillColumn = 20 | ||
| 28 | options.autoFill = true | ||
| 29 | var cases: [EmacsOracle.Case] = [] | ||
| 30 | var ours: [(label: String, text: String, caret: Int)] = [] | ||
| 31 | for text in Self.texts { | ||
| 32 | // At the end of each line, and in the middle of the last one. | ||
| 33 | let ns = text as NSString | ||
| 34 | var carets: [Int] = [] | ||
| 35 | var at = 0 | ||
| 36 | while at <= ns.length { | ||
| 37 | let line = ns.lineRange(for: NSRange(location: min(at, max(0, ns.length - 1)), length: 0)) | ||
| 38 | let end = NSMaxRange(line) - (ns.substring(with: line).hasSuffix("\n") ? 1 : 0) | ||
| 39 | carets.append(end) | ||
| 40 | if NSMaxRange(line) >= ns.length { break } | ||
| 41 | at = NSMaxRange(line) | ||
| 42 | } | ||
| 43 | carets.append(max(0, ns.length - 6)) | ||
| 44 | for caret in Set(carets).sorted() { | ||
| 45 | cases.append(EmacsOracle.Case(text: text, point: EmacsOracle.point(caret, in: text), form: """ | ||
| 46 | (progn (setq fill-column 20) (auto-fill-mode 1) (let ((last-command-event ?\\s)) (self-insert-command 1))) | ||
| 47 | """)) | ||
| 48 | let context = EditContext(revision: 0, text: text, tree: OrgParser.parse(text), selection: [caret..<caret], options: options) | ||
| 49 | guard case .commit(let result) = AutoFillSpace().run(in: context) else { | ||
| 50 | ours.append(("at \(caret) in \(text.debugDescription)", "failed", caret)) | ||
| 51 | continue | ||
| 52 | } | ||
| 53 | let new = result.edits.sorted { $0.range.lowerBound > $1.range.lowerBound }.reduce(text) { $1.apply(to: $0) } | ||
| 54 | ours.append(("at \(caret) in \(text.debugDescription)", new, result.selection?.first?.lowerBound ?? -1)) | ||
| 55 | } | ||
| 56 | } | ||
| 57 | let results = try EmacsOracle.run(cases) | ||
| 58 | var mismatches = 0 | ||
| 59 | for (mine, theirs) in zip(ours, results) { | ||
| 60 | let theirCaret = theirs.text.unicodeScalars.prefix(theirs.point - 1).reduce(0) { $0 + $1.utf16.count } | ||
| 61 | if mine.text != theirs.text || mine.caret != theirCaret { | ||
| 62 | mismatches += 1 | ||
| 63 | if mismatches <= 12 { Issue.record("\(mine.label)\n ours: \(mine.text.debugDescription) @\(mine.caret)\n emacs: \(theirs.text.debugDescription) @\(theirCaret) \(theirs.error)") } | ||
| 64 | } | ||
| 65 | } | ||
| 66 | #expect(mismatches == 0, "\(mismatches) of \(cases.count) differ") | ||
| 67 | } | ||
| 68 | } | ||
Tests/OrgCoreTests/ISearchTests.swift added +77
| @@ -0,0 +1,77 @@ | |||
| 1 | import Foundation | ||
| 2 | import Testing | ||
| 3 | @testable import OrgCore | ||
| 4 | |||
| 5 | /// Key sequences through `isearch-forward` and `isearch-backward`, against Emacs: where point | ||
| 6 | /// ends up after RET. | ||
| 7 | struct ISearchTests { | ||
| 8 | static let text = "foo bar foo baz foo\nFoo bar\tbaz\nend of foobar text\n" | ||
| 9 | |||
| 10 | static let sequences: [(origin: Int, keys: [String])] = [ | ||
| 11 | (4, ["C-s", "f", "o", "o", "RET"]), | ||
| 12 | (11, ["C-r", "f", "o", "o", "RET"]), | ||
| 13 | (0, ["C-s", "b", "a", "C-s", "C-s", "RET"]), | ||
| 14 | (0, ["C-s", "b", "a", "C-s", "C-s", "C-s", "C-s", "C-s", "C-s", "RET"]), | ||
| 15 | (0, ["C-s", "b", "a", "z", "z", "C-g", "RET"]), | ||
| 16 | (0, ["C-s", "b", "a", "z", "z", "DEL", "DEL", "RET"]), | ||
| 17 | (0, ["C-s", "F", "o", "o", "RET"]), | ||
| 18 | (0, ["C-s", "f", "o", "o", "SPC", "b", "RET"]), | ||
| 19 | (0, ["C-s", "b", "a", "r", "SPC", "b", "RET"]), | ||
| 20 | (30, ["C-r", "b", "a", "C-r", "RET"]), | ||
| 21 | (30, ["C-r", "b", "a", "C-s", "RET"]), | ||
| 22 | (0, ["C-s", "o", "C-s", "C-r", "RET"]), | ||
| 23 | (0, ["C-s", "f", "o", "o", "b", "RET"]), | ||
| 24 | (50, ["C-r", "f", "o", "o", "b", "a", "r", "RET"]), | ||
| 25 | (50, ["C-r", "z", "z", "C-r", "RET"]), | ||
| 26 | (5, ["C-s", "q", "C-s", "RET"]), | ||
| 27 | (0, ["C-s", "e", "n", "d", "DEL", "DEL", "o", "RET"]), | ||
| 28 | ] | ||
| 29 | |||
| 30 | static func ours(_ origin: Int, _ keys: [String]) -> Int { | ||
| 31 | var search: ISearch? | ||
| 32 | for key in keys { | ||
| 33 | switch key { | ||
| 34 | case "C-s", "C-r": | ||
| 35 | if search == nil { search = ISearch(origin: origin, forward: key == "C-s") } else { search!.again(forward: key == "C-s", in: text) } | ||
| 36 | case "DEL": search?.delete() | ||
| 37 | case "C-g": if search?.abort() == false { return origin } | ||
| 38 | case "RET": return search?.point ?? origin | ||
| 39 | case "SPC": search?.add(" ", in: text) | ||
| 40 | default: search?.add(key, in: text) | ||
| 41 | } | ||
| 42 | } | ||
| 43 | return search?.point ?? origin | ||
| 44 | } | ||
| 45 | |||
| 46 | @Test(.enabled(if: ProcessInfo.processInfo.environment["ORGSTAR_SKIP_ORACLE"] == nil)) | ||
| 47 | func searchingMatchesEmacs() throws { | ||
| 48 | var cases: [EmacsOracle.Case] = [] | ||
| 49 | for (origin, keys) in Self.sequences { | ||
| 50 | let macro = keys.joined(separator: " ") | ||
| 51 | // isearch reads keys in the selected window's buffer, which stays current for the | ||
| 52 | // oracle to read point from. | ||
| 53 | cases.append(EmacsOracle.Case(text: Self.text, point: EmacsOracle.point(origin, in: Self.text), form: """ | ||
| 54 | (let ((text (buffer-string)) (p (point))) | ||
| 55 | (switch-to-buffer (get-buffer-create "isearch")) | ||
| 56 | (erase-buffer) (insert text) (goto-char p) | ||
| 57 | (execute-kbd-macro (kbd \(macro.debugDescription)))) | ||
| 58 | """)) | ||
| 59 | } | ||
| 60 | let results = try EmacsOracle.run(cases) | ||
| 61 | for (index, (sequence, theirs)) in zip(Self.sequences, results).enumerated() { | ||
| 62 | let theirPoint = Self.text.unicodeScalars.prefix(theirs.point - 1).reduce(0) { $0 + $1.utf16.count } | ||
| 63 | #expect(Self.ours(sequence.origin, sequence.keys) == theirPoint, "case \(index): \(sequence.keys.joined(separator: " ")) \(theirs.error)") | ||
| 64 | } | ||
| 65 | } | ||
| 66 | |||
| 67 | @Test func messages() { | ||
| 68 | var search = ISearch(origin: 0, forward: true) | ||
| 69 | search.add("b", in: Self.text) | ||
| 70 | #expect(search.message == "I-search: b") | ||
| 71 | search.add("q", in: Self.text) | ||
| 72 | #expect(search.message == "Failing I-search: bq") | ||
| 73 | var back = ISearch(origin: 10, forward: false) | ||
| 74 | back.add("z", in: Self.text) | ||
| 75 | #expect(back.message == "Failing I-search backward: z") | ||
| 76 | } | ||
| 77 | } | ||
Tests/OrgEditorAppKitTests/ISearchEditorTests.swift added +68
| @@ -0,0 +1,68 @@ | |||
| 1 | import AppKit | ||
| 2 | import OrgCore | ||
| 3 | import Testing | ||
| 4 | @testable import OrgApp | ||
| 5 | @testable import OrgEditorAppKit | ||
| 6 | |||
| 7 | /// C-s, C-r, Vim's `/` and auto-fill through the editor's key handling. | ||
| 8 | @MainActor | ||
| 9 | struct ISearchEditorTests { | ||
| 10 | let keys = ModalTests() | ||
| 11 | |||
| 12 | @Test func controlSSearchesAsYouTypeWithoutTyping() { | ||
| 13 | let h = Harness("foo bar foo baz\n") | ||
| 14 | var messages: [String] = [] | ||
| 15 | h.editor.onMessage = { messages.append($0) } | ||
| 16 | h.caret(at: 0) | ||
| 17 | keys.type(h, "C-s b a") | ||
| 18 | #expect(h.textView.selectedRange() == NSRange(location: 4, length: 2)) | ||
| 19 | keys.type(h, "z") | ||
| 20 | #expect(h.textView.selectedRange() == NSRange(location: 12, length: 3)) | ||
| 21 | #expect(messages.last == "I-search: baz") | ||
| 22 | keys.type(h, "RET") | ||
| 23 | #expect(h.string == "foo bar foo baz\n") | ||
| 24 | #expect(h.textView.selectedRange() == NSRange(location: 15, length: 0)) | ||
| 25 | // C-r from there, and C-g back to where it began. | ||
| 26 | keys.type(h, "C-r f o o C-g") | ||
| 27 | #expect(h.textView.selectedRange() == NSRange(location: 15, length: 0)) | ||
| 28 | #expect(h.editor.isearch == nil) | ||
| 29 | } | ||
| 30 | |||
| 31 | @Test func anotherKeyEndsTheSearchAndRuns() { | ||
| 32 | let h = Harness("foo bar foo baz\n") | ||
| 33 | h.caret(at: 0) | ||
| 34 | keys.type(h, "C-s b a r C-a") | ||
| 35 | #expect(h.editor.isearch == nil) | ||
| 36 | #expect(h.textView.selectedRange() == NSRange(location: 0, length: 0)) | ||
| 37 | } | ||
| 38 | |||
| 39 | @Test func vimSlashSearchesAndNRepeats() { | ||
| 40 | let h = keys.doom("one two one two\n") | ||
| 41 | h.caret(at: 0) | ||
| 42 | keys.type(h, "/ t w o") | ||
| 43 | #expect(h.textView.selectedRange() == NSRange(location: 4, length: 3)) | ||
| 44 | keys.type(h, "RET") | ||
| 45 | #expect(h.textView.selectedRange().location == 4) | ||
| 46 | keys.type(h, "n") | ||
| 47 | #expect(h.textView.selectedRange().location == 12) | ||
| 48 | #expect(h.string == "one two one two\n") | ||
| 49 | } | ||
| 50 | |||
| 51 | @Test func spaceAutoFillsPastTheFillColumn() { | ||
| 52 | let h = Harness("\n") | ||
| 53 | var options = h.editor.options | ||
| 54 | options.fillColumn = 12 | ||
| 55 | options.autoFill = true | ||
| 56 | h.editor.options = options | ||
| 57 | h.caret(at: 0) | ||
| 58 | for word in ["alpha", "beta", "gamma", "delta"] { | ||
| 59 | for letter in word { keys.type(h, String(letter)) } | ||
| 60 | keys.type(h, "SPC") | ||
| 61 | } | ||
| 62 | #expect(h.string == "alpha beta\ngamma delta \n") | ||
| 63 | h.editor.run("editor.toggle-auto-fill") | ||
| 64 | for letter in "epsilonzeta" { keys.type(h, String(letter)) } | ||
| 65 | keys.type(h, "SPC") | ||
| 66 | #expect(h.string == "alpha beta\ngamma delta epsilonzeta \n") | ||
| 67 | } | ||
| 68 | } | ||
docs/manual/guide/02-the-editor.org +29 −3
| @@ -297,7 +297,9 @@ Long lines wrap at the edge of the editor by default. View ▸ Truncate or Wrap | |||
| 297 | 297 | ||
| 298 | To truncate lines in every file, turn on Settings ▸ Editing ▸ "Long lines run off the edge instead of wrapping", or set =org-startup-truncated = true= in =config.toml=. The default is to wrap, as Doom does; Emacs's own default is to truncate. | 298 | To truncate lines in every file, turn on Settings ▸ Editing ▸ "Long lines run off the edge instead of wrapping", or set =org-startup-truncated = true= in =config.toml=. The default is to wrap, as Doom does; Emacs's own default is to truncate. |
| 299 | 299 | ||
| 300 | Wrapping is display only. To rewrap the text of a paragraph, use Org ▸ Fill Paragraph (=org-fill-paragraph=), which breaks the paragraph's lines at the fill column: =M-q= in the Emacs preset and in every Doom state, =⌃⌘P= in the Mac preset. With a selection, it fills every paragraph the selection touches. In Doom's normal and visual states, =gq= and =gw= with a motion fill the paragraphs in the lines it covers (=gqq= and =gww= for the current lines); =gq= leaves the caret on the last line, =gw= where it was. Unlike Fill Paragraph, =gq= and =gw= keep extra spaces between words and at the ends of lines, as Doom does. See [[file:03-keys.org][Keys and commands]]. The fill column is Settings ▸ Editing ▸ "M-q fills to column N" (80 by default, 40 to 200), or =fill-column= in =config.toml=. orgstar has no auto-fill: lines are not broken as you type. | 300 | Wrapping is display only. To rewrap the text of a paragraph, use Org ▸ Fill Paragraph (=org-fill-paragraph=), which breaks the paragraph's lines at the fill column: =M-q= in the Emacs preset and in every Doom state, =⌃⌘P= in the Mac preset. With a selection, it fills every paragraph the selection touches. In Doom's normal and visual states, =gq= and =gw= with a motion fill the paragraphs in the lines it covers (=gqq= and =gww= for the current lines); =gq= leaves the caret on the last line, =gw= where it was. Unlike Fill Paragraph, =gq= and =gw= keep extra spaces between words and at the ends of lines, as Doom does. See [[file:03-keys.org][Keys and commands]]. The fill column is Settings ▸ Editing ▸ "M-q fills to column N" (80 by default, 40 to 200), or =fill-column= in =config.toml=. |
| 301 | |||
| 302 | =auto-fill-mode= breaks lines as you type: typing a space past the fill column breaks the line at the last space before the column, as often as it takes, and the new line starts with the line's fill prefix, as =org-auto-fill-function= has it: a list item's text lines up under the item, a comment line starts with =#=, and headings, tables and code aren't broken. Turn it on for every file with =auto-fill-mode = true= in =config.toml=, or for the current buffer with View ▸ Turn Auto Fill On or Off (=auto-fill-mode=, in the palette too); the echo area says =Auto-Fill mode enabled in current buffer= or =disabled=. Only a typed space fills, not =RET=. | ||
| 301 | 303 | ||
| 302 | * View toggles | 304 | * View toggles |
| 303 | 305 | ||
| @@ -305,6 +307,7 @@ Wrapping is display only. To rewrap the text of a paragraph, use Org ▸ Fill Pa | |||
| 305 | |-------------------------------+-------------------------------+-------------------------------------------------+---------+----------------------------------+----------------| | 307 | |-------------------------------+-------------------------------+-------------------------------------------------+---------+----------------------------------+----------------| |
| 306 | | Show Markup | View ▸ Show Markup | =⇧⌘M= | off | =show-markup= | every buffer | | 308 | | Show Markup | View ▸ Show Markup | =⇧⌘M= | off | =show-markup= | every buffer | |
| 307 | | Show Line Numbers | View ▸ Show Line Numbers | =⇧⌘L= | on | =display-line-numbers-type= | every buffer | | 309 | | Show Line Numbers | View ▸ Show Line Numbers | =⇧⌘L= | on | =display-line-numbers-type= | every buffer | |
| 310 | | Auto fill | View ▸ Turn Auto Fill On or Off | palette | off | =auto-fill-mode= | current buffer | | ||
| 308 | | Inline images | Org ▸ Show or Hide Inline Images | =C-c C-x C-v= (Emacs, Doom) | off | =org-startup-with-inline-images= | current buffer | | 311 | | Inline images | Org ▸ Show or Hide Inline Images | =C-c C-x C-v= (Emacs, Doom) | off | =org-startup-with-inline-images= | current buffer | |
| 309 | | LaTeX previews | palette | =C-c C-x C-l= (Emacs, Doom) | off | =org-startup-with-latex-preview= | current buffer | | 312 | | LaTeX previews | palette | =C-c C-x C-l= (Emacs, Doom) | off | =org-startup-with-latex-preview= | current buffer | |
| 310 | | Spell checking | palette | =SPC t s= (Doom) | off | =spell-check= | current buffer | | 313 | | Spell checking | palette | =SPC t s= (Doom) | off | =spell-check= | current buffer | |
| @@ -316,6 +319,16 @@ Toggles that apply to the current buffer last until it closes; the =config.toml= | |||
| 316 | 319 | ||
| 317 | Line numbers show in a margin left of the text, as =display-line-numbers-mode= shows them: one number per line of the file, so wrapped lines are numbered once and folded lines are skipped. The caret's line number is brighter. Line numbers are on by default. | 320 | Line numbers show in a margin left of the text, as =display-line-numbers-mode= shows them: one number per line of the file, so wrapped lines are numbered once and folded lines are skipped. The caret's line number is brighter. Line numbers are on by default. |
| 318 | 321 | ||
| 322 | View ▸ Line Numbers chooses how they count, as =display-line-numbers-type= does in =config.toml=: | ||
| 323 | |||
| 324 | | View ▸ Line Numbers | =display-line-numbers-type= | Numbers | | ||
| 325 | |---------------------+------------------------------+-----------------------------------------------------------------------------------| | ||
| 326 | | Absolute | =true= | The line's number in the file. | | ||
| 327 | | Relative | ="relative"= | How many lines of the file away from the caret's line. | | ||
| 328 | | Visual | ="visual"= | How many lines on the screen away from the caret's, counting each wrapped line. | | ||
| 329 | |||
| 330 | In the relative and visual kinds the caret's line shows its own number, as =display-line-numbers-current-absolute= does. =display-line-numbers-type = false= turns the numbers off. The iOS editor has no line numbers. | ||
| 331 | |||
| 319 | * Themes | 332 | * Themes |
| 320 | 333 | ||
| 321 | The editor's font, size, line spacing and heading sizes are in Settings ▸ Appearance. Colours for the editor, the sidebar, the modeline, line numbers, the selection and the caret come from =config.toml=, under =[theme]= for both appearances, =[theme.light]= and =[theme.dark]= for one, and =[theme.todo]= for colours of TODO keywords. Settings ▸ Appearance ▸ Show Default Theme opens =default-theme.toml=, which lists every colour with its default value. Changes apply while orgstar runs. See [[file:13-configuration.org][Configuration]]. | 334 | The editor's font, size, line spacing and heading sizes are in Settings ▸ Appearance. Colours for the editor, the sidebar, the modeline, line numbers, the selection and the caret come from =config.toml=, under =[theme]= for both appearances, =[theme.light]= and =[theme.dark]= for one, and =[theme.todo]= for colours of TODO keywords. Settings ▸ Appearance ▸ Show Default Theme opens =default-theme.toml=, which lists every colour with its default value. Changes apply while orgstar runs. See [[file:13-configuration.org][Configuration]]. |
| @@ -337,17 +350,30 @@ The undo history is cleared when the buffer reloads or merges changes from disk, | |||
| 337 | 350 | ||
| 338 | * Finding text in a file | 351 | * Finding text in a file |
| 339 | 352 | ||
| 353 | =C-s= and =C-r= in the Emacs preset search as you type (=isearch-forward=, =isearch-backward=): the echo area shows =I-search:= and what you have typed, the next match is selected as each character goes in, and the other matches are highlighted. While searching: | ||
| 354 | |||
| 355 | | Key | What it does | | ||
| 356 | |---------------+----------------------------------------------------------------------------------------------------| | ||
| 357 | | characters | Add to the search string. | | ||
| 358 | | =C-s=, =C-r= | The next or previous match; with nothing typed yet, the last search again. After =Failing I-search=, the search wraps around the file (=Wrapped I-search=). | | ||
| 359 | | =DEL= | Undo the last key: a character, or a move to another match. | | ||
| 360 | | =RET= | Stop, with the caret after the match (before it going backward). | | ||
| 361 | | =C-g= | With a failing search, take off the part that fails; otherwise stop and go back to where the search began. | | ||
| 362 | | other keys | Stop where the search is, then run as usual. | | ||
| 363 | |||
| 364 | A space matches any run of spaces and tabs, and an upper-case letter makes the search case-sensitive, as Emacs's defaults have it. =C-M-s= and =C-M-r= search with a regular expression (=isearch-forward-regexp=); patterns are ICU regular expressions. Folded text opens around a match. In Doom, =/= and =?= search the same way with a regular expression, the echo area showing =/= or =?= and the pattern; =RET= ends it as Vim's search does, so =n= and =N= repeat it, and =Esc= or =C-g= go back. On iOS, =C-s= and =C-r= work with a hardware keyboard, and Incremental Search is in Commands; typing on the on-screen keyboard adds to the search. iOS doesn't highlight the other matches. | ||
| 365 | |||
| 340 | Edit ▸ Find opens the find bar above the text. | 366 | Edit ▸ Find opens the find bar above the text. |
| 341 | 367 | ||
| 342 | | Menu item | Shortcut | Emacs preset | Doom | | 368 | | Menu item | Shortcut | Emacs preset | Doom | |
| 343 | |-----------------------------------+----------+-------------------+-----------------------| | 369 | |-----------------------------------+----------+-------------------+-----------------------| |
| 344 | | Edit ▸ Find ▸ Find… | =⌘F= | =C-s=, =C-r= | =SPC s s= | | 370 | | Edit ▸ Find ▸ Find… | =⌘F= | | =SPC s s= | |
| 345 | | Edit ▸ Find ▸ Find and Replace… | =⌥⌘F= | =M-%= | | | 371 | | Edit ▸ Find ▸ Find and Replace… | =⌥⌘F= | =M-%= | | |
| 346 | | Edit ▸ Find ▸ Find Next | =⌘G= | | | | 372 | | Edit ▸ Find ▸ Find Next | =⌘G= | | | |
| 347 | | Edit ▸ Find ▸ Find Previous | =⇧⌘G= | | | | 373 | | Edit ▸ Find ▸ Find Previous | =⇧⌘G= | | | |
| 348 | | Edit ▸ Find ▸ Use Selection for Find | =⌘E= | | | | 374 | | Edit ▸ Find ▸ Use Selection for Find | =⌘E= | | | |
| 349 | 375 | ||
| 350 | In the Emacs preset =C-s= and =C-r= open the find bar; they are not incremental search. In Doom, =:s/PATTERN/REPLACEMENT/= and =:%s/…/…/= with the =g= and =i= flags substitute with regular expressions on the current line or in the whole file. | 376 | In Doom, =:s/PATTERN/REPLACEMENT/= and =:%s/…/…/= with the =g= and =i= flags substitute with regular expressions on the current line or in the whole file. |
| 351 | 377 | ||
| 352 | To search all your files, use the toolbar's search field; see [[file:01-files-and-folders.org][Files, folders and buffers]]. | 378 | To search all your files, use the toolbar's search field; see [[file:01-files-and-folders.org][Files, folders and buffers]]. |
| 353 | 379 | ||
docs/manual/guide/03-keys.org +8 −3
| @@ -343,14 +343,14 @@ Motions move the caret in normal state, extend the selection in visual states, a | |||
| 343 | | =s= /xy/, =S= /xy/ | evil-snipe: to the next or previous /xy/ on the line. Each character matches its variants as for =f=, and /xy/ without a capital matches case-insensitively. =SPC= and =TAB= are read as a space and a tab. Not available after an operator. | | 343 | | =s= /xy/, =S= /xy/ | evil-snipe: to the next or previous /xy/ on the line. Each character matches its variants as for =f=, and /xy/ without a capital matches case-insensitively. =SPC= and =TAB= are read as a space and a tab. Not available after an operator. | |
| 344 | | =%= | The bracket matching the next =()=, =[]= or ={}= on the line. | | 344 | | =%= | The bracket matching the next =()=, =[]= or ={}= on the line. | |
| 345 | | ={=, =}= | Previous, next blank line. | | 345 | | ={=, =}= | Previous, next blank line. | |
| 346 | | =/=, =?= | Asks in the echo area for a regular expression and searches forward or backward, wrapping around the file. | | 346 | | =/=, =?= | Searches forward or backward as you type a regular expression, the match selected and the others highlighted; =RET= goes there, wrapping around the file, and =Esc= goes back. On iOS, asks in the echo area instead. | |
| 347 | | =n=, =N= | Repeats the last search in the same or the opposite direction. | | 347 | | =n=, =N= | Repeats the last search in the same or the opposite direction. | |
| 348 | | =*=, =#= | Searches forward or backward for the whole word under the caret. | | 348 | | =*=, =#= | Searches forward or backward for the whole word under the caret. | |
| 349 | | =C-d=, =C-u= | Down, up half the window's height; with a count, that many lines. | | 349 | | =C-d=, =C-u= | Down, up half the window's height; with a count, that many lines. | |
| 350 | | =H=, =M=, =L= | First non-blank of the top, middle or bottom line the window shows. With a count, =H= goes to that line from the top and =L= from the bottom. Lines are text lines, not wrapped screen lines. Linewise after an operator. | | 350 | | =H=, =M=, =L= | First non-blank of the top, middle or bottom line the window shows. With a count, =H= goes to that line from the top and =L= from the bottom. Lines are text lines, not wrapped screen lines. Linewise after an operator. | |
| 351 | | ='= /a/, =`= /a/ | To mark /a/: its line's first non-blank, or its exact position. See [[*Marks and jumps][Marks and jumps]]. | | 351 | | ='= /a/, =`= /a/ | To mark /a/: its line's first non-blank, or its exact position. See [[*Marks and jumps][Marks and jumps]]. | |
| 352 | 352 | ||
| 353 | Search patterns are ICU regular expressions as macOS uses them, close to PCRE; Emacs and Vim regexp syntax such as =\(...\)= or =\<= does not work. =:noh= is accepted and does nothing; searches are not highlighted. | 353 | Search patterns are ICU regular expressions as macOS uses them, close to PCRE; Emacs and Vim regexp syntax such as =\(...\)= or =\<= does not work. =:noh= is accepted and does nothing; matches are highlighted only while =/= or =?= is being typed. |
| 354 | 354 | ||
| 355 | ** Operators | 355 | ** Operators |
| 356 | 356 | ||
| @@ -769,7 +769,12 @@ When a key appears in several rows, it runs the command whose condition holds at | |||
| 769 | | Yank (=edit.yank=) | =C-y= | — | — | Inserts the text last deleted with Kill Line, from the macOS kill buffer, not the clipboard (=yank=). There is no kill ring. | | 769 | | Yank (=edit.yank=) | =C-y= | — | — | Inserts the text last deleted with Kill Line, from the macOS kill buffer, not the clipboard (=yank=). There is no kill ring. | |
| 770 | | Undo (=edit.undo=) | =C-/=, =C-_=, =C-x u= | — | — | Undoes the last change (=undo=). | | 770 | | Undo (=edit.undo=) | =C-/=, =C-_=, =C-x u= | — | — | Undoes the last change (=undo=). | |
| 771 | | Transpose Characters (=edit.transpose-chars=) | =C-t= | — | — | Swaps the characters around the caret (=transpose-chars=). | | 771 | | Transpose Characters (=edit.transpose-chars=) | =C-t= | — | — | Swaps the characters around the caret (=transpose-chars=). | |
| 772 | | Find (=edit.find=) | =C-s=, =C-r= | — | =SPC s s= (N) | Opens the find bar. =C-s= and =C-r= both open it; there is no incremental search (=isearch-forward=). | | 772 | | Find (=edit.find=) | — | =⌘F= | =SPC s s= (N) | Opens the find bar. | |
| 773 | | Incremental Search (=edit.isearch-forward=) | =C-s= | — | — | Searches forward as you type (=isearch-forward=). See [[file:02-the-editor.org][The editor]]. | | ||
| 774 | | Incremental Search Backward (=edit.isearch-backward=) | =C-r= | — | — | Searches backward as you type (=isearch-backward=). | | ||
| 775 | | Incremental Regexp Search (=edit.isearch-forward-regexp=) | =C-M-s= | — | — | The same with a regular expression (=isearch-forward-regexp=). | | ||
| 776 | | Incremental Regexp Search Backward (=edit.isearch-backward-regexp=) | =C-M-r= | — | — | The same backward (=isearch-backward-regexp=). | | ||
| 777 | | Turn Auto Fill On or Off (=editor.toggle-auto-fill=) | — | — | — | Turns =auto-fill-mode= on or off in the current buffer. | | ||
| 773 | | Find and Replace (=edit.replace=) | =M-%= | — | — | Opens the find bar with replace (=query-replace=). | | 778 | | Find and Replace (=edit.replace=) | =M-%= | — | — | Opens the find bar with replace (=query-replace=). | |
| 774 | | Find Next (=edit.find-next=) | — | — | — | Goes to the next match of the find bar's text. | | 779 | | Find Next (=edit.find-next=) | — | — | — | Goes to the next match of the find bar's text. | |
| 775 | | Find Previous (=edit.find-previous=) | — | — | — | Goes to the previous match. | | 780 | | Find Previous (=edit.find-previous=) | — | — | — | Goes to the previous match. | |
docs/manual/guide/13-configuration.org +5 −3
| @@ -153,7 +153,7 @@ These settings have no control in the Settings window. Some are in the View menu | |||
| 153 | | =org-use-speed-commands= | | | 153 | | =org-use-speed-commands= | | |
| 154 | | =spell-check= | | | 154 | | =spell-check= | | |
| 155 | | =electric-pair-mode= | | | 155 | | =electric-pair-mode= | | |
| 156 | | =display-line-numbers-type= | View ▸ Show Line Numbers (=⇧⌘L=) | | 156 | | =display-line-numbers-type= | View ▸ Show Line Numbers (=⇧⌘L=), View ▸ Line Numbers | |
| 157 | | =tab-bar= | View ▸ Show Tab Bar | | 157 | | =tab-bar= | View ▸ Show Tab Bar | |
| 158 | | =show-markup= | View ▸ Show Markup (=⇧⌘M=) | | 158 | | =show-markup= | View ▸ Show Markup (=⇧⌘M=) | |
| 159 | | =ignored-folders= | | | 159 | | =ignored-folders= | | |
| @@ -212,6 +212,7 @@ A key you remove from the file goes back to its default. A key that isn't in the | |||
| 212 | | =org-tags-exclude-from-inheritance= | string | =""= | Tags that never inherit, separated by spaces. Read at launch. Mirrors =org-tags-exclude-from-inheritance=. | | 212 | | =org-tags-exclude-from-inheritance= | string | =""= | Tags that never inherit, separated by spaces. Read at launch. Mirrors =org-tags-exclude-from-inheritance=. | |
| 213 | | =org-tag-alist= | string | =""= | The tags Set Tags offers in files without =#+TAGS=, in =#+TAGS= syntax with keys and groups, rows separated by =\n=. Mirrors =org-tag-alist=. | | 213 | | =org-tag-alist= | string | =""= | The tags Set Tags offers in files without =#+TAGS=, in =#+TAGS= syntax with keys and groups, rows separated by =\n=. Mirrors =org-tag-alist=. | |
| 214 | | =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=. | | 214 | | =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=. | |
| 215 | | =auto-fill-mode= | boolean | =false= | Typing a space past =fill-column= breaks the line. View ▸ Turn Auto Fill On or Off changes it for one buffer. Mirrors =auto-fill-mode= in =org-mode-hook=. | | ||
| 215 | | =org-roam-directory= | string | =""= | The folder org-roam notes are in; empty for the first sidebar folder. Mirrors =org-roam-directory=. | | 216 | | =org-roam-directory= | string | =""= | The folder org-roam notes are in; empty for the first sidebar folder. Mirrors =org-roam-directory=. | |
| 216 | | =org-roam-dailies-directory= | string | ="daily/"= | The folder daily notes are in, relative to =org-roam-directory=. Mirrors =org-roam-dailies-directory=. | | 217 | | =org-roam-dailies-directory= | string | ="daily/"= | The folder daily notes are in, relative to =org-roam-directory=. Mirrors =org-roam-dailies-directory=. | |
| 217 | | =org-roam-dailies-file= | string | ="%<%Y-%m-%d>.org"= | A daily note's file name; =%<…>= formats its date. | | 218 | | =org-roam-dailies-file= | string | ="%<%Y-%m-%d>.org"= | A daily note's file name; =%<…>= formats its date. | |
| @@ -234,7 +235,7 @@ A key you remove from the file goes back to its default. A key that isn't in the | |||
| 234 | | =org-use-speed-commands= | boolean | =false= | Single keys at the start of a heading line run commands (=n=, =p=, =t=, =c=, …). Mirrors =org-use-speed-commands=. | | 235 | | =org-use-speed-commands= | boolean | =false= | Single keys at the start of a heading line run commands (=n=, =p=, =t=, =c=, …). Mirrors =org-use-speed-commands=. | |
| 235 | | =org-cycle-hide-drawer-startup= | boolean | =true= | Fold drawers when a file opens. =#+STARTUP: hidedrawers= / =nohidedrawers= override it. Mirrors =org-cycle-hide-drawer-startup=. | | 236 | | =org-cycle-hide-drawer-startup= | boolean | =true= | Fold drawers when a file opens. =#+STARTUP: hidedrawers= / =nohidedrawers= override it. Mirrors =org-cycle-hide-drawer-startup=. | |
| 236 | | =org-cycle-hide-block-startup= | boolean | =false= | Fold blocks when a file opens. =#+STARTUP: hideblocks= / =nohideblocks= override it. Mirrors =org-cycle-hide-block-startup=. | | 237 | | =org-cycle-hide-block-startup= | boolean | =false= | Fold blocks when a file opens. =#+STARTUP: hideblocks= / =nohideblocks= override it. Mirrors =org-cycle-hide-block-startup=. | |
| 237 | | =display-line-numbers-type= | boolean | =true= | Line numbers in the editor's gutter. orgstar numbers lines absolutely; there is no relative or visual mode. | | 238 | | =display-line-numbers-type= | boolean or string | =true= | Line numbers in the editor's gutter: =true=, =false=, ="relative"= or ="visual"=. See [[file:02-the-editor.org][The editor]]. | |
| 238 | | =org-agenda-span= | integer | =10= | Days the agenda shows. Mirrors =org-agenda-span=. | | 239 | | =org-agenda-span= | integer | =10= | Days the agenda shows. Mirrors =org-agenda-span=. | |
| 239 | | =org-agenda-start-day= | string | ="+0d"= | The agenda's first day relative to today, as ="-3d"= or ="+0d"=. Only day offsets are accepted. Mirrors =org-agenda-start-day=. | | 240 | | =org-agenda-start-day= | string | ="+0d"= | The agenda's first day relative to today, as ="-3d"= or ="+0d"=. Only day offsets are accepted. Mirrors =org-agenda-start-day=. | |
| 240 | | =org-agenda-start-on-weekday= | string | ="1"= | The day weeks start on, ="0"= (Sunday) to ="6"= (Saturday), for the week view and spans of 7 or 14 days. ="nil"= starts them on the day the view starts from. Mirrors =org-agenda-start-on-weekday=. | | 241 | | =org-agenda-start-on-weekday= | string | ="1"= | The day weeks start on, ="0"= (Sunday) to ="6"= (Saturday), for the week view and spans of 7 or 14 days. ="nil"= starts them on the day the view starts from. Mirrors =org-agenda-start-on-weekday=. | |
| @@ -563,7 +564,8 @@ Only variables whose names start with =org-=, =appt-=, =display-line-numbers=, = | |||
| 563 | | =org-publish-project-alist= | A =[[publish]]= table in =config.toml= per project whose publishing functions are =org-html-publish-to-html=, =org-md-publish-to-md= or =org-publish-attachment=: the directories, =:base-extension=, =:recursive=, =:exclude=, =:include=, =:body-only=, the sitemap properties and =:components=. Other properties are reported as left out | | 564 | | =org-publish-project-alist= | A =[[publish]]= table in =config.toml= per project whose publishing functions are =org-html-publish-to-html=, =org-md-publish-to-md= or =org-publish-attachment=: the directories, =:base-extension=, =:recursive=, =:exclude=, =:include=, =:body-only=, the sitemap properties and =:components=. Other properties are reported as left out | |
| 564 | | =org-log-done=, =org-log-reschedule=, =org-log-redeadline= | The same key: =nil=, =time= (also =t=) or =note= | | 565 | | =org-log-done=, =org-log-reschedule=, =org-log-redeadline= | The same key: =nil=, =time= (also =t=) or =note= | |
| 565 | | =org-log-into-drawer= | A string as given; =t= becomes ="LOGBOOK"=; =nil= becomes =""= | | 566 | | =org-log-into-drawer= | A string as given; =t= becomes ="LOGBOOK"=; =nil= becomes =""= | |
| 566 | | =display-line-numbers-type= | =true= unless =nil=; =relative= and =visual= become absolute numbers | | 567 | | =display-line-numbers-type= | =true= unless =nil=; =relative= and =visual= as they are | |
| 568 | | =auto-fill-mode= | =true= for =(add-hook 'org-mode-hook #'auto-fill-mode)= or =turn-on-auto-fill=, or in =text-mode-hook= | | ||
| 567 | | =org-agenda-span= | A number, or =day= (1), =week= (7), =fortnight= (14), =month= (30), =year= (365) | | 569 | | =org-agenda-span= | A number, or =day= (1), =week= (7), =fortnight= (14), =month= (30), =year= (365) | |
| 568 | | =org-clock-idle-time= | Minutes; =nil= becomes =0= (never) | | 570 | | =org-clock-idle-time= | Minutes; =nil= becomes =0= (never) | |
| 569 | | =org-clock-history-length= | The same key, when the value is a positive number | | 571 | | =org-clock-history-length= | The same key, when the value is a positive number | |
docs/manual/guide/14-ios.org +3 −1
| @@ -135,6 +135,8 @@ Cancel answers nothing, as =C-g= does. | |||
| 135 | 135 | ||
| 136 | More ▸ Backlinks lists the links to the heading at the caret and to the file; More ▸ Daily Notes, Find Node… and Insert Node Link… work with org-roam-style notes, and the Folders tab's calendar menu opens today's, yesterday's and tomorrow's note. See [[file:09-links.org][Links]]. | 136 | More ▸ Backlinks lists the links to the heading at the caret and to the file; More ▸ Daily Notes, Find Node… and Insert Node Link… work with org-roam-style notes, and the Folders tab's calendar menu opens today's, yesterday's and tomorrow's note. See [[file:09-links.org][Links]]. |
| 137 | 137 | ||
| 138 | Incremental Search is in Commands, and on =C-s= and =C-r= with a hardware keyboard; see [[file:02-the-editor.org][The editor]]. =auto-fill-mode= works as on the Mac. | ||
| 139 | |||
| 138 | The org-timer commands are in Commands; a running timer shows above the text. See [[file:06-dates-and-clocking.org][Dates and clocking]]. | 140 | The org-timer commands are in Commands; a running timer shows above the text. See [[file:06-dates-and-clocking.org][Dates and clocking]]. |
| 139 | 141 | ||
| 140 | More ▸ Attachments has the org-attach commands and Attach Photo or Video…; files shared to orgstar can be attached to an entry. See [[file:04-outlines.org][Outlines]]. | 142 | More ▸ Attachments has the org-attach commands and Attach Photo or Video…; files shared to orgstar can be attached to an entry. See [[file:04-outlines.org][Outlines]]. |
| @@ -362,7 +364,7 @@ These settings from =config.toml= apply on iOS: | |||
| 362 | - =org-archive-location=, =[org-structure-template-alist]= | 364 | - =org-archive-location=, =[org-structure-template-alist]= |
| 363 | - =org-use-tag-inheritance=, =org-tags-exclude-from-inheritance=, =org-tag-alist= | 365 | - =org-use-tag-inheritance=, =org-tags-exclude-from-inheritance=, =org-tag-alist= |
| 364 | - =org-use-speed-commands=, with a hardware keyboard | 366 | - =org-use-speed-commands=, with a hardware keyboard |
| 365 | - =electric-pair-mode=, =spell-check= | 367 | - =electric-pair-mode=, =spell-check=, =auto-fill-mode= |
| 366 | - =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=, =org-agenda-log-mode-items=, the =org-agenda-todo-ignore-= settings, =org-agenda-tags-todo-honor-ignore-options= | 368 | - =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=, =org-agenda-log-mode-items=, the =org-agenda-todo-ignore-= settings, =org-agenda-tags-todo-honor-ignore-options= |
| 367 | - =calendar-events=, =calendar-event-calendars= | 369 | - =calendar-events=, =calendar-event-calendars= |
| 368 | - =reminders=, =appt-message-warning-time= | 370 | - =reminders=, =appt-message-warning-time= |
docs/manual/guide/15-alongside-emacs.org +3 −1
| @@ -245,7 +245,9 @@ Other: | |||
| 245 | - Priority ranges that aren't letters or numbers are refused. | 245 | - Priority ranges that aren't letters or numbers are refused. |
| 246 | - =#+SETUPFILE= URLs aren't fetched. | 246 | - =#+SETUPFILE= URLs aren't fetched. |
| 247 | - Most =#+STARTUP= options for footnotes, entities, numbering and odd levels are accepted and ignored; see [[file:13-configuration.org][Configuration]]. | 247 | - Most =#+STARTUP= options for footnotes, entities, numbering and odd levels are accepted and ignored; see [[file:13-configuration.org][Configuration]]. |
| 248 | - =display-line-numbers-type= has no relative or visual mode. | 248 | - Line numbers are on the Mac only. Visual line numbers count the screen lines in view; with the caret scrolled out of view they count lines of the file. |
| 249 | - Incremental search doesn't save the mark where it began, and has no =M-e= editing, =C-w= or =C-y= yanking into the string, or search ring beyond the last search. | ||
| 250 | - =auto-fill-mode= fills on a typed space only, not on =RET=. | ||
| 249 | - The agenda's text search (see [[file:07-agenda.org][The agenda]]) covers the agenda files only: =org-agenda-text-search-extra-files= and =org-agenda-search-view-max-outline-level= aren't supported. It runs from the view menu rather than the dispatcher's =s= and =S=, and the search view's =[=, =]=, ={= and =}= keys, which add words and regexps to the search, aren't supported. | 251 | - The agenda's text search (see [[file:07-agenda.org][The agenda]]) covers the agenda files only: =org-agenda-text-search-extra-files= and =org-agenda-search-view-max-outline-level= aren't supported. It runs from the view menu rather than the dispatcher's =s= and =S=, and the search view's =[=, =]=, ={= and =}= keys, which add words and regexps to the search, aren't supported. |
| 250 | - In regexps, =\<=, =\>= and =\b= use Org's word syntax but don't find a word boundary where the script changes between two word characters, as Emacs does (for example between an emoji and a letter). | 252 | - In regexps, =\<=, =\>= and =\b= use Org's word syntax but don't find a word boundary where the script changes between two word characters, as Emacs does (for example between an emoji and a letter). |
| 251 | - org-roam: nodes come from orgstar's index, not org-roam's database, so =ROAM_ALIASES=, =ROAM_REFS=, =ROAM_EXCLUDE=, node tags in the chooser and the graph aren't supported. Insert Node Link… and Find Node… don't make new nodes from a title that isn't found. Daily notes use the first of =org-roam-dailies-capture-templates=, without choosing among several, and the date prompt prefers future dates, where org-roam prefers past ones. Capturing to a daily note files the entry at once rather than in a capture buffer. | 253 | - org-roam: nodes come from orgstar's index, not org-roam's database, so =ROAM_ALIASES=, =ROAM_REFS=, =ROAM_EXCLUDE=, node tags in the chooser and the graph aren't supported. Insert Node Link… and Find Node… don't make new nodes from a title that isn't found. Daily notes use the first of =org-roam-dailies-capture-templates=, without choosing among several, and the date prompt prefers future dates, where org-roam prefers past ones. Capturing to a daily note files the entry at once rather than in a capture buffer. |