Learning Emacs [topic split on request]

Thank you for creating this! The level of syntax highlighting is compelling me as a newbie Inform 7 user.

So much so, that I figure I might as well learn Emacs too! I’m going to do some googling, but is there any resources you (or others on this thread) have for learning Emacs?

Or things to avoid / major beginner tips?

(I know this is a bit of thread-drift but I hope it’s still pertinent. I can imagine others in my shoes!)


[Split by Mod on request -H]

2 Likes

https://emacswiki.org

Edit: Beginner tip about keys to press:

  • “M - something” means “Alt-something”
  • “C - whatever” means “Ctrl-whatever”

Many important key combinations start with Ctrl-x.

2 Likes

With the important caveat that it’s been a few years since I’ve tried to stay on top of the Emacs world…

Emacs has been around since the seventies, GNU Emacs since 1985. The core project is conservative about fundamental changes to default keyboard commands. The rest of the world is mostly settled on ^x, ^c, ^v for cut, copy, paste, but not Emacs. Likewise, there are a lot of very useful packages that aren’t there by default.

Various starter kits represent various attempts to make Emacs more usable out of the box. You might want to consider one of, say:

ErgoEmacs just changes a bunch of keybindings; the other two are highly opinionated and change a lot. Like always, that’s a double-edged sword: there may be lots of advantages, but you’ve diverged so far from the rest of the Emacs world that the solutions you find on the web for how to do things in Emacs may not work.

Otherwise, start with Emacs Life. The Emacs world is big and active. This weekly Emacs news roundup maintained by the same person as Emacs Life, Sacha Chua, has a lot of items every week. Having linked to her stuff, I’ll mostly bow out and let her do the heavy lifting. She has stayed on top of Emacs community news.

Mastering Emacs is a good book if you’re at least an intermediate Emacs user.

Org Mode is very cool.

EmacsWiki has lots of good stuff, but with the substantial problem that it’s been around for a lot of years and a lot of specific advice to be found may no longer work or no longer be anything close to the best approach to a problem (at least all that was true last time I was familiar with it… maybe there’s been massive cleanup and updating).

3 Likes

@Zed Thx for the links! Emacs life is really helpful imho. For example this one-page cheat sheet:

2 Likes

This is probably tip zero on all the guides you’ll see but just in case it’s not: remap your caps lock key to be another control key.

1 Like

I recommend using the Fira Code font

