Idiomdrottning’s homepage

Bad Emacs defaults

Littering backup files all over the place

Emacs by default leaves files~ and #files# all over.

This is annoying because those files may get autoloaded.

A solution is

(defun make-backup-file-name (file)
  (concat "~/.emacs_backups/" (file-name-nondirectory file) "~"))

I was working on a new installation where I didn’t have this in place yet and I kept trying to update a shell function, re-sourcing it but it never changed. Turns out it was loading from a backup~ of the same file.

Backs up by moving the actual file

(setq backup-by-copying t)

The default is nil and that means that every time it makes one of those backups~, it actually moves your file there, copies the backup to the original name, and gives you the copy to work on. This isn’t just a philosophical dilemma (“Am I a butterfly that dreams I am a backup~?”) but actually breaks hardlinks. I can’t believe this is the default.

Sentences have two spaces between them

(setq sentence-end-double-space nil)

The default is t which might’ve made sense in the typewriter era but not only messes up filling paragraphs, it also borks the wonderful family of forward-sentence, kill-sentence, transpose-sentences etc.

Indentation, tabs, and spaces

Emacs famously has its idiosyncratic brace style and indentation style using a mix of tabs and spaces that no-one else uses.

Which would be fine in a vacuum but you end up fighting it when making changes in other people’s projects.

We’re on a super AI Lisp genius pile, can’t it figure it out from the rest of the file or the other files in the directory?

For this, I still use the old guess-style packages but I hope there is a better way. Write in!

Ctrl-H doesn’t delete backwards

C-h being a convenient, home row way to backspace has been a thing since the original ASCII table was laid out, and is a staple feature whenever you see “Emacs shortcuts supported” like bash or zsh. Except in Emacs itself, where it launches a huge, prompting, window-splitting help affair.

This was the first Emacs setting I ever changed.

Not sure what’s the best way to do it; I use:

(global-set-key [(control h)] 'delete-backward-char)
(keyboard-translate ?\C-h ?\C-?)

Bonus: Kill whole line

The fact that Emacs just clears the line, not kill it, when there is no prefix arg is maybe not such a bad default. Starting out, I actually liked it, compared to vi. But the more time passes the less I like it. Pretty much all of the time I found myself hitting 1k instead of just k. Thankfully, there is:

(setq kill-whole-line t)