Commit Graph

411 Commits

Author SHA1 Message Date
jonahbeckford f8affb8cfb
Fix unavailable expunge on Windows (#447)
Fix unavailable expunge on Windows

Without this commit, get:

```
File "src/top/dune", line 33, characters 0-131:
33 | (rule
34 |  (targets utop-expunged.bc)
35 |  (action
36 |   (run %{ocaml_where}/expunge %{dep:utop.bc} %{targets}
37 |     %{read-lines:modules.txt})))
Error: File unavailable:
Z:/source/dkml/build/pkg/bump/.ci/o/PR/lib/ocaml/expunge
```

Co-authored-by: Etienne Millon <me@emillon.org>
2023-07-07 17:34:13 +02:00
Skye Soss 972996374a
XDG Base Directory Compliance (#431)
This uses xdg to load files in the right place.
2023-07-03 11:43:57 +02:00
Etienne Millon 21439f537e
Bump compatibility to 4.11+ (#444) 2023-07-03 11:29:30 +02:00
Etienne Millon 4e6aae168c
Remove deprecated values (#427)
Follow-up to #415: we remove these values.
2023-06-23 17:16:36 +02:00
Thibaut Mattio 351741b820
Check Zed.next_error index value is within the string length (#442)
This fixes Zed.Out_of_bound errors

Co-authored-by: Etienne Millon <me@emillon.org>
2023-06-23 15:09:05 +02:00
Etienne Millon 87871f442e
Add test for fix_string (#443) 2023-06-23 14:28:14 +02:00
Etienne Millon e885c5ee93
expunge: move system code to dune (#439)
The logic to create utop from utop-full is as follows:

- use ocamlobjinfo on utop-full to determine which modules are used
- use ocamlobjinfo on ocamlcommon, ocamlbytecomp, and ocamltoplevel to
  determine which modules to exclude (a priori)
- compute the set used - (exclude - {Topmain,Toploop,Topdirs})
- call expunge with this set of modules

Previously, this was all done in expunge/expunge.ml, meaning core logic
+ process handling.
What this PR does is offload the process handling to dune: calling
ocamlobjinfo and expunge is done instead in dune rules, and
expunge/modules.ml is just about reading sets of module names and
outputing the result.

Besides simplicity and portability, the other advantage is that the
intermediate modules.txt can be inspected directly.
2023-06-23 13:56:38 +02:00
Etienne Millon bfabaacf2a
use lang 2.0 and format dune files (#440) 2023-06-23 11:37:09 +02:00
Garth Tuohy f2f2aef137 More compatible fix 2023-06-12 11:38:04 +02:00
Etienne Millon a922be057f fix regression with unit qualification
Fixes #428

The change in #418 introduced a regression if a `Unit` module in scope
does not have a `()` constructor in it.

This switches to the more explicit `Stdlib.Unit.()` path.
2023-04-21 12:18:30 +02:00
Jake Shilling 0e9f0c6893 emacs: implement completion-at-point
Fixes #261
2023-04-19 16:14:59 +02:00
Etienne Millon ed895283db Qualify () constructor
We are building a hidden expression that contains "()" but it is not
qualified. So it will pick the constructor in scope. This can cause
problems if `()` has been redefined. The correct fix is to qualify it as
part of the `Unit` module.

(additionally, this removes an unused ident)

Fixes #417
2023-04-17 13:36:23 +02:00
Etienne Millon 1a70e0fb85 Do not pass -safe-string explicitly
Strings are safe now.
2023-04-17 13:34:23 +02:00
Etienne Millon 78349cc4b8 Fix add_let 2023-04-12 10:23:15 +02:00
Etienne Millon 846af28b3c OCaml 5.1 support 2023-04-12 10:23:15 +02:00
Etienne Millon 13011b0d45 Move compat functions to their module
The utop code base is full of #if OCAML_VERSION to adapt to the changes
in compiler-libs. This has some issues - for example the corresponding
logic is harder to recognize, and some logic is duplicated in several
places. Also, this prevents using a formatter.

One medium-term goal is to move most of the compat functions to a new
Utop_compat module which would be the only place we use cppo.

This contains the "easy" cases - moving existing functions, etc. It is a
bit more difficult (and controversial) to convert pattern matching to
this pattern so it'll be done separately.
2023-02-22 11:51:32 +01:00
Etienne Millon ace481388a Mark deprecated values with attribute
They have been deprecated in 2012 and most of them are ignored.
2023-02-02 16:39:37 +01:00
Etienne Millon 5aae06f007 Do not display a backtrace when exiting normally
Exiting normally here refers to the `Exit_with_status` exception.
It is in particular triggered by `#quit;;` so we want to exit quietly
in that case.

Closes #398
2023-01-05 15:21:51 +01:00
Brian Leung c596ac7b88
Shut up Emacs 29's byte-compiler (#404)
* Shut up Emacs 29's byte-compiler

* Fix docstring to comply with checkdoc
2022-11-03 08:46:06 -06:00
Brian Leung 0cb4ffe584
utop.el: always insert phrase terminator at the end-ish of input (#402)
* utop.el: always insert phrase terminator at the end-ish of input

When point is at the letter "n" in

utop[1]> let thi[n]g = 42

or in

utop[2]> let thi[n]g = 8734;

and the user presses C-j, it is always because they want to terminate
the expression at the end-ish of the input.

The unpatched behavior did not move point, and inserted two semicolons
in the middle of the expression.
2022-11-02 18:27:07 -06:00
metanivek bbd9a6ed45 feature: Add toplevel_printer support for functors 2022-07-27 11:10:32 -05:00
Etienne Millon f9b5ec7266
Merge pull request #393 from emillon/408
Bump the compat to 4.08+
2022-07-21 10:15:10 +02:00
Bozhidar Batsov ebca87c7a3 Try to appease checkdoc
Things like 'done are not allowed in docstrings.
2022-07-19 16:11:42 -05:00
Bozhidar Batsov 036eac86b0 Remove a deprecated function
I think we can safely assume 7 years are enough time for most people
to have learned about `utop-minor-mode`.
2022-07-19 16:11:42 -05:00
Bozhidar Batsov b8b8dd6d8d Remove some dead code
Seems 9 years ago someone tried to extract types from the evaluation
results but never got this working. I think it's time for this code to
go away, given that we have much better options today (e.g. Merlin).
2022-07-19 16:11:42 -05:00
Bozhidar Batsov bfbe143ce1 Rename utop-is-running to utop-running-p
That's the Emacs convention for predicates.
2022-07-19 16:11:42 -05:00
Bozhidar Batsov 9c0a55f2c0 Fix the :active checks in the minor mode's menu
When there you need to retrieve the utop buffer first - you can't
check for the state directly.
2022-07-19 16:11:42 -05:00
Bozhidar Batsov 6658ca4c21 Fix some typos 2022-07-19 16:11:42 -05:00
Bozhidar Batsov 2bee980a9d Add C-c C-e as an alias for C-x C-e
That's the practice in most similar Emacs modes.
2022-07-19 16:11:42 -05:00
Bozhidar Batsov 5049cd9344 Add missing keybinding for utop-switch-to-recent-buffer 2022-07-19 16:11:42 -05:00
Etienne Millon a05100db32 Bump the compat to 4.08+
Utop supports a wide range of OCaml versions, but this is getting more
difficult to support. In addition, some of the dependencies we use do
not support 4.03-4.07, so utop can not be built on these versions.
2022-07-19 11:38:52 +02:00
Etienne Millon 8c2039543b Handle Syntaxerr.Removed_string_set 2022-07-19 11:07:42 +02:00
Bozhidar Batsov e89802f24c Address a compilation warning 2022-07-18 15:34:13 -05:00
Bozhidar Batsov 8149df9132 Add a complication check GHA
It's based on Eldev.
2022-07-18 15:34:13 -05:00
Bozhidar Batsov 2a405226f2 Add commands to switch to and from a utop buffer
Those are extremely common in Emacs modes and allow people to
quickly jump to a REPL and back to the last source buffer they
were editing, while using the same keybinding.

I've modeled the implementation here after that of inf-clojure (a similar
mode written by me). I've also implemented a mode menu for
utop-minor-mode, so it's easier for the users to discover its
functionality.
2022-07-18 14:29:54 -05:00
Bozhidar Batsov 09d26a7509 Use defvar-local where appropriate 2022-07-18 10:04:04 -05:00
Bozhidar Batsov ba18d8ad38 Group the major mode code more tightly 2022-07-18 10:04:04 -05:00
Bozhidar Batsov f91c126afb [Fix #389] Require Emacs 26 in utop.el 2022-07-18 10:04:04 -05:00
Bozhidar Batsov e7b1ff36d1 [Fix #358] Fix code completion for module identifiers in utop.el
Without those changes you won't get any completion for things like
"List.m". I'm not very familiar with the code, but it seems that the
backend returns the completion candidates without the module prefix
which caused the problem.

I've opted to fix this by handling prefixes with a "." in them specially
and this works fine in the limited testing I conducted locally.
2022-07-16 13:32:11 -05:00
Bozhidar Batsov 1a7c112a71 Add :safe properties to defcustoms 2022-07-16 11:32:15 -05:00
Bozhidar Batsov a84d499301 Remove redundant :group properties
Those are auto-inferred from the :prefix set in defgroup.
2022-07-16 11:32:15 -05:00
Bozhidar Batsov 2c08182649 Add some package description
package.el repos typically extract and show this info.
2022-07-16 11:32:15 -05:00
Bozhidar Batsov ec1f09420d Reformat a couple of let bindings
This makes it easier to see the definitions they introduce.
2022-07-16 11:32:15 -05:00
Bozhidar Batsov c117c6cf57 Use #' for function references where appropriate 2022-07-16 11:32:15 -05:00
Bozhidar Batsov dee6a8752a Use the kbd macro for all keybindings
This makes more complex keybindings easier to read and write.
2022-07-16 11:32:15 -05:00
Bozhidar Batsov b24f94243f Update a few URL references 2022-07-16 11:32:15 -05:00
Etienne Millon 6c55ea7996 Use logs.lwt instead of lwt_logs
The latter is deprecated and incompatible with OCaml 5.0.
2022-07-05 17:20:22 +02:00
Etienne Millon 2569162157 Compatibility with zed 3.2.0
This updates utop to use the uu packages instead of camomile, following
ocaml-community/zed#46 and ocaml-community/lambda-term#109.
2022-07-05 15:41:25 +01:00
David Allsopp fbbaec6be8 Support new Load_path.init API 2022-06-09 10:35:44 +01:00
David Allsopp 42614160c2 Adapt to new mechanism for loading topdirs.cmi 2022-04-16 10:36:40 -05:00