Now Reading
Dangerous Emacs defaults

Dangerous Emacs defaults

2023-10-11 08:10:14


Dangerous Emacs defaults






Idiomdrottning’s homepage

Littering backup recordsdata in every single place

Emacs by default leaves recordsdata~ and #recordsdata# throughout.

That is annoying as a result of these recordsdata could get autoloaded.

An answer is

(make-directory "~/.emacs_backups/" t)
(make-directory "~/.emacs_autosave/" t)
(setq auto-save-file-name-transforms '((".*" "~/.emacs_autosave/" t)))
(setq backup-directory-alist '(("." . "~/.emacs_backups/")))

I used to be engaged on a brand new set up the place I didn’t have this in place
but and I stored making an attempt to replace a shell perform, re-sourcing it however
it by no means modified. Seems it was loading from a backup~ of the identical
file.

Due to Susam for determining a cleaner resolution to what I
initially had right here.

I additionally discovered that technomancy has a post similar to this and
that is the one overlap we had at first. Folks actually don’t like
Emacs’ littering.♥

Backs up by shifting the precise file

(setq backup-by-copying t)

The default is nil and that signifies that each time it makes certainly one of
these backups~, it really strikes your file there, copies the backup
to the unique title, and offers you the copy to work on. This isn’t
only a philosophical dilemma (“Am I a butterfly that goals I’m a
backup~?”) however really breaks hardlinks. I can’t consider that is the default.

Sentences have two areas between them

(setq sentence-end-double-space nil)

The default is t which could’ve made sense within the typewriter period however
not solely messes up filling paragraphs, it additionally borks the great
household of forward-sentence, kill-sentence, transpose-sentences and so on.

In the event you just like the double-spaces between sentences in paragraphs (which I
don’t) however need to have the ability to use the sentence instructions on textual content,
a friend of mine has a solution.

Indentation, tabs, and areas

Emacs famously has its idiosyncratic brace fashion and indentation fashion
utilizing a mixture of tabs and areas that no-one else makes use of.

Which might be wonderful in a vacuum however you find yourself combating it when making
modifications in different folks’s tasks.

We’re on a brilliant AI Lisp genius pile, can’t it determine it out from the
remainder of the file or the opposite recordsdata within the listing?

rrthomas and link2xt each wrote in suggesting dtrt-indent which,
you’re gonna have to make use of a package deal for this one.

In the event you’re utilizing straight.el:

(straight-use-package 'dtrt-indent)
(require 'dtrt-indent)

In the event you’re utilizing the default package deal installer:

(until (package-installed-p 'dtrt-indent) (package-install 'dtrt-indent)))

Then, to show it on:

(setq dtrt-indent-global-mode t)

After which, when you’re positive you’ve obtained it arrange the way in which you wish to,
and also you wanna cover it from the modeline:

(setcar (alist-get 'dtrt-indent-mode minor-mode-alist) "")

Normally, in Emacs, shadowing an alist by pushing to go works nevertheless it didn’t for this, therefore the setcar shenanigans.

There additionally Editor Config which you’ll be able to set up and conceal (as soon as you already know if it really works) equally.

Ctrl-H doesn’t delete backwards

C-h being a handy, residence row strategy to backspace has been a factor
for the reason that unique ASCII desk was laid out, and is a staple characteristic
everytime you see “Emacs shortcuts supported” like bash or zsh. Besides
in Emacs itself, the place it launches an enormous, prompting,
window-splitting assist affair.

This was the primary Emacs setting I ever modified.

Unsure what’s one of the simplest ways to do it; I exploit:

See Also

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

require-final-newline

(setq require-final-newline t)

Technomancy’s setup jogged my memory of this one, which I additionally use. Not at all times what you need however more often than not, and, ought to definitively have been the default particularly on bash. Issues can get bizarre when your recordsdata don’t finish in a newline.

frame-inhibit-implied-resize

From Tony Zorman’s Potpourri of Emacs Tweaks there’s an ideal instance of an “I can’t consider nil is the default”:

(setq frame-inhibit-implied-resize t)

With out this, Emacs will attempt to resize itself to a selected column
dimension, however like Tony, I’m on a tiling wm, and I modify font sizes all
the time, so that is no good.

He additionally suggests

(setq pixel-scroll-precision-mode t)

and his description for why does make sense to me, however my older
set up of Emacs doesn’t have that variable but.

show-trailing-whitespace

It is a combined bag as a result of it may possibly drive some folks loopy so whereas it
shouldn’t be on for everybody, it ought to most likely be the default:

(setq show-trailing-whitespace t)

This may spotlight whitespace on the finish of your traces.

That is good not just for exhibiting whitespace you’ve put there by
mistake, it’s additionally a great way to keep track of unfinished parts your
file
.

One cause to show it again off could be in case you’re chatting with folks
who go away trailing whitespaces or in case you’re working in code repos with
numerous trailing whitespaces. However it’s one thing which you could toggle
on and off as you please.

Bonus: Kill complete line

The truth that Emacs simply clears the road, not kill it, when there may be
no prefix arg is perhaps not such a foul default. Beginning out, I
really favored it, in comparison with vi. However the extra time passes the much less I
prefer it. Just about all the time I discovered myself hitting 1k
as a substitute of simply ok. Fortunately, there may be:

(setq kill-whole-line t)

It kills as much as newline if I’m not at column zero, however kills the entire
line (newline and all) if I’m at column zero. Fairly pleased with that.

Source Link

What's Your Reaction?
Excited
0
Happy
0
In Love
0
Not Sure
0
Silly
0
View Comments (0)

Leave a Reply

Your email address will not be published.

2022 Blinking Robots.
WordPress by Doejo

Scroll To Top