Posted by weakfish 2 days ago
Ask HN: Where to begin with "modern" Emacs?
I’m a longtime Neovim user who’s been EMacs-curious. The hold up for me has been that I’ve been unable to find a source of truth for what’s top-of-the-line as far as plugins are. With Neovim, it’s a safe bet to look at what folks like Folke are doing, but I have struggled to find a similar figure in the Emacs community who gives insight into what’s-what. I know Doom exists, but I want to fully “own” my config and not over complicate it.
Thanks!
- An LSP: https://emacs-lsp.github.io/lsp-mode/tutorials/CPP-guide/ - Neotree to browse the file system: https://github.com/jaypei/emacs-neotree - Awesome-tab for tabs: https://github.com/manateelazycat/awesome-tab
If you want more, look at the extensions section of the LSP page and then go down the rabbit hole.
I likewise do not use Doom or any of the bundled variants because I want full control and understanding of my config. But those variants are still useful to learn what's out there and selectively add things to your mix.
- real buttons in GUI
- rendering inline images/LaTeX
- varies fonts (eg font sizes)
There may be others but I can't think of them. Neither of the above is things I do more often than a handful of times a year.
Meanwhile, terminal Emacs plays well with tmux and SSH which I do a lot of. For example, a workflow I have is to SSH to a Linux box, start a tmux session and have Emacs/ipython/jupyter with port forwarding open on the remote box. I can steal this tmux session from any new connection. It also survives if the machine I'm sshing from dies or reboots. I can't think of a way to make it work with GUI emacs.
I 99% of the time use emacs in a terminal. 90% of the time over ssh or in a non-GUI VM/docker etc.
I usually install emacs-nox to speed up the install.
Vanilla emacs is fine. Maximum I scp my .emacs file from another machine, but there's actually very little in it. Mostly it's disabling the menu bar, tool bar, and scroll bars.
Usually all I'll do is adjust things such as indenting and other code formatting things to match the codebase I'm working on -- which varies from project to project anyway, and you need to do with any editor to avoid making a mess.
I do have one little elisp function that tries to find and open the header file for the C file I'm currently in, or the c, cc, cpp, c++ file for the header file I'm in.
I'll reproduce that below, if anyone cares. Please don't laugh too much at my elisp -- I probably wrote that in the 90s.
    ;;;;;;;;;;;; Automatic switching between source and header files ;;;;;;;;;;;;;;;;
    
    (defvar c++-source-extension-list '("c" "cc" "C" "cpp" "c++" "pcc" "pc"))
    (defvar c++-header-extension-list '("h" "hh" "H" "hpp"))
    (defvar c++-header-ext-regexp "\\.\\(hpp\\|h\\|\hh\\|H\\)$")
    (defvar c++-source-ext-regexp "\\.\\(cpp\\|c\\|\cc\\|C\\|pcc\\|pc\\)$")
    
    (defun toggle-source-header()
      "Switches to the source buffer if currently in the header buffer and vice versa."
      (interactive)
      (let* ((buf (current-buffer))
             (name (file-name-nondirectory (buffer-file-name)))
             (check (lambda (regexp extns)
                      (let ((offs (string-match regexp name)))
                        (if offs
                            (let ((file (substring name 0 offs)))
                              (loop for ext in extns
                                    for test-file = (concat file "." ext)
                                    do (if (file-exists-p test-file)
                                           (return (find-file test-file))))))))))
    
        (or (funcall check c++-header-ext-regexp c++-source-extension-list)
            (funcall check c++-source-ext-regexp c++-header-extension-list))))
    
    (global-set-key [?\C-c ?`] 'toggle-source-header)Just like config.d dir in ~.ssh/, you can have a 'load' instruction in your emacs.el/init.el file and a separate directory for configs. This way you can easily do see what does what (by name) and have even more comments in the beginning of files.
So even if you added some modification late at night/under influence of substances, you can still tell that you were thinking and easily switch it off or improve it.
Edit: and love your question, even tho I used Emacs for over 10 years, I've learned a lot in here.
So you split your main ~/.ssh/config file into smaller, reusable files stored in a subdirectory like ~/.ssh/config.d/. The main config file then "includes" (loads) these modular files automatically. So for instance, you might have:
~/.ssh/config.d/10-general.conf
~/.ssh/config.d/20-work.conf
~/.ssh/config.d/30-github.conf
Can confirm this works great in teams or on multi-host setups, as it keeps things organized without cluttering a single massive config file and it works across tools like ssh, scp, rsync, etc.
And same for for Emacs: it's much easier to vibe code some changes (don't know ELisp that well). And then when knowledge of the language matures I can look at fixes and at least know what was the idea behind them.
I got into vim because it made total sense to me as a way to transfer thoughts to words, I loved it , I lived it and I love it and live it. Then I heard about emacs org-mode – after trying for ages to find the "software to organise my life" (pick your poison).
I found it to be totally workable, initially, via doom-emacs.
Then they said "You won't believe Magit".
I didn't leave my wife, instead I invited everyone into my world.
True, I had been fooling around looking for a wife. I hit on vim. She was perfect. In her world there were people who knew all about perfection – no surprise – until I met her beautiful sister. I fell in love with her. Then I met a relation of hers (her name was Magic, also beautiful) and I invited them all back to what became their place where I am now welcome too.
I’m happy with result, but this was 7 years ago so there may be better options than prelude to do something similar today.
I now feel it was bad advice.
As someone who grew up with good dx tools like Sublime, it’s really hard to be productive in vanilla eMacs.
I’d suggest going with Doom, but don’t enable any package except Evil, LSP, Treesitter and Projectile.
This will give you a Vim like experience with basic project management.
As you become more comfortable, you can enable more packages.
This way you will stay productive and learn on the back of the community wisdom.
I started before Doom existed but ended up in a configuration similar to Doom but more brittle. I ended up just declaring .emacs bankruptcy and started over with Doom and was pleasantly surprised that my over 2000 line configuration became less than 30 customized lines.
If you want to do it the hard way I’d start with figuring out elpa and going from there installing the specific plugins that you want. Likely, evil being a first.