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

realgud:gdb overshadows comint mode bindings #255

Open
mohkale opened this issue Sep 20, 2019 · 11 comments
Open

realgud:gdb overshadows comint mode bindings #255

mohkale opened this issue Sep 20, 2019 · 11 comments

Comments

@mohkale
Copy link

mohkale commented Sep 20, 2019

I've found that realgud:gdb seems to be locally resetting my comint mode bindings with realgud:gdb-track-mode-map. To reproduce:

  • run emacs -q
  • navigate to a project which you can debug
  • compile the project to recieve an executeable... if one doesn't exist.
  • type M-x realgud:gdb and run it on the compiled executeable.
  • run M-x describe-bindings
  • navigate to the major mode bindings section.

For me it's been reduced to:

Major Mode Bindings:
key             binding
---             -------

C-c             Prefix Command

C-c !           Prefix Command

Is this the intended behaviour? I couldn't find any mention of this in the wiki or README and seeing as the actual major mode of the gdb buffer (as found through M-: major-mode) is still comint-mode this is actually a pretty pesky bug to hunt down.

Update: wrapping my comint bindings into a method (such that I can pass which keymap I want them bound to manually) & doing so to realgud:gdb-track-mode-map has restored my bindings. I still feel this qualifies as a bug, unless this is how its supposed to work? 😄.

@rocky
Copy link
Collaborator

rocky commented Sep 20, 2019

Is this the intended behaviour?

I don't think anyone gave that much thought. And clearly the fact that this is the first time anyone has mentioned it in the 10 years the project has been around suggests it's not been that big a deal. (Perhaps part of that is because it hasn't been used as much).

Make a suggestion of how this should work, or better put in a pull request and if it's reasonable we'll do.

@mohkale
Copy link
Author

mohkale commented Sep 21, 2019

Well shouldn't any minor mode normally add bindings to it's own keymap (which is then accessible while the mode is active) instead of replacing the major modes bindings with it's own map? I was under the impression that's how modes were supposed to work. though if you feel this doesn't warrant much of a change, then I'd appreciate if we could include a post in the wiki mentioning that comint binding don't work in realgud sessions (just to assist others who were as baffled as I was).

@rocky
Copy link
Collaborator

rocky commented Sep 21, 2019

The wiki anyone an add to, so feel free to put something there.

Or create its own keymap etc.

@mohkale
Copy link
Author

mohkale commented Sep 21, 2019

kay, I will, thnx 😄

@813gan
Copy link
Collaborator

813gan commented Aug 31, 2020

@mohkale It should be fixed by 75a6e60. Could you re-check it?

@TauPan
Copy link

TauPan commented Oct 15, 2020

@mohkale It should be fixed by 75a6e60. Could you re-check it?

I have that problem since upgrading to emacs 27. Before that comint-previous-input (M-p) and comint-next-input (M-n) just worked.

I can confirm that the 75a6e60 (I assume it's in 20200923.610 from melpa) does not fix this (it also seems related to the source buffer, not the pdb buffer but maybe I'm misreading it).

Confusingly, describe-mode still lists the comint keys:

<C-down>        comint-next-input
<C-up>          comint-previous-input
[...]
M-n             comint-next-input
M-p             comint-previous-input

@TauPan
Copy link

TauPan commented Oct 15, 2020

Update: wrapping my comint bindings into a method (such that I can pass which keymap I want them bound to manually) & doing so to realgud:gdb-track-mode-map has restored my bindings. I still feel this qualifies as a bug, unless this is how its supposed to work? .

I'm not clear on how to accomplish that.

[...]

The wiki anyone an add to, so feel free to put something there.

Or create its own keymap etc.

[...]

kay, I will, thnx smile

I don't see anything in the wiki either.

@mohkale
Copy link
Author

mohkale commented Oct 15, 2020

Whoops @TauPan, I installed realgud but then promptly never ended up using it so this issue kind of slipped my mind.

Here's what I meant:

(defun +comint-set-bindings (keymap)
  ;; abstracted into a method because realgud seems
  ;; to hide all of these bindings.
  (general-define-key
   :keymaps keymap
   "RET" 'comint-send-input
   "M-RET" 'comint-accumulate))

(with-eval-after-load 'comint
  (+comint-set-bindings 'comint-mode-map))

(with-eval-after-load 'realgud
  (+comint-set-bindings 'realgud:gdb-track-mode-map))

@TauPan
Copy link

TauPan commented Oct 26, 2020

Hm... I was wondering why it used to work and I'm one of those guys who update emacs packages very infrequently.

I found the following commit to be relevant: 62f7eb5

In fact I see that it makes sense to use shell-mode-map in bashdb, but I don't see why this would be useful in other debuggers.

So it looks like I was using an over 6 year old version of realgud for a very long time and updated after the emacs 27 update (possibly because of other issues).

Don't know how to properly fix this, since I'm not using bashdb at all.

@TauPan
Copy link

TauPan commented Oct 26, 2020

I found the following commit to be relevant: 62f7eb5

Nah, reverting this locally doesn't help. What also doesn't help is to copy the realgud-track-mode-map in the local track-mode-maps via realgud-track-mode-vars. I really have no idea. 🤷‍♂️

@TauPan
Copy link

TauPan commented Feb 15, 2021

Whoops @TauPan, I installed realgud but then promptly never ended up using it so this issue kind of slipped my mind.

Here's what I meant:

(defun +comint-set-bindings (keymap)
  ;; abstracted into a method because realgud seems
  ;; to hide all of these bindings.
  (general-define-key
   :keymaps keymap
   "RET" 'comint-send-input
   "M-RET" 'comint-accumulate))

(with-eval-after-load 'comint
  (+comint-set-bindings 'comint-mode-map))

(with-eval-after-load 'realgud
  (+comint-set-bindings 'realgud:gdb-track-mode-map))

For my use-case (pdb) the following works:

(defun +comint-set-bindings (keymap)
                 ;; abstracted into a method because realgud seems
                 ;; to hide all of these bindings.
                 (bind-key "M-p" #'comint-previous-input keymap)
                 (bind-key "M-n" #'comint-next-input keymap))
(with-eval-after-load 'realgud
                 (+comint-set-bindings realgud-track-mode-map)
                 (+comint-set-bindings realgud-backtrace-mode-map))

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

No branches or pull requests

4 participants