Skip to content

(fun)

function definitions

clojure
(fun name? args?)

Where:

  1. name: function name (the name in def name():) *
  2. args: function parameters *

Matching:

  1. simple definitions, e.g. def name():
  2. definitions with parameters, e.g. def name(arg):

Behavior

  • Matches def statements; does not match lambda expressions.

Examples

Find test functions for cleanup.

clojure
(fun /^test_/)

Selects in lines { 1, 3 } but not in { 5 }:

python
def test_login():
    pass
def test_logout():
    pass
def helper():
    pass

Identify handlers that accept a request parameter.

clojure
(fun _ (arg 1 (id request)))

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

python
def handle(request, response):
    pass
def handle_no_request(response):
    pass

Locate main entrypoints for refactoring.

clojure
(fun main)

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

python
def main():
    pass
def run():
    pass

Arguments

name

• Identifier: shorthand for (id)
• Pattern: shorthand for (id)
(id)
(:into) (:and) (:or) (:not) (:text) (:kind) (:replace) (:capture)

args

(arg)
(:into) (:and) (:or) (:not) (:text) (:kind) (:replace) (:capture)

Copyright © 2022-present Semantic Works, Inc.