krz/orgstar

A native macOS editor for org-mode files. editor org-mode swift

Commit 1579064da0

1579064da0c5254538179562c0bd12605582e763

parent: 2d92459d2a

Verified · cmc

cmc <hello@cleberg.net> · 2026-10-08 03:27 UTC

Babel :eval no-export interactively and inline calls on C-c C-c

:eval never-export and no-export only stop evaluation during export, as
org-babel-check-evaluate does, so C-c C-c runs those blocks. C-c C-c on
an inline call_name() runs it, as org-ctrl-c-ctrl-c does for
inline-babel-call.

Layout: unified · split

Sources/OrgCore/Compute/Babel.swift +3 −3
@@ -294,7 +294,7 @@ public enum Babel {
294294 let needsFile = options.file == nil && params.lisp.contains { params.evaluated[$0] == nil }
295295 guard let language = block.language else { return .failure(.message("This block has no language")) }
296296 let eval = params.single[":eval"]?.lowercased()
297 if eval == "never" || eval == "no" || eval == "never-export" || eval == "no-export" {
297 if eval == "never" || eval == "no" {
298298 return .failure(.message("Evaluation of this \(language) code block\(block.name.map { " (\($0)) " } ?? " ")is disabled."))
299299 }
300300 if params.single[":cmdline"] != nil, !["dot", "plantuml", "mermaid"].contains(language), !shells.contains(language) {
@@ -1903,14 +1903,14 @@ public struct ExecuteSrcBlock: OrgCommand {
19031903 public var title: String { "Run Source Block" }
19041904 public func applies(in context: EditContext) -> Bool { KeyContext.holds("src", in: context) || Self.atCallOrInline(context) }
19051905
1906 /// On a `#+CALL:` line or an inline `src_` block.
1906 /// On a `#+CALL:` line, an inline `call_` or an inline `src_` block.
19071907 static func atCallOrInline(_ context: EditContext) -> Bool {
19081908 let ns = context.text as NSString
19091909 let line = ns.substring(with: ns.lineRange(for: NSRange(location: min(context.caret, ns.length), length: 0)))
19101910 if line.range(of: "(?i)^[ \\t]*#\\+CALL:", options: .regularExpression) != nil { return true }
19111911 var node = context.tree.root
19121912 while let child = node.child(containing: context.caret) {
1913 if child.kind == .inlineSourceBlock { return true }
1913 if child.kind == .inlineSourceBlock || child.kind == .inlineBabelCall { return true }
19141914 node = child
19151915 }
19161916 return false
Tests/OrgCoreTests/BabelTests.swift +25
@@ -328,6 +328,17 @@ struct BabelTests {
328328 #expect(got == message)
329329 }
330330 }
331
332 @Test func noExportStillRunsInteractively() {
333 for eval in ["never-export", "no-export"] {
334 let text = "#+begin_src sh :eval \(eval)\necho 1\n#+end_src\n"
335 let context = EditContext(revision: 0, text: text, tree: OrgParser.parse(text), selection: [2..<2])
336 guard case .success = Babel.plan(context) else {
337 Issue.record("refused :eval \(eval)")
338 continue
339 }
340 }
341 }
331342}
332343
333344struct BabelCallTests {
@@ -378,6 +389,20 @@ struct BabelCallTests {
378389 }
379390}
380391
392extension BabelCallTests {
393 @Test func ctrlCCtrlCRunsInlineCalls() {
394 let text = Self.named + "Inline call_double(n=6) here.\n"
395 let caret = (text as NSString).range(of: "call_").location + 2
396 let context = EditContext(revision: 0, text: text, tree: OrgParser.parse(text), selection: [caret..<caret])
397 #expect(ExecuteSrcBlock().applies(in: context))
398 guard case .external(.babel(let job)) = CtrlCCtrlC().run(in: context) else {
399 Issue.record("inline call not run")
400 return
401 }
402 #expect((job.script ?? job.input).contains("echo $((n*2))"))
403 }
404}
405
381406struct BabelFileTests {
382407 static let cases = [
383408 "#+begin_src sh :results file :file out.txt\necho hello\necho there\n#+end_src\n",