reddit / emacs
Emacs + a nice theme + editing features is awesome! (plus some questions about extra configuration)
DistilledProblems · 2022-12-06 13:21
So Atom has shut down. I could probably still use it, but for permanence I decided to switch to Emacs since I'm extremely picky with my editors.
To be honest, the first time I tried it I was disappointed how hard it was do something simple as save a file, copy/paste and whatnot. However, the "steep learning curve" everyone talks about is just a matter of having a nanosecond of patience. Then speed comes later. What I love about the keybindings is it confines all of my work to the keyboard and the bindings are ergonomic if you also use the right Ctrl and shift keys. My workflow is honestly magnitudes better, being able to jump at lightning speed, completely neglecting arrow keys and the mouse. Also, for the first time ever, I am using all ten fingers to type.
The question: I've set up a theme which I like, auto pairing brackets, indent and auto-complete. Curious if there's a way to get linting support? i.e. underlining missing semicolons, typos.
Also, can I integrate a terminal into emacs as well? So far having the screen split with emacs and terminal (GNOME on Ubuntu) is working fine, but wondering if there's an even better way.
Thanks.
soundslogical · 2022-12-06 13:48
For linting you should look into flymake, or lsp or eglot for the more in-depth stuff.
For terminals, there are many options with competing trade-offs. For a fast terminal that behaves almost exactly like your system default, try vterm.
jmite · 2022-12-06 13:48
All of this is possible! But configuring it takes some work.
Awesome-emqcs is a great resource for knowing what packages are there: https://github.com/emacs-tw/awesome-emacs
This might be controversial, but I'd highly recommend using a starter kit for configuration, like doom emacs, spacemacs, crafted emacs, etc. They are basically pre-made emacs.d config files that include sensible defaults that give you lots of the goodies you want right out of the gate . I use doom and can't imagine managing the complexity of my config without it, but a lot of people say the start with a starter and then learn how to make their own config from that.
nakuaga · 2022-12-06 13:54
For linting you should take a look at lsp, or flymake.
For an internal shell, M-x shell
oantolin · 2022-12-06 13:55
> To be honest, the first time I tried it I was disappointed how hard it was do something simple as save a file, copy/paste and whatnot.
None of those things are hard to do in Emacs; they're not hard to do in any editor I've ever heard of! Making an editor where those basic tasks were difficult would be madness.
mickeyp · 2022-12-06 14:43
It's sad Atom died. We need more diversity and not less!
Yes, you'll quickly become proficient in Emacs's key bindings. There are many, but you can learn them piecemeal. Don't forget to keep the menu bar so you can pick up on new features as it's contextual.
For terminal emulation give my overview a shot:
https://www.masteringemacs.org/article/running-shells-in-emacs-overview
It covers all the bases, including alternatives and other ways of accomplishing tasks that can be done in Emacs.
DistilledProblems · 2022-12-06 14:54
Thanks. Is it possible to find previous commands like in the standard terminal? Up/down arrows keys don't work like in the native GNOME terminal.
nakuaga · 2022-12-06 15:09
Absolutely! You should do C-up and C-down
andyjda · 2022-12-06 15:26
If you’re someone who’s not very familiar with a keyboard-based workflow, I can totally understand finding these tasks hard. Maybe “hard” isn’t the right word, but it’s definitely cumbersome to get used to things like Ctrl-s not meaning ‘save’, or the kill-yank workflow and shortcuts being different from the usual copy-paste approach
spauldo_the_hippie · 2022-12-06 16:02
It's a lot harder to do if you follow everyone's advice and remove the menu bar. People expect C-s for save, and it takes time to build the muscle memory.
I really think removing the menu bar is a bad thing to recommend to newcomers. Screen resolutions are high enough that the little bit of space it takes is worth it. The menu bar is great for discoverability and lists the keybindings on each menu item, making it easy to learn new modes without digging through C-h m.
I disable the tool bar and scroll bars 'cause I rarely use the mousel in Emacs, but the menu bar stays - even after years of Emacs use.
deaddyfreddy · 2022-12-06 18:02
> It covers all the bases, including alternatives and other ways of accomplishing tasks that can be done in Emacs.
Ever tried [Detached](https://git.sr.ht/~niklaseklund/detached.el)? I've remapped some commands with provided detached versions (see README) some time ago and couldn't be happier!
oantolin · 2022-12-06 18:09
People advise *newcomers* to remove the menu bar? That's bad advice. But also anyone following that advice is at least aware of the existence of the menu bar. Probably even worse are "starter kits" that remove it for you without you even knowing.
WallyMetropolis · 2022-12-06 18:22
On thing you may want to do when working with a shell of any kind in emacs (though I personally use a like vterm and multi-vterm after having used most of the common and few uncommon options like Shelldon) is to get your environment variables loaded properly. The package `exec-path-from-shell` is very helpful.
Here's my use-package based config for reference:
(use-package exec-path-from-shell
:config
(setq exec-path-from-shell-shell-name "/bin/zsh"
exec-path-from-shell-arguments '("-l")
exec-path-from-shell-variables '("PATH"
"MANPATH"
"PYTHONPATH"
"CDPATH"
"SBT_OPTS"
"LSP_USE_PLIST"
"NODE_OPTIONS"
"DOCKERHOST"
"DICTIONARY_API_KEY"
"THESAURUS_API_KEY"
"SPARK_LOCAL_IP"))
jmite · 2022-12-06 18:23
They're hard if you're expecting CUA keys and don't have which-key installed. Not to mention the model of cut/paste is totally different in emacs with a kill ring.
They don't seem hard if you're used to Emacs, but for most people it's different from every piece of software they even ever used.
Awkward_Tradition · 2022-12-06 18:29
Start first with a distro like Doom Emacs or Spacemacs. They have all of that basic stuff set up already (there are like 4 terminal emulators to choose from in Doom for example), and you can draw inspiration from them if you decide to start from scratch. Although, they're both made with evil-mode in mind (essentially vim as your editor), but they can work with default bindings.
If you want to start from scratch immediately check out the "Emacs from scratch" series and "Mastering Emacs".
Pro tip: if you're using a desktop keyboard and default keybindings, press C and M with your palm instead of your fingers. It'll save you from RSI, and that's no joke. Mashing C with your pinkie all day long will lead to pain and suffering. Also, evil-mode is so much nicer on your hands, besides being a lot nicer for editing, since you can for example tap ESC to enter normal mode and then move around, instead of having to hold down modifiers to do the same.
Awkward_Tradition · 2022-12-06 18:35
C-p and C-n are actually the Linux (Unix?) standard for previous and next commands. They're actually superior to using arrow keys since you don't have to move your hand from the home row. I think every Emacs terminal and repl I've used implemented them, but there are some inconsistencies like some of them only working in normal while others in insert states.
Check out the rest, you'll be surprised what you can do.
Awkward_Tradition · 2022-12-06 18:48
>I really think removing the menu bar is a bad thing to recommend to newcomers.
On one hand I've never seen that recommended, on the other I literally had to toggle it to be sure I'm thinking about the right thing. I don't think I've ever used it, even when I was just starting off with vanilla Emacs and going through parts of the tutorial daily. And there was definitely no need for it after I've learned about describe- functions.
oantolin · 2022-12-06 18:50
I agree it may be unfamiliar, but I refuse to call it hard. It's just different. Are people just saying "hard" to mean "unfamiliar"? If so, I take back my objection, I just apparently don't know what "hard" means.
oantolin · 2022-12-06 18:53
I think the word "hard" confused me, it's definitely not the right word. I think OP, and several of the commenters, meant "unfamiliar". If you make that change, a lot of what they said makes sense to me and I agree.
ComprehensiveAd5882 · 2022-12-06 19:01
I don't like vim.
agumonkey · 2022-12-06 19:09
the keyboard oriented is nice, but wait until you get to write your own elisp snippets/extensions
spauldo_the_hippie · 2022-12-06 19:20
It's the first thing I see on most "how to set up Emacs" blogs.
Two_Souls · 2022-12-06 19:22
I'd recommend getting into system Crafters on YouTube rather than using doom emacs. Personal opinion. The beginners videos will take you through how to setup everything you need from scratch. And there a lot of fun!
timmymayes · 2022-12-06 19:23
Yes this is where the magic happens
timmymayes · 2022-12-06 19:26
Emacs pinky was one of those things that made zero sense when I first heard of it. I legit have never pressed Ctrl with anything but my palm.
spauldo_the_hippie · 2022-12-06 19:27
I assume we're talking about the same thing - the smaller bar with the text menus, not the toolbar with the buttons (which I've never found a use for, but that's personal preference). I should have said I use Emacs in GUI mode; I wouldn't give up a line of text in a terminal for it.
The menus make discoverability very easy. Someone with menus wouldn't be wondering how to save, copy/paste, etc., and even after you've learned the basics they're still handy for major modes that you don't use often.
spauldo_the_hippie · 2022-12-06 19:39
UNIX users learned vi back in the day because often it was the only game in town - Emacs didn't come preinstalled on most UNIX machines, and the only other editor guaranteed to be there was ed.
It surprises me how popular vim is these days, when it seems like a large percentage of Linux users born after the 80s aren't comfortable at the command line. They've got notepad clones and nano and various IDEs, but still choose to learn vim.
It's a mystery to me. I probably wouldn't have learned it back in the day if Solaris came with pico. I'm glad I did though.
Edit: typo
ComprehensiveAd5882 · 2022-12-06 19:40
I didn't learn vim, and used nano for the longest time. But now— EMACS
pbgc · 2022-12-06 20:04
Just change caps lock to Ctrl. I use emacs everyday for more than 20years and my pinky is great!
oantolin · 2022-12-06 20:05
Well, if the blog post says "the following code turns off the menubar", then at least users following those instructions learn about the existence of the menubar, and they can follow the advice at their own peril. It would probably be better if blogs didn't advise that or did it in a more nuanced way, like "once you learn most of the key bindings you need day to day you may prefer to turn off the menubar, and only activate it when you need it" or something like that.
mickeyp · 2022-12-06 20:53
Been meaning to play around with it. I used the `bpr` package for a while to do this, but this looks more advanced.
verdigris2014 · 2022-12-06 21:02
You sound like a technical user with your talk of keybindings and work flow. If you also care about aesthetics I’d recommend checking out nano eMacs. It’s a package you can load early with whatever config you settle on. Wish I’d found it sooner.
DistilledProblems · 2022-12-06 21:03
I dabble in C mostly. In spring I'll have to use Fortran though.
Awkward_Tradition · 2022-12-06 22:47
> I don't like vim.
> I didn't learn vim
Wow, great input there...
Awkward_Tradition · 2022-12-06 23:01
The top one with file, edit, etc. (menu-bar-mode).
Idk, it can be handy I guess, but between M-x, apropos, and mnemonic groupings in Doom I've never had the use for it.
Awkward_Tradition · 2022-12-06 23:09
And the oldest woman smoked until she was like 110, but that doesn't mean it's not unhealthy.
When I started seriously learning lisp, after the first day or two I couldn't use my hand for a few days due to pressing shift with my pinky with every parens (binding lispy-parens to tab fixed that up). I imagine I'd already be set for surgery if I had to pinky-C with default bindings.
But yeah, C and ESC on caps is a must on laptop keyboards.
your_sweetpea · 2022-12-06 23:10
I can't really blame them, despite it probably being a bad idea. The emacs menu bar and tool bar are pretty ugly and I've never seen an emacs theme that actually themes them, although I understand it should be possible.
EDIT: I just checked and it doesn't seem possible to change the menu bar font, either. Just the foreground and background colors.
terminal_cope · 2022-12-06 23:37
And I use [XKeySnail](https://github.com/mooz/xkeysnail) to have the basic Emacs keys *everywhere*. I'm sure there are others, but it does enough to keep me happy.
Though it does make me not bother with some Emacs packages I might otherwise have switched to. For instance, I use the Slack browser-based client because it's tolerable with Emacs keys.
thoomfish · 2022-12-07 00:01
On a standard desktop keyboard, I can't hit Ctrl with my palm without *seriously* contorting my hand or removing my fingers from the keyboard.
_viz_ · 2022-12-07 03:47
If you're using the Gtk build, then it simply follows your Gtk theme. Don't blame Emacs for that.
If you're using the lucid or motif build, you can control all these via xresources. Check the Emacs manual for details.
deaddyfreddy · 2022-12-07 08:52
[a link to BPR for lazy](https://github.com/ilya-babanov/emacs-bpr)
Yeah, it looks like more a framework/library, while Detached is a drop-in replacement for multiple commands.
your_sweetpea · 2022-12-07 09:33
I see no reason why I wouldn't blame emacs for that? The rest of the GUI is also implemented in GTK and somehow manages to let me theme it. I shouldn't have to chase dotfiles around my system to properly theme an application that already has a theme system built into it IMO.
_viz_ · 2022-12-07 11:24
What you call rest is actually a minuscule amount of things and boils down to basically the menu-bar, the tool-bar, the scrollbar, the dialog boxes, and the tooltip if enabled. The rest of these things aren't richly configurable as well. Despite me agreeing with your statement, I wouldnt hope for customisability from Gtk.
ClickyCode · 2022-12-07 14:57
I know everyone has their favorite home remedies to the frequent use of C and M so I'll throw mine in here: swap the positions of Ctrl and Alt. Being able to use my thumbs for C has been really nice.
jumper047 · 2022-12-07 16:28
In shell mode jumping through history binded to M-n/M-p, and, if I remember correctly, search through history is bound to M-r. (Away from my PC so can't check if I rebounded these keys or they are default ones). You can also check vterm - it uses different mechanics, and uses same bindings as usual linux term - C-(n/p)