reddit / emacs

If I see a config snippet in a blog somewhere. What do I do with it?

Sekenre · 2022-02-23 14:22
I don't even know the words to explain how lost I am, so I'll describe the scenario: I want to try out Emacs and I want to set it up as a python IDE and play around with some other features (DOOM, evil-mode etc., Tramp mode) so I look up how to configure something and I am presented with this: > Let's start by configuring lsp-mode which is a client for LSP servers: > > (use-package lsp-mode > :hook (prog-mode . lsp)) > > (use-package lsp-ui) Okay, great it's a piece of code. but am I supposed to copy/paste that code somewhere? run it? bask in it's glory? do I have to restart emacs? Also where in the Emacs for beginners tutorials does it explain what to do with such a configuration snippet? If you have a lot of configuration how do you organize it? If I need to find out what configuration options are available for a package (like tramp on windows, how do I tell it to use TortoiseGitPlink.exe instead of Plink.exe) how do I discover it?
patrick_thomson · 2022-02-23 14:57
Your configuration files is generally called `init.el`, and can be located in a few places. But it sounds like you should take a look at the [System Crafters](https://wiki.systemcrafters.cc/emacs) introduction to Emacs basics. It’ll give you an overview of the pieces you’re missing.
sunnyata · 2022-02-23 14:59
Copy the code into your init file (most often `~/.emacs.d/init.el`, you can create that file if it doesn't exist) then evaluate it with `M-x eval-buffer`. If you just want to evaluate part of the file put the point (cursor) at the end of the line in question and type `C-x C-e`. If you want to evaluate an expression without putting it in any file, type `M-:` then the expression. People who have a lot of config, have written a bunch of functions themselves etc and want to organise it all neatly break it out into different files and load them into the init file. You don't need to worry about that for the time being. To find out how to configure a mode, read the docs that come with it. You can do that within emacs but what you're looking for is probably online too if you prefer, e.g. https://www.gnu.org/software/tramp/
cuttle_codes · 2022-02-23 15:03
+1 for the system crafters series on configuration
tejaswidp · 2022-02-23 15:21
Use the scratch buffer
Sekenre · 2022-02-23 16:31
Thanks that's really helpful
Sekenre · 2022-02-23 16:33
Thanks i will try this out
TommyHeizer · 2022-02-23 17:34
Another big +1 on system crafters series. There's a lot of content so I suggest watching the essentials and then as you build your config, watch the rest and learn along the way.
SlowValue · 2022-02-23 21:59
In principle that is correct, but with the examples you provided: Beware: `use-package` is not built in. There is a package with the same name, which must be installed first. For testing purposes I would not copy pieces of code into your `init.el`, but first into the `*scratch*` buffer, as others already mentioned and eval it from there. If everything works as expected the code can be copied into `init.el` .....
redguardtoo · 2022-02-24 10:31
`M-x help-with-tutorial` in Emacs at least once. I don't know what's `plink.exe`. My first job is embedded Linux development. so I'm familiar with cli and shell. If I have to work on Windows, I use Cygwin to install "ssh.exe" and "git.exe", then Cygwin executables' directory into Windows environment variable "PATH" so Windows Emacs could detect Cygwin executables