I'm using emacs for my daily javascript editing, to switch between buffers I use C-x LEFT and C-x RIGHT and I'm fine with this (even if I find it difficult to know the path of the file I'm modifying).

My problems:

  1. at the startup I always have *scratch* and *Messages* opened, I thought that putting (kill-buffer "*scratch*") in my .emacs would solve the issue, but it's not, do you have a suggestion?

  2. when I open files I always do TAB autocomplete, so each time I'm creating a new *Messages* buffer containing the options for the completion, how do I prevent this from creating, or better, how do I make emacs kill it, after I've made my choice?

Do say your opinion if you think I'm doing something that's not "the way it should be" with me navigating as I said at the top.

  • 1
    You may want to explore other ways of switching buffers as Trey suggested. If you opt for an other method which is not sequential then you can jump to the wanted buffer right away, so it does not matter if unwanted buffers are in the buffer list. I use iswitchb myself.
    – Tom
    Sep 1, 2011 at 4:40

3 Answers 3


This drove me mad.. until I fixed it.

Now there's no scratch, messages, or completions buffers to screw with your flow. Enjoy!

Place this in your .emacs:

;; Makes *scratch* empty.
(setq initial-scratch-message "")

;; Removes *scratch* from buffer after the mode has been set.
(defun remove-scratch-buffer ()
  (if (get-buffer "*scratch*")
      (kill-buffer "*scratch*")))
(add-hook 'after-change-major-mode-hook 'remove-scratch-buffer)

;; Removes *messages* from the buffer.
(setq-default message-log-max nil)
(kill-buffer "*Messages*")

;; Removes *Completions* from buffer after you've opened a file.
(add-hook 'minibuffer-exit-hook
      '(lambda ()
         (let ((buffer "*Completions*"))
           (and (get-buffer buffer)
                (kill-buffer buffer)))))

;; Don't show *Buffer list* when opening multiple files at the same time.
(setq inhibit-startup-buffer-menu t)

;; Show only one active window when opening multiple files at the same time.
(add-hook 'window-setup-hook 'delete-other-windows)


;; No more typing the whole yes or no. Just y or n will do.
(fset 'yes-or-no-p 'y-or-n-p)
  • 2
    Thank you so much for this, I wish I could give you more rep. Sep 2, 2014 at 20:30
  • You're most welcome! :D
    – Ole
    Sep 4, 2014 at 9:17
  • 2
    Wouldn't it make sense to do (if (get-buffer "*Messages*") (kill-buffer "*Messages*")) in case one reloads the config? Purely inspired by that other macro of yours.
    – sshine
    Jul 19, 2015 at 11:44
  • 2
    I hadn't realized just how much these buffers bothered me until I got rid of them.
    – automaton
    Sep 6, 2016 at 12:41
  • 1
    It crashed the emacs
    – alper
    Dec 28, 2018 at 8:11

Well... it's partially the way Emacs works, but there are things you can do to help switching in general.

First, Emacs has to have at least one buffer. So, even if you wanted to get rid of *scratch* and *Messages*, you'd be left with yet another buffer you didn't want (or you'd get the point where Emacs just ignored your last kill-buffer request because it was re-creating that buffer (b/c it needs one buffer).

So, the best way to get to the point where switching buffers makes more sense is to actually have buffers you want to switch to.

And, when you've done that, you can look at all the options/packages available to you for switching buffers - many of which are listed on the Emacs Wiki under SwitchingBuffers. ido is pretty popular, as are icicles and anything.

  • 1
    I'm saving my sessions with (desktop-save-mode 1), so almost always I'll have something open at startup, I'll look at those packages, thanks. Sep 1, 2011 at 12:38

If anyone is interested in removing only the *scratch* buffer and being left with *Messages* buffer, this code worked for me:

(defun acg-initial-buffer-choice ()
  (if (get-buffer "*scratch*")
      (kill-buffer "*scratch*"))
  (get-buffer "*Messages*"))

(setq initial-buffer-choice 'acg-initial-buffer-choice)

One thing you should keep in mind is, if at any time Emacs is left with no buffer to display (e.g. you killed all buffers) it'll create either a *scratch* or a *Messages* buffer, so be sure you won't be deleting all buffers during your workflow, or *scratch* can come back to life again.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .