Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an ocamldebug command for back stepping #227

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aatxe
Copy link

@aatxe aatxe commented Jan 10, 2020

I noticed when attempting to customize bindings for ocamldebug that Tuareg is actually missing a definition for backstep. This small change resolves that by creating an ocamldebug-back command (like the ocamldebug-next) command.

@leungbk
Copy link

leungbk commented Sep 24, 2020

It looks like C-b is already taken by break?

@aatxe
Copy link
Author

aatxe commented Sep 24, 2020

Ah, that is true. It seems to take the first one defined, so I didn’t notice. I can change it, but I don’t know what would be the most suitable/mnemonic.

@bbatsov
Copy link
Contributor

bbatsov commented Jul 13, 2022

I'd just C-j, C-k or C-m as they are close to the keybinding C-n (for next line). Perhaps we can also add C-j and C-k as aliases for C-m and C-n, even if they are inspired by vim. :-)

@monnier
Copy link
Contributor

monnier commented Oct 2, 2023

This is old, but I think it's still relevant.
The "natural" binding for the opposite of C-n is C-p (C-b is the opposite of C-f), so the conflict with C-b == break is a non-issue (Yay!). Instead we have a conflict with C-p == print (bummer!).

But do we need a new binding or could we use a numeric prefix (like C-u - 2 C-n to backstep 2 lines)?

@gasche
Copy link
Member

gasche commented Feb 24, 2025

The OCaml manual (debugger chapter) mentions C-c C-k as the keybinding to step back, and this seems to have been implemented in caml-mode/camldebug.el in 1997. I'm not sure if Tuareg removed this keybinding (maybe due to a conflict with the kill keybinding?) or if it was forked from camldebug.el before it was added.

I do find it convenient to have support for both step and back(step), and I think it would make sense to reuse C-c C-k for this to follow the manual's documentation. This may require making C-k for the kill command not work anymore, and I think it would be a fair deal. (You only kill the program once in your debug section, but you may step back and forth quite a bit.)

@bbatsov
Copy link
Contributor

bbatsov commented Feb 24, 2025

@gasche Do you know who are the maintainers of the project these days? I've noticed there has been no activity in the past 18 months.

@gasche
Copy link
Member

gasche commented Feb 24, 2025

This isn't necessarily such a bad sign, this is old code that is in maintenance mode -- and maybe Emacs is good about not asking for too much code churn. If you want to ask for specific changes, I would try asking @monnier.

monnier added a commit that referenced this pull request Feb 26, 2025
Align GPL version with that of `tuareg.el`.
Use `macroexp-file-name` when available.
Add `backstep` (C-k) and `display` (C-d) commands.
(ocamldebug-track-frame): Mark it as a user option.
(ocamldebug-mode-map): Comment out broken `M-?` binding.
(ocamldebug-mode): Make sure \\[..] refs are resolved relative to the
mode map rather than the current map.
(def-ocamldebug): Prefer `when`.
(ocamldebug-complete-filter): Use `push`.
(ocamldebug-complete): Use `declare`.
(ocamldebug): Rename arg to `file`, to match the docstring.
Try and behave a bit better when `make-comint` returns another buffer
than the one we expected.
(ocamldebug-set-current-event): Remove `pos` argument.
Use `before` instead (in the tty case) to decide whether to use `spos`
or `epos`, like we already did in the GUI case.  Also, set
`overlay-arrow-position` in the current buffer only.
(ocamldebug-display-line): Adjust caller accordingly.
monnier added a commit that referenced this pull request Feb 26, 2025
Align GPL version with that of `tuareg.el`.
Use `macroexp-file-name` when available.
Add `backstep` (C-k) and `display` (C-d) commands.
(ocamldebug-track-frame): Mark it as a user option.
(ocamldebug-mode-map): Comment out broken `M-?` binding.
(ocamldebug-mode): Make sure \\[..] refs are resolved relative to the
mode map rather than the current map.
(def-ocamldebug): Prefer `when`.
(ocamldebug-complete-filter): Use `push`.
(ocamldebug-complete): Use `declare`.
(ocamldebug): Rename arg to `file`, to match the docstring.
Try and behave a bit better when `make-comint` returns another buffer
than the one we expected.
(ocamldebug-set-current-event): Remove `pos` argument.
Use `before` instead (in the tty case) to decide whether to use `spos`
or `epos`, like we already did in the GUI case.  Also, set
`overlay-arrow-position` in the current buffer only.
(ocamldebug-display-line): Adjust caller accordingly.
@monnier
Copy link
Contributor

monnier commented Feb 26, 2025

OMG, I can't believe I hadn't really registered the duplication between camldebug.el and ocamldebug.el. I remember having the feeling of deja-vu when I fixed the completion code, but somehow ....
Anyway, I have a PR #319 that partially syncs up with camldebug.el and that brings in C-c C-k for backstep as well as C-c C-d for display.

The new code passes the tests, but AFAIK none of our tests cover the ocamldebug.el code, so could some kind souls out there try that code of mine and confirms it seems to work at least for them?

@gasche
Copy link
Member

gasche commented Feb 26, 2025

Wow, very nice! (I'm not qualified to review the change unfortunately, but I'm in favor.)

monnier added a commit that referenced this pull request Feb 27, 2025
ocamldebug.el: Try and partially sync with `camldebug.el` (#227)
@monnier
Copy link
Contributor

monnier commented Feb 27, 2025 via email

@monnier monnier closed this Feb 27, 2025
@monnier
Copy link
Contributor

monnier commented Feb 27, 2025

Actually, I was confused. The camldebug.el code I brought in is not really a solution because it has both

(def-camldebug "backstep" "\C-k" "Step one event backward.")

and

(def-camldebug "kill"   "\C-k")

As already pointed out by @gasche (sorry, I was too dense to understand that comment).
[ Similarly, that patch supposedly added a C-c C-d binding for display, but it collides with the existing binding for delete. ]

@monnier monnier reopened this Feb 27, 2025
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.

5 participants