Skip to content

(:before)

selects values that appear before an anchor in source order

clojure
(:before anchor val)

Where:

  1. anchor: the reference point in the source code *
  2. val: what to find before the anchor *

Behavior

  • Respects lexical scope - only considers values and anchors within the same scope.
  • Using (:into) on the anchor includes the anchor itself in the search area.

Examples

Find module-level calls that execute before function definitions to detect initialization order issues.

clojure
(:before (fun) (call))

Selects in lines { 1 } but not in { }:

typescript
configure()
def configure():
  pass

def render():
  setup()

Locate translate() calls before i18n initialization to fix ordering bugs.

clojure
(:inside
  (fun /render/)
  (:before
    (call init_i18n)
    (call translate)))

Selects in lines { 2, 2 } but not in { }:

typescript
def render1():
  translate()

def render2():
  init_i18n()
  translate()

def render3():
  translate()
  init_i18n()

Find variables declared before a specific import to reorder dependencies.

clojure
(:before (import react) (id))

Selects in lines { 1 } but not in { }:

typescript
x
import { useState } from 'react'
y

Include the anchor in results by refining with :into.

clojure
(:before (:into (fun)) (id))

Selects in lines { 1, 2 } but not in { }:

typescript
x
def y():

Arguments

anchor

Does NOT support: CompositionReplacement

val

inherit

Copyright © 2022-present Semantic Works, Inc.