Commit Graph

983 Commits

Author SHA1 Message Date
Qi Xiao
1910948a86 edit.md: Upgrade syntax. 2021-12-28 17:11:59 +00:00
Qi Xiao
1ec9c95142 Fix the doc for ttyshots.
- Wrap the command in "print" to get byte output.

- Use global-binding to ensure that the key works in all modes.
2021-12-28 13:01:21 +00:00
Qi Xiao
7da4b58f2f Revise doc for the builtin module.
- Revise the introduction section.

- Link to the notes on commands taking value inputs from all such commands.

- Revise the doc on the "all" command.

- Revise references to the builtin module from the language reference.
2021-12-28 12:01:35 +00:00
Qi Xiao
560bd17c17 pkg/eval: Break up builtin_fn_container.go.
- range -> builtin_fn_num.go

- all, one, take, drop, count, order -> new builtin_fn_stream.go

- repeat -> builtin_fn_io.go

- compare -> builtin_fn_pred.go
2021-12-26 12:22:14 +00:00
Christopher Loessl
bd76b46b8e
Doc update (#1457)
* docs(effective-elvish): follow same style as other docs

e.g., https://elv.sh/ref/language.html

* docs(builtin): ref from take to drop

* docs(language): remove mention of :up and :down ns

* docs(fundamentals): update to new lambda format

* docs(tour): update to new lambda syntax

* docs(builtin): update to new lambda syntax

* docs(language): update to new lambda syntax

* docs(unique-semantics): update to new lambda syntax

* docs(tour): fix typo

* Revert "docs(effective-elvish): follow same style as other docs"

This reverts commit db4306a400c61f5f7b6acec7a1e1f39feb9b1ba0.

https://github.com/elves/elvish/pull/1457#discussion_r775102178
2021-12-26 12:02:00 +00:00
Qi Xiao
b1460e4269 Wording tweak for the doc of edit:add-var. 2021-12-24 01:40:26 +00:00
Kurtis Rader
9cf2cfffa6 Cleanups to rc.elv references 2021-12-24 01:40:01 +00:00
Qi Xiao
3bdd7b49e8 Fixup for #1452 2021-12-20 13:31:53 +00:00
Kurtis Rader
91f21858ac More improvements to edit:add-var documentation
The existing `edit:add-var` documentation incorrectly implies the `$init`
value is optional. It also doesn't include any examples that are useful
in practice. This addresses both shortcomings.
2021-12-20 13:13:56 +00:00
Qi Xiao
db0cf05893 Expand the doc of edit:add-var. 2021-12-18 11:58:12 +00:00
Qi Xiao
c71f46642b Update eawk's doc.
* Remove a superfluous line break in the equivalent Elvish code.

* Keep code in transcripts on the same line to be correctly highlited.

* Add another example using digit-only argument names.
2021-12-17 19:53:30 +00:00
Qi Xiao
046e02869d pkg/eval/vals: Document the use of 0 in UnifyNums. 2021-12-17 10:52:44 +00:00
Qi Xiao
7463203bda pkg/mods: Import pkg/mods/unix. 2021-12-17 00:50:53 +00:00
Qi Xiao
71e5bff8da Replace direct reference to persistent types with their aliases in eval/vals. 2021-12-17 00:21:20 +00:00
Qi Xiao
82d92ad467 pkg/eval/vals: De-export the Eq util and move into a _test file. 2021-12-16 23:55:24 +00:00
moko256
c054b0a24d pkg/cli/term: Use ENABLE_WRAP_AT_EOL_OUTPUT on Windows. 2021-12-16 22:20:44 +00:00
Qi Xiao
089752147a Fixup for #1447. 2021-12-13 01:23:14 +00:00
Kurtis Rader
87656c99fa Replace AnyError in tests with a specific error
The `AnyError` placeholder error can cause tests to succeed for errors
other than what was expected. That is, the use of `AnyError` can mask
bugs in a unit test. So replace it with the specific error, or error type,
the test expects to be raised.

This does not remove the anyError structure because it is used in
the TestCase.DoesNotCompile() method. To keep the size of this change
as small as possible I want to defer updating that use to a separate
change. However, remove the public AnyError var so future test writers
don't attempt to use it.
2021-12-13 01:08:24 +00:00
Qi Xiao
973fe39798 Implement the tmp special command.
This addresses #1114.
2021-12-09 22:12:38 +00:00
Qi Xiao
c1adf58b6d Document using "range n | each" to execute something n times.
This addresses #1433.
2021-12-08 00:32:32 +00:00
Qi Xiao
8cbd39f006 Support calling edit:notify with a styled text.
This fixes #1438.
2021-12-08 00:26:17 +00:00
Qi Xiao
2941f5308e Fix deprecated code in epm. 2021-12-07 00:44:28 +00:00
Harald Hanche-Olsen
fe8af31f2d Fix deprecated code in readline-bindings 2021-12-07 00:30:33 +00:00
Qi Xiao
6a9931e662 Bump version and deprecation level
Now that v0.17-release has been branched, the HEAD build will show deprecations
intended for 0.17.0, and be considered a pre-release version of 0.18.0.
2021-12-06 00:30:36 +00:00
Qi Xiao
14a81d12f8 pkg/eval: Initialize ns variables to an empty ns, rather than nil.
This fixes #1257.
2021-12-06 00:18:09 +00:00
Qi Xiao
ab88de7c15 Fix ScanToGo's error message when ptr points to an interface.
When the destination to scan into is an interface, its zero value is simply a
nil interface, losing the information of the original type and resulting in
error messages like "need nil, got $actual-type".

ScanToGo now handles this case specifically, and uses the string representation
of the interface type in the error message.

Before:

~> ns []
Exception: wrong type of argument 0: wrong type: need nil, got list
~> var x~ = x
Exception: wrong type: need nil, got string

After:

~> ns []
Exception: wrong type of argument 0: wrong type: need !!hashmap.Map, got list
~> var x~ = x
Exception: wrong type: need !!eval.Callable, got string

This is still not ideal, since the "need" type is not given as an Elvish "kind",
but it's much less confusing than than old "need nil" messages.

This fixes #715.
2021-12-05 23:49:49 +00:00
Qi Xiao
82dda13def Fixup for #1435. 2021-12-05 20:51:17 +00:00
Qi Xiao
713a16bc6e
Merge branch 'master' into add-compare-builtin 2021-12-05 20:37:13 +00:00
Qi Xiao
b1154a95dc Fixup for #1439.
* Fix the case when start is near the overflow point and add regression tests.

* Rewrite the implementation in a less abstract way.

* Rewrite the elvdoc.
2021-12-05 20:22:44 +00:00
Kurtis Rader
2ba69c32dd Augment builtin:range to support counting down
Resolves #1436
2021-12-05 18:44:59 +00:00
Qi Xiao
64661d6b33 pkg/eval: Execute the last form in a pipeline on the current goroutine.
This simple optimization improves the performance of pipelines containing only
one form drastically. Pipelines containing more than one form also execute a
little bit faster.

A subset of the benchmark results, on MacBook Air M1 2020:

| Benchmark | Before      | After       | Speedup |
| --------- | ----------- | ----------- | ------- |
| nop       |  3398 ns/op | 934.1 ns/op | 3.6x    |
| nop-nop   | 13596 ns/op | 11423 ns/op | 1.2x    |
| put-x     |  4163 ns/op |  1611 ns/op | 2.6x    |
2021-12-02 00:34:36 +00:00
Qi Xiao
9e6555a4fb pkg/eval: Reorganize benchmarks.
Use b.Run to run benchmarks. Also remove the dedicated tests for output capture.
2021-12-02 00:30:01 +00:00
Qi Xiao
246706aeca website: Preserve ":" in elvdoc header IDs.
This fixes #1430.
2021-11-29 23:47:59 +00:00
Qi Xiao
a0b93968a3 Fix broken relative links. 2021-11-29 20:03:09 +00:00
Qi Xiao
b05fc3250c Fixup for #1440.
- Fix whitespace inconsistency

- Fix comment in parse/parse.go
2021-11-28 21:32:41 +00:00
Kurtis Rader
d4b4edbbbe Replace legacy lambda with new lambda examples
I was surprised to see so many legacy lambda syntax examples in the
documentation. This replaces all of them with the new syntax -- excluding
the handful of cases meant to explicitly verify the legacy form is still
valid. This also adds a link to the issue in the release notes which
documents the change in syntax.

Related #664
2021-11-28 21:30:59 +00:00
Qi Xiao
08c5f512bf Apply more tweaks to the path module's elvdoc. 2021-11-28 21:14:43 +00:00
Kurtis Rader
bf04fae352 Improve the path: module documentation
This change is due to a recent IM discussion wherein someone had
difficulty finding the `path:is-regular` command. It attempts to make
such discovery easier.
2021-11-28 21:13:46 +00:00
Kurtis Rader
3068edaa5f Add a builtin:compare command
Expose the default comparison function used by the `builtin:order`
command as a command in its own right. This command is useful when
writing, in Elvish, something like `builtin:order`. Such as a semantic
version comparison command.

Resolves #1347
2021-11-21 19:32:25 -08:00
Qi Xiao
4df04d7cd4 Support omitting $low in randint.
Like range, it defaults to 0 when omitted.
2021-11-20 15:07:26 +00:00
Qi Xiao
6a5619b01e Simplify the doc for randint. 2021-11-20 14:57:03 +00:00
Qi Xiao
2463a9ad10 pkg/eval: Link to Wikipedia for the interval notation in the doc for randint. 2021-11-19 16:32:29 +00:00
Kurtis Rader
c59e01abfc Document the use of slurp with printf
A recent IM question, and subsequent discussion, resulted in @hhanche
commenting that if you need to explicitly move the output of `printf`
from the byte to the value stream you should use `slurp` rather than
`put` or `from-lines`. Include that insight in the `printf`
documentation.
2021-11-14 16:19:46 +00:00
Kurtis Rader
8faf8930b3 Add use unit tests and tweak documentation
This explicitly tests a common error case not currently verified by the
existing unit tests. Thus improving test coverage by one line.  :-)
2021-11-14 16:17:51 +00:00
Qi Xiao
5198e38f28 Advice against "useless use of put". 2021-11-07 23:36:56 +00:00
Qi Xiao
b6cf0a355f Fixup for #1417 2021-11-07 15:08:22 +00:00
Sauyon Lee
b60228cdb6 fixup! pkg/edit: Implement transpose-{alnum- small- ""}word 2021-11-07 14:50:57 +00:00
Sauyon Lee
cf4539ae9e Add transpose binds to readline-binding 2021-11-07 14:50:57 +00:00
Sauyon Lee
1b4f2b32df pkg/edit: Implement transpose-{alnum- small- ""}word 2021-11-07 14:50:57 +00:00
Sauyon Lee
66a3116451 pkg/edit: Implement transpose-char 2021-11-07 14:50:57 +00:00