reddit / emacs
Packages for Emacs beginner
midnightcom · 2022-03-08 01:00
So I don't do a lot of heaving coding, but I do embedded code in C/C++, scripts in Python and play with Racket/Lisp when time permits. I've been using VS code for work, but in school we used a very basic setup for Java programming in Emacs and I enjoyed using Emacs (I don't do Java programming though).
I want to really learn Emacs and have gone through the basic tutorials. I want to start adding packages but it all seems so overwhelming to me. I'd like to add a package at a time to my basically blank configuration.
Can anyone recommend just the basic packages I should have to do C/C++ and Python until I learn how to use those? I'd like the basic IDE stuff like syntax highlighting, autocomplete, file differences and a file tree. Recommendations? What else should I have?
eis3nheim · 2022-03-08 02:03
I recommend watching [System Crafter's ](https://youtube.com/playlist?list=PLEoMzSkcN8oNvsrtk_iZSb94krGRofFjN) playlist on Emacs IDE.
thetemp_ · 2022-03-08 02:29
> syntax highlighting, autocomplete, file differences and a file tree.
Built-in major modes handle syntax highlighting already. Here's a list of some external package to get you started.
- company-mode (short for "complete anything". Shows a list of the options under the cursor. There are also built-in options for completing what you've typed, such as dabbrev and hippie-expand.)
- treemacs (a file tree. another option is the built-in speedbar package, but that uses a separate frame)
- magit (git interface. Showing version differences is only one feature. There's also a built-in diff command that you can use for comparing files that aren't being tracked in a git repo. And there's also the built-in vc commands which provide a less comprehensive interface to git as compared with magit.)
- minimap (a graphical overview of the buffer and your current view of it.)
For more IDE stuff, there's lsp-mode, but it's a bit more complex. Setting up company-mode and treemacs will give you a head start on that.
midnightcom · 2022-03-08 03:06
Will do. Thanks!
midnightcom · 2022-03-08 03:07
Thanks! I saw some stuff on lsp-mode but it's kinda over my head at the moment. What exactly is a language server and why do I need it over just something like elpy for python?
Danrobi1 · 2022-03-08 03:26
> just the basic packages
- use-package, marginalia, auto-package-update and ctrlf.
thetemp_ · 2022-03-08 03:38
Why do you need lsp-mode? You probably don't. But it's what most people turn to for "IDE features".
The cool thing about lsp-mode (and the whole language server ecosystem) is that it separates the language specific features from the editor. So you can have the same features regardless of using Emacs, Vim, VSCode, etc.
But Emacs already has a ton of language-specific features that are built-in or available via external packages. So I wouldn't worry about lsp-mode unless and until you feel like there are features you want that you can't get elsewhere.
Elpy wasn't being actively maintained the last time I checked. However, there are a lot of people still using it, so that might change. Another non-lsp option is anaconda-mode.
sunnyata · 2022-03-08 09:27
Rather than one of the fat and opinionated "distros" (doom, spacemacs) I like [emacs for you](https://github.com/susam/emfy). It will set you up with a minimal config that you can learn from and add to as you go.
Hastrack · 2022-03-08 10:59
1. Autocomplete
* Corfu
* Cape
2. Language server
* Eglot
3. Syntax highlighting
* They are already made by the major mode
* But you could use **tree-sitter** for finer highlighting
4. File differences
* Diff - Built-in diff tool to show the difference between two files
* Magit - Git interface
5. File tree
* Treemacs
pailanderCO · 2022-03-08 13:09
One question: I have recently started using Corfu, but also Company as I thought the latter is dependent on the former. Am I right?
Hastrack · 2022-03-08 13:20
You aren't right, Company and Corfu are independent from each other. Corfu is more like a minimalist brother of company. They mostly do the same thing, but corfu tends to be use more built-in features of emacs instead of creating everything from scratch wich makes it more lighweight.
pailanderCO · 2022-03-08 14:07
So I can just disable Company, and Corfu can still work fine?
pailanderCO · 2022-03-08 14:08
Could you share your Corfu settings, please?
Hastrack · 2022-03-08 14:53
Yes, you can disable company
[Here my config](https://gitlab.com/mfxarc/dotfiles/-/blob/main/.config/emacs/utils/mf-ui.el#L36)
pailanderCO · 2022-03-08 15:19
Thanks!
pailanderCO · 2022-03-08 15:20
Thanks!
super-linux-nerd · 2022-03-08 15:40
Shame Corfu presents completions in a new frame. Can't be used without GUI and emacs has frame bugs on scaled hidpi displays :(
shmulkinator · 2022-03-08 15:48
One gotcha with Corfu: it is not functional (by design at this point) if you are running Emacs in text mode. Probably not a big consideration for most, but worth knowing.
pathemata · 2022-03-08 16:47
what do you mean by not functional?
shmulkinator · 2022-03-08 16:53
From the [corfu github](https://github.com/minad/corfu) page:
​
>NOTE: Corfu uses child frames to show the popup. For now Corfu falls back to
the default setting of the completion-in-region-function on non-graphical
displays.
pailanderCO · 2022-03-08 17:40
Good to know. Thanks
midnightcom · 2022-03-08 19:57
Thanks! Just what I was looking for to start with. I've installed it and working through the other recommendations on here for packages.
dpoggio · 2022-03-09 02:01
Must haves IMO include YASnippet, Helm, Which-key-mode, ORG Mode and ORG Babel (for Python), CUA handles copying with `C-c` without touching all of the `C-c something` keybindings (unless if those need the region) and gives you `C-v` paste. This is useful to avoid some bad muscle memory moments. Evil gets you into Vim. I don’t like vim, but the command `evil-ex`, like vim’s `:`, is amazing, so I bound it to `C-:`. That gives me lovely sed-like regex substitutions and more. Multiple cursors is another game changer. Magit is a great companion, so is VC. Check for iMenu compatibility in major modes.
I think the most important packages are those helping you to know more about Emacs. Knowing how to learn Emacs is more important than knowing which packages to install. Which-key-mode is very helpful. Helm is amazing to browse `M-x` and understand the huge set of commands available. Once you set helm-M-x up, you can start writing things in any order and helm will show available commands, so you don’t need to really know the command you want to use, just a bit about the problem’s domain. Also, browse `customize`, learn about the modes you use through `C-h m`, the keybindings with `C-h k` and the binding you want to know about. Read more with `C-h i`. Inside helm-M-x, F2 gives you the same as `C-h f command-to-learn`. Those are ways you can browse almost any source, also.
Quick things to keep in mind: Narrowing is extremely useful. Saving your position to registers to go back later is great. The mark ring is a friend, just `C-u C-SPC` after some search or `C-SPC C-SPC` to set the mark anywhere. You can copy rectangles. The kill ring is great, Helm has a functionality for this, I bound it to `M-y` overriding the default kill ring behavior, which is rotating once you pasted. Modes have inheritance, this means some hooks are shared by many modes.
I hope this helps.
fragbot2 · 2022-03-09 07:39
For embedded C/C++ code, I'd suggest c-mode (customize it as the defaults for things like indentation are startlingly atrocious), ediff, etags, dired, vc-mode, hexl-mode and a debugger integration. For python, I just use standard python-mode as I've never written Python code in a larger codebase so the lsp stuff is overkill.
I intentionally constrained everything above to emacs base packages. Relaxing this, I'd swap magit for vc-mode when using git for source control and would consider a templated code generator like yasnippet or SRecode (unlike yasnippet, this one is built-in but I found it unintuitive and I had a difficult time understanding the documentation).
ramin-honary-xc · 2022-03-10 12:10
I'd start with either `use-package` or `leaf`. These are packages that help you install and configure other Emacs packages more easily. For example, here are some snippets from my `init.el`
(use-package project
:ensure t
:defer nil
:config
(define-key project-prefix-map (kbd "C-o") #'project-display-buffer)
:bind-keymap
("C-x p" . project-prefix-map))
(use-package which-key
:diminish
:defer nil
:ensure t
:config
(which-key-mode 1))
As you can see, it has a simplified syntax for setting keybindings with the `:bind` and `:bind-keymap` keywords, it has the `:ensure` keyword which tells Emacs to automatically download the package from your package repositories (ELPA, Non-GNU Elpa, Melpa), it has the `:defer` keyword to delay loading of the package until after the user is up and running (which reduces Emacs startup time), and the `:config` keyword to set custom variables and enable minor modes. It also has an `:after` keyword to tell one package to not load until another has loaded first, which is a good way to make explicit that one package depends on another.
I tried configuring my Emacs the old-fashioned way for a while, but `use-package` made things so much easier and cleaner, it is a great way to try out new packages.
midnightcom · 2022-03-11 02:38
Very cool. Thanks! I'll read up on it.