reddit / emacs
~/.emacs.d ~/.emacs ~/.config/emacs/init.el
ekbruliganto · 2022-09-25 22:00
Why is emacs so confusing about this?
Which is the one true place where the init.el should go?
​
I'm working on my first init.el file and this seems very confusing.
anaumann · 2022-09-25 22:02
It's been extensively dealt with in the manual: [https://www.gnu.org/software/emacs/manual/html\_node/emacs/Init-File.html](https://www.gnu.org/software/emacs/manual/html_node/emacs/Init-File.html)
navakelvin · 2022-09-25 22:08
New to emacs too.
`~/.emacs` is a single file without extension that contains all the configuration itself.
On the other hand, it seems that `~/.emacs.d/init.el` is to make a modular configuration from where it is possible to have an `init.el` file that contains configuration lines and also reference to other .el files (packages for example).
Emacs can read either setting but if \~/.emacs is present, it will take precedence and \~/.emacs.d/\* will be ignored.
anaumann · 2022-09-25 22:14
What about `~/.config/emacs/init.el`, then? :D
`.emacs` is just the old(or traditional :P) name for the configuration file.. `.emacs.d` holds all the things that emacs creates on its own(like downloaded packages) and `.emacs.d/init.el` is the "new" default location for the configuration file, just so everything emacs will be neatly contained within the `.emacs.d` folder.
And if you're hell-bent of having everything conforming to the freedesktop spec, you can also have a `~/.config/emacs/init.el`...
Neither the `.emacs` nor the `init.el` need to contain every bit of lisp code you're using(you can still use `load-file`, for example).. It's just a bit more clear that the `init.el` file is loaded and executed on startup, whereas with the `.emacs` file, it wasn't even clear from the filename that it's supposed to contain elisp code..
navakelvin · 2022-09-25 22:26
lol, thanks for the clarification
[deleted] · 2022-09-25 22:27
[deleted]
orzechod · 2022-09-25 23:19
don't forget about early-init.el !
xtifr · 2022-09-25 23:37
There is no "one true place". The original, way back when, was \~/.emacs, which is still fully supported. As Emacs grew more complex, it got its own separate subdirectory, \~/.emacs.d, and, to avoid cluttering the home directory, the option of using \~/.emacs.d/init.el was added. Then, the Freedesktop project came up with a (not-Emacs-specific) standard to limit the cluttering of the home directory, which is where \~/.config/emacs/init.el came in. Most desktop applications have moved to using the Freedesktop standards. But Emacs rarely abandons anything, so this was added as simply one more option!
It's entirely up to you which one you use. I still use .emacs because when I started, that was the only option. However, I'm strongly considering switching to \~/.config/emacs because I do appreciate the goal of an uncluttered home dir, and I'm generally a fan of standards.
HM0880 · 2022-09-26 01:38
`C-h v RET user-init-file RET` gives "File name, including directory, of user’s initialization file."
The value of the `user-init-file` variable is where emacs is looking for your init file.
ekbruliganto · 2022-09-26 02:08
This is awesome, thanks!
ekbruliganto · 2022-09-26 02:09
thank you for the link.
arthurno1 · 2022-09-26 05:47
> Why is emacs so confusing about this?
I
t is just historical remnants.
Use .emacs.d/init.el instead of ~/.emacs file. That way, your entire Emacs configuration will be in the same place so it is bit easier to backup, put in git repo etc.
I personally don't think it matters where you put your .emacs.d directory itself; either in ~/ or in ~/.config, but some people prefer newer XDG_* standard (~/.config).
lj-read-it · 2022-09-26 09:21
I love how Extremely Emacs this whole thread is, the answer to what looks like an open-and-shut question is "however you like it" + suggested best practices + a history lesson.
paretoOptimalDev · 2022-09-26 15:40
I always ask emacs questions first these days by:
`C-h R` (aka info-display-manual) and typing a relevant manual name, then using `C-s` to search for keywords related to my problem.
NOTE: let me know if there's an even better way! (I tried consult apropos but it doesn't work for this method).
Here that looks like:
- `C-h R emacs RET`
- `C-s xdg RET`
That puts you at [the same manual page recommended above](https://www.gnu.org/software/emacs/manual/html_node/emacs/Init-File.html].
Also note that at first switching to looking things up in info versus searching in a web browser will be a mixed bag of increased and decreased productivity.
At least, I had an adjustment period. However having the "answers at my fingertips" feeling and getting used to processing pure textual information in emacs has been a good investment for all of my other uses of emacs.
anaumann · 2022-09-26 15:44
I must admit that I prefer googling myself, but especially for beginners, using (seemingly) small things like the built-in help makes for some great training and improving emacs proficiency..
I used to browse around what M-x had to offer and used describe-function on functions that seemed useful to me :)
paretoOptimalDev · 2022-09-26 16:32
> I must admit that I prefer googling myself, but especially for beginners, using (seemingly) small things like the built-in help makes for some great training and improving emacs proficiency..
I used to google everything.
This video sort of prodded me to try using info and built in documentation for more:
https://youtube.com/watch?v=ozrGXYQIBHg
I don't see googling as inferior, just that after getting acclimated to info that I found I get:
- typically the same time to find many answers, though some require more thinking
- higher quality answers
- related context that builds a stronger understanding
I still goo... well duckduckgo for things, but I try to use info first.
I do a similar thing where I search my org- roam notes first and it's starting to pay off because I tailor my notes to my search patterns.
So to summarize I:
1. Search roam
2. Search info
3. Search duckduckgo if no answer or i'm feeling too lazy to think
I should probably make an omnisearch thing with consult that searches these sources at once really.
marsnomoon · 2022-09-28 11:14
Thanks for that suggestion. I'm actually feeling the need to move in that direction, but I've been reading so many manuals lately that I'm at my wit's end.
I stumbled onto Emacs a little over a year ago, and you can imagine the rabbit hole I fell into. Set myself up with Doom Emacs even though I mainly use org mode in Emacs. I basically stopped using Emacs months ago and I'm getting back into it but wanting to understand it better, so I'm pulling the plug on Doom, at least for a while.
So I'm at square one... How to start editing my configuration.
marsnomoon · 2022-09-28 11:20
One thing that annoys me about the Emacs manual is bumping into the phrase "for historical reasons."
It seems so stubborn to continue to call a window a frame. To call alt meta. Del is backspace not delete. I have never seen a meta key in my entire life. Keyboards have both backspace and delete for a long time now. It's like the worst case of 'stuck in the past' because everyone who touches Emacs has to deal with this now.
I can appreciate a little history, but geez...
As far as this thread goes, it's cute. Also shows people at different points in the Emacs "journey" (I hate that phrase too).
Signed,
Not In My Backyard.
marsnomoon · 2022-09-28 11:22
I'm OP btw lol, different device, different account apparently.
paretoOptimalDev · 2022-09-28 14:06
I would give customizing via the customization interface a try, here's a good video:
https://youtu.be/76jp8qkLZC8