Skip to content

[ ide-mode ] return formatted options string for :interpret ":opts" IDE command#1

Draft
keram wants to merge 2 commits intoide-mode-interpret-versionfrom
ide-mode-interpret-ops
Draft

[ ide-mode ] return formatted options string for :interpret ":opts" IDE command#1
keram wants to merge 2 commits intoide-mode-interpret-versionfrom
ide-mode-interpret-ops

Conversation

@keram
Copy link
Copy Markdown
Owner

@keram keram commented Apr 24, 2026

Previously, the :interpret ":opts" returned a list of S-expression same as
((:get-options) n)

This leads to bad user experience at least in Emacs
See: idris-hackers/idris-mode#661
and idris-hackers/idris-mode#662

This change distinguish between :get-options to return original S-expression
and `:interpret ":opts" to return formatted options as a string.

Before:

idris2 --ide-mode
((:interpret ":opts") 3)
00009b(:return (:ok ((:show-implicits :False) (:show-machinenames :False) (:show-namespace :False) (:show-types :False) (:eval "normalise") (:editor "vim"))) 3)
((:get-options) 3)
00009b(:return (:ok ((:show-implicits :False) (:show-machinenames :False) (:show-namespace :False) (:show-types :False) (:eval "normalise") (:editor "vim"))) 3)

In Emacs

before-fix-version-opts

After:

$ idris2 --ide-mode
((:interpret ":opts") 3)
00008d(:return (:ok "showimplicits = False
showmachinenames = False
shownamespace = False
showtypes = False
eval = normalise
editor = \"vim\"") 3)
((:get-options) 3)
00009b(:return (:ok ((:show-implicits :False) (:show-machinenames :False) (:show-namespace :False) (:show-types :False) (:eval "normalise") (:editor "vim"))) 3)

Emacs:

opts-idris-repl-emacs-after

Relates to:

idris-lang#3768

keram added 2 commits April 24, 2026 17:42
… IDE command

Previously, the `:interpret ":opts"` returned a list of S-expression same as
`((:get-options) n)`

This leads to bad user experience at least in Emacs
See: idris-hackers/idris-mode#661
and idris-hackers/idris-mode#662

This change distinguish between `:get-options` to return original S-expression
and `:interpret ":opts" to return formatted options as a string.

 Before:

```
idris2 --ide-mode
((:interpret ":opts") 3)
00009b(:return (:ok ((:show-implicits :False) (:show-machinenames :False) (:show-namespace :False) (:show-types :False) (:eval "normalise") (:editor "vim"))) 3)
((:get-options) 3)
00009b(:return (:ok ((:show-implicits :False) (:show-machinenames :False) (:show-namespace :False) (:show-types :False) (:eval "normalise") (:editor "vim"))) 3)
```

 After:

```
$ idris2 --ide-mode
((:interpret ":opts") 3)
00008d(:return (:ok "showimplicits = False
showmachinenames = False
shownamespace = False
showtypes = False
eval = normalise
editor = \"vim\"") 3)
((:get-options) 3)
00009b(:return (:ok ((:show-implicits :False) (:show-machinenames :False) (:show-namespace :False) (:show-types :False) (:eval "normalise") (:editor "vim"))) 3)
```

Relates to:
idris-lang#3768
Comment on lines +133 to +146
getOptions : {auto c : Ref Ctxt Defs} ->
{auto o : Ref ROpts REPLOpts} ->
Core (List REPLOpt)
getOptions = do
pp <- getPPrint
opts <- get ROpts
pure $ [ ShowImplicits (showImplicits pp)
, ShowMachineNames (showMachineNames pp)
, ShowNamespace (fullNamespace pp)
, ShowTypes (showTypes opts)
, EvalMode (evalMode opts)
, Editor (editor opts)
]

Copy link
Copy Markdown
Owner Author

@keram keram Apr 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is copy-paste from Idris/REPL.idr https://github.com/idris-lang/Idris2/blob/main/src/Idris/REPL.idr#L191 as when trying reusing it here got an error.

Error: While processing right hand side of process. 
Name Idris.REPL.getOptions is private.
...
Suggestion: add an explicit export or public export modifier. 

I don't know which is the right suggested solution or some other better way to get the opts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant