Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Using the debugger in emacs is nice: You can step through the code with the next command, and emacs will always show the code line that is currently executed, like this:

  int x;
  int y;
=>int z;

But unfortunately, if your file is long, that pointer => will eventually move to the bottom and always show the current line at the bottom of the buffer.

It would be nicer if the pointer => always stayed in the middle of the buffer (vertically centered), so that I can see what's coming up right after the current line, before I say next again, like here:

  int y;
=>int z;
  std::cout << z;

Is that possible? Can I set that somewhere?

share|improve this question

1 Answer 1

There's no built-in mechanism to keep the line centered, however this advice does the trick for me:

(defadvice gud-display-line (after gud-display-line-centered activate)
  "Center the line in the window"
  (when (and gud-overlay-arrow-position gdb-source-window)
    (with-selected-window gdb-source-window
      ; (marker-buffer gud-overlay-arrow-position)
      (save-restriction
        (goto-line (ad-get-arg 1))
        (recenter)))))
share|improve this answer
    
Doesn't work for me. When I say 'next' in gdb, emacs gives an error in process filter: Symbol's value as variable is void: gud-overlay-arrow-position –  dehmann Apr 19 '10 at 2:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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