Skip to content

Instantly share code, notes, and snippets.

@rebolek
Last active February 16, 2018 14:58
Show Gist options
  • Save rebolek/8e404c02c4b94e186f496c9d54adab85 to your computer and use it in GitHub Desktop.
Save rebolek/8e404c02c4b94e186f496c9d54adab85 to your computer and use it in GitHub Desktop.
Find where function is defined
Red[
Title: "Where"
Purpose: "Find where function is defined"
Author: "Boleslav Březovský"
]
where: function [
"Return file where function is defined or NONE, if the definition can't be found"
'name
/in
path "Start search in this path (default is current directory)"
][
name: form name
root: any [path %./]
find-where: function [
path
name
][
files: read path
foreach file files [
file: rejoin [path file]
case [
%.red = suffix? file [
content: read file
if find content rejoin [name ": func"][return file]
]
dir? file [
if result: find-where file name [return result]
]
]
]
none
]
find-where root name
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment