Ali Awan
Ali Awan

Reputation: 352

How can I toggle the appearance of the *Compilation* buffer?

I've recently switched to using emacs. One of the things that I want to be able to do is to toggle the appearance of the compilation buffer using Ctrl+, (i.e. when the compilation buffer is visible on the screen, I want to be able to press Ctrl+, to hide it, and then press Ctrl+, to bring it back up).

Upvotes: 0

Views: 202

Answers (1)

Tianshu Wang
Tianshu Wang

Reputation: 758

Here is a function modified from Spacemacs:

(defun toggle-compilation-window ()
  "Show/Hide the window containing the '*compilation*' buffer."
  (interactive)
  (when-let ((buffer compilation-last-buffer))
    (if (get-buffer-window buffer 'visible)
        (delete-windows-on buffer)
      (display-buffer buffer))))

(bind-key "C-," #'toggle-compilation-window)

I also suggest taking a look at this awesome package popper

Upvotes: 1

Related Questions