Emacs: Preventing gud & pdb from controlling windows

前端 未结 4 1394
栀梦
栀梦 2020-12-10 16:53

I\'m using pdb to debug Python programs and am unhappy with it\'s behaviour.

I have the screen divided into multiple emacs windows, and when I execute pdb, it (ran

相关标签:
4条回答
  • 2020-12-10 17:05

    Look into sticky windows.

    0 讨论(0)
  • 2020-12-10 17:06

    I have a solution that prevents the gdb from stealing windows. It works with Emacs 24.4 (2014-07-18 snapshot) and does not require dedicating buffers. The benefit over other answers is you won't have to bother dedicating and undedicating buffers whenever you change buffers, which quickly becomes tedious.

    Place this advice in your .emacs:

    (defadvice gdb-inferior-filter
        (around gdb-inferior-filter-without-stealing)
      (with-current-buffer (gdb-get-buffer-create 'gdb-inferior-io)
        (comint-output-filter proc string)))
    (ad-activate 'gdb-inferior-filter)
    

    This effectively replaces this function as defined in gdb-mi.el and removes the branch that calls gdb-display-buffer, which is the cause of the window thievery.

    0 讨论(0)
  • 2020-12-10 17:12

    You should use Sticky Windows to make your windows and buffers stick where they are but Sticky Windows won't stop gud/pdb from trying to steal your windows. When gud/pdb can't steal your source code window, it opens a new Emacs Frame even if there is another window on the current frame.

    This comes from the fact that the function that tries to jump to the gud-pdb buffer (py-pdbtrack-track-stack-file) calls function pop-to-buffer with argument OTHER-WINDOW set to t.

    To circumvent this behavior for all libraries that calls pop-to-buffer, you could cancel the role of OTHER-WINDOW by defining an advice on pop-to-buffer (in your .emacs) :

    (defadvice pop-to-buffer (before cancel-other-window first)
      (ad-set-arg 1 nil))
    
    (ad-activate 'pop-to-buffer)
    

    You should also customize variable pop-up-windows to nil in order to force display-buffer (the low-level routine used to display a particular buffer on windows and frames) to not create a new window.

    0 讨论(0)
  • 2020-12-10 17:26

    I tried all these approaches without success on Emacs 24. If you are still interested I reverted to the old gdb behavior using 'gud-gdb' which implements the old behavior of gdb/emacs interaction (no dedicated-windows and no I/O buffer). If you don't want to call M-x gud-gdb when you use it, you can define an alias for M-x gdb

    0 讨论(0)
提交回复
热议问题