Ensure Idris is running and current idr file loaded when using idris-switch-to-repl#643
Ensure Idris is running and current idr file loaded when using idris-switch-to-repl#643keram wants to merge 3 commits intoidris-hackers:mainfrom
idris-switch-to-repl#643Conversation
32a9313 to
76d183c
Compare
idris-repl.el
Outdated
| (interactive) | ||
| (if (and buffer-file-name | ||
| ;; in Emacs 29.1 > we can use string-equal-ignore-case | ||
| (string= "idr" (downcase (file-name-extension buffer-file-name)))) |
There was a problem hiding this comment.
Is it not the case that idris files can have other extensions if we are in literate mode?
There was a problem hiding this comment.
Good point! I have updated the implementation to check also for lidr files although I don't have any good lidr examples to test it with.
b339073 to
1686c02
Compare
idris-repl.el
Outdated
| "Load the current Idris file buffer and jump to the Idris REPL." | ||
| (interactive) | ||
| (if (or (idris-idr-p) (idris-lidr-p)) | ||
| (idris-load-file-sync) |
There was a problem hiding this comment.
Using synchronous load as async idris-load-file causes point to be moved from repl back to source file.
1686c02 to
d0495e9
Compare
d0495e9 to
ba38636
Compare
| (idris-run) | ||
| (idris-switch-to-repl)) | ||
| (pop-to-buffer (idris-repl-buffer)) | ||
| (goto-char (point-max))) |
There was a problem hiding this comment.
Removed (idris-switch-to-repl) because user can invoke idris-repl without being in Idris file
and idris-switch-to-repl has now dependency to be invoked only within idr or lidr files.
ba38636 to
8b42812
Compare
8b42812 to
a7488bd
Compare
…idris-switch-to-repl` Why: Allows to jump to the repl without having to manually start repl using a shortcut
Why: When jumping to a repl from non-loaded file we want to do optimistic load. Ergo even if Idris finds errors in the file the jump to the repl should succeed.
This improves the user workflow. When writing Idris code, it is often useful to switch back and forth to the REPL (e.g., to test functions, look up docs, or check types), even when the code is in a broken state. However, when an error occurs, switching to the REPL is interrupted, leaving the point in the original buffer and forcing the user to dismiss the Idris notes.
a7488bd to
48d1e5c
Compare
| "Select the output buffer and scroll to bottom." | ||
| (interactive) | ||
| "Load the current Idris file buffer and jump to the Idris REPL." | ||
| (interactive nil idris-mode) |
There was a problem hiding this comment.
Specifying idris mode should exclude this command from M-x list in non idris-mode based buffers. Depends on user setting as per documentation:
If MODES is present, it should be one or more mode names (symbols)
for which this command is applicable. This is so that ‘M-x TAB’
will be able to exclude this command from the list of completion
candidates if the current buffer’s mode doesn’t match the list.
Which commands are excluded from the list of completion
candidates based on this information is controlled by the value
of ‘read-extended-command-predicate’, which see.
Why:
Allows to jump to the repl without having to manually start repl using a shortcut.
This change improves user experience. For example in scenario:
foo.idrfileC-c C-z(default key binding for `idris-switch-to-repl')Previously invoking
idris-switch-to-replon a "cold" idr file would return an error: "idris-repl has no process".