reddit / emacs

The 6 Emacs Settings Every User Should Consider

daviwil · 2022-02-22 13:29
daviwil · 2022-02-22 13:29
Hey folks! In this video, I take you through a tour of 6 essential configuration settings and modes that every Emacs user should consider adding to their configuration! Show notes are here: https://systemcrafters.net/emacs-from-scratch/the-best-default-settings/
rednosehacker · 2022-02-22 13:38
Thanks to your video, I just adopted 4/6 settings. ;)
7890yuiop · 2022-02-22 13:44
> Emacs will show prompts to confirm many different types of actions, and for some of them it shows a graphical dialog box. If you prefer to keep your Emacs workflow more keyboard-focused, you can turn off those dialog box prompts Erm, do you realise that Emacs only does that if you *triggered the event in question using the mouse*? Being prompted to answer questions using the input device you are *currently* using is incredibly convenient. I honestly don't know why anyone would want to turn that feature off.
daviwil · 2022-02-22 13:45
Was not aware of that, thanks for the clarification! Edit: I pinned a comment to the video with this correction.
sp3ak3r1 · 2022-02-22 14:38
Thanks you this video. I need to watch this for a better time and add useful stuff to the settings file. Thanks for the other emacs videos you've made. They have been useful information that has not otherwise “opened up” to me
trae · 2022-02-22 17:04
I love that there's a text post associated with the video. Thanks for putting this together!
tritis · 2022-02-22 17:05
> Erm, do you realise that Emacs only does that if you triggered the event in question using the mouse? Not quite the same, but I need to set (setq epg-pinentry-mode 'loopback) which prompts for the PGP passphrase in the minibuffer instead of the default which opens a GTK window. The GTK pop up breaks my workflow if connected to an emacs session in a terminal.
BeetleB · 2022-02-22 17:37
global-auto-revert-mode can really bite you. Occasionally my file gets accidentally modified outside of Emacs and the fact that Emacs *doesn't* revert them has saved my behind a few times. Also, on one system I was editing files across a network drive, and something weird was going on at the OS level and those files would be marked as "modified" every few minutes, even though nothing had changed. Auto revert would have been *really* annoying.
pwnedary · 2022-02-22 17:41
>global-auto-revert-mode can really bite you. Occasionally my file gets accidentally modified outside of Emacs and the fact that Emacs doesn't revert them has saved my behind a few times. IIRC it adds an entry to the undo-list whenever it reverts, which would make this a non-issue.
Available-Bug8339 · 2022-02-22 17:54
How does one pull up the undo-list? Is this a module you have?
HighlyRegardedExpert · 2022-02-22 17:59
`yank-pop` mapped to `M-y` by default iirc. Let’s you cycle through the kill ring.
nnreddit-user · 2022-02-22 18:08
There's a known heisenbug in process.c that locks up emacs under `global-auto-revert-mode` implicating the inotify mechanism. This affects me on ubuntu 18.04 and ubuntu 20.04. Your platform may find `global-auto-revert-mode` works like a dream. I've also had to unfortunately turn off `magit-auto-revert-mode`, which is problematic if you switch branches (whereupon all your open buffers incorrectly continue showing the switched-from branch's version). As a projectile user, I remediate via: (defun projectile-revert-buffers () (interactive) (let* ((project (projectile-acquire-root)) (project-name (projectile-project-name project)) (buffers (projectile-project-buffers project))) (when (yes-or-no-p (format "Are you sure you want to revert %s buffers for '%s'? " (length buffers) project-name)) (dolist (buffer buffers) (unless (buffer-base-buffer buffer) (revert-buffer buffer t t))))))
pwnedary · 2022-02-22 18:41
I do not know about visualizing it, but I am talking about the normal Emacs undo mechanism.
hey_parkerj · 2022-02-22 19:56
Happy to see that Doom defaulted me to the majority of these (not custom file or global-auto-revert-mode. for those interested).
JDRiverRun · 2022-02-22 20:47
[undo-tree](https://elpa.gnu.org/packages/undo-tree.html) can show a "diff" to the prior state for each item on its change tree (and is cool for other reasons too).
tutux84 · 2022-02-22 20:59
Thank you for this video. Regarding management of recent file I prefer to use something like `counsel-recentf`, mapped to `C-x C-r`, which allows me to directly search the recent file list in the mini-buffer with Ivy.
elimik31 · 2022-02-22 21:54
I mostly just use `consult-buffer`, which in addition to open buffers also shows recent files and bookmarks as "virtual buffers", though you can configure it via `consult-buffer-sources`. I assume `counsel-buffer` does something similar as `consult` was inspired by it. Saved me from internalizing another keybinding.
elimik31 · 2022-02-22 22:26
I switched back from undo-tree to [undo-fu](https://gitlab.com/ideasman42/emacs-undo-fu), which re-uses the emacs undo-system instead of replacing it and makes it more intuitive to use while still preserving the full undo history. I sometimes miss the nice visualizations such as the tree and I didn't even know (or remember) the diff, but in 99% of cases I just need simple undo and most of the time I have git anyway to save intermediate states of my files. For seeing the diff of my current buffer state after a series of undo/redo steps against what is saved on disk I would just use `M-x diff-buffer-with-file`. And the diff of the last change is most of the time obvious when undoing/redoing (I jump between `undo-fu-only-undo` and `undo-fu-only-redo`).
elimik31 · 2022-02-22 22:35
Strictly speeking you can check the state of the undo-list via the variable `buffer-undo-list`* ([elisp manual description](https://emacsdocs.org/docs/elisp/Undo#variable-buffer-undo-list)). But it's not meant to be human readable, so just use the normal emacs undo mechanism (see [editing manual](https://emacsdocs.org/docs/emacs/Undo)) and if you want to compare the state to what's on disk use `diff-buffer-with-file`. *If you use the `undo-tree` package, which offers a nice visualization of the undo tree, from what I read it uses its own data structure for recording the undo history, so `buffer-undo-list` might help then.
JDRiverRun · 2022-02-22 22:48
Didn't know undo-fu; I will give it a look. In undo-tree hit `d` to see the diff. And an even better (if rarely needed) feature: hit `s` to "pin" the state under point, and diff all the way to where you cursor is (`Enter` to update the "pin"). So I can easily see a full days worth of undos as a `single diff` (page up until you see -1d appear).
00-11 · 2022-02-22 22:53
+1 for mentioning using `custom-file`.
tromey · 2022-02-22 23:26
It also interacts badly with "git rebase". It can cause spurious rebase failures because Emacs will run various git commands when auto-reverting, and there's no way to disable this during a rebase operation. I have a "revert-all-buffers" command that I use instead, and I just run it whenever I feel the need to mass update, like if I switched git branches or the like. This is maybe less of an issue if you use magit, but also somehow the reason I don't -- I can't break the habit of rebase outside of Emacs and magit's own auto-revert has this same problem and can't (AFAICT) be disabled.
7890yuiop · 2022-02-23 01:53
`magit-auto-revert-mode` is how you disable magit's own auto-revert.
Available-Bug8339 · 2022-02-23 02:32
diff-buffer-with-file now there's a hidden gem. thank you sir.
frozeninfate · 2022-02-23 04:27
Using a window manager keyboard shortcut to close an emacs window counts as a mouse command. By default closing the window creates a popup asking if you want to write files, etc. When disabling it, closing creates a minibuffer prompt to save files, etc. As such, I turn use-dialog-box off as I rarely use mouse with emacs but I use keyboard shortcuts to close the window often.
[deleted] · 2022-02-23 05:33
[deleted]
daviwil · 2022-02-23 06:20
Try clicking the link in the comment you replied to :)
[deleted] · 2022-02-23 07:09
[deleted]
daviwil · 2022-02-23 07:45
No worries! I realize now that I should describe what that link is a little more clearly, "show notes" is a little vague