1

Emacs creates far too many buffers, like this one when it starts up:

Loading /home/david/.recentf...done
Cleaning up the recentf list...done (0 removed)
For information about GNU Emacs and the GNU system, type C-h C-a.

And others like the following one when I want auto-completes:

Click <mouse-2> on a completion to select it.
In this buffer, type RET to select the completion near point.

Possible completions are:
perl-backward-to-noncomment     perl-beginning-of-function
perl-electric-terminator    perl-end-of-function
perl-indent-command     perl-indent-exp
perl-mark-function  perl-mode
perldb

Is there a way I can just make emacs kill auto-completion buffers and not create that one on the beginning? Thanks.

David Gomes
  • 5,644
  • 16
  • 60
  • 103
  • 1
    I think they are useful sometimes, but why you want to forbid them Since they don't come generally come in your way.? – kindahero Mar 03 '12 at 21:57
  • 6
    You accept too few answers. – Sean Mar 03 '12 at 23:23
  • 1
    See harpo's answer. You shouldn't travel the buffer list in a linear order when you want to switch to a buffer. It's very inefficient. Just use [iswitchb](http://www.emacswiki.org/emacs/IswitchBuffers) and you won't have to worry about how many open buffers you have. – Tom Mar 04 '12 at 06:24
  • 2
    When I was first learning emacs I had a lot of trouble with buffers, so I asked this question: http://stackoverflow.com/questions/3145332/emacs-help-me-understand-file-buffer-management. A lot of the suggestions there helped me out, particularly ido-mode: http://www.emacswiki.org/emacs/InteractivelyDoThings – Wilduck Mar 04 '12 at 07:57

5 Answers5

5

I felt this way when I first started using emacs. While I do generally close such "temporary" buffers when I'm done with them, the more general answer is that you just need to put them out of your mind and develop a workflow where you can get to the buffers you do want. Otherwise, you're going to start regarding your own buffers as clutter when they are not relevant, and waste energy closing them.

iswitchb-mode is a good start.

harpo
  • 41,820
  • 13
  • 96
  • 131
4

in emacs 24 there is the elisp function:

clean-buffer-list

this is provided by MidnightMode which can be added to other versions.

As the name suggests that can also be scheduled.

nic ferrier
  • 1,573
  • 13
  • 14
2

A alternative to iswitchb mode is ido-mode which is very similar but looks a little cleaner, it also makes C-x-C-f (find file) look nicer.

Shantanu
  • 504
  • 5
  • 15
1

By the way, if you choose iswitchb you also can setup it to ignore certain buffers. Just add the following code to your emacs init file:

(add-to-list 'iswitchb-buffer-ignore "*Messages*")
(add-to-list 'iswitchb-buffer-ignore "*scratch")
(add-to-list 'iswitchb-buffer-ignore "*Completions")
N.N.
  • 8,336
  • 12
  • 54
  • 94
theotheo
  • 2,664
  • 1
  • 23
  • 21
  • Warning (initialization): An error occurred while loading `/home/david/.emacs.el': Symbol's value as variable is void: iswitchb-buffer-ignore To ensure normal operation, you should investigate and remove the cause of the error in your initialization file. Start Emacs with the `--debug-init' option to view a complete error backtrace. I got that when I added those three lines to the config file, thank you! – David Gomes Mar 04 '12 at 22:01
  • That's maybe because you didn't install iswitchb. So you must install it first. In order to do that, you should add (iswitchb-mode 1) before the others. I.e.: `(iswitchb-mode 1) (add-to-list 'iswitchb-buffer-ignore "*Messages*") (add-to-list 'iswitchb-buffer-ignore "*scratch") (add-to-list 'iswitchb-buffer-ignore "*Completions")` I'm sure that help. – theotheo Mar 04 '12 at 23:07
  • I added that, but I still get the starting buffer "Loading /home/david/.recentf...done (...)" – David Gomes Mar 05 '12 at 20:21
0

Or just disable the scratch, message and completions buffer altogether, without breaking anything:

Posted first here, and pasted bellow:

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)
Community
  • 1
  • 1
Ole
  • 487
  • 7
  • 20