-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5362 from unisonweb/topic/text-search
- Loading branch information
Showing
9 changed files
with
402 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
|
||
# The `text.find` command | ||
|
||
```ucm:hide | ||
scratch/main> builtins.merge lib.builtin | ||
``` | ||
|
||
The `text.find` (or `grep`) command can be used to search for text or numeric literals appearing anywhere in your project. Just supply one or more tokens to search for. Unlike regular grep over the text of your code, this ignores local variables and function names that happen to match your search tokens (use `dependents` or `find` for that purpose). It's only searching for text or numeric literals that match. | ||
|
||
```ucm | ||
scratch/main> help grep | ||
``` | ||
|
||
```ucm | ||
scratch/main> help text.find.all | ||
``` | ||
|
||
Here's an example: | ||
|
||
```unison | ||
foo = | ||
_ = "an interesting constant" | ||
1 | ||
bar = match "well hi there" with | ||
"ooga" -> 99 | ||
"booga" -> 23 | ||
_ -> 0 | ||
baz = ["an", "quaffle", "tres"] | ||
qux = | ||
quaffle = 99 | ||
quaffle + 1 | ||
lib.foo = [Any 46, Any "hi", Any "zoink"] | ||
lib.bar = 3 | ||
``` | ||
|
||
```ucm:hide | ||
scratch/main> add | ||
``` | ||
|
||
```ucm | ||
scratch/main> grep hi | ||
scratch/main> view 1 | ||
scratch/main> grep "hi" | ||
scratch/main> text.find.all hi | ||
scratch/main> view 1-5 | ||
scratch/main> grep oog | ||
scratch/main> view 1 | ||
``` | ||
|
||
```ucm | ||
scratch/main> grep quaffle | ||
scratch/main> view 1-5 | ||
scratch/main> text.find "interesting const" | ||
scratch/main> view 1-5 | ||
scratch/main> text.find "99" "23" | ||
scratch/main> view 1 | ||
``` | ||
|
||
Now some failed searches: | ||
|
||
```ucm:error | ||
scratch/main> grep lsdkfjlskdjfsd | ||
``` | ||
|
||
Notice it gives the tip about `text.find.all`. But not here: | ||
|
||
```ucm:error | ||
scratch/main> grep.all lsdkfjlskdjfsd | ||
``` |
Oops, something went wrong.