Commit Graph

89 Commits

Author SHA1 Message Date
Qi Xiao
da576e221c pkg/eval: Use a Context inside Frame to pass interrupts. 2023-05-07 21:44:28 +01:00
Qi Xiao
833569303c Fixups for #1629. 2022-12-28 12:42:31 +00:00
Manuel Mendez
9fae00d125 eval: Add DeleteGlobal
Will be use by edit module soon.
2022-12-28 12:27:17 +00:00
Qi Xiao
5a237d7888 pkg/eval: When compiling, emit autofixes for using unimported builtin modules. 2022-12-11 14:21:09 +00:00
Qi Xiao
121509d8d2 pkg/eval: Preserve all compilation errors.
Multiple compilation errors are packed using diag.PackCognateErrors, like parse errors.
2022-11-30 01:40:03 +00:00
Qi Xiao
94ab1b5390 Generalize parse.Errors and move it to diag.
This generalized type will be used to pack multiple compilation errors.
2022-11-30 01:05:16 +00:00
Qi Xiao
a3f4384495 Move all elvdocs into .d.elv files.
The elvdocs still use the old format (#elvdoc:fn or #elvdoc:var) for now, but
will be changed to "fn" and "var" forms soon.

Also remove the accidentally committed cmd/mvelvdoc. It has been used to perform
the conversion automatically but is not supposed to be committed.
2022-11-20 21:59:45 +00:00
Kurtis Rader
c6e10f12a2 Some minor documentation fixes
Mostly elimination of duplicated words but also a few other fixes such
as the output of commands such as `%`.
2022-08-29 12:04:59 +01:00
Qi Xiao
551e246d96 webiste/cmd/macros: Strip leading $ from anchor targets of @cf.
Also add previously missing $'s in @cf arguments. This doesn't matter for the
anchor target, but matters for the link text.
2022-08-08 00:09:17 +01:00
Qi Xiao
9794eecd68 Add new runtime module.
This module provides $runtime:{lib-dirs rc-path effective-rc-path}. It will
likely grow in future.

This fixes #1385.
2022-08-08 00:09:02 +01:00
Qi Xiao
bd569f8132 pkg/eval: Add a note about the use of echo in after-chdir's example. 2022-08-07 22:25:47 +01:00
Qi Xiao
6a1e7b3996 pkg/shell: Add more daemon-related tests.
Also:

- Remove duplicate code for closing daemon client.

- Avoid using (*testing.T).TempDir - it uses test name in the path, which can
  exceed the limit of the address when calling bind(2):
  https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_un.h.html#tag_13_6
7_04
2022-06-19 21:45:36 +01:00
Qi Xiao
75ee261fcb pkg/eval: Remove access methods for exported fields.
The exported fields are intended to be mutated directly.
2022-06-18 19:01:59 +01:00
Qi Xiao
d48b6f1843 pkg/eval/vals: Replace MakeListFromStrings with a generic MakeListSlice. 2022-06-17 16:50:38 +01:00
Qi Xiao
3a3b8f5700 pkg/edit/complete: Change Complete to take an Evaler.
The PureEvaler abstraction made things unnecessarily complex; it's better to
just create a real Evaler for tests is pretty.

The Evaler has a new ReplaceBuiltin method to make it easier to construct the
expected test result.
2022-04-11 21:39:29 +01:00
Qi Xiao
51e4d97568 interface{} -> any now that Elvish requires Go 1.18. 2022-03-20 16:17:19 +00:00
Qi Xiao
38d4553833 Update assignment syntax in docs.
- Also remove the section for the legacy assignment syntax.

- Also add a paragraph to "eval" about upvalues.
2022-01-03 19:45:39 +00:00
Qi Xiao
653c9f9d0f Remove dir-history, deprecated since 0.17.0. 2022-01-03 00:47:41 +00:00
Qi Xiao
097e32b375 pkg/eval/vals: Add ReprPlain, Repr without pretty-printing.
Also de-export NoPretty now that it is no longer needed.
2021-12-31 21:05:07 +00:00
Qi Xiao
de5f0e0d32 Add new util vals.MakeListFromStrings. 2021-12-30 13:09:18 +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
973fe39798 Implement the tmp special command.
This addresses #1114.
2021-12-09 22:12:38 +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
c1dce661b7 Fix use of the builtin module via explicit "builtin".
Some of the variables are added after the Evaler is created, but that change was
not synchronized back to the copy of the builtin module that is imported with
"use builtin".

This fixes #1414.
2021-10-28 22:28:13 +01:00
Qi Xiao
d71e52cbd7 Refactor the API of eval.NsBuilder to be completely based on methods. 2021-10-23 21:44:11 +01:00
Qi Xiao
6a92571a23 Check assignments to read-only variable during compilation. 2021-10-13 23:57:14 +01:00
Qi Xiao
e299010be8 pkg/eval: Export the config fields and remove access methods. 2021-10-05 00:53:38 +01:00
Qi Xiao
fc754f6822 pkg/eval: Deliver message for finished bg job using editor notification.
This fixes #1067.
2021-10-05 00:08:14 +01:00
Qi Xiao
e70216421f pkg/eval: Remove more unnecessary mutex guards. 2021-10-04 23:27:06 +01:00
Qi Xiao
6eae543ecf pkg/eval: Remove unnecessary mutex guards. 2021-10-03 23:57:26 +01:00
Qi Xiao
1f362db665 pkg/eval: Add before-exit hook for daemon cleanup.
The daemon client in the Evaler is now only used by the dir-history builtin
command and can be removed when it is removed.
2021-10-03 23:16:20 +01:00
Qi Xiao
7e526534cd pkg/eval: Remove Eval.libInstallDir; it's not used anywhere. 2021-10-03 23:01:26 +01:00
Qi Xiao
47de83c7d1 Reorganize standard library modules.
- Move from pkg/eval/mods to pkg/mods

- Introduce mods.AddTo that adds all standard library modules

- Move epm and readline-binding into their own packages
2021-08-24 15:56:04 +01:00
Qi Xiao
e035930e49 Merge branch 'master' into xdg-dir 2021-08-05 22:36:53 +01:00
Qi Xiao
d8ff3e743e pkg/eval: Fill in default dummy ports in Evaler.prepareFrame.
Also fix the value of Frame.port in a benchmark.

This fixes #1355.
2021-08-01 21:38:30 +01:00
Qi Xiao
2d09e1a500 Implement XDG directory support.
Tests will be added in a followup commit before this branch is merged.

This addresses #383.
2021-07-10 02:20:59 +01:00
Qi Xiao
27eec7c8ee Reorganize the daemon module.
* Move client, spawning and activation code into pkg/daemon/client.

* Move API types into pkg/daemon/daemondefs.
2021-06-19 01:06:11 +01:00
Kurtis Rader
e2f810048e Add $edit:after-command and $edit:command-duration
The `edit:after-command` hooks are called with a single argument:
a pseudo-map with these keys:

    "command": the command line that was run
    "duration": the execution duration in seconds
    "error": any error that occurred ($nil if no error occurred)

The `edit:command-duration` variable is the elapsed seconds (as a
float64) of the most recently run interactive command.

Resolves #1029
2021-05-05 22:17:19 +01:00
Qi Xiao
91b6f6dd72 Use the integrated persistent package. 2021-05-03 22:17:46 +01:00
Kurtis Rader
12980c2719 Some golint cleanups 2021-04-05 15:31:53 +01:00
Qi Xiao
c96bfade21 pkg/parse: Small API tweak. 2021-02-01 14:20:56 +00:00
Qi Xiao
196eea21d4 Change module import path to src.elv.sh 2021-01-27 01:30:25 +00:00
Qi Xiao
b87cc7b5de Add back support for circular module dependency.
This fixes #1226.
2021-01-24 14:10:45 +00:00
Qi Xiao
629144195b pkg/eval: Fix handling of the global scope in (*Evaler).Eval.
- Do not mutate ev.global if cfg.Global is not nil. This fixes #1223.

- Handle concurrent mutations correctly. This addresses #1138.
2021-01-17 00:36:18 +00:00
Qi Xiao
56ceeedd21 pkg/eval: Store variable deletion information in *Ns.
This fixes #1213.
2021-01-10 00:54:02 +00:00
Qi Xiao
363b712f66 pkg/eval: Eliminate in-place mutations of *Ns.
This commit replaces scopeOp, the only remaining place that mutates *Ns in
place, with nsOp, which performs copy-on-write for *Ns.

As a result, the "eval" command no longer mutates the passed namespace. The
default namespace it uses is also changed to match the default of "-source" (an
amalgamated namespace from the local and upvalue scopes), making "-source $file"
equivalent to "eval (slurp <$file)", and formally deprecated.

Another result is that (*Evaler).Eval can now guard the mutation of the global
namespace with the mutex, making it concurrency-safe to execute multiple sources
that touch the global namespace.

This fixes #1137.
2021-01-09 15:02:15 +00:00
Qi Xiao
9af4c83bf6 pkg/eval: Minor cleanups. 2021-01-05 16:05:34 +00:00
Qi Xiao
2033600881 pkg/eval: Clean up Port related code. 2021-01-05 05:23:17 +00:00
Qi Xiao
6e8ecc8bd5 pkg/eval: Cleanups for reducing the API surface area number of files.
- Move NewEnvListVar to pkg/eval/vars.

- De-export GlobPattern, GlobFlag and ExternalCmd.

- Merge editor.go and chdir.go into eval.go, value_helper.go into compile_value.go.

- Remove eval_internal_test.go and replace it with a new test for $pid.
2021-01-05 04:33:52 +00:00
Qi Xiao
75baa0b5a2 pkg/eval: Remove (*Ns).Append.
This change makes Ns immutable from the exposed API. Internally there is exactly
one place that still mutates Ns, in scopeOp; this will be addressed later.
2021-01-05 01:09:04 +00:00