dangnam2910
dangnam2910

Reputation: 83

clear gdb screen in emacs?

As the title, how can I clear gdb command screen in Emacs. I tried with shell clear but It only work with gdb in terminal.

Have anyone here give me an ideal?

Thank in advance!

Upvotes: 1

Views: 539

Answers (3)

juanleon
juanleon

Reputation: 9410

You can bind this defun to a key of your choice:

(defun clean-comint-buffer()
  (interactive)
  (delete-region (point-min)
                 (save-excursion
                   (goto-char (point-max))
                   (forward-line 0)
                   (point))))

It works for gdb and other comint-based modes (shell, interactive sql, etc...) that sometimes tend to grow with lines no longer useful.

EDIT

For binding this function to all comint buffers (gdb buffer is one of those), you may use (assuming you want C-c g):

(add-hook 'comint-mode-hook
          (lambda ()
            (local-set-key "\C-cg" 'clean-comint-buffer)))

Upvotes: 1

Thomas
Thomas

Reputation: 17422

You can clear the whole buffer by typing C-x h C-w SPC RET.

Upvotes: 1

Thomas
Thomas

Reputation: 17422

Type C-l C-l. This will scroll the buffer so that the current line is at the top of the window.

Upvotes: 0

Related Questions