If you've ever been saved by an Emacs backup file, you
probably want more of them, not less of them. It is annoying
that they go in the same directory as the file you're editing,
but that is easy to change. You can make all backup files go
into a directory by putting something like the following in your
.emacs
.
(setq backup-directory-alist `(("." . "~/.saves")))
There are a number of arcane details associated with how Emacs
might create your backup files. Should it rename the original
and write out the edited buffer? What if the original is linked?
In general, the safest but slowest bet is to always make backups
by copying.
(setq backup-by-copying t)
If that's too slow for some reason you might also have a look at
backup-by-copying-when-linked
.
Since your backups are all in their own place now, you might want
more of them, rather than less of them. Have a look at the Emacs
documentation for these variables (with C-h v
).
(setq delete-old-versions t
kept-new-versions 6
kept-old-versions 2
version-control t)
Finally, if you absolutely must have no backup files:
(setq make-backup-files nil)
It makes me sick to think of it though.
GNU Emacs default bindings:
C-xb *scratch*
RET
or, more verbosely
M-x switch-to-buffer *scratch*
RET
The *scratch*
buffer is the buffer selected upon startup, and has the major mode Lisp Interaction. Note: the mode for the *scratch*
buffer is controlled by the variable initial-major-mode
.
In general you can create as many "scratch" buffers as you want, and name them however you choose.
C-xb NAME
RET
switches to a buffer NAME
, creating it if it doesn't exist. A new buffer is not associated with a file on disk until you use C-xC-w (or M-x write-file
RET) to choose a file where it should be saved.
M-x text-mode
RET
changes the current buffer's major mode to Text mode. To find all the modes available (that is, without requiring any new packages), you can get a list by typing:
M-x apropos-command -mode$
RET
Best Answer
To expand on Seth's answer, I'd do this:
The check for
buffer-file-name
avoids saving buffers w/out files. You need to figure out all the entry points you use for switching buffers that you care about (I'd also adviseother-window
).