News for hackers. Stuff that matters.
Re:Ask HN: Resources to grok Emacs and use it well? by kabdib on Wednesday April 15, 2020 @05:53PM (#22883532)
Emacs user here, it's been my go-to editor for about 40 years.

I have a few customizations, not many. My .emacs file is 63 lines long, doesn't include any other files, and mostly just tweaks some key bindings and turns off features that I don't like. The only modes I use are built-in ones (e.g., C-mode, auto-wrapping text mode, etc.). I can't write elisp without a reference manual, and I think that's okay.

I suggest:

- not installing a bunch of random stuff until you're comfortable with the core experience or you simply have to adjust or disable something that bugs you

- just using Emacs, and not customizing the crap out of it, ditto

If you haven't gone through the Emacs tutorial, it's how I learned it (at 300 baud, uphill both ways and in the snow -- not kidding about the 300 baud thing, though).

Re:Ask HN: Resources to grok Emacs and use it well? by smitty1e on Wednesday April 15, 2020 @06:46PM (#22884046)
I had to go to Spacemacs[1] for a few reasons:

- Using the spacebar to invoke functionality is a massive physical boon to usage. Stock emacs wrecks me from fingers to neck for an real amounts of usage. This is a purely subjective weakness.

- Spacemacs vi emulation. I drank the modal Kook-aid. Especially if one has to SSH into headless instances in the cloud. vi is part of the POSIX standard, so you know it's there and it's robust.

- Spacemacs engineering. Great package integration in the form of layers.

[1] https://www.spacemacs.org/

Re:Ask HN: Resources to grok Emacs and use it well? by kalium_xyz on Wednesday April 15, 2020 @07:27PM (#22884370)
You can also just run evil mode for the vi emulation (its what spacemacs does), spacemacs is the best emacs IDE though IMHO.
Re:Ask HN: Resources to grok Emacs and use it well? by banachtarski on Thursday April 16, 2020 @03:27AM (#22887006)
My experience with Spacemacs was the complete opposite. There's a ton of inconsistency with the quality of the provided layers which is why YMMV when using it. The C++ layers up till last year was an utter disaster and I don't know if it's been fixed since.

The WORST thing about spacemacs though is their absolutely broken release process. The master branch rarely upgrades with fixes applied to the develop branch, and the tacit recommendation is just to run "on the bleeding edge." I have no idea why spacemacs users tolerate this, but my productivity has since improved after ditching it.

Re:Ask HN: Resources to grok Emacs and use it well? by mijoharas on Thursday April 16, 2020 @06:08AM (#22887822)
I run the develop branch and I can't really remember any significant bugs I've had.

I can kinda agree the C++ layer was definitely a bit of a pain, but I had general pain setting up a good workflow for C++ in emacs with the project I was working on (most of the emacs packages assumed a different layout, so couldn't understand my CMakeLists to generate the files it would need to look at for smart completion).

Overall, I quite like spacemacs, I used to hack on it a bit to make it suit my needs better, but now I rarely have anything I need to do it "just works" now.

I particularly appreciate that almost any language I want to use, I can just download a layer (I think it often prompts you to install one when you open the file automatically!) and a lot of the common across languages editor functions you want have similar keybindings, and the `which-key` popup will tell you anything you're missing. It makes a very short ramp up to being productive in your editor for a new language.

Re:Ask HN: Resources to grok Emacs and use it well? by banachtarski on Thursday April 16, 2020 @12:26PM (#22890984)
I'll be honest, my experience since has been that VSCode is... just better? I've been using vim/emacs for over 20 years now so it's a tough pill to swallow, but after trying out VSCode, I have to say that making it easy to program extensions with async functionality from the get-go was the right way to go. I think no combination of rtags, cquery, clangd, lsp, etc in Emacs/Vim/Neovim can approach the performance and quality of VSCode's C++ dev experience. And I say that having honestly tried every permutation of the above for many hours across many weeks.
Re:Ask HN: Resources to grok Emacs and use it well? by weaksauce on Wednesday April 15, 2020 @07:33PM (#22884413)
you definitely can use evil mode but you will find a lot of edge cases where you have to configure something in some modes to behave sanely whereas with spacemacs they have usually done all that legwork of anything you want to use.
Re:Ask HN: Resources to grok Emacs and use it well? by michaelmrose on Wednesday April 15, 2020 @08:10PM (#22884684)
You can get a lot of help with evil-collection

https://github.com/emacs-evil/evil-collection

Which provides evil bindings for a lot of modes

Re:Ask HN: Resources to grok Emacs and use it well? by kalium_xyz on Wednesday April 15, 2020 @08:29PM (#22884816)
You also have doom which is just evil and not space centric AFAIK
Re:Ask HN: Resources to grok Emacs and use it well? by weaksauce on Thursday April 16, 2020 @06:21PM (#22894167)
i'm a large fan of space as a leader key even coming from vim so spacemacs felt like a natural extension. but yeah doom works for many people
Re:Ask HN: Resources to grok Emacs and use it well? by smitty1e on Wednesday April 15, 2020 @09:07PM (#22885074)
Doom has good reviews AFAICT
Re:Ask HN: Resources to grok Emacs and use it well? by shanavasm on Thursday April 16, 2020 @09:07AM (#22888939)
I switched to doom from spacemacs and quite happy with it. Lot more easier to tweak that spacemacs.
Re:Ask HN: Resources to grok Emacs and use it well? by alexeiz on Thursday April 16, 2020 @08:03PM (#22894878)
I considered Spacemacs, because I used Vim extensively in the past (and still use it for some tasks), but I felt that Vim emulation in Emacs would only hinder my understanding of Emacs and steepen the learning curve. So I ended up incorporating useful bits and pieces from Spacemacs into my .emacs config, but stayed with native Emacs key bindings. I'm comfortable with my choice, but please change my mind if you feel like it.
Re:Ask HN: Resources to grok Emacs and use it well? by 29athrowaway on Thursday April 16, 2020 @01:52AM (#22886529)
Is there a way to make Spacemacs more performant? It felt slower than an IDE.
Re:Ask HN: Resources to grok Emacs and use it well? by mkesper on Thursday April 16, 2020 @02:06AM (#22886601)
Use its client-server capabilities (http://wikemacs.org/wiki/Emacs_server). Most slowness I felt was startup time (except on Windows, there everything felt slooow).
Re:Ask HN: Resources to grok Emacs and use it well? by jimhefferon on Wednesday April 15, 2020 @05:57PM (#22883576)
Forgive the noise, but I second this. I haven't committed a hundred key combinations to memory. I find that knowing the twenty things I need to know (which are different for everyone), and having another twenty in my back pocket for once or twice a year has lasted me since 1992, and left me very satisfied indeed with emacs.
Re:Ask HN: Resources to grok Emacs and use it well? by downerending on Wednesday April 15, 2020 @06:16PM (#22883750)
Also seconding. Vanilla emacs is already extremely powerful, and if you're doing real work, you'll end up having to use hosts that don't have all of your wonderful enhancements installed. It's good to know vanilla emacs.

Beyond that, add language modes for anything you need that's not already included.

If you use 'git', 'magit' is very nice.

Beyond that, helm is interesting, though very large and kind of mind-blowing.

Recommend these in your ~/.emacs.d/init.el, to avoid being that guy:

    (setq-default show-trailing-whitespace 't)
    (setq-default indicate-empty-lines 't)

    ; try not to use tab characters ever when formatting code
    (setq-default indent-tabs-mode nil)

    (setq-default require-final-newline 'ask)
    (setq-default mode-require-final-newline 'ask)
Re:Ask HN: Resources to grok Emacs and use it well? by philsnow on Wednesday April 15, 2020 @06:57PM (#22884145)
> if you're doing real work, you'll end up having to use hosts that don't have all of your wonderful enhancements installed. It's good to know vanilla emacs.

If you're talking about production hosts, they shouldn't really have vanilla emacs installed either. Not having your creature comforts present on production machines is a feature, like the red shell prompt / terminal background some people use, a reminder to get you to think twice and try to not do things directly in production. If you really must, just use TRAMP, it's amazing.

If, on the other hand, you're talking about using somebody else's laptop to do anything, that doesn't make sense to optimize for, at least in my experience. I prefer not to even touch other peoples' laptops/keyboards.

Re:Ask HN: Resources to grok Emacs and use it well? by downerending on Wednesday April 15, 2020 @07:32PM (#22884402)
I'm fine with not installing emacs, as long as no one ever asks me to fix their crap on those hosts. In practice, their stuff will always break, and they always will ask me to fix it. Production hosts should never be neutered. At a bare minimum, emacs-nox, strace, nmap, tcpdump, lsof. No exceptions.

Tramp is great, but not all such hosts are reachable that way.

> I prefer not to even touch other peoples' laptops/keyboards.

Me too, but that's why they call it work.

Re:Ask HN: Resources to grok Emacs and use it well? by mbrock on Thursday April 16, 2020 @01:21AM (#22886355)
Hopefully the Emacs is also configured to not leave tilde backup files everywhere!
Re:Ask HN: Resources to grok Emacs and use it well? by User23 on Wednesday April 15, 2020 @10:45PM (#22885531)
> Also seconding. Vanilla emacs is already extremely powerful, and if you're doing real work, you'll end up having to use hosts that don't have all of your wonderful enhancements installed. It's good to know vanilla emacs.

I wonder if I'm weird, but I use a highly customized Emacs on my dev machine, but if I have to ssh into a host and edit something I just use vi there. The correct answer to vi or emacs has always been "both" for me.

Re:Ask HN: Resources to grok Emacs and use it well? by kqr on Thursday April 16, 2020 @01:12AM (#22886299)
I'm the same way, and I don't see why that would be so controversial. Vi(m) clearly has the better defaults, but Emacs is the better platform. (Then again, I'm the person who occasionally also uses ed just to keep it fresh in my memory, so there's that.)
Re:Ask HN: Resources to grok Emacs and use it well? by regularfry on Thursday April 16, 2020 @07:17AM (#22888267)
They're just optimised for different jobs. Vim for line-based editing, emacs for nested. It just so happens that editing config files on remote hosts tends to be line-based, while editing code locally involves editing nested structures. I'll happily use both on the same machine though.
Re:Ask HN: Resources to grok Emacs and use it well? by kbp on Thursday April 16, 2020 @08:01AM (#22888507)
You can also ssh in via Emacs with Tramp, and use your highly customised Emacs to edit remotely.
Re:Ask HN: Resources to grok Emacs and use it well? by fantispug on Thursday April 16, 2020 @06:42AM (#22888028)
I'm the same; I use evil-mode in emacs and find the friction of switching between them small.
Re:Ask HN: Resources to grok Emacs and use it well? by dizzystar on Thursday April 16, 2020 @05:09AM (#22887512)
for trailing whitespace:

(add-hook 'before-save-hook 'delete-trailing-whitespace)

This deletes all whitespace when you save a buffer.

Re:Ask HN: Resources to grok Emacs and use it well? by shermanmccoy on Thursday April 16, 2020 @12:08AM (#22885951)
Linux kernel developers would not want to use the third option on your list.
Re:Ask HN: Resources to grok Emacs and use it well? by downerending on Thursday April 16, 2020 @12:00PM (#22890723)
magit? Why not?
Re:Ask HN: Resources to grok Emacs and use it well? by shermanmccoy on Thursday April 16, 2020 @08:31PM (#22895066)
Some coding styles insist on tabs. I was referring to the third line of your configuration as quoted below.

; try not to use tab characters ever when formatting code (setq-default indent-tabs-mode nil)

Re:Ask HN: Resources to grok Emacs and use it well? by jwr on Thursday April 16, 2020 @03:28AM (#22887011)
This advice is fine for the first year or so, but afterwards I would start trying out various packages and customizations. There are packages that can make your experience much better (projectile, swiper, ace-window, ace-jump, move-border, eyebrowse, winner, color-identifier-mode, off the top of my init.el).

And, of course, if you do any programming at all, you should install magit immediately. It is the best git experience anywhere, on any platform, period. It is an unbelievable productivity booster, and people who haven't used it do not even appreciate what it can do (ever wanted to quickly apply a single diff from one of your stashes to your current code tree? it's two keystrokes).

Approach emacs like you would a musical instrument: you are not expected to play the piano on your first day, and the first year will require some patience and training, but eventually you'll start playing those sonatas.

[context: my Emacs init file has lines that are 27 years old]

Re:Ask HN: Resources to grok Emacs and use it well? by cjauvin on Thursday April 16, 2020 @09:13AM (#22888974)
Typical Emacs user experience: sees a list of packages some other user likes, picks one with a name he finds intriguing (in my case eyebrowse), checks it, finds it cool, adopts it (possibly for a long time).
Re:Ask HN: Resources to grok Emacs and use it well? by jwr on Friday April 17, 2020 @07:23AM (#22898040)
I've done this so many times. This is why I name-drop packages :-)
Re:Ask HN: Resources to grok Emacs and use it well? by b3n on Thursday April 16, 2020 @08:29AM (#22888680)
In case you weren't aware, winner-mode is now part of Emacs, and as far as I can tell the Emacs 27 tab-bar-mode makes eyebrowse redundant. For me project.el that ships with Emacs is enough for my project needs.
Re:Ask HN: Resources to grok Emacs and use it well? by jwr on Thursday April 16, 2020 @03:27PM (#22892587)
Hmm. Do you mean that tab-bar-mode lets me have a full-screen Emacs (no UI elements whatsoever, as one does) and switch between window configs like if they were workspaces (which is what eyebrowse does)?

If so, I might want to try it.

Re:Ask HN: Resources to grok Emacs and use it well? by b3n on Friday April 17, 2020 @10:33AM (#22899283)
Yes exactly, by default it has a tab-bar UI element, but you just have to set tab-bar-show to nil and you can use it to switch between window configs without the UI.
Re:Ask HN: Resources to grok Emacs and use it well? by dhosek on Wednesday April 15, 2020 @10:59PM (#22885598)
I'm in this school of emacs usage. I use Aquamacs on my Mac and while I've been using Emacs for almost as long as kabdib, I've barely scratched the surface of what Emacs can do. For me, the biggest thing that'll get me to drop out of IntelliJ (I was so happy to learn that there were Emacs keybindings hidden in one of IntelliJ's Mac keymaps) and into Emacs is to do ctrl-x(...ctrl-x) to record a macro, then ctrl-x NUMBER ctrl-x e (I'm hoping I'm translating muscle memory correctly) to do a repeated complex edit on a block of text. It's always fun to see junior devs (and occasional seniors) watch me do this and ask, How did you DO that?
Re:Ask HN: Resources to grok Emacs and use it well? by kabdib on Wednesday April 15, 2020 @11:32PM (#22885769)
It's fun to see someone's jaw drop when you show them what you can do with a keyboard macro, some regular expressions and a little shell integration.

More than simple fun; I've saved people from hours and sometimes days of drudgery with just a few minutes of mucking about in Emacs. Teaching someone simple automation is pretty rewarding. Even if they are not technically capable of repeating your solution, at least they go away with a problem solved AND the knowledge that there are usually better options available than drudgery.

Re:Ask HN: Resources to grok Emacs and use it well? by acomjean on Thursday April 16, 2020 @01:24AM (#22886374)
I work the same way. Drop out of phpStorm or inteliJ into emacs to do some Marco recording. I tend to use f3 to record and f4 to run said macro.

That and white space mode for examining files..

Re:Ask HN: Resources to grok Emacs and use it well? by scns on Thursday April 16, 2020 @02:29AM (#22886723)
You can use Vim style macros in Intellij with the Vim plugin
Re:Ask HN: Resources to grok Emacs and use it well? by h91wka on Wednesday April 15, 2020 @06:32PM (#22883900)
There is another positive side effect of limiting customization to reasonable levels. Default Emacs shortcuts are hidden everywhere. Most importantly, bash understands them, as well as many other REPLs (erlang, ghci, julia, ...). Developing muscle memory for the default Emacs allows one to use many tools much more efficiently.
Re:Ask HN: Resources to grok Emacs and use it well? by zozbot234 on Wednesday April 15, 2020 @07:00PM (#22884163)
Default Emacs shortcuts are bad for RSI. Even the original author of Emacs has had to cut down pretty dramatically on their coding activity, due to getting "Emacs pinky" and other RSI problems.
Re:Ask HN: Resources to grok Emacs and use it well? by alexhutcheson on Wednesday April 15, 2020 @07:30PM (#22884391)
Mapping Caps Lock to be "Control" helps a lot with this. Reaching down to the bottom row for Control all the time is terrible and should definitely be avoided. Using Alt as Meta has been less of an issue for me since I can easily hit it with my thumb without moving too much.

evil is also great, and it might actually be the most popular option for new users at this point, thanks to Spacemacs and Doom.

Re:Ask HN: Resources to grok Emacs and use it well? by __d on Wednesday April 15, 2020 @10:50PM (#22885557)
Second this: the key to the left of 'A' (for QWERTY) should be control for regular Emacs use.
Re:Ask HN: Resources to grok Emacs and use it well? by donio on Thursday April 16, 2020 @11:19AM (#22890276)
That's true for traditional keyboards and layouts. A keyboard with a thumb cluster that puts ctrl and meta under your thumbs makes all the difference.
Re:Ask HN: Resources to grok Emacs and use it well? by xemdetia on Wednesday April 15, 2020 @09:01PM (#22885040)
I started this way and my next step was taking advantage of the current package manager. The fact you can inject new functionality so quickly made me really fall in love with emacs. Adding additional programming modes/file format modes without any headaches has been a boon to my usage of Emacs. I'm rarely tuning settings in elisp anymore and instead just adding a feature so the file has colourization and tab stops working properly. If I do actually want to customize something since customize-mode works well enough now I can usually find the modest setting I do want to change without much hassle.
Re:Ask HN: Resources to grok Emacs and use it well? by drfuchs on Wednesday April 15, 2020 @11:34PM (#22885778)
My advice (and experience) is exactly the same as kabdib's (though his .emacs file is longer, and his baud rate lower, than mine). Literally the only advanced feature I use is Keyboard Macros (as dhosek mentions), but just that one feature is so useful, every other editor I've tried feels hobbled (even vi, which I used professionally for years). And no, multiple IPs doesn't do the trick at all. On the other hand, my pinky hurts.
Re:Ask HN: Resources to grok Emacs and use it well? by boulos on Wednesday April 15, 2020 @09:05PM (#22885057)
What’s emacs --version say for you? My main complaint from using a Mac laptop for so long is that I often had to download some .el packages, that are basically unnecessary with more recent emacs updates. Other than that, I’ve also got a fairly simple .emacs file modulo a few project specific “let me make this a macro for this terrible manual process I need to do”.
Re:Ask HN: Resources to grok Emacs and use it well? by alexhutcheson on Thursday April 16, 2020 @11:28AM (#22890388)
FYI - the Emacs binary that's bundled with pre-Catalina versions of macOS (as /usr/bin/emacs) is 22.1, which is an ancient version from 2007. Apple kept that version because it's the last one that was released as GPLv2, and they've avoided bundling anything that's licensed GPLv3. This is the same reason that macOS includes an ancient version of Bash, and why they're switching to zsh as the default login shell.

Because it's so old, no one bothers to maintain compatibility with it anymore, and almost all modern elisp will break in some way if it's loaded in 22.1. Somewhat fortunately, it seems like Apple has removed this emacs binary from Catalina, so it won't be an issue on future versions of macOS.

To get a modern Emacs: https://emacsformacosx.com/ has binary builds of the official Emacs releases, with some additional scripts that let you launch it from Launchpad, etc.

Re:Ask HN: Resources to grok Emacs and use it well? by squirrelmaker on Wednesday April 15, 2020 @08:22PM (#22884777)
Was it an acoustic modem? Just adds to the joy.
Re:Ask HN: Resources to grok Emacs and use it well? by kabdib on Wednesday April 15, 2020 @11:19PM (#22885699)
Yup, a Novation Cat. I still have it, not that it's useful other than as a conversation piece.