(add-to-list 'default-frame-alist '(font . "Fira Code-10" ))
(set-face-attribute 'default t :font "Fira Code-10" )

Remember that Emacs has a built-in tutorial. Don’t feel like you have to learn everything at once or even ever. Use the mouse and the menu bar all you want; don’t feel like you have to renounce them just because you can use keyboard commands too.

3 Likes

This appearance of this topic made me think, “It’s time to find out what Emacs is.”

@Zed suggested start with Emacs Life, so I went there. It didn’t tell me what Emacs was.

I googled “What is Emacs?” and visited the high-ranking opensource com result (What is Emacs? | Opensource.com). This was pretty good technically, but got abstract too fast about the awesome features of Emacs. I’m still thinking: Why would I want to use Emacs? What’s it for?

So then I googled “use cases for Emacs”. The top result was a reddit topic that began like this:

"I was configuring Emacs, yet again, and then it hit me.
The primary use case of Emacs is configuring Emacs."

Yes, this was a joke (a pretty good one too, I thought). In the mean time, the discussion it prompted went through a part where this user said “…Emacs is a software embryo that was made with the purpose of extending itself into a perticular program to fit its user. Thus every Emacs resembles the habbits of its master and every line of configuration furthers the completion of the mirroring of its user’s soul.”

So, Emacs = text-editing soul mirror. Got it!

Admittedly I might have avoided all this weirdness if I had instead followed @Pebblerubble 's link to https://emacswiki.org/ and happened to go to the right part of it when I landed, which I did:

EmacsWiki (a site) → Learning About Emacs (a section) → EmacsNewbie (a link) → Getting Started (a section) → Guided tour: GnuEmacs (a link)

There I saw this

“The GNU Emacs Manual calls Emacs the extensible, customizable, self-documenting real-time display editor , but this description tells beginners little about what Emacs is capable of. To give you an idea, here is a sampling of the things you can do with Emacs…”

And I was like HALLELUJAH!

-Wade

3 Likes

You could’ve quit there, that basically nails it.

3 Likes

We should also mention that Emacs comes with the adventure Dunnett built in, which might be the most familiar place to start for some people here.

6 Likes

Less flippantly, I had been presuming that someone already interested in a particular Emacs mode knew what Emacs was; “what is emacs, anyway?” I would’ve answered differently.

This xkcd strip seems appropriate here.

1 Like

Author of the inform7 mode here.

Beginner tip 1: use cua-mode!!! It makes regular ctrl-v, ctrl-c, etc work in your Emacs. That’ll help you get started! :slight_smile:

Beginner tip 2: don’t start with raw Emacs. That’s like making a kit car your first car. I really really think beginners should just use Doom Emacs instead. I’ve used vim, and then visual studio code, and then plain Emacs, and then Spacemacs, and finally I’ve settled on Doom for several important reasons.

Beginner tip 3: if you like Obsidian and/or would like a personal wiki / mind map note taking app built directly into your editor, check out org-roam. You can even embed wikilinks to notes into your Inform code if you want, turning your code itself into a personal wiki too. I’ve heard of people doing stuff lile that, anyway

Beginner tip 4: every function and variable in emacs has documentation you can bring up in-editor. Use that!

Why Doom over stock emacs?

The benefits of emacs is that it is less of an editor per se and more of a sort of mini operating system oriented around an extremely dynamic, live, modifiable system and a very interesting sort of text and graphical hybrid interface paradigm. 90% of it is written in lisp, which is also its extension language, with only a small core written in c, so almost every part of the program is dynamically available to you at runtime for you to inspect, modify, or replace at will. It’s kind of like the live image environments of Smalltalk, and it’s basically the last surviving Lisp Machine OS, running in a window on your computer.

To give you a sense of this, emacs has a built-in command that will let you run any arbitrary lisp expression that your cursor is located in (from any text file that you have open) in the current editor context, so for instance if I decide that I suddenly want to add a command to my editor with a certain key binding, or I want to run some code to tell it to do something, or I decide I want to temporarily replace an existing editor command with a new one, I just open up a blank file, type in the lisp I want, hit a key command, and my editor has been modified. Hell, a command to bring up a lisp REPL is one of the core basic emacs commands, and long time Emacs users embed emacs lisp expressions in the comments of their other coding projects so they can just run them to perform certain edits on the section of code near the comment!

The problem with this is that, by default, emacs is essentially an operating environment designed for handling every sort of text related use case you can imagine, but it isn’t really a text editor. Or, at least, not a good one. So you will have to build one yourself. That’s cool, but a lot of work writing a many hundred line configuration file, including dozens and dozens of plugins and lisp libraries, to get to the point where it feels like you are at feature parity with something like Visual Studio Code. You’ll have to worry about whether the packages you are using to build that functionality have been updated recently enough, whether they are compatible, whether there are any subsidiary or related packages that will vastly improve your experience with that package and bring in more functionality you need, and most importantly, you’ll have to do continual maintenance on your configuration file throughout the entire time that you are using emacs as an editor as updates to the editor, the packages, and your development environment happen.

That’s not a really great value proposition, despite the power of emacs, in my opinion. That’s where Doom comes in: like Spacemacs, Doom is essentially a pre-configured distribution of emacs. It does all the work for you of building a configuration of emacs and maintaining it, including having terminal commands for diagnosing why your configuration may not work, updating your configuration and associated packages, and so on. It then presents you with a simple and effective customization framework in lisp for you to use if you want to further customize it, that abstract away all of the nitty gritty annoying details and integrates your customizations with itself so that it can diagnose any problems with your own customizations as well. It also gives you a list of something like over a hundred “layers”, which represent entire programming languages or categories of features (like workspaces, project management, and so on) that you can enable or disable depending on what you want to do with your editor and how you want it to behave. Under the cover, those layers are usually around a dozen carefully selected and integrated emacs lisp packages that the maintainers of Doom have assembled to give you the best version of that feature or behavior or language environment, and provided with an extensive default configuration. So for instance, I can just uncomment the rust line in my Doom init.el file and I will get an entire IDE class development environment for rust downloaded and installed when I run my doomsync command, one that is very comparable to something like intellij. Essentially, Doom takes the advanced operating environment that emacs provides and builds an actual modern editor out of it, instead of you having to do that yourself.

Additionally, a lot of people in this thread are saying that you should learn the default emacs key bindings, but I really think that’s the wrong move. The default emacs key bindings are designed to carry semantic meaning, not to be ergonomic, which means that you very often get long key chords involving many modifier keys that will seriously, and I really mean this, probably give you RSI. Instead, you should lean on the fact that emacs actually has the best Vim emulation in existence, evil-mode, which is so good that it’s actually superior to the original, and that Doom emacs comes with that mode pre-enabled, and extended so that every corner of the editor has had its default he bindings replaced with Vim style key bindings, because Vim key bindings are infinitely more productive and most importantly infinitely more ergonomic.

Why Doom over Spacemacs?

Mostly because Doom is extremely fast, relatively simple and easy to understand so you can more easily figure out what’s going on under the hood, better configured by default, with its layers tending to have a lot more interesting and helpful packages installed by default and far more optional packages to customize behavior. Furthermore, unlike Spacemacs, which in my experience has been buggy and not directed by any kind of coherent vision, Doom has never once bugged out on me, and feels very coherent, like its own editor that was intentionally designed on top of emacs.

5 Likes

While I am interested to see this perspective, I want to stress that it’s not everybody’s. I started using Emacs in college (figure 1988), which was of course long before DoomEmacs or Spacemacs. I used it as a text editor. I still use it as a text editor.

35 years is long enough for anybody to accumulate some Emacs configuration tweaks. But for me, most of it has been switching off features that someone thought was a good idea. No menu bar, thanks. No fonts, thanks. No graphics, thanks. I want to edit text with my text editor. (In fact I always run Emacs in a terminal window, which I admit is perverse. I could customize the normal Emacs windows to behave how I want; I’ve just never bothered.)

I added one custom keybinding early on (esc-n for “go to line number”) but otherwise stick to the defaults.

Oh, I’ve also spent some time customizing how indentation behaves in different source files.

My only caveat is that while I use Emacs regularly for source code and any kind of short text file, I don’t use it for writing long-form prose. This is more or less because the aforementioned choice about always using it in a terminal window; I don’t have normal mouse control and the standard keybindings don’t make sense for long paragraphs. If my habits had developed slightly differently I could have wound up Emacs-everywhere.

2 Likes

Yeah, I’m with Andrew (though I haven’t used emacs in probably 20 years): I barely configured it at all. Ran it in a terminal window, maybe changed a few UI and code formatting/highlighting settings, remapped a couple long commands to short ones. It’s always cool to hear from the people who get deep into the customization, but despite knowing some Lisp I never did much elisp: it wasn’t something I needed from a text editor. That said, I’ve never had much use for most modern IDE features either…

2 Likes

Yeah, I can chuckle at the “Emacs is a great operating system; too bad it doesn’t have a decent text editor” joke… but I think it is a decent text editor as well as being extensible to be “an operating environment designed for handling every sort of text related use case you can imagine”.

(I do customize both my keyboard layout and my Emacs keybindings to get the ergonomics I want.)

2 Likes

@Zed @zarf @JoshGrams it’s really interesting to hear all of your perspectives on this, because I’ve actually never talked to someone before who used emacs largely “raw”! My comments were definitely meant to be my own personal opinions, not the word of god, and I hope it’s clear it comes from a place of love for the editor — I’ve used it for the last eight years! And yeah, I can definitely see how if your editing needs have primarily to do with editing text, and less to do with needing a full development environment with IDE like features, vanilla emacs could be just fine! Especially if you don’t mind the key bindings. I was saying that it wasn’t a “good editor” by default not from that perspective, but from the perspective of assuming someone who wants/expects something that has the full IDE-lite feature set expected of a modern editor, like what Visual Studio Code has — and from that perspective, you really do have to do a lot of customization to get vanilla emacs up to speed, although a lot of it is just installing packages and configuring them, not writing your own elisp de novo, to be fair.

2 Likes

I am happy to be on this forum because you all manage to discuss Emacs pro and con without turning it into a religious war as it is done normally. :slight_smile:

4 Likes

I am very late to the “full IDE-lite feature set expected of a modern editor” thing. I first encountered those flashy language-server-style features in Xcode (iOS development). “Hm, interesting,” I thought, but I never felt the urge to make the rest of my coding life work the same way.

My new job uses Rider (C# integration) and I am still deciding whether I like it.

(On the up side, the “modern editor” standard says that all these features must be extremely customizable. So I’m sure I can get it to where I want it.)

2 Likes

I learned vi in a Unix/C course back in the 80s. I still use it almost daily via (no pun intended) the command line. In linux, I rarely start up the GUI. I use emacs rarely. Coherent, unix clone I used in the early 90s on a 386 laptop to do homework had a port of microemacs.

I like both vi and emacs pretty much raw.

PS. Once I learned Unix, I pretty much thought MS Windows was a waste of bandwidth…

3 Likes