Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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 '11 at 4:40
Thanks for the suggestion, I'll have a look at it. – Alberto Zaccagni Sep 1 '11 at 12:38
up vote 9 down vote accepted

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)
share|improve this answer
Thank you so much for this, I wish I could give you more rep. – Alberto Zaccagni Sep 2 '14 at 20:30
You're most welcome! :D – oles Sep 4 '14 at 9:17
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. – Simon Shine Jul 19 '15 at 11:44

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.

share|improve this answer
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. – Alberto Zaccagni Sep 1 '11 at 12:38

Your Answer


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.