content(archives): tweak headings and format emacs spotlight

This commit is contained in:
Jean-Philippe Sirois
2020-05-24 22:12:10 -04:00
parent b01dbb006c
commit f128585a46
+78 -82
View File
@@ -1,36 +1,31 @@
### Table of Contents
- [What is Emacs?](#what-is-emacs)
- [Where to get Emacs?](#where-to-get-emacs)
- [Note](#note)
- [Why Emacs?](#why-emacs)
- [Emacs Basics](#emacs-basics)
- [Other General Points](#other-general-points)
- [Distributions](#distributions)
- [Resources](#resources)
- [Fun Facts](#fun-facts)
### What is Emacs?
## What is Emacs?
Emacs is a Lisp interpreter. It is commonly used as a **text editor** for reading and writing code, although you can use
it to write academic documents or do your taxes, if that is more your style. It has a very rich history and it is almost
certainly the most flexible text editor that is publicly available. As such, it tends to be the case that one devs use
of Emacs is **very** different than anothers.
### Where to get Emacs?
## Where to get Emacs?
- MacOS:
- [Instructions from WikEmacs](http://wikemacs.org/wiki/Installing_Emacs_on_OS_X)
- Windows:
- [Instructions from EmacsWiki](https://www.emacswiki.org/emacs/MsWindowsInstallation)
- You may want to look into WSL as well
- Linux:
- [Instructions from WikEmacs](http://wikemacs.org/index.php/Installing_Emacs_on_GNU/Linux)
- [Instructions for Snap](https://snapcraft.io/install/emacs/elementary) (26.3, stable and recommended if you choose snap)
- Catchall:
- Build from source [(GitHub Mirror)](https://github.com/emacs-mirror/emacs)
### MacOS:
### Note
- [Instructions from WikEmacs](http://wikemacs.org/wiki/Installing_Emacs_on_OS_X)
### Windows:
- [Instructions from EmacsWiki](https://www.emacswiki.org/emacs/MsWindowsInstallation)
- You may want to look into WSL as well
### Linux:
- [Instructions from WikEmacs](http://wikemacs.org/index.php/Installing_Emacs_on_GNU/Linux)
- [Instructions for Snap](https://snapcraft.io/install/emacs/elementary) (26.3, stable and recommended if you choose snap)
### Catchall:
- Build from source [(GitHub Mirror)](https://github.com/emacs-mirror/emacs)
## Note
This spotlight has a tendency to change tenses and focuses. This is because it was written by 5 separate people. Emacs
also has quite a bit to offer. This spotlight was written to share and introduce Emacs, not necessary make experts nor
@@ -40,7 +35,7 @@ you have any remarks or fixes, feel free to make a pull request
tech champions (as well as other TPHers) are available in the [discord](https://discord.gg/programming) on the
`#editors` channel. Feel free to drop by and say hi. There are a few memes that kept us sane scattered around.
### Why Emacs?
## Why Emacs?
Many people look at how poor the out of the box experience with Emacs is, compare it to VS Code and dismiss Emacs as an
option, stating that its simply too difficult to use, its ugly, and that concludes their experience with Emacs. Im
@@ -52,13 +47,14 @@ going to attempt to persuade you for a few moments of the following points:
Lets address these points in order.
#### Point one: The Emacs out of the box experience
### Point one: The Emacs out of the box experience
It is absolutely true that Emacs seems to be barebones and archaic when first used. Lets take the example average user:
They download VS Code first and attempt to use it, it has syntax out of the box, you open a JavaScript file and it says
“Hey, do you want to download X, Y and Z plugins?”, they click “yes” and theyre ready to edit some JavaScript. Then
they download Emacs, they run it, they are presented with some screen about how Emacs is “one component of the GNU
operating system” and a bunch of links. Immediate questions:
- How do I open a file?
- How do I “do things”?
- Why are the blue links in my face and a handbook link?
@@ -66,8 +62,8 @@ operating system” and a bunch of links. Immediate questions:
This is not how Emacs should be used. Emacs is not a text editor, it is only incidentally a text editor. Emacs is much
more like an application framework, inside of which you have control over everything. This application framework is
controlled by *Lisp*, in specific, Emacs Lisp. You know nothing of Emacs Lisp or Emacs and you just opened Emacs up, how
can you expect to be anything *except* confused?
controlled by _Lisp_, in specific, Emacs Lisp. You know nothing of Emacs Lisp or Emacs and you just opened Emacs up, how
can you expect to be anything _except_ confused?
So we have this apparent complexity issue with Emacs, and we want to be pragmatic in the same way that we were when we
opened VS Code, without any extra information, we started coding. Were going to have to sacrifice a small amount here,
@@ -100,12 +96,11 @@ What this will do is install a sane, default configuration for you. There is ver
learning Spacemacs initially. Weve documented it later. If a good out of the box experience is super key for you, its
recommended that you use a distribution like Spacemacs, as that is the singular focus of distributions.
#### Point two: The Emacs learning curve myth
### Point two: The Emacs learning curve myth
A lot of times people will associate Emacs with having a very steep learning curve. This is not true on any front
actually, even for the base, clunky, ugly Emacs you saw earlier. The reason for this is that Emacs is actually
self-documenting. It does a really good job of helping people to learn it, you just have to be *willing* to learn it. It
self-documenting. It does a really good job of helping people to learn it, you just have to be _willing_ to learn it. It
can take 1 - 2 days to get very familiar with all of the basics (Described in the basics section) and then maybe a
further 1 - 2 weeks to be as productive as you were before. After that, the sky's the limit. Weve included some basic
configurations for a lot of common programming languages in `tphmacs`
@@ -122,7 +117,7 @@ than asking google.
![What's
googling?](https://lh3.googleusercontent.com/proxy/G6sSs4tj68tQQuM00xckwrqDKOsxOlhqN8eF386xLY5rQAtKTSJwq_yHahlle15oSFwrPGklB54VUSefL-VwMNzmfPQIjSj_iopnHx9uZPUb0he_CiDgWSKzHYDbey0Lo-z3R7SDMUSlYAcKQRDj9VJuZCDesBmnIbw)
#### Point three: [Generally] Emacs is capable of much more than any other editor
### Point three: [Generally] Emacs is capable of much more than any other editor
So up until this point, weve just been laying out the ground work which indicates what makes Emacs equal to your old
editor. Its certainly the case that Emacs isnt as good in some specific cases, for example, with Kotlin. This language
@@ -134,30 +129,31 @@ demonstrate the raw power present within Emacs, that might help to persuade you
- Emacs can be used as a Window manager using EXWM. Say goodbye to i3wm.
- Emacs has a web browser built into it (EWW) - the name is fitting because its not pretty, but Ive used it so many
times for just quickly jumping to a link from the comfort of my editor.
- Emacs allows you to write a *literate configuration file*. This means that the configuration file you have in Emacs is
super easy to understand. (Anecdote in bound) Back when I was using vim, I had a very long .vimrc which essentially
consisted of stuff that I had copy/pasted from stack-overflow, that I had no real understanding of. In Emacs, Ive made
my entire configuration file myself, and I can understand it all, because its just code with associated documentation.
times for just quickly jumping to a link from the comfort of my editor.
- Emacs allows you to write a _literate configuration file_. This means that the configuration file you have in Emacs is
super easy to understand. (Anecdote in bound) Back when I was using vim, I had a very long .vimrc which essentially
consisted of stuff that I had copy/pasted from stack-overflow, that I had no real understanding of. In Emacs, Ive made
my entire configuration file myself, and I can understand it all, because its just code with associated documentation.
- Emacs has Eshell, which is actually significantly more powerful than the regular terminal you are used to. It is a
*Lisp REPL* as well as a fully fledged terminal. This can be immensely powerful. Additionally, because Eshell outputs to
just a regular text buffer inside of emacs, you can search, yank, paste, and manipulate text in the same way that you
can throughout the rest of Emacs.
_Lisp REPL_ as well as a fully fledged terminal. This can be immensely powerful. Additionally, because Eshell outputs to
just a regular text buffer inside of emacs, you can search, yank, paste, and manipulate text in the same way that you
can throughout the rest of Emacs.
- Org mode is one of the most powerful document formats available, and it requires no special encoding to use it, its
just a plain text file. You can hook it into pandoc, too. Its worth noting that you can export to LaTeX and its much
more ergonomic than regular LaTeX.
just a plain text file. You can hook it into pandoc, too. Its worth noting that you can export to LaTeX and its much
more ergonomic than regular LaTeX.
- Vim emulation inside of Emacs is basically perfect. If you are persuaded by any promise that you can find from vim,
Emacs has the ability to use *everything* inside of vim.
Emacs has the ability to use _everything_ inside of vim.
### Emacs Basics
## Emacs Basics
#### Keybinding Syntax Basics
### Keybinding Syntax Basics
**Sequence of keys:** `a b c d` represent the following sequence of key, a then b then c then d
**Key modifiers:** They are followed directly by a `-`, they represent "special" keys such as control, alt, the "windows
key" and so on. They are meant to be used simultaneously with other keys, such that `C-x` means pressing control + x at
the same time. The list of available modifiers:
key" and so on. They are meant to be used simultaneously with other keys, such that `C-x` means pressing control + x at
the same time. The list of available modifiers:
- `C`, the control key
- `M`, the meta key, commonly bound to alt or option
- `s`, the super key, also known as the "windows key"
@@ -167,7 +163,7 @@ the same time. The list of available modifiers:
**Keychords:** They're represented by one or more modifiers followed by a dash and any key, such that `C-b` is control+b
and `M-s-s` is meta+super+s
#### Holy Mode Users
### Holy Mode Users
Humble note: commands tend to start with `C-x` or `C-c` with holy bindings. With that, here are some basic operations
everyone user needs with holy keybindings:
@@ -182,13 +178,13 @@ everyone user needs with holy keybindings:
**Stuck in the middle of a command?:** Mash `C-g`!
#### Evil Mode Users
### Evil Mode Users
The first obvious question to ask here about operating an evil-mode configuration is “how close is evil mode to regular
vim”. The answer is: Very. Certainly as a long term vim user, Ive never noticed anything out of place. So if you have
read vimtutor, all of that applies here.
#### Evil Operations
### Evil Operations
Some basic operations for you, I have taken the liberty of writing the mnemonic with them:
@@ -200,84 +196,83 @@ Some basic operations for you, I have taken the liberty of writing the mnemonic
**Delete a file:** In normal mode `!rm <file.txt>` (rm is for REMOVE)
#### Some evil mode notes
### Some evil mode notes
Personally, I dont use the file operations from evil mode. I just use evil mode for the text navigation and
manipulation. For searching I use swiper which Ive bound to `C-s`, and I use Helm to find my files. Counsel with ivy is
a popular alternative to Helm. Thats the beauty of it, you can mix and match whatever makes more sense to you
personally.
### Other General Points
## Other General Points
#### Buffers and Windows
### Buffers and Windows
Emacs' terminology relating to what people usually refers to as windows and buffers is different, it's important to at
least roughly know the difference between them as these terms will be used later on.
A *buffer* refers to the data
A _buffer_ refers to the data
associated with a certain type of file or action, for example the content of a file, a terminal emulator or an
image. They can be hidden or displayed in a window.
A *window* refers to a panel or split inside a frame, it is used to
A _window_ refers to a panel or split inside a frame, it is used to
display a buffer.
A *frame* in emacs refers to the graphical window you are using emacs in, it contains windows, you
A _frame_ in emacs refers to the graphical window you are using emacs in, it contains windows, you
can have multiple frames per Emacs instances.
[Here](https://emacs.stackexchange.com/a/13584) is a more detailed explanation on stackexchange with an illustration.
#### Major and Minor modes
### Major and Minor modes
Modes are Emacs' way of understanding what you are doing and what you want to do. All all time you have one active
major mode and 0 or more active minor modes. A mode can alter the behavior of emacs in many ways, such as changing
Modes are Emacs' way of understanding what you are doing and what you want to do. All all time you have one active
major mode and 0 or more active minor modes. A mode can alter the behavior of emacs in many ways, such as changing
keybindings, changing the display of the buffer, enabling auto-completion, modify an existing function, the list goes
on.
Major modes provide ways to interact with specific file types, like a file containing source code, or a specific buffer,
like an interpreter or a git interface. Minor modes are just like major modes, but you can have multiple of them
like an interpreter or a git interface. Minor modes are just like major modes, but you can have multiple of them
enabled at the same time, an example of a minor mode is `line-number-mode` which displays the line numbers in your
modeline and isn't specific to a file type.
There are multiple ways to enable a mode:
- Manually, by invoking the mode like a function eg. `(line-number-mode t)`
- By using the variable `auto-mode-alist` to associate a *major* mode with a file extension, `(add-to-list
'auto-mode-alist '("\\.py\\'" . python-mode))`
- By using *hooks*, which will run the modes like functions when the hook is triggered, `(add-hook
'prog-mode-hook#'line-number-mode)` By default, the appropriate major mode should activate automatically depending on
file extension, just like in any other editor.
- By using the variable `auto-mode-alist` to associate a _major_ mode with a file extension, `(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))`
- By using _hooks_, which will run the modes like functions when the hook is triggered, `(add-hook 'prog-mode-hook#'line-number-mode)` By default, the appropriate major mode should activate automatically depending on
file extension, just like in any other editor.
#### Dired Mode
### Dired Mode
Emacs includes a _dir_ectory _ed_itor mode called `dired` that lets you view directory contents, traverse directories,
Emacs includes a \_dir_ectory \_ed_itor mode called `dired` that lets you view directory contents, traverse directories,
and manipulate files, just like you would in a normal shell. A cheat sheet is available
[here](https://ebzzry.io/en/emacs-dired/), and see [this section in the
manual](https://www.gnu.org/software/emacs/manual/html_node/emacs/Dired.html) for all the details.
### Eshell/Term/other terminals
## Eshell/Term/other terminals
Because of Emacs long history, there are a number of solutions for accessing terminal functionality. Further
explanations are in [stackexchange here](https://unix.stackexchange.com/q/104325).
- **M-!**: not a full-featured shell, but lets you run a single command quickly, like `!` in vim.
- **Shell**: The original Emacs terminal implementation. Because of how it runs the underlying shell, its color display
support is flaky and curses apps dont work.
support is flaky and curses apps dont work.
- **Term and ansi-term**: A newer terminal implementation, where everything looks and works closer to what youd
expect. You probably want `ansi-term`, which will open a new buffer with a fresh terminal every time its called.
expect. You probably want `ansi-term`, which will open a new buffer with a fresh terminal every time its called.
- **Libvterm**: A much more performant and customizable terminal, but needs `(use-package vterm)` and for Emacs to be
compiled using `--with-modules`.
compiled using `--with-modules`.
- **Eshell**: Unlike all the other emulators, this one lets you evaluate Elisp directly at the prompt. See [this section
in the manual](https://www.gnu.org/software/emacs/manual/html_node/eshell/index.html) for how to best take advantage of
this power.
in the manual](https://www.gnu.org/software/emacs/manual/html_node/eshell/index.html) for how to best take advantage of
this power.
### Distributions
## Distributions
Setting up Emacs is hard, here are some prebuilt Emacs distributions you might want to try <https://www.spacemacs.org/>
<https://github.com/hlissner/doom-emacs> Doom is Spacemacs taken to the extreme: very opinionated, evil only, and
designed to go fast. <http://www.emacs-bootstrap.com/> Interactively generate a config with only the languages you care
about. If you want a non-Spacemacs experience, closer to what youd get if you configured Emacs from scratch, but in a
literate style <https://en.wikipedia.org/wiki/Org-mode>, use our config wholesale: `git clone
https://github.com/the-programmers-hangout/emacs.git ~/tphmacs; ln -sv ~/tphmacs ~/.emacs.d`. Pull requests welcome!
designed to go fast. <http://www.emacs-bootstrap.com/> Interactively generate a config with only the languages you care
about. If you want a non-Spacemacs experience, closer to what youd get if you configured Emacs from scratch, but in a
literate style <https://en.wikipedia.org/wiki/Org-mode>, use our config wholesale: `git clone https://github.com/the-programmers-hangout/emacs.git ~/tphmacs; ln -sv ~/tphmacs ~/.emacs.d`. Pull requests welcome!
### Resources
## Resources
- <https://learnxinyminutes.com/docs/emacs/>
- [The GNU Emacs Reference Card](https://www.gnu.org/software/emacs/refcards/pdf/refcard.pdf)
@@ -288,7 +283,8 @@ https://github.com/the-programmers-hangout/emacs.git ~/tphmacs; ln -sv ~/tphmacs
(in particular, the Magit videos are good and not Doom-specific)
- <https://www.masteringemacs.org/>
### Fun Facts
## Fun Facts
- Some users use vs code and whatnot, but pop open Emacs just for [Magit](https://github.com/magit/magit) because it's
just so amazing.
- Again, some other editor users pop open Emacs just for Org-mode.
@@ -301,6 +297,6 @@ https://github.com/the-programmers-hangout/emacs.git ~/tphmacs; ln -sv ~/tphmacs
- [Famous Emacs Users (that are not famous for using Emacs)](http://wenshanren.org/?p=418)
- you'll definitely recognize quite a few names....
### End Note
## End Note
Happy Emacsing!