Prevent unwanted buffers from opening

bufferemacs

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.

Best Answer

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)

Bonus:

;; No more typing the whole yes or no. Just y or n will do.
(fset 'yes-or-no-p 'y-or-n-p)
Related Question