reddit / emacs
Setting up Emacs on linux.
ApexYenzy · 2022-12-17 10:20
So I've installed emacs onto my linux system however, when I try to create a file using the emacs command it opens up in a different window than my terminal. How do I get it to open the file in my terminal? I know about the emacs -nw command but I want to have to type that every time. Also when I was able to get a file open there were no line numbers, how do i setup emacs. I've tried looking it up but all the guides online are about installing emacs.
[deleted] · 2022-12-17 10:37
[deleted]
field_thought_slight · 2022-12-17 10:38
> I know about the emacs -nw command but I want to have to type that every time.
You could always alias `emacs` to `emacs -nw`.
aazang · 2022-12-17 10:43
Emacs is meant to be used as GUI. Which I also recommend you do. If you insist on using it in terminal mode you could make an alias in your bashrc or equivalent file.
If you check the 'about' section of this subreddit there are a lot of helpful links on how to customize emacs. There should also be a sensible default config, with line numbers enabled. But if you want to just have line-numbers you could enable them in emacs with M-x global-linum-mode RET.
sunnyata · 2022-12-17 10:45
You can [set an alias](https://www.thegeekdiary.com/how-to-make-alias-command-work-in-bash-script-or-bashrc-file/) in your shell if you don't want to type `emacs -nw` every time. Follow the tutorial by typing `C-h t`. [Turn on line numbers](http://xahlee.info/emacs/emacs/emacs_line_number_mode.html).
Configuration goes in the init file, eg `~/.emacs.d/init el`. A lot of people will tell you to use a "distro", a version of Emacs bundled with a lot of configuration already done. It's an option but you will learn a lot more about how things work if you start with an empty init file and add to it as you need to. Free software is about controlling your own environment, not taking someone's word for it.
Horrih · 2022-12-17 11:18
I simply use 'e' as alias for emacs -nw
Awkward_Tradition · 2022-12-17 12:07
Install Doom Emacs or Spacemacs. They've got everything set up for you, so you'll have a usable system until you figure out Emacs.
This isn't vim. In Emacs terminal comes to you, not the other way around, so use the GUI.
As for line numbers, and generally learning Emacs, use "C-h a" for apropos. There search for line number, and you'll find the display-line-numbers-mode function. You can toggle it per, or set the default in your config.
aanatk · 2022-12-17 12:33
>I know about the emacs -nw command but I want to have to type that every time.
You should to install `emacs-nox` instead.
sambrightman · 2022-12-17 13:29
It’s not “meant” to be used as a GUI at all. Both are valid.
Ghosty141 · 2022-12-17 13:53
The next level would be to use vterm as your terminal emulator and then you dont need to use the emacs command but just C-x C-f open the file
peatfreak · 2022-12-17 14:59
>Emacs is meant to be used as GUI.
Not true at all. The maintainers put a lot of effort in to ensuring that console mode Emacs is as good as it possibly can be.
NotAFedoraUser · 2022-12-17 15:10
Either alias it to `emacs -nw` or use `emacsclient -t` (See https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html) for more details
Equal-Jelly-3543 · 2022-12-17 15:40
Search for emacs-nox version. Also terminal may block some keybindings which is reason why I switch to exwm and gui emacs.
theunixman · 2022-12-17 16:18
Add this to your shell init file:
alias emacs “emacs -nw”
FrozenOnPluto · 2022-12-17 17:05
For OP -nox is ‘no X’ as in no GUI mode per se, just terminal. Then it just runs in place
yurikhan · 2022-12-17 17:34
They do, but, at the current state of affairs in terminal emulators, many things do not “just work”. (I mean, specifically, 24-bit color, font and underline styles, and keys such as `Super`+anything, `Ctrl`+digit, `Ctrl`+punctuation, `Ctrl`+`Shift`+letter, and other such. With the right combination of terminal emulator, terminfo database, and custom configuration, these are possible, but not out of the box.)
peatfreak · 2022-12-17 17:46
Of course it's not possible to have these work out of the box in a portable way. It's literally impossible to create a generalized solution, and anybody who knows how terminal emulators work (and who has read the relevant section on the Elisp manual) is knowledgeable enough to fix it. Even when xterm was the only game in town every distro configured it differently. Now we have a million different terminal emulators, some of which are pretty bad.
There was a time when simply getting backspace/delete (the old '^H'/'^?' problem) working correctly across applications and distros was the biggest concern. And that was before people started using modifier key combinations that are impossible to send to any terminal application, such as what you're trying to do. None of this is Emacs's fault. This is basic Unix stuff.
yurikhan · 2022-12-17 17:55
Yeah, and that’s why Emacs is better used as a GUI application, for a novice at least, — to be free from those backward compatibility issues preventing things from just working.
peatfreak · 2022-12-17 18:16
This has nothing to do with backward compatibility. Everything is documented in the Emacs Tutorial and Emacs Manual. A novice simply can't use Emacs effectively without reading these, so it's a moot point. And you're changing the argument now anyway.
DrPiwi · 2022-12-17 19:08
In this case, no matter what people say about emacs, it is first and foremost an editor. There really is no need for it to have 24 bit colour, underline styles etc. The OP is clearly getting started with emacs . No need for fancy stuff yet. By the time he'll start using all that he will know how to work around these.
aanatk · 2022-12-18 00:10
Indeed. But anyway we don't know what exactly needed.
RipKord42 · 2022-12-18 04:05
OP, is it your intent to run it in terminal only instead of the GUI?
ApexYenzy · 2022-12-18 23:58
Yes