I am unable to find any gdb-kill-hook or similar.

After calling gdb with gdb-many-windows the frame gets a new window layout.

I am trying to store the previous layout in a register and to restore it after quitting gdb.

Is there any way to achieve this?


Try this:

;; Select a register number which is unlikely to get used elsewere
(defconst my-windows-config-register 313465989
  "Internal used")

(defvar my-windows-config nil)

(defun set-my-windows-config ()
  (setq my-windows-config (window-configuration-to-register my-windows-config-register)))

(defun jump-to-my-windows-config ()
  (jump-to-register my-windows-config-register))

One command to register, the other to jump resp. restore window-configuration.


Based on the answer of Andreas Röhler I was able to create the following functions. In the gdb buffer you can press 'q' to quit gdb as usual and restore the previous layout.

;; Select a register number which is unlikely to get used elsewere
(defconst egdbe-windows-config-register 313465989
  "Internal used")

(defvar egdbe-windows-config nil)

(defun set-egdbe-windows-config ()
  (setq egdbe-windows-config (window-configuration-to-register egdbe-windows-config-register)))

(defun egdbe-restore-windows-config ()
  (jump-to-register egdbe-windows-config-register))

(defun egdbe-start-gdb (&optional gdb-args)
  (call-interactively 'gdb))

(defun egdbe-quit ()
  (gud-basic-call "quit")

(defun egdbe-gud-mode-hook ()
  (local-unset-key (kbd "q"))
  (local-set-key (kbd "q") 'egdbe-quit))

(add-hook 'gud-mode-hook 'egdbe-gud-mode-hook)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.