3

Currently, I am using GUD in the newest version of Emacs. The keybinding has changed since the old Emacs. Now it is "\C-x \C-a \C-b" for setting a breakpoint but it was \C-[space].

I was wondering if there is anyway to change the keybinding to the old format? (For some reason I cannot change my Emacs version)

I am using Emacs 24.5

Here is my .emacs file:

;; .emacs

;;; uncomment this line to disable loading of "default.el" at startup
;; (setq inhibit-default-init t)

;; turn on font-lock mode
(when (fboundp 'global-font-lock-mode)
  (global-font-lock-mode t))

;; enable visual feedback on selections
;(setq transient-mark-mode t)

;; default to better frame titles
(setq frame-title-format
      (concat  "%b - emacs@" (system-name)))

;; default to unified diffs
(setq diff-switches "-u")

;; always end a file with a newline
;(setq require-final-newline 'query)

;; Show main source buffer when using gdb
(setq gdb-show-main t)

;; Show all debugging frames in GDB
(setq gdb-many-windows t)

;; see buffer list on the same frame
(global-set-key "\C-x\C-b" 'buffer-menu)

;; old keybinding for breakoint in GUD
(require 'gud)
(define-key gud-mode-map "\C-x SPC" 'gud-break)
Mehrdad
  • 107
  • 8

2 Answers2

2

Changing your Emacs version should not be necessary. Try this:

(require 'gud)
(define-key gud-mode-map (kbd "C-SPC") 'gud-break)

This will allow you to trigger gud-break with C-SPC. If you are not talking about the gud-break command, replace it with the command you are referring too.

Generally, the answer to the question "can I change this keybinding?" is always "yes" in Emacs.

elethan
  • 16,408
  • 8
  • 64
  • 87
  • @Mehrdad it should be `gud-mode-map` not `gud-mod-map`. Let me know if you still have issues after correcting that. – elethan Sep 08 '16 at 16:02
  • Sorry about that! I misspelled ( I have to retype the message, I cannot copy it) my in my comment, in fact the message was Symbol's value as variable is void: "gud-mode-map" – Mehrdad Sep 08 '16 at 16:06
  • @Mehrdad try my updated answer. The problem is that `gud` has not been loaded, so Emacs doesn't know what `gud-mode-map` is. I missed this the first time because `gud` is being loaded by another package in my init file. – elethan Sep 08 '16 at 16:13
  • @Mehrdad hmm, I am stumped. If your `.emacs` is almost empty would you mind posting its contents in your question to see if something stands out? – elethan Sep 08 '16 at 16:27
1

Somehow I was able to fix it with this:

(require 'gud)
(global-set-key [24 32] (quote gud-break))
Mehrdad
  • 107
  • 8
  • Very strange, I am not sure why it wouldn't work the other way. I don't see anything in your .emacs that would have caused it either. One thing that strikes me as odd is the backtick in your code example, that is the `\`` in `(require \`gud)`. This should not work with a backtick instead of a single quote `'`, so I am wondering if when copying my code, one of the single quotes ended up as a backtick like this. Either way, I am glad you got it working! – elethan Sep 08 '16 at 18:42
  • you are right! it was quote! That happened because I had to type it instead of copying it! misspelling when I was typing it in Stackoverflow! Thank you – Mehrdad Sep 08 '16 at 20:22