Skip to content

Instantly share code, notes, and snippets.

@sogaiu
Created April 25, 2026 23:36
Show Gist options
  • Select an option

  • Save sogaiu/3f9c11e808a696efd05bce9603b34318 to your computer and use it in GitHub Desktop.

Select an option

Save sogaiu/3f9c11e808a696efd05bce9603b34318 to your computer and use it in GitHub Desktop.
emacs gdb auto-center source buffer around current line
;; references:
;;
;; * https://superuser.com/a/118138
;; * https://superuser.com/a/1680006
;; * http://kousik.blogspot.com/2005/10/highlight-current-line-in-gdbemacs.html
(defadvice gud-display-line (after my-gud-display-line-center activate)
;; true-file is an argument to the original function
(let* ((buffer (gud-find-file true-file)))
(save-excursion
(with-selected-window (get-buffer-window buffer)
(save-restriction
;; line is an argument to the original function
(goto-line line)
(recenter))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